Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

upgrade geth to v1.10.15 #935

Merged
merged 10 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
-BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
crypto-facs marked this conversation as resolved.
Show resolved Hide resolved
# check for nostrip option
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
Expand Down
2 changes: 1 addition & 1 deletion app/ante/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type EVMKeeper interface {

ChainID() *big.Int
GetParams(ctx sdk.Context) evmtypes.Params
NewEVM(ctx sdk.Context, msg core.Message, cfg *evmtypes.EVMConfig, tracer vm.Tracer, stateDB vm.StateDB) *vm.EVM
NewEVM(ctx sdk.Context, msg core.Message, cfg *evmtypes.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) *vm.EVM
DeductTxCostsFromUserBalance(
ctx sdk.Context, msgEthTx evmtypes.MsgEthereumTx, txData evmtypes.TxData, denom string, homestead, istanbul, london bool,
) (sdk.Coins, error)
Expand Down
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ import (
"github.com/tharsis/ethermint/x/feemarket"
feemarketkeeper "github.com/tharsis/ethermint/x/feemarket/keeper"
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"

// Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v3 v3.0.0-beta1
github.com/davecgh/go-spew v1.1.1
github.com/ethereum/go-ethereum v1.10.11
github.com/ethereum/go-ethereum v1.10.15
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/ethereum/go-ethereum v1.10.11 h1:KKIcwpmur9iTaVbR2dxlHu+peHVhU+/KX//NWvT1n9U=
github.com/ethereum/go-ethereum v1.10.11/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw=
github.com/ethereum/go-ethereum v1.10.15 h1:E9o0kMbD8HXhp7g6UwIwntY05WTDheCGziMhegcBsQw=
github.com/ethereum/go-ethereum v1.10.15/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
Expand Down
14 changes: 8 additions & 6 deletions x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"math/big"
"time"

"github.com/ethereum/go-ethereum/eth/tracers/logger"

"github.com/ethereum/go-ethereum/eth/tracers"

"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -469,7 +471,7 @@ func (k *Keeper) traceTx(
) (*interface{}, uint, error) {
// Assemble the structured logger or the JavaScript tracer
var (
tracer vm.Tracer
tracer vm.EVMLogger
overrides *ethparams.ChainConfig
err error
)
Expand Down Expand Up @@ -513,12 +515,12 @@ func (k *Keeper) traceTx(
go func() {
<-deadlineCtx.Done()
if errors.Is(deadlineCtx.Err(), context.DeadlineExceeded) {
tracer.(*tracers.Tracer).Stop(errors.New("execution timeout"))
tracer.(tracers.Tracer).Stop(errors.New("execution timeout"))
}
}()

case traceConfig != nil:
logConfig := vm.LogConfig{
logConfig := logger.Config{
EnableMemory: traceConfig.EnableMemory,
DisableStorage: traceConfig.DisableStorage,
DisableStack: traceConfig.DisableStack,
Expand All @@ -527,7 +529,7 @@ func (k *Keeper) traceTx(
Limit: int(traceConfig.Limit),
Overrides: overrides,
}
tracer = vm.NewStructLogger(&logConfig)
tracer = logger.NewStructLogger(&logConfig)
default:
tracer = types.NewTracer(types.TracerStruct, msg, cfg.ChainConfig, ctx.BlockHeight())
}
Expand All @@ -541,15 +543,15 @@ func (k *Keeper) traceTx(

// Depending on the tracer type, format and return the trace result data.
switch tracer := tracer.(type) {
crypto-facs marked this conversation as resolved.
Show resolved Hide resolved
case *vm.StructLogger:
case *logger.StructLogger:
// TODO: Return proper returnValue
result = types.ExecutionResult{
Gas: res.GasUsed,
Failed: res.Failed(),
ReturnValue: "",
StructLogs: types.FormatLogs(tracer.StructLogs()),
}
case *tracers.Tracer:
case tracers.Tracer:
result, err = tracer.GetResult()
if err != nil {
return nil, 0, status.Error(codes.Internal, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (k *Keeper) PostTxProcessing(ctx sdk.Context, from common.Address, to *comm
}

// Tracer return a default vm.Tracer based on current keeper state
func (k Keeper) Tracer(ctx sdk.Context, msg core.Message, ethCfg *params.ChainConfig) vm.Tracer {
func (k Keeper) Tracer(ctx sdk.Context, msg core.Message, ethCfg *params.ChainConfig) vm.EVMLogger {
return types.NewTracer(k.tracer, msg, ethCfg, ctx.BlockHeight())
}

Expand Down
17 changes: 8 additions & 9 deletions x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (k *Keeper) NewEVM(
ctx sdk.Context,
msg core.Message,
cfg *types.EVMConfig,
tracer vm.Tracer,
tracer vm.EVMLogger,
stateDB vm.StateDB,
) *vm.EVM {
blockCtx := vm.BlockContext{
Expand All @@ -98,7 +98,7 @@ func (k *Keeper) NewEVM(

// VMConfig creates an EVM configuration from the debug setting and the extra EIPs enabled on the
// module parameters. The config generated uses the default JumpTable from the EVM.
func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, params types.Params, tracer vm.Tracer) vm.Config {
func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, params types.Params, tracer vm.EVMLogger) vm.Config {
fmParams := k.feeMarketKeeper.GetParams(ctx)

var debug bool
Expand All @@ -107,11 +107,10 @@ func (k Keeper) VMConfig(ctx sdk.Context, msg core.Message, params types.Params,
}

return vm.Config{
Debug: debug,
Tracer: tracer,
NoRecursion: false, // TODO: consider disabling recursion though params
crypto-facs marked this conversation as resolved.
Show resolved Hide resolved
NoBaseFee: fmParams.NoBaseFee,
ExtraEips: params.EIPs(),
Debug: debug,
Tracer: tracer,
NoBaseFee: fmParams.NoBaseFee,
ExtraEips: params.EIPs(),
}
}

Expand Down Expand Up @@ -335,7 +334,7 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
// Commit parameter
//
// If commit is true, the `StateDB` will be committed, otherwise discarded.
func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg core.Message, tracer vm.Tracer, commit bool, cfg *types.EVMConfig, txConfig statedb.TxConfig) (*types.MsgEthereumTxResponse, error) {
func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool, cfg *types.EVMConfig, txConfig statedb.TxConfig) (*types.MsgEthereumTxResponse, error) {
var (
ret []byte // return bytes from evm execution
vmErr error // vm errors do not effect consensus and are therefore not assigned to err
Expand Down Expand Up @@ -425,7 +424,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg core.Message, trace
}

// ApplyMessage calls ApplyMessageWithConfig with default EVMConfig
func (k *Keeper) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.Tracer, commit bool) (*types.MsgEthereumTxResponse, error) {
func (k *Keeper) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool) (*types.MsgEthereumTxResponse, error) {
cfg, err := k.EVMConfig(ctx)
if err != nil {
return nil, sdkerrors.Wrap(err, "failed to load evm config")
Expand Down
77 changes: 21 additions & 56 deletions x/evm/types/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"os"
"time"

"github.com/ethereum/go-ethereum/eth/tracers/logger"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/vm"
Expand All @@ -21,22 +23,22 @@ const (

// NewTracer creates a new Logger tracer to collect execution traces from an
// EVM transaction.
func NewTracer(tracer string, msg core.Message, cfg *params.ChainConfig, height int64) vm.Tracer {
func NewTracer(tracer string, msg core.Message, cfg *params.ChainConfig, height int64) vm.EVMLogger {
// TODO: enable additional log configuration
logCfg := &vm.LogConfig{
logCfg := &logger.Config{
Debug: true,
}

switch tracer {
crypto-facs marked this conversation as resolved.
Show resolved Hide resolved
case TracerAccessList:
precompiles := vm.ActivePrecompiles(cfg.Rules(big.NewInt(height)))
return vm.NewAccessListTracer(msg.AccessList(), msg.From(), *msg.To(), precompiles)
preCompiles := vm.ActivePrecompiles(cfg.Rules(big.NewInt(height)))
return logger.NewAccessListTracer(msg.AccessList(), msg.From(), *msg.To(), preCompiles)
case TracerJSON:
return vm.NewJSONLogger(logCfg, os.Stderr)
return logger.NewJSONLogger(logCfg, os.Stderr)
case TracerMarkdown:
return vm.NewMarkdownLogger(logCfg, os.Stdout) // TODO: Stderr ?
return logger.NewMarkdownLogger(logCfg, os.Stdout) // TODO: Stderr ?
case TracerStruct:
return vm.NewStructLogger(logCfg)
return logger.NewStructLogger(logCfg)
default:
return NewNoOpTracer()
}
Expand Down Expand Up @@ -79,7 +81,7 @@ type StructLogRes struct {
}

// FormatLogs formats EVM returned structured logs for json output
func FormatLogs(logs []vm.StructLog) []StructLogRes {
func FormatLogs(logs []logger.StructLog) []StructLogRes {
formatted := make([]StructLogRes, len(logs))
for index, trace := range logs {
formatted[index] = StructLogRes{
Expand Down Expand Up @@ -123,7 +125,7 @@ func FormatLogs(logs []vm.StructLog) []StructLogRes {
return formatted
}

var _ vm.Tracer = &NoOpTracer{}
var _ vm.EVMLogger = &NoOpTracer{}

// NoOpTracer is an empty implementation of vm.Tracer interface
type NoOpTracer struct{}
Expand All @@ -134,60 +136,23 @@ func NewNoOpTracer() *NoOpTracer {
}

// CaptureStart implements vm.Tracer interface
func (dt NoOpTracer) CaptureStart(
env *vm.EVM,
from, to common.Address,
create bool,
input []byte,
gas uint64,
value *big.Int,
) {
}

// CaptureEnter implements vm.Tracer interface
func (dt NoOpTracer) CaptureEnter(
typ vm.OpCode,
from common.Address,
to common.Address,
input []byte,
gas uint64,
value *big.Int,
) {
func (dt NoOpTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
}

// CaptureExit implements vm.Tracer interface
func (dt NoOpTracer) CaptureExit(output []byte, gasUsed uint64, err error) {}

// CaptureState implements vm.Tracer interface
func (dt NoOpTracer) CaptureState(
env *vm.EVM,
pc uint64,
op vm.OpCode,
gas, cost uint64,
scope *vm.ScopeContext,
rData []byte,
depth int,
err error,
) {
func (dt NoOpTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
}

// CaptureFault implements vm.Tracer interface
func (dt NoOpTracer) CaptureFault(
env *vm.EVM,
pc uint64,
op vm.OpCode,
gas, cost uint64,
scope *vm.ScopeContext,
depth int,
err error,
) {
func (dt NoOpTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error) {
}

// CaptureEnd implements vm.Tracer interface
func (dt NoOpTracer) CaptureEnd(
output []byte,
gasUsed uint64,
t time.Duration,
err error,
) {
func (dt NoOpTracer) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error) {}

// CaptureEnter implements vm.Tracer interface
func (dt NoOpTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
}

// CaptureExit implements vm.Tracer interface
func (dt NoOpTracer) CaptureExit(output []byte, gasUsed uint64, err error) {}
12 changes: 6 additions & 6 deletions x/evm/types/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package types

import (
"fmt"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/holiman/uint256"
"github.com/stretchr/testify/require"
)
Expand All @@ -17,17 +17,17 @@ func TestFormatLogs(t *testing.T) {

testCases := []struct {
name string
logs []vm.StructLog
logs []logger.StructLog
exp []StructLogRes
}{
{
"empty logs",
[]vm.StructLog{},
[]logger.StructLog{},
[]StructLogRes{},
},
{
"non-empty stack",
[]vm.StructLog{
[]logger.StructLog{
{
Stack: zeroUint256,
},
Expand All @@ -42,7 +42,7 @@ func TestFormatLogs(t *testing.T) {
},
{
"non-empty memory",
[]vm.StructLog{
[]logger.StructLog{
{
Memory: zeroByte,
},
Expand All @@ -57,7 +57,7 @@ func TestFormatLogs(t *testing.T) {
},
{
"non-empty storage",
[]vm.StructLog{
[]logger.StructLog{
{
Storage: make(map[common.Hash]common.Hash),
},
Expand Down