Skip to content

Commit

Permalink
Temporary Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Apr 24, 2024
1 parent e4b50f4 commit 5c797f4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/ante/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (ctd CanTransferDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
}

stateDB := statedb.New(ctx, ctd.evmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())))
evm := ctd.evmKeeper.NewEVM(ctx, coreMsg, cfg, evmtypes.NewNoOpTracer(), stateDB)
evm := ctd.evmKeeper.NewEVM(ctx, coreMsg, cfg, evmtypes.NewNoOpTracer(), stateDB, nil)

// check that caller has enough balance to cover asset transfer for **topmost** call
// NOTE: here the gas consumed is from the context with the infinite gas meter
Expand Down
9 changes: 8 additions & 1 deletion app/ante/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ type EVMKeeper interface {
statedb.Keeper
DynamicFeeEVMKeeper

NewEVM(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) evm.EVM
NewEVM(
ctx sdk.Context,
msg core.Message,
cfg *statedb.EVMConfig,
tracer vm.EVMLogger,
stateDB vm.StateDB,
precompilesMetadata []*vm.PrecompileMetadata,
) evm.EVM
DeductTxCostsFromUserBalance(ctx sdk.Context, fees sdk.Coins, from common.Address) error
GetBalance(ctx sdk.Context, addr common.Address) *big.Int
ResetTransientGasUsed(ctx sdk.Context)
Expand Down
7 changes: 4 additions & 3 deletions x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (k *Keeper) NewEVM(
cfg *statedb.EVMConfig,
tracer vm.EVMLogger,
stateDB vm.StateDB,
precompilesMetadata []*vm.PrecompileMetadata,
) evm.EVM {
blockCtx := vm.BlockContext{

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

View workflow job for this annotation

GitHub Actions / Run golangci-lint

blockCtx declared and not used (typecheck)
CanTransfer: core.CanTransfer,
Expand All @@ -70,7 +71,7 @@ func (k *Keeper) NewEVM(
tracer = k.Tracer(ctx, msg, cfg.ChainConfig)
}
vmConfig := k.VMConfig(ctx, msg, cfg, tracer)

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

View workflow job for this annotation

GitHub Actions / Run golangci-lint

vmConfig declared and not used (typecheck)
return k.evmConstructor(blockCtx, txCtx, stateDB, cfg.ChainConfig, vmConfig, k.customPrecompiles)
return k.evmConstructor(blockCtx, txCtx, stateDB, cfg.ChainConfig, vmConfig, k.customPrecompiles, precompilesMetadata)
}

// GetHashFn implements vm.GetHashFunc for Ethermint. It handles 3 cases:
Expand Down Expand Up @@ -329,9 +330,9 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context,
return nil, errorsmod.Wrap(types.ErrCallDisabled, "failed to call contract")
}

enabledPrecompiles := k.evmutilKeeper.GetEnabledPrecompiles()
precompilesMetadata := k.evmutilKeeper.GetPrecompilesMetadata()
stateDB := statedb.New(ctx, k, txConfig)
evm := k.NewEVM(ctx, msg, cfg, tracer, stateDB)
evm := k.NewEVM(ctx, msg, cfg, tracer, stateDB, precompilesMetadata)

leftoverGas := msg.Gas()

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

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

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

//type PrecompileMetadata struct {
// Name string
// Address string
// IsEnabled bool
//}

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

// Event Hooks
Expand Down
3 changes: 2 additions & 1 deletion x/evm/vm/geth/geth.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ func NewEVM(
chainConfig *params.ChainConfig,
config vm.Config,
_ evm.PrecompiledContracts, // unused
precompilesMetadata []*vm.PrecompileMetadata,
) evm.EVM {
return &EVM{
EVM: vm.NewEVM(blockCtx, txCtx, stateDB, chainConfig, config),
EVM: vm.NewEVM(blockCtx, txCtx, stateDB, chainConfig, config, precompilesMetadata),
}
}

Expand Down
1 change: 1 addition & 0 deletions x/evm/vm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ type Constructor func(
chainConfig *params.ChainConfig,
config vm.Config,
customPrecompiles PrecompiledContracts,
precompilesMetadata []*vm.PrecompileMetadata,
) EVM

0 comments on commit 5c797f4

Please sign in to comment.