-
Notifications
You must be signed in to change notification settings - Fork 360
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
Precompile used gas #175
base: master
Are you sure you want to change the base?
Precompile used gas #175
Conversation
I suspect this point. The precompile record_cost implementation like this: https://github.com/rust-blockchain/evm/blob/master/src/executor/stack/executor.rs#L1455-L1462, it uses the parent gasometer directly instead of creating a new one. |
Before executing the precompile a new |
If I remember correctly, the executor will make all tx gas limit as used_gas at first, then reduce this value when executing the opcode or precompile one by one. The gasometer will |
I believe this is all true as stated. However, this seems a bit tangential to the changes introduced in the PR and doesn’t alter the established behavior. Breaking down the PR:
|
Would you mind to explain more this use case? This seems to be about querying the internal state of the actual running machine, so I'm wondering if we should just make a new opcode instead. Precompiles have rather defined semantics -- they are essentially external code, but following all other rules of a normal call stack. For example, they are supposed to also work with CALLCODE/DELEGATECALL. They are supposed to properly OOG like a normal call stack. We can use it for pure functions. We can use it for dynamic functions (with the caveats that you might want to disallow the case when But... if you really want to go with this route -- the |
A set of changes that were useful for us to implement a precompile that returns gas usage.
Changes:
fn used_gas(&self) -> u64;
toPrecompileHandle
to support querying used_gas in precompilesused_gas
into the precompiles (since precompile uses its own gasometer that starts at 0)Retreive -> Retrieve
Hope that none of these are too controversial.