Skip to content

Commit

Permalink
update log
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Nov 6, 2024
1 parent c19a0f6 commit 19e5d3b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fvm/evm/emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package emulator

import (
"errors"
"fmt"
"math/big"

"github.com/holiman/uint256"
Expand All @@ -14,6 +15,7 @@ import (
gethVM "github.com/onflow/go-ethereum/core/vm"
gethCrypto "github.com/onflow/go-ethereum/crypto"
gethParams "github.com/onflow/go-ethereum/params"
"github.com/rs/zerolog/log"

"github.com/onflow/flow-go/fvm/evm/emulator/state"
"github.com/onflow/flow-go/fvm/evm/types"
Expand Down Expand Up @@ -327,6 +329,9 @@ func (bl *BlockView) newProcedure() (*procedure, error) {
return nil, err
}
cfg := bl.config
log.Info().
Str("chain_config", fmt.Sprintf("%+v", cfg.ChainConfig)).
Msg("new EVM with configs")
return &procedure{
config: cfg,
evm: gethVM.NewEVM(
Expand Down Expand Up @@ -647,6 +652,9 @@ func (proc *procedure) run(
// if the block gas limit is set to anything than max
// we need to update this code.
gasPool := (*gethCore.GasPool)(&proc.config.BlockContext.GasLimit)
log.Info().
Str("tx_hash", txHash.Hex()).
Msg("Running EVM transaction")

// transit the state
execResult, err := gethCore.NewStateTransition(
Expand Down Expand Up @@ -678,6 +686,13 @@ func (proc *procedure) run(
return nil, err
}

log.Info().
Str("tx_hash", txHash.Hex()).
Uint64("gas_used", res.GasConsumed).
Uint64("cumulative_gas_used", res.CumulativeGasUsed).
Uint64("gas_refund", res.GasRefund).
Msg("EVM transaction executed")

// we need to capture the returned value no matter the status
// if the tx is reverted the error message is returned as returned value
res.ReturnedData = execResult.ReturnData
Expand Down

0 comments on commit 19e5d3b

Please sign in to comment.