-
Notifications
You must be signed in to change notification settings - Fork 695
DELEGATECALL should receive only 63/64 of the remaining gas (and msg.gas should reflect that) #367
Comments
Can confirm. Testrpc version info: |
This is an EVM bug. I've raised ethereumjs/ethereumjs-monorepo#255 to address it. |
And thanks for reporting, @carver! |
Branch https://github.com/trufflesuite/ganache-core/commits/all-but-one-64th created for this issue, including failing gas-estimation tests. Still need to add tests to explicitly test the "All but one 64th" rule. Because we don't properly estimate gas from the "All but one 64th" rule this one is blocked by trufflesuite/ganache#147. |
This should now be fixed in the latest beta tagged releases of ganache-cli and ganache-core. This fix involved pretty significant code changes; check out the release notes for details. We'd love it if you'd test this beta out to make sure things are good to go before we release to stable. If you using npm install -g ganache-cli@beta If you are using npm install ganache-core@beta Let us know if you discover any bugs with this new beta release! Thanks! |
A
DELEGATECALL
instruction should receive 63/64 of the remaining gas, but appears to be receiving the full remaining gas (according to amsg.gas
call in solidity).The gas used is defined in the yellow paper at Cgascap
Function L is defined in equation 224 on page 22:
L(n) ≡ n − floor(n/64)
The Stackoverflow answer that inspired this report is here.
Tested this contract:
Expected Behavior
The value of x when called with y:
y=0, x=2.98M
y=1, x~=2.93M
y=2, x~=2.88M
Current Behavior
y=0, 2978464
y=1, 2977288, diff = 1176
y=2, 2976176, diff = 1112
Steps to Reproduce (for bugs)
Context
I was testing this contract to try to understand (and protect against) stack depth attacks.
The text was updated successfully, but these errors were encountered: