-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zkevm_estimateCounters is always returning the same amount of Steps for different executions #1677
Comments
I took a look at this one. Adding some addition details. SMT DepthThe method cdk-erigon/turbo/jsonrpc/zkevm_counters.go Lines 302 to 322 in 2a22c67
Example CaseOn the Bali network, the transaction {
"A": 627,
"B": 65216,
"M": 2,
"K": 3,
"D": 6,
"P": 1025802,
"SHA": 0,
"S": 1468504
} These values make sense to me because the test is meant to push the poseidon counters and this is very close to the limit of The issue is, if we use {
"smtDepth": 0,
"batchNumber": 86693,
"blockFrom": 9637277,
"blockTo": 9637277,
"countersUsed": {
"gas": 1386010,
"keccakHashes": 9,
"poseidonhashes": 368,
"poseidonPaddings": 6,
"memAligns": 0,
"arithmetics": 622,
"binaries": 826,
"steps": 12491,
"SHA256hashes": 0
},
"countersLimits": {
"gas": 0,
"keccakHashes": 9029,
"poseidonhashes": 1028275,
"poseidonPaddings": 569223,
"memAligns": 996141,
"arithmetics": 996141,
"binaries": 1992283,
"steps": 31876521,
"SHA256hashes": 7083
}
} The amount of gas used looks right and aligns with the receipt: As far as I can tell, both cdk-erigon/core/vm/zk_batch_counters.go Lines 218 to 271 in 5626125
It seems like this method collects counters for blocks, l2 data, rlp, and stuff like that, but I'm not seeing where it actually accounts for the counters used by transactions. There is a similar function in the package called cdk-erigon/core/vm/zk_batch_counters.go Lines 296 to 305 in 5626125
If I switch to using this method, I can see the counter value increases a lot but seems to be about 3x higher than expected. |
Complementary to this, I can have a TX mined using Bali, but when I estimate its counters, I get an Steps to reproduce:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract ZkCounters {
uint256 public count;
function maxKeccakHashes() public {
count = 0;
assembly {
let _bytes := 10000000
let test := keccak256(0, _bytes)
test := keccak256(0, _bytes)
test := keccak256(0, _bytes)
test := keccak256(0, _bytes)
test := keccak256(0, _bytes)
}
}
}
Here are the logs showing the response I'm getting from the zkevm_estimateCounters for this test: This shows the counters:
This shows the TX was already mined, as we have
|
Thanks for all the detail! Working on it now :) |
Any news about it? |
Steps to reproduce:
Actual result:
The response has the
countersUsed.steps
equal for all methods execution.Expected result:
The response should have the
countersUsed.steps
different for each method, given the number of operations.The text was updated successfully, but these errors were encountered: