refactor: move salt bucket capacity lookup into revm::Database trait#188
Open
WonderLawrence wants to merge 5 commits intomainfrom
Open
refactor: move salt bucket capacity lookup into revm::Database trait#188WonderLawrence wants to merge 5 commits intomainfrom
WonderLawrence wants to merge 5 commits intomainfrom
Conversation
fd83d28 to
b85bede
Compare
b85bede to
6b530c3
Compare
6b530c3 to
96092a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors how SALT bucket capacity is queried during EVM execution for v1.4.1, removing the
SaltEnvabstraction and integrating capacity lookup directly into therevm::Databasetrait via a newsalt_bucket_capacity(address, Option<U256>) -> (usize, u64)method.Problem
Previously, bucket capacity was provided through
ExternalEnvTypes::SaltEnv— an external environment trait injected viaExternalEnvFactory. This required the factory to accept ablock: BlockNumberparameter to return historically-correct capacity values. The design was overly complex and coupled gas calculation to an external oracle abstraction rather than the database layer.Changes
SaltEnvtrait andExternalEnvs::salt_envfield: All SALT bucket capacity queries now go throughdb.salt_bucket_capacity(address, key)on therevm::Databasetrait (added in the upstreammegaeth-labs/revm-database-interfacefork)DynamicGasCostis no longer generic:DynamicGasCost<SaltEnvImpl>→DynamicGasCost; gas functions (sstore_set_gas,new_account_gas,create_contract_gas) now takedb: &DBdirectlyExternalEnvFactory::external_envsdrops theblockparameter: Block context for historical capacity resolution is now handled at the database level by the caller (e.g.StateProviderDatabasewrapping aHistoricalStateProviderRef)TestDatabaseWrapperintroduced: ReplacesTestExternalEnvs::with_bucket_capacityfor test setups; wraps anyrevm::Databaseand provides configurable per-bucket capacity overridesMotivation
The
revm::Databaseis already the single source of truth for all state during execution. Routing capacity queries through it allows historical replay correctness to be handled entirely at the storage layer (see megaeth-labs/mega-reth#1489), without requiring the EVM execution layer to know about block numbers or provider types.