Skip to content

Commit

Permalink
mock beacon root
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Apr 2, 2024
1 parent 1127dbd commit dd8accf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package evm
import (
"encoding/json"
"fmt"
"math"
"math/big"

// this line is used by starport scaffolding # 1

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/tests"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand Down Expand Up @@ -166,11 +169,24 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
func (AppModule) ConsensusVersion() uint64 { return 4 }

// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
func (am AppModule) BeginBlock(sdk.Context, abci.RequestBeginBlock) {
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
// clear tx responses from last block
am.keeper.SetTxResults([]*abci.ExecTxResult{})
// clear the TxDeferredInfo
am.keeper.ClearEVMTxDeferredInfo()
// mock beacon root if replaying
if am.keeper.EthReplayConfig.Enabled {
if beaconRoot := am.keeper.ReplayBlock.BeaconRoot(); beaconRoot != nil {
blockCtx, err := am.keeper.GetVMBlockContext(ctx, core.GasPool(math.MaxUint64))
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}
statedb := state.NewDBImpl(ctx, am.keeper, false)
vmenv := vm.NewEVM(*blockCtx, vm.TxContext{}, statedb, types.DefaultChainConfig().EthereumConfig(am.keeper.ChainID(ctx)), vm.Config{})
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
statedb.Finalize()

Check failure on line 187 in x/evm/module.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `statedb.Finalize` is not checked (errcheck)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

path flow from Begin/EndBlock to a panic call
}
}
}

// EndBlock executes all ABCI EndBlock logic respective to the evm module. It
Expand Down

0 comments on commit dd8accf

Please sign in to comment.