Skip to content

Commit

Permalink
WIP: Injecting precompile metadata to EVM
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Apr 24, 2024
1 parent 541ad3c commit e4b50f4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func NewEthermintApp(
app.EvmKeeper = evmkeeper.NewKeeper(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, stakingKeeper, app.FeeMarketKeeper,
app.AccountKeeper, app.BankKeeper, stakingKeeper, app.FeeMarketKeeper, nil,
nil, geth.NewEVM, tracer, evmSs,
)

Expand Down
3 changes: 3 additions & 0 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Keeper struct {
stakingKeeper types.StakingKeeper
// fetch EIP1559 base fee and parameters
feeMarketKeeper types.FeeMarketKeeper
evmutilKeeper types.EvmutilKeeper

// chain ID number obtained from the context's chain id
eip155ChainID *big.Int
Expand Down Expand Up @@ -90,6 +91,7 @@ func NewKeeper(
bankKeeper types.BankKeeper,
sk types.StakingKeeper,
fmk types.FeeMarketKeeper,
evmutilKeeper types.EvmutilKeeper,
customPrecompiles evm.PrecompiledContracts,
evmConstructor evm.Constructor,
tracer string,
Expand Down Expand Up @@ -117,6 +119,7 @@ func NewKeeper(
bankKeeper: bankKeeper,
stakingKeeper: sk,
feeMarketKeeper: fmk,
evmutilKeeper: evmutilKeeper,
storeKey: storeKey,
transientKey: transientKey,
customPrecompiles: customPrecompiles,
Expand Down
1 change: 1 addition & 0 deletions x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context,
return nil, errorsmod.Wrap(types.ErrCallDisabled, "failed to call contract")
}

enabledPrecompiles := k.evmutilKeeper.GetEnabledPrecompiles()

Check failure on line 332 in x/evm/keeper/state_transition.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

enabledPrecompiles declared and not used (typecheck)
stateDB := statedb.New(ctx, k, txConfig)
evm := k.NewEVM(ctx, msg, cfg, tracer, stateDB)

Expand Down
6 changes: 6 additions & 0 deletions x/evm/types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package types

import (
"github.com/ethereum/go-ethereum/precompile/contract"
"math/big"

paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
Expand Down Expand Up @@ -64,6 +65,11 @@ type FeeMarketKeeper interface {
AddTransientGasWanted(ctx sdk.Context, gasWanted uint64) (uint64, error)
}

type EvmutilKeeper interface {
IsEnabled(blockHeight uint64, address string) bool
GetEnabledPrecompiles() []contract.StatefulPrecompiledContract
}

// Event Hooks
// These can be utilized to customize evm transaction processing.

Expand Down

0 comments on commit e4b50f4

Please sign in to comment.