From 6b1cd9343f5cfb9236ae885f3504fe8ce7cd3f35 Mon Sep 17 00:00:00 2001 From: Levi Schoen Date: Fri, 1 Dec 2023 13:36:40 -0800 Subject: [PATCH 1/3] use evm index and tendermint as source of truth when trace status discrepency. --- rpc/backend/tracing.go | 48 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/rpc/backend/tracing.go b/rpc/backend/tracing.go index d9eca7fe6c..abca1c5117 100644 --- a/rpc/backend/tracing.go +++ b/rpc/backend/tracing.go @@ -18,6 +18,7 @@ package backend import ( "encoding/json" "fmt" + "math" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -125,7 +126,52 @@ func (b *Backend) TraceTransaction(hash common.Hash, config *evmtypes.TraceConfi return nil, err } - return decodedResult, nil + jsonResult, ok := decodedResult.(map[string]interface{}) + + if !ok { + // gracefully fallback to default behavior + return decodedResult, nil + } + + // handle edge cases in differences between traced tx status + // and actual tx status when it was executed as part of a block + // this can happen when + // - tracing a tx succeeds even though when the tx was executed + // the block gas meter became exhausted + if jsonResult["failed"] != transaction.Failed { + // override trace transaction status with actual tx status + jsonResult["failed"] = transaction.Failed + _, exists := jsonResult["error"] + + if !exists { + // use tendermint as source of truth for error message + // and gas usage + query := fmt.Sprintf("%s.%s='%s'", evmtypes.TypeMsgEthereumTx, evmtypes.AttributeKeyEthereumTxHash, hash.Hex()) + resTxs, err := b.clientCtx.Client.TxSearch(b.ctx, query, false, nil, nil, "") + + if err != nil { + panic(err) + } + + if resTxs.TotalCount != 1 { + // gracefully fallback to default behavior + return decodedResult, nil + } + + txMe := resTxs.Txs[0] + + // using the actual gas used amount for when the tx was executed + jsonResult["gas_used"] = txMe.TxResult.GasUsed + + // TODO: supporting configuring max error string length + // some indexing services (e.g. blockscout) have a character limit + // for the field that stores this data + maxErrorStringLength := math.Min(200, float64(len(txMe.TxResult.Log)-1)) + jsonResult["error"] = txMe.TxResult.Log[0:int64(maxErrorStringLength)] + } + } + + return jsonResult, nil } // TraceBlock configures a new tracer according to the provided configuration, and From 779739107ecff8a1424cd54207fd6380b3187993 Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Thu, 21 Dec 2023 09:40:02 -0500 Subject: [PATCH 2/3] Synchronize start cmd flags with cosmos-sdk v0.46 --- server/flags/flags.go | 6 ------ server/start.go | 14 +++++++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/server/flags/flags.go b/server/flags/flags.go index 6613ef4ceb..34ef8476b1 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -42,12 +42,6 @@ const ( GRPCWebAddress = "grpc-web.address" ) -// Cosmos API flags -const ( - RPCEnable = "api.enable" - EnabledUnsafeCors = "api.enabled-unsafe-cors" -) - // JSON-RPC flags const ( JSONRPCEnable = "json-rpc.enable" diff --git a/server/start.go b/server/start.go index 97ec064309..c906f922d5 100644 --- a/server/start.go +++ b/server/start.go @@ -185,15 +185,21 @@ which accepts a path for the resulting pprof file. cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks") cmd.Flags().String(srvflags.AppDBBackend, "", "The type of database for application and snapshots databases") + cmd.Flags().Bool(server.FlagAPIEnable, false, "Define if the API server should be enabled") + cmd.Flags().Bool(server.FlagAPISwagger, false, "Define if swagger documentation should automatically be registered (Note: the API must also be enabled)") + cmd.Flags().String(server.FlagAPIAddress, serverconfig.DefaultAPIAddress, "the API server address to listen on") + cmd.Flags().Uint(server.FlagAPIMaxOpenConnections, 1000, "Define the number of maximum open connections") + cmd.Flags().Uint(server.FlagRPCReadTimeout, 10, "Define the Tendermint RPC read timeout (in seconds)") + cmd.Flags().Uint(server.FlagRPCWriteTimeout, 0, "Define the Tendermint RPC write timeout (in seconds)") + cmd.Flags().Uint(server.FlagRPCMaxBodyBytes, 1000000, "Define the Tendermint maximum response body (in bytes)") + cmd.Flags().Bool(server.FlagAPIEnableUnsafeCORS, false, "Define if CORS should be enabled (unsafe - use it at your own risk)") + cmd.Flags().Bool(srvflags.GRPCOnly, false, "Start the node in gRPC query only mode without Tendermint process") cmd.Flags().Bool(srvflags.GRPCEnable, true, "Define if the gRPC server should be enabled") cmd.Flags().String(srvflags.GRPCAddress, serverconfig.DefaultGRPCAddress, "the gRPC server address to listen on") cmd.Flags().Bool(srvflags.GRPCWebEnable, true, "Define if the gRPC-Web server should be enabled. (Note: gRPC must also be enabled.)") cmd.Flags().String(srvflags.GRPCWebAddress, serverconfig.DefaultGRPCWebAddress, "The gRPC-Web server address to listen on") - cmd.Flags().Bool(srvflags.RPCEnable, false, "Defines if Cosmos-sdk REST server should be enabled") - cmd.Flags().Bool(srvflags.EnabledUnsafeCors, false, "Defines if CORS should be enabled (unsafe - use it at your own risk)") - cmd.Flags().Bool(srvflags.JSONRPCEnable, true, "Define if the JSON-RPC server should be enabled") cmd.Flags().StringSlice(srvflags.JSONRPCAPI, config.GetDefaultAPINamespaces(), "Defines a list of JSON-RPC namespaces that should be enabled") cmd.Flags().String(srvflags.JSONRPCAddress, config.DefaultJSONRPCAddress, "the JSON-RPC server address to listen on") @@ -220,6 +226,8 @@ which accepts a path for the resulting pprof file. cmd.Flags().Uint64(server.FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval") cmd.Flags().Uint32(server.FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep") + cmd.Flags().Bool(server.FlagDisableIAVLFastNode, false, "Disable fast node for IAVL tree") + // add support for all Tendermint-specific command line options tcmd.AddNodeFlags(cmd) return cmd From 0ef382225e6c650076f0d720370c38d51d809a1e Mon Sep 17 00:00:00 2001 From: Draco Date: Mon, 5 Feb 2024 13:49:04 -0500 Subject: [PATCH 3/3] Update cosmos-sdk to v0.47.7-kava.1 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4ea9a60934..95a4f43d3a 100644 --- a/go.mod +++ b/go.mod @@ -214,7 +214,7 @@ replace ( // use cosmos keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 // Use cosmos-sdk fork with staking transfer events, and custom tally handler support - github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.47.2-0.20240101221523-62b74a63ed1b + github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.47.7-kava.1 // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0 diff --git a/go.sum b/go.sum index bbec855d33..d417f4f64c 100644 --- a/go.sum +++ b/go.sum @@ -851,8 +851,8 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= -github.com/kava-labs/cosmos-sdk v0.47.2-0.20240101221523-62b74a63ed1b h1:dEGcAv0vfjrsZ4Y4JVNPATTo66cJAclAKJavHkP20lM= -github.com/kava-labs/cosmos-sdk v0.47.2-0.20240101221523-62b74a63ed1b/go.mod h1:7ODtonLpPpUXz1euAxNbpZEZTSnq61dibiA3X/5/oYU= +github.com/kava-labs/cosmos-sdk v0.47.7-kava.1 h1:35qRvLNoOSOmmDSQt2rm0q7YB+DamcJHjYzjuKvsYs8= +github.com/kava-labs/cosmos-sdk v0.47.7-kava.1/go.mod h1:7ODtonLpPpUXz1euAxNbpZEZTSnq61dibiA3X/5/oYU= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=