-
Notifications
You must be signed in to change notification settings - Fork 2.2k
perf(rpc): reduce estimate gas trait bounds to EvmStateProvider #19746
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
perf(rpc): reduce estimate gas trait bounds to EvmStateProvider #19746
Conversation
Use a minimal EvmStateProvider instead of full StateProvider trait.
mattsse
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, but have questions re what appear to be unrelated changes
| let TxKind::Call(to) = tx_env.kind() | ||
| { | ||
| code.map(|code| code.is_empty()).unwrap_or(true) | ||
| match db.basic(to) { | ||
| Ok(Some(account)) => account.code_hash == KECCAK_EMPTY, | ||
| _ => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When switching from the StateProvider trait to EvmStateProvider, we can no longer use the account_code function and can only use the basic or basic_account functions from the Database or EvmStateProvider traits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see, ty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then this is equivalent
| ) -> Result<U256, Self::Error> | ||
| where | ||
| DB: Database<Error = ProviderError>, | ||
| DB: Database<Error = ProviderError> + Debug, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems appropriate, but why is this necessary here?
can we undo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, let me undo. Because I switched to using revm’s Database trait without Debug, I’ll switch back to reth_revm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattsse In case you've missed this PR, it's ready again Sir.
mattsse
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
| let TxKind::Call(to) = tx_env.kind() | ||
| { | ||
| code.map(|code| code.is_empty()).unwrap_or(true) | ||
| match db.basic(to) { | ||
| Ok(Some(account)) => account.code_hash == KECCAK_EMPTY, | ||
| _ => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then this is equivalent
Replaces
StateProviderwithEvmStateProvidertrait bound inestimate_gas_withsince the EVM only needs the minimal database interface, not the full state provider API with block lookups, proofs, etc. This reduces trait overhead and makes dependencies explicit.It also makes it easier to implement another state provider to feed
estimate_gas_with, which we need.