Skip to content

Commit

Permalink
imp(deps): Geth upgrade v1.10.19 (evmos#1159)
Browse files Browse the repository at this point in the history
* upgrade geth and fix build

* add support for

* update EIPs

* fix keeper tests

* update traceTx function with latest geth changes

* remove unnecessary comments

* fix tests

* update proto

* add migrations

* update module version

* fix grpc test

* fix lint

* fix lint

* update changelog

* fix typo

* remove unnecessary format logs

* Update proto/ethermint/evm/v1/evm.proto

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* remove debug true on default

* update comments

* fixing ante tests

* fixed cycle imports on migrate_test

* fix wrong naming

* update comment

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
2 people authored and hoanguyenkh committed Aug 17, 2022
1 parent c220c56 commit d096edc
Show file tree
Hide file tree
Showing 22 changed files with 4,488 additions and 356 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -45,6 +45,9 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [v0.17.1] - 2022-07-13

### State Machine Breaking
* (deps) [\#1159](https://github.com/evmos/ethermint/pull/1159) Bump Geth version to `v1.10.19`.

### Improvements

* (rpc) [\#1169](https://github.com/evmos/ethermint/pull/1169) Remove unnecessary queries from `getBlockNumber` function
Expand Down
3 changes: 2 additions & 1 deletion app/ante/utils_test.go
Expand Up @@ -83,7 +83,8 @@ func (suite *AnteTestSuite) SetupTest() {
maxInt := sdk.NewInt(math.MaxInt64)
evmGenesis.Params.ChainConfig.LondonBlock = &maxInt
evmGenesis.Params.ChainConfig.ArrowGlacierBlock = &maxInt
evmGenesis.Params.ChainConfig.MergeForkBlock = &maxInt
evmGenesis.Params.ChainConfig.GrayGlacierBlock = &maxInt
evmGenesis.Params.ChainConfig.MergeNetsplitBlock = &maxInt
}
if suite.evmParamsOption != nil {
suite.evmParamsOption(&evmGenesis.Params)
Expand Down
3 changes: 2 additions & 1 deletion docs/api/proto-docs.md
Expand Up @@ -182,7 +182,8 @@ instead of *big.Int.
| `berlin_block` | [string](#string) | | Berlin switch block (nil = no fork, 0 = already on berlin) |
| `london_block` | [string](#string) | | London switch block (nil = no fork, 0 = already on london) |
| `arrow_glacier_block` | [string](#string) | | Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated) |
| `merge_fork_block` | [string](#string) | | EIP-3675 (TheMerge) switch block (nil = no fork, 0 = already in merge proceedings) |
| `gray_glacier_block` | [string](#string) | | EIP-5133 (bomb delay) switch block (nil = no fork, 0 = already activated) |
| `merge_netsplit_block` | [string](#string) | | Virtual fork after The Merge to use as a network splitter |



Expand Down
8 changes: 5 additions & 3 deletions go.mod
Expand Up @@ -6,12 +6,11 @@ require (
github.com/armon/go-metrics v0.4.0
github.com/btcsuite/btcd v0.22.1
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/cosmos/cosmos-sdk v0.45.5
github.com/cosmos/cosmos-sdk v0.45.5-0.20220523154235-2921a1c3c918
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v3 v3.1.0
github.com/davecgh/go-spew v1.1.1
github.com/ethereum/go-ethereum v1.10.17
github.com/evmos/evmos/v6 v6.0.1
github.com/ethereum/go-ethereum v1.10.19
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
Expand Down Expand Up @@ -51,6 +50,7 @@ require (
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
Expand Down Expand Up @@ -99,6 +99,8 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
Expand Down
15 changes: 12 additions & 3 deletions proto/ethermint/evm/v1/evm.proto
Expand Up @@ -115,11 +115,20 @@ message ChainConfig {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"arrow_glacier_block\""
];
// EIP-3675 (TheMerge) switch block (nil = no fork, 0 = already in merge proceedings)
string merge_fork_block = 19 [
// DEPRECATED: merge fork block was deprecated: https://github.com/ethereum/go-ethereum/pull/24904
reserved 19;
reserved "merge_fork_block";
// EIP-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
string gray_glacier_block = 20 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"merge_fork_block\""
(gogoproto.moretags) = "yaml:\"gray_glacier_block\""
];
// Virtual fork after The Merge to use as a network splitter
string merge_netsplit_block = 21 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"merge_netsplit_block\""
];

}

// State represents a single Storage key value pair item.
Expand Down
11 changes: 6 additions & 5 deletions rpc/types/block.go
Expand Up @@ -30,9 +30,10 @@ const (
)

const (
BlockParamEarliest = "earliest"
BlockParamLatest = "latest"
BlockParamPending = "pending"
BlockParamEarliest = "earliest"
BlockParamLatest = "latest"
BlockParamFinalized = "finalized"
BlockParamPending = "pending"
)

// NewBlockNumber creates a new BlockNumber instance.
Expand All @@ -57,7 +58,7 @@ func ContextWithHeight(height int64) context.Context {
}

// UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports:
// - "latest", "earliest" or "pending" as string arguments
// - "latest", "finalized", "earliest" or "pending" as string arguments
// - the block number
// Returned errors:
// - an invalid block number error when the given argument isn't a known strings
Expand All @@ -72,7 +73,7 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
case BlockParamEarliest:
*bn = EthEarliestBlockNumber
return nil
case BlockParamLatest:
case BlockParamLatest, BlockParamFinalized:
*bn = EthLatestBlockNumber
return nil
case BlockParamPending:
Expand Down
111 changes: 43 additions & 68 deletions x/evm/keeper/grpc_query.go
Expand Up @@ -488,100 +488,75 @@ func (k *Keeper) traceTx(
) (*interface{}, uint, error) {
// Assemble the structured logger or the JavaScript tracer
var (
tracer vm.EVMLogger
tracer tracers.Tracer
overrides *ethparams.ChainConfig
err error
timeout = defaultTraceTimeout
)

msg, err := tx.AsMessage(signer, cfg.BaseFee)
if err != nil {
return nil, 0, status.Error(codes.Internal, err.Error())
}

if traceConfig != nil && traceConfig.Overrides != nil {
if traceConfig == nil {
traceConfig = &types.TraceConfig{}
}

if traceConfig.Overrides != nil {
overrides = traceConfig.Overrides.EthereumConfig(cfg.ChainConfig.ChainID)
}

switch {
case traceConfig != nil && traceConfig.Tracer != "":
timeout := defaultTraceTimeout
// TODO: change timeout to time.duration
// Used string to comply with go ethereum
if traceConfig.Timeout != "" {
timeout, err = time.ParseDuration(traceConfig.Timeout)
if err != nil {
return nil, 0, status.Errorf(codes.InvalidArgument, "timeout value: %s", err.Error())
}
}
logConfig := logger.Config{
EnableMemory: traceConfig.EnableMemory,
DisableStorage: traceConfig.DisableStorage,
DisableStack: traceConfig.DisableStack,
EnableReturnData: traceConfig.EnableReturnData,
Debug: traceConfig.Debug,
Limit: int(traceConfig.Limit),
Overrides: overrides,
}

tCtx := &tracers.Context{
BlockHash: txConfig.BlockHash,
TxIndex: int(txConfig.TxIndex),
TxHash: txConfig.TxHash,
}
tracer = logger.NewStructLogger(&logConfig)

// Construct the JavaScript tracer to execute with
tCtx := &tracers.Context{
BlockHash: txConfig.BlockHash,
TxIndex: int(txConfig.TxIndex),
TxHash: txConfig.TxHash,
}

if traceConfig.Tracer != "" {
if tracer, err = tracers.New(traceConfig.Tracer, tCtx); err != nil {
return nil, 0, status.Error(codes.Internal, err.Error())
}
}

// Handle timeouts and RPC cancellations
deadlineCtx, cancel := context.WithTimeout(ctx.Context(), timeout)
defer cancel()

go func() {
<-deadlineCtx.Done()
if errors.Is(deadlineCtx.Err(), context.DeadlineExceeded) {
tracer.(tracers.Tracer).Stop(errors.New("execution timeout"))
}
}()

case traceConfig != nil:
logConfig := logger.Config{
EnableMemory: traceConfig.EnableMemory,
DisableStorage: traceConfig.DisableStorage,
DisableStack: traceConfig.DisableStack,
EnableReturnData: traceConfig.EnableReturnData,
Debug: traceConfig.Debug,
Limit: int(traceConfig.Limit),
Overrides: overrides,
// Define a meaningful timeout of a single transaction trace
if traceConfig.Timeout != "" {
if timeout, err = time.ParseDuration(traceConfig.Timeout); err != nil {
return nil, 0, status.Errorf(codes.InvalidArgument, "timeout value: %s", err.Error())
}
tracer = logger.NewStructLogger(&logConfig)
default:
tracer = types.NewTracer(types.TracerStruct, msg, cfg.ChainConfig, ctx.BlockHeight())
}

// Handle timeouts and RPC cancellations
deadlineCtx, cancel := context.WithTimeout(ctx.Context(), timeout)
defer cancel()

go func() {
<-deadlineCtx.Done()
if errors.Is(deadlineCtx.Err(), context.DeadlineExceeded) {
tracer.Stop(errors.New("execution timeout"))
}
}()

res, err := k.ApplyMessageWithConfig(ctx, msg, tracer, commitMessage, cfg, txConfig)
if err != nil {
return nil, 0, status.Error(codes.Internal, err.Error())
}

var result interface{}

// Depending on the tracer type, format and return the trace result data.
switch tracer := tracer.(type) {
case *logger.StructLogger:
returnVal := ""
revert := res.Revert()
if len(revert) > 0 {
returnVal = fmt.Sprintf("%x", revert)
} else {
returnVal = fmt.Sprintf("%x", res.Return())
}
result = types.ExecutionResult{
Gas: res.GasUsed,
Failed: res.Failed(),
ReturnValue: returnVal,
StructLogs: types.FormatLogs(tracer.StructLogs()),
}
case tracers.Tracer:
result, err = tracer.GetResult()
if err != nil {
return nil, 0, status.Error(codes.Internal, err.Error())
}

default:
return nil, 0, status.Errorf(codes.InvalidArgument, "invalid tracer type %T", tracer)
result, err = tracer.GetResult()
if err != nil {
return nil, 0, status.Error(codes.Internal, err.Error())
}

return &result, txConfig.LogIndex + uint(len(res.Logs)), nil
Expand Down

0 comments on commit d096edc

Please sign in to comment.