Skip to content

Commit

Permalink
IBCTransfer doesn't panic
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Feb 15, 2024
1 parent ced8cbb commit ea6805c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func (k *Keeper) NewEVM(
tracer vm.EVMLogger,
stateDB vm.StateDB,
) evm.EVM {
goCtx := sdk.WrapSDKContext(ctx)

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

View workflow job for this annotation

GitHub Actions / Run golangci-lint

goCtx declared and not used (typecheck)

blockCtx := vm.BlockContext{

Check failure on line 57 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,
Transfer: core.Transfer,
Expand All @@ -70,7 +72,7 @@ func (k *Keeper) NewEVM(
tracer = k.Tracer(ctx, msg, cfg.ChainConfig)
}
vmConfig := k.VMConfig(ctx, msg, cfg, tracer)

Check failure on line 74 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(goCtx, blockCtx, txCtx, stateDB, cfg.ChainConfig, vmConfig, k.customPrecompiles)
}

// GetHashFn implements vm.GetHashFunc for Ethermint. It handles 3 cases:
Expand Down
4 changes: 4 additions & 0 deletions x/evm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (s *StateDB) Keeper() Keeper {
return s.keeper
}

func (s *StateDB) Context() context.Context {
return s.ctx
}

// AddLog adds a log, called by evm.
func (s *StateDB) AddLog(log *ethtypes.Log) {
s.journal.append(addLogChange{})
Expand Down
4 changes: 3 additions & 1 deletion x/evm/vm/geth/geth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package geth

import (
"context"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -40,6 +41,7 @@ type EVM struct {
// the default precompiled contracts and the EVM concrete implementation from
// geth.
func NewEVM(
goCtx context.Context,
blockCtx vm.BlockContext,
txCtx vm.TxContext,
stateDB vm.StateDB,
Expand All @@ -48,7 +50,7 @@ func NewEVM(
_ evm.PrecompiledContracts, // unused
) evm.EVM {
return &EVM{
EVM: vm.NewEVM(blockCtx, txCtx, stateDB, chainConfig, config),
EVM: vm.NewEVMWithContext(goCtx, blockCtx, txCtx, stateDB, chainConfig, config),
}
}

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

import (
"context"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -75,6 +76,7 @@ type EVM interface {
// Constructor defines the function used to instantiate the EVM on
// each state transition.
type Constructor func(
goCtx context.Context,
blockCtx vm.BlockContext,
txCtx vm.TxContext,
stateDB vm.StateDB,
Expand Down

0 comments on commit ea6805c

Please sign in to comment.