diff --git a/x/evm/keeper/precompile.go b/x/evm/keeper/precompile.go index 377a8cd540..2c939f3544 100644 --- a/x/evm/keeper/precompile.go +++ b/x/evm/keeper/precompile.go @@ -28,6 +28,7 @@ type InitializationConfig struct { Uninitialize []common.Address } +// SyncEnabledPrecompiles is a keeper wrapper over the SyncEnabledPrecompiles function, which does most of the work. func (k *Keeper) SyncEnabledPrecompiles(ctx sdk.Context, enabledPrecompiles []common.Address) error { txConfig := statedb.TxConfig{ BlockHash: common.Hash{}, @@ -51,11 +52,19 @@ func (k *Keeper) SyncEnabledPrecompiles(ctx sdk.Context, enabledPrecompiles []co return nil } +// SyncEnabledPrecompiles takes enabled precompiles from old state and new state and performs following steps: +// - determines a list of contracts that must be validated and validates their state +// - determines a list of contracts that must be initialized and initializes them +// - determines a list of contracts that must be uninitialized and uninitializes them func SyncEnabledPrecompiles(stateDB StateDB, old []common.Address, new []common.Address) error { cfg := DetermineInitializationConfig(old, new) return ApplyInitializationConfig(stateDB, cfg) } +// DetermineInitializationConfig takes enabled precompiles from old state and new state and performs following steps: +// - determines a list of contracts that must be validated +// - determines a list of contracts that must be initialized +// - determines a list of contracts that must be uninitialized func DetermineInitializationConfig(old []common.Address, new []common.Address) *InitializationConfig { return &InitializationConfig{ ValidateInitialized: old, @@ -65,6 +74,7 @@ func DetermineInitializationConfig(old []common.Address, new []common.Address) * } } +// ApplyInitializationConfig performs precompile initialization based on InitializationConfig. func ApplyInitializationConfig(stateDB StateDB, cfg *InitializationConfig) error { if err := ValidatePrecompilesInitialized(stateDB, cfg.ValidateInitialized); err != nil { return err