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 Jul 27, 2022
1 parent e610e94 commit aac7428
Show file tree
Hide file tree
Showing 21 changed files with 4,483 additions and 353 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -38,6 +38,9 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

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

### Improvements

* (feemarket) [\#1165](https://github.com/evmos/ethermint/pull/1165) Add hint in specs about different gas terminology for gas in Cosmos and Ethereum.
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
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 @@ -485,100 +485,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 aac7428

Please sign in to comment.