You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been benchmarking gas usage and was having trouble with a contract that makes a CREATE call internally -- the gas estimation came out far higher than expected. The results I was getting were similar to here: polkadot-evm/frontier#252 (comment)
And to clarify, by l64 I mean the protocol defined here, to pass gas into subcontracts: ethereum/EIPs#150
Investigation shows the following cost occurring in the gasometer at l64 time:
I note that the l64 cost is approximately equal to the amount of gas remaining / 64. My suspicion is that, because the gasometer runs the code with a MAX_U256 starting gas, the l64 calls are being improperly estimated when compared with the amount of starting gas used in practice. Note that this starting gas comes from the following line in frontier: https://github.com/paritytech/frontier/blob/master/client/rpc/src/eth.rs#L760, but should theoretically be unneeded for the purposes of estimation.
If useful, here is the entire contract I've been using for testing, specifically the spawn() call on the CreateContract.
As a quick point of comparison, the gas estimate I get with EIP-150 enabled is 67227213, but if I set call_l64_after_gas: false in the config, I instead get 119183 -- much closer if not exactly the amount of gas used when the call is actually executed.
pragma solidity ^0.5.0;
contract SubContract {
constructor() public payable { }
function getAddress() external view returns (address ownAddress) {
return address(this);
}
function getValue() external view returns (uint) {
return address(this).balance;
}
}
contract CreateContract {
address public deployed;
constructor() public { }
function spawn() external returns (SubContract subAddress) {
SubContract result = new SubContract();
deployed = address(result);
return result;
}
function spawnWithValue() external payable returns (SubContract subAddress) {
SubContract result = (new SubContract).value(msg.value)();
deployed = address(result);
return result;
}
}
The text was updated successfully, but these errors were encountered:
When calling create/call/... from the contract, it uses the take_l64 as expected. The way it seems to work is by "consuming" the 64th of the current gas left (around U256::max for estimateGas) to set the gas left at 63th of the gas left (as defined in Long-term gas cost changes for IO-heavy operations to mitigate transaction spam attacks ethereum/EIPs#150) however, when returning from that create/call, the 64th that has been consumed is not restored.
I've been benchmarking gas usage and was having trouble with a contract that makes a CREATE call internally -- the gas estimation came out far higher than expected. The results I was getting were similar to here: polkadot-evm/frontier#252 (comment)
And to clarify, by
l64
I mean the protocol defined here, to pass gas into subcontracts: ethereum/EIPs#150Investigation shows the following cost occurring in the gasometer at
l64
time:I note that the l64 cost is approximately equal to the amount of gas remaining / 64. My suspicion is that, because the gasometer runs the code with a MAX_U256 starting gas, the
l64
calls are being improperly estimated when compared with the amount of starting gas used in practice. Note that this starting gas comes from the following line in frontier: https://github.com/paritytech/frontier/blob/master/client/rpc/src/eth.rs#L760, but should theoretically be unneeded for the purposes of estimation.If useful, here is the entire contract I've been using for testing, specifically the
spawn()
call on theCreateContract
.As a quick point of comparison, the gas estimate I get with EIP-150 enabled is
67227213
, but if I setcall_l64_after_gas: false
in the config, I instead get119183
-- much closer if not exactly the amount of gas used when the call is actually executed.The text was updated successfully, but these errors were encountered: