From 6ba79bbfd890dbc3cdf7e99781612e65c9d63173 Mon Sep 17 00:00:00 2001 From: Oleg Nikonychev Date: Thu, 12 Sep 2024 04:45:03 +0400 Subject: [PATCH] fix(evm): debug calls with custom tracer and tracer options (#2031) --- CHANGELOG.md | 1 + app/app.go | 3 + e2e/evm/test/debug_queries.test.ts | 37 ++- proto/eth/evm/v1/evm.proto | 9 +- x/evm/evm.pb.go | 354 +++++++++++++++++++++-------- x/evm/keeper/grpc_query.go | 15 +- 6 files changed, 314 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9df469730..ba5b6877a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,6 +117,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#2020](https://github.com/NibiruChain/nibiru/pull/2020) - test(evm): e2e tests for debug namespace - [#2022](https://github.com/NibiruChain/nibiru/pull/2022) - feat(evm): debug_traceCall method implemented - [#2023](https://github.com/NibiruChain/nibiru/pull/2023) - fix(evm)!: adjusted generation and parsing of the block bloom events +- [#2031](https://github.com/NibiruChain/nibiru/pull/2031) - fix(evm): debug calls with custom tracer and tracer options #### Dapp modules: perp, spot, oracle, etc diff --git a/app/app.go b/app/app.go index 72e728927..9230a3553 100644 --- a/app/app.go +++ b/app/app.go @@ -52,6 +52,9 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/rakyll/statik/fs" "github.com/spf13/cast" + + // force call init() of the geth tracers + _ "github.com/ethereum/go-ethereum/eth/tracers/native" ) const ( diff --git a/e2e/evm/test/debug_queries.test.ts b/e2e/evm/test/debug_queries.test.ts index 934767b2c..c01723d90 100644 --- a/e2e/evm/test/debug_queries.test.ts +++ b/e2e/evm/test/debug_queries.test.ts @@ -32,6 +32,11 @@ describe("debug queries", () => { it("debug_traceBlockByNumber", async () => { const traceResult = await provider.send("debug_traceBlockByNumber", [ blockNumber, + { + tracer: "callTracer", + timeout: "3000s", + tracerConfig: { onlyTopCall: false }, + }, ]) expectTrace(traceResult) }) @@ -40,13 +45,24 @@ describe("debug queries", () => { it("debug_traceBlockByHash", async () => { const traceResult = await provider.send("debug_traceBlockByHash", [ blockHash, + { + tracer: "callTracer", + timeout: "3000s", + tracerConfig: { onlyTopCall: false }, + }, ]) expectTrace(traceResult) }) - // TODO: impl in EVM: remove skip - it.skip("debug_traceTransaction", async () => { - const traceResult = await provider.send("debug_traceTransaction", [txHash]) + it("debug_traceTransaction", async () => { + const traceResult = await provider.send("debug_traceTransaction", [ + txHash, + { + tracer: "callTracer", + timeout: "3000s", + tracerConfig: { onlyTopCall: false }, + }, + ]) expectTrace([{ result: traceResult }]) }) @@ -61,7 +77,11 @@ describe("debug queries", () => { const traceResult = await provider.send("debug_traceCall", [ tx, "latest", - {}, + { + tracer: "callTracer", + timeout: "3000s", + tracerConfig: { onlyTopCall: false }, + }, ]) expectTrace([{ result: traceResult }]) }) @@ -90,8 +110,11 @@ const expectTrace = (traceResult: any[]) => { expect(traceResult.length).toBeGreaterThan(0) const trace = traceResult[0]["result"] - expect(trace).toHaveProperty("failed", false) + expect(trace).toHaveProperty("from") + expect(trace).toHaveProperty("to") expect(trace).toHaveProperty("gas") - expect(trace).toHaveProperty("returnValue") - expect(trace).toHaveProperty("structLogs") + expect(trace).toHaveProperty("gasUsed") + expect(trace).toHaveProperty("input") + expect(trace).toHaveProperty("output") + expect(trace).toHaveProperty("type", "CALL") } diff --git a/proto/eth/evm/v1/evm.proto b/proto/eth/evm/v1/evm.proto index ce50798a7..7be577a1c 100644 --- a/proto/eth/evm/v1/evm.proto +++ b/proto/eth/evm/v1/evm.proto @@ -145,6 +145,11 @@ message AccessTuple { repeated string storage_keys = 2 [ (gogoproto.jsontag) = "storageKeys" ]; } +// TracerConfig stores additional tracer args. For geth it's only one attr: onlyTopCall +message TracerConfig { + bool only_top_call = 1 [ (gogoproto.jsontag) = "onlyTopCall" ]; +} + // TraceConfig holds extra parameters to trace functions. message TraceConfig { // DEPRECATED: DisableMemory and DisableReturnData have been renamed to @@ -173,6 +178,6 @@ message TraceConfig { bool enable_memory = 11 [ (gogoproto.jsontag) = "enableMemory" ]; // enable_return_data switches the capture of return data bool enable_return_data = 12 [ (gogoproto.jsontag) = "enableReturnData" ]; - // tracer_json_config configures the tracer using a JSON string - string tracer_json_config = 13 [ (gogoproto.jsontag) = "tracerConfig" ]; + // tracer_config configures the tracer options + TracerConfig tracer_config = 13 [ (gogoproto.jsontag) = "tracerConfig" ]; } diff --git a/x/evm/evm.pb.go b/x/evm/evm.pb.go index c8e6bebf3..13c357492 100644 --- a/x/evm/evm.pb.go +++ b/x/evm/evm.pb.go @@ -495,6 +495,51 @@ func (m *AccessTuple) XXX_DiscardUnknown() { var xxx_messageInfo_AccessTuple proto.InternalMessageInfo +// TracerConfig stores additional tracer args. For geth it's only one attr: onlyTopCall +type TracerConfig struct { + OnlyTopCall bool `protobuf:"varint,1,opt,name=only_top_call,json=onlyTopCall,proto3" json:"onlyTopCall"` +} + +func (m *TracerConfig) Reset() { *m = TracerConfig{} } +func (m *TracerConfig) String() string { return proto.CompactTextString(m) } +func (*TracerConfig) ProtoMessage() {} +func (*TracerConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_98abbdadb327b7d0, []int{7} +} +func (m *TracerConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TracerConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TracerConfig.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TracerConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_TracerConfig.Merge(m, src) +} +func (m *TracerConfig) XXX_Size() int { + return m.Size() +} +func (m *TracerConfig) XXX_DiscardUnknown() { + xxx_messageInfo_TracerConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_TracerConfig proto.InternalMessageInfo + +func (m *TracerConfig) GetOnlyTopCall() bool { + if m != nil { + return m.OnlyTopCall + } + return false +} + // TraceConfig holds extra parameters to trace functions. type TraceConfig struct { // tracer is a custom javascript tracer @@ -516,15 +561,15 @@ type TraceConfig struct { EnableMemory bool `protobuf:"varint,11,opt,name=enable_memory,json=enableMemory,proto3" json:"enableMemory"` // enable_return_data switches the capture of return data EnableReturnData bool `protobuf:"varint,12,opt,name=enable_return_data,json=enableReturnData,proto3" json:"enableReturnData"` - // tracer_json_config configures the tracer using a JSON string - TracerJsonConfig string `protobuf:"bytes,13,opt,name=tracer_json_config,json=tracerJsonConfig,proto3" json:"tracerConfig"` + // tracer_config configures the tracer options + TracerConfig *TracerConfig `protobuf:"bytes,13,opt,name=tracer_config,json=tracerConfig,proto3" json:"tracerConfig"` } func (m *TraceConfig) Reset() { *m = TraceConfig{} } func (m *TraceConfig) String() string { return proto.CompactTextString(m) } func (*TraceConfig) ProtoMessage() {} func (*TraceConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_98abbdadb327b7d0, []int{7} + return fileDescriptor_98abbdadb327b7d0, []int{8} } func (m *TraceConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -616,11 +661,11 @@ func (m *TraceConfig) GetEnableReturnData() bool { return false } -func (m *TraceConfig) GetTracerJsonConfig() string { +func (m *TraceConfig) GetTracerConfig() *TracerConfig { if m != nil { - return m.TracerJsonConfig + return m.TracerConfig } - return "" + return nil } func init() { @@ -631,84 +676,87 @@ func init() { proto.RegisterType((*Log)(nil), "eth.evm.v1.Log") proto.RegisterType((*TxResult)(nil), "eth.evm.v1.TxResult") proto.RegisterType((*AccessTuple)(nil), "eth.evm.v1.AccessTuple") + proto.RegisterType((*TracerConfig)(nil), "eth.evm.v1.TracerConfig") proto.RegisterType((*TraceConfig)(nil), "eth.evm.v1.TraceConfig") } func init() { proto.RegisterFile("eth/evm/v1/evm.proto", fileDescriptor_98abbdadb327b7d0) } var fileDescriptor_98abbdadb327b7d0 = []byte{ - // 1123 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0xb6, 0x2c, 0xca, 0xa6, 0x56, 0x4a, 0xc4, 0xac, 0x9d, 0x94, 0x4d, 0x10, 0x51, 0x60, 0x81, - 0x42, 0x05, 0x02, 0xa9, 0x51, 0x91, 0x1e, 0x52, 0xa0, 0xa8, 0xe5, 0xd8, 0xa8, 0x55, 0x3b, 0x08, - 0x36, 0x4a, 0x0f, 0xbd, 0x10, 0x2b, 0x72, 0x4c, 0xb1, 0x22, 0xb9, 0x06, 0x77, 0xa9, 0xca, 0x0f, - 0x50, 0xa0, 0xc7, 0x3e, 0x42, 0xee, 0x7d, 0x91, 0xa0, 0xa7, 0x00, 0xbd, 0x14, 0x3d, 0x10, 0x85, - 0x73, 0x69, 0x75, 0xf4, 0x13, 0x14, 0xbb, 0x4b, 0x59, 0x8e, 0x0b, 0xb4, 0x27, 0xce, 0xf7, 0xcd, - 0xce, 0x0f, 0x67, 0xbe, 0x25, 0xd1, 0x2e, 0x88, 0x69, 0x1f, 0xe6, 0x49, 0x7f, 0xfe, 0x58, 0x3e, - 0x7a, 0x67, 0x19, 0x13, 0x0c, 0x23, 0x10, 0xd3, 0x9e, 0x84, 0xf3, 0xc7, 0xf7, 0x77, 0x43, 0x16, - 0x32, 0x45, 0xf7, 0xa5, 0xa5, 0x4f, 0xb8, 0xbf, 0x54, 0x90, 0x79, 0x98, 0xa7, 0x63, 0x36, 0x83, - 0x14, 0xbf, 0x42, 0x08, 0x32, 0x7f, 0xf0, 0xa9, 0x47, 0x83, 0x20, 0xb3, 0x2b, 0x9d, 0x4a, 0xb7, - 0x3e, 0xfc, 0xfc, 0x4d, 0xe1, 0x6c, 0xfc, 0x51, 0x38, 0xbd, 0x30, 0x12, 0xd3, 0x7c, 0xd2, 0xf3, - 0x59, 0xd2, 0x7f, 0x1e, 0x4d, 0xa2,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1b, 0xdf, 0x7d, 0xfc, 0xbf, 0x7f, 0xc5, 0x85, 0xfc, 0x1d, 0x4f, - 0xb6, 0xd4, 0xdf, 0xf6, 0xb3, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa2, 0xa8, 0xe3, 0xf2, 0xa7, - 0x07, 0x00, 0x00, + // 1153 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0x3f, 0x6f, 0xdb, 0x46, + 0x14, 0xb7, 0x2c, 0xca, 0xa6, 0x4e, 0x72, 0xa4, 0x9c, 0x9d, 0x94, 0x4d, 0x10, 0xd3, 0x60, 0x81, + 0xc2, 0x05, 0x02, 0xa9, 0x71, 0x90, 0x0e, 0xe9, 0x52, 0xcb, 0xb1, 0x51, 0xab, 0x76, 0x1a, 0x5c, + 0x94, 0x0e, 0x5d, 0x88, 0x13, 0xf9, 0x4c, 0x11, 0x22, 0x79, 0xc2, 0xdd, 0x51, 0x95, 0x3f, 0x40, + 0x81, 0x8e, 0xfd, 0x08, 0xd9, 0xfb, 0x45, 0x82, 0x4e, 0x01, 0xba, 0x14, 0x1d, 0x88, 0xc2, 0x59, + 0x0a, 0x8d, 0x1e, 0x3b, 0x15, 0x77, 0x47, 0x5b, 0xb2, 0x0b, 0xb4, 0x13, 0xdf, 0xef, 0xf7, 0xee, + 0xfd, 0xb9, 0xf7, 0x7e, 0x24, 0xd1, 0x16, 0xc8, 0x51, 0x17, 0xa6, 0x69, 0x77, 0xfa, 0x44, 0x3d, + 0x3a, 0x13, 0xce, 0x24, 0xc3, 0x08, 0xe4, 0xa8, 0xa3, 0xe0, 0xf4, 0xc9, 0x83, 0xad, 0x88, 0x45, + 0x4c, 0xd3, 0x5d, 0x65, 0x99, 0x13, 0xde, 0x2f, 0x15, 0x64, 0x1f, 0xe5, 0xd9, 0x80, 0x8d, 0x21, + 0xc3, 0x6f, 0x10, 0x02, 0x1e, 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5a, 0xbf, 0xce, 0x2d, 0xfd, 0x5e, 0xaf, 0xd6, 0x34, 0x25, 0x97, + 0x18, 0x72, 0x03, 0xf5, 0x2d, 0xdb, 0x6a, 0xd7, 0xcc, 0xb7, 0xb4, 0x6f, 0xd9, 0xa8, 0xdd, 0xb8, + 0x9e, 0x4c, 0x79, 0x39, 0xb2, 0x79, 0x85, 0x97, 0xba, 0xee, 0x7d, 0xf5, 0xee, 0x62, 0xbb, 0xf2, + 0xfe, 0x62, 0xbb, 0xf2, 0xe7, 0xc5, 0x76, 0xe5, 0xe7, 0x0f, 0xdb, 0x2b, 0xef, 0x3f, 0x6c, 0xaf, + 0xfc, 0xfe, 0x61, 0x7b, 0xe5, 0xfb, 0x4f, 0xff, 0xf7, 0x5f, 0x3b, 0x53, 0x3f, 0xf9, 0xe1, 0x9a, + 0xfe, 0x87, 0x3f, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0xad, 0xf4, 0x1f, 0x30, 0xfd, 0x07, 0x00, + 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -1159,6 +1207,39 @@ func (m *AccessTuple) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TracerConfig) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TracerConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TracerConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.OnlyTopCall { + i-- + if m.OnlyTopCall { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *TraceConfig) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1179,10 +1260,15 @@ func (m *TraceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.TracerJsonConfig) > 0 { - i -= len(m.TracerJsonConfig) - copy(dAtA[i:], m.TracerJsonConfig) - i = encodeVarintEvm(dAtA, i, uint64(len(m.TracerJsonConfig))) + if m.TracerConfig != nil { + { + size, err := m.TracerConfig.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvm(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x6a } @@ -1450,6 +1536,18 @@ func (m *AccessTuple) Size() (n int) { return n } +func (m *TracerConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.OnlyTopCall { + n += 2 + } + return n +} + func (m *TraceConfig) Size() (n int) { if m == nil { return 0 @@ -1485,8 +1583,8 @@ func (m *TraceConfig) Size() (n int) { if m.EnableReturnData { n += 2 } - l = len(m.TracerJsonConfig) - if l > 0 { + if m.TracerConfig != nil { + l = m.TracerConfig.Size() n += 1 + l + sovEvm(uint64(l)) } return n @@ -2733,6 +2831,76 @@ func (m *AccessTuple) Unmarshal(dAtA []byte) error { } return nil } +func (m *TracerConfig) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TracerConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TracerConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OnlyTopCall", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OnlyTopCall = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipEvm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *TraceConfig) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2966,9 +3134,9 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { m.EnableReturnData = bool(v != 0) case 13: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TracerJsonConfig", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TracerConfig", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvm @@ -2978,23 +3146,27 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthEvm } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthEvm } if postIndex > l { return io.ErrUnexpectedEOF } - m.TracerJsonConfig = string(dAtA[iNdEx:postIndex]) + if m.TracerConfig == nil { + m.TracerConfig = &TracerConfig{} + } + if err := m.TracerConfig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 4509e5ed2..c2c051be3 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -528,9 +528,9 @@ func (k Keeper) TraceTx( } var tracerConfig json.RawMessage - if req.TraceConfig != nil && req.TraceConfig.TracerJsonConfig != "" { + if req.TraceConfig != nil && req.TraceConfig.TracerConfig != nil { // ignore error. default to no traceConfig - _ = json.Unmarshal([]byte(req.TraceConfig.TracerJsonConfig), &tracerConfig) + tracerConfig, _ = json.Marshal(req.TraceConfig.TracerConfig) } msg, err := tx.AsMessage(signer, cfg.BaseFee) @@ -596,9 +596,9 @@ func (k Keeper) TraceCall( txConfig := statedb.NewEmptyTxConfig(gethcommon.BytesToHash(ctx.HeaderHash().Bytes())) var tracerConfig json.RawMessage - if req.TraceConfig != nil && req.TraceConfig.TracerJsonConfig != "" { + if req.TraceConfig != nil && req.TraceConfig.TracerConfig != nil { // ignore error. default to no traceConfig - _ = json.Unmarshal([]byte(req.TraceConfig.TracerJsonConfig), &tracerConfig) + tracerConfig, _ = json.Marshal(req.TraceConfig.TracerConfig) } // req.Msg is not signed, so to gethcore.Message because it's not signed and will fail on getting @@ -681,6 +681,11 @@ func (k Keeper) TraceBlock( if baseFee != nil { cfg.BaseFee = baseFee } + var tracerConfig json.RawMessage + if req.TraceConfig != nil && req.TraceConfig.TracerConfig != nil { + // ignore error. default to no traceConfig + tracerConfig, _ = json.Marshal(req.TraceConfig.TracerConfig) + } signer := gethcore.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) txsLength := len(req.Txs) @@ -698,7 +703,7 @@ func (k Keeper) TraceBlock( result.Error = err.Error() continue } - traceResult, logIndex, err := k.TraceEthTxMsg(ctx, cfg, txConfig, msg, req.TraceConfig, true, nil) + traceResult, logIndex, err := k.TraceEthTxMsg(ctx, cfg, txConfig, msg, req.TraceConfig, true, tracerConfig) if err != nil { result.Error = err.Error() } else {