From 4bbcc99340ed00bd4a8d57af3ee5bffb5ee1ba3b Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 9 Jan 2024 18:18:48 +0800 Subject: [PATCH 01/18] Problem: block overrides is not supported in debug_traceCall --- CHANGELOG.md | 1 + tests/integration_tests/expected_constants.py | 2 ++ tests/integration_tests/test_tracers.py | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a68cfac2b..c3a4166fa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (statedb) [#333](https://github.com/crypto-org-chain/ethermint/pull/333) Support native action in statedb, prepare for precompiles. * (rpc) [#369](https://github.com/crypto-org-chain/ethermint/pull/369) Support state overrides in eth_call. * (precompile) [#371](https://github.com/crypto-org-chain/ethermint/pull/371) Add StateDB itself into native context for precompiles to emit evm logs directly. +* (rpc) [#](https://github.com/crypto-org-chain/ethermint/pull/) Support block overrides in debug_traceCall. ### State Machine Breaking diff --git a/tests/integration_tests/expected_constants.py b/tests/integration_tests/expected_constants.py index cc491d167a..7dd5996d74 100644 --- a/tests/integration_tests/expected_constants.py +++ b/tests/integration_tests/expected_constants.py @@ -159,3 +159,5 @@ "type": "CREATE", "value": "0x0", } + +EXPECTED_BLOCK_OVERRIDES_TRACERS = '{"failed": false, "gas": 53020, "returnValue": "", "structLogs": [{"depth": 1, "gas": 12517, "gasCost": 2, "op": "NUMBER", "pc": 0, "stack": []}, {"depth": 1, "gas": 12515, "gasCost": 0, "op": "STOP", "pc": 1, "stack": ["0x1337"]}]}' # noqa: E501 diff --git a/tests/integration_tests/test_tracers.py b/tests/integration_tests/test_tracers.py index 4c0c5e8537..c932afcde1 100644 --- a/tests/integration_tests/test_tracers.py +++ b/tests/integration_tests/test_tracers.py @@ -5,6 +5,7 @@ from web3 import Web3 from .expected_constants import ( + EXPECTED_BLOCK_OVERRIDES_TRACERS, EXPECTED_CALLTRACERS, EXPECTED_CONTRACT_CREATE_TRACER, EXPECTED_STRUCT_TRACER, @@ -454,3 +455,25 @@ def test_debug_tracecall_return_revert_data_when_call_failed(ethermint): tx_res["returnValue"] == "08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a46756e6374696f6e20686173206265656e207265766572746564000000000000" # noqa: E501 ) + + +def test_debug_tracecall_block_overrides(ethermint, geth): + method = "debug_traceCall" + gas = hex(65535) + price = hex(88500000000) + # https://github.com/ethereum/go-ethereum/blob/v1.11.6/core/vm/opcodes.go#L95 + tx = {"from": ADDRS["validator"], "input": "0x43", "gas": gas, "gasPrice": price} + future_blk = "0x1337" + tracer = {"blockOverrides": {"number": future_blk}} + + def process(w3): + w3_wait_for_new_blocks(w3, 1) + tx_res = w3.provider.make_request(method, [tx, "latest", tracer]) + return json.dumps(tx_res["result"], sort_keys=True) + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert (res[0] == res[-1] == EXPECTED_BLOCK_OVERRIDES_TRACERS), res From 9e4544f094669e6c15251144a291cb3bb545993e Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 9 Jan 2024 18:14:32 +0800 Subject: [PATCH 02/18] cleanup proto --- client/docs/swagger-ui/swagger.yaml | 501 +++++++++++ proto/ethermint/evm/v1/trace_config.proto | 13 + proto/ethermint/evm/v1/trace_config_v0.proto | 13 - .../migrations/v0/types/trace_config_v0.pb.go | 835 +----------------- 4 files changed, 544 insertions(+), 818 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 7bf9bb04d4..63250bb35f 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -2691,6 +2691,448 @@ paths: format: int64 tags: - Query + /ethermint/evm/v1/trace_call: + get: + summary: TraceCall implements the `debug_traceCall` rpc api + operationId: TraceCall + responses: + '200': + description: A successful response. + schema: + type: object + properties: + data: + type: string + format: byte + title: data is the response serialized in bytes + title: QueryTraceCallResponse defines TraceCallResponse + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: args + description: args uses the same json format as the json rpc api. + in: query + required: false + type: string + format: byte + - name: gas_cap + description: gas_cap defines the default gas cap to be used. + in: query + required: false + type: string + format: uint64 + - name: proposer_address + description: proposer_address of the requested block in hex format. + in: query + required: false + type: string + format: byte + - name: trace_config.tracer + description: tracer is a custom javascript tracer. + in: query + required: false + type: string + - name: trace_config.timeout + description: >- + timeout overrides the default timeout of 5 seconds for + JavaScript-based tracing + + calls. + in: query + required: false + type: string + - name: trace_config.reexec + description: >- + reexec defines the number of blocks the tracer is willing to go + back. + in: query + required: false + type: string + format: uint64 + - name: trace_config.disable_stack + description: disable_stack switches stack capture. + in: query + required: false + type: boolean + - name: trace_config.disable_storage + description: disable_storage switches storage capture. + in: query + required: false + type: boolean + - name: trace_config.debug + description: debug can be used to print output during capture end. + in: query + required: false + type: boolean + - name: trace_config.limit + description: >- + limit defines the maximum length of output, but zero means + unlimited. + in: query + required: false + type: integer + format: int32 + - name: trace_config.overrides.homestead_block + description: homestead_block switch (nil no fork, 0 = already homestead). + in: query + required: false + type: string + - name: trace_config.overrides.dao_fork_block + description: >- + dao_fork_block corresponds to TheDAO hard-fork switch block (nil no + fork). + in: query + required: false + type: string + - name: trace_config.overrides.dao_fork_support + description: >- + dao_fork_support defines whether the nodes supports or opposes the + DAO hard-fork. + in: query + required: false + type: boolean + - name: trace_config.overrides.eip150_block + description: >- + eip150_block: EIP150 implements the Gas price changes + + (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil + no fork). + in: query + required: false + type: string + - name: trace_config.overrides.eip150_hash + description: >- + eip150_hash: EIP150 HF hash (needed for header only clients as only + gas pricing changed). + in: query + required: false + type: string + - name: trace_config.overrides.eip155_block + description: 'eip155_block: EIP155Block HF block.' + in: query + required: false + type: string + - name: trace_config.overrides.eip158_block + description: 'eip158_block: EIP158 HF block.' + in: query + required: false + type: string + - name: trace_config.overrides.byzantium_block + description: >- + byzantium_block: Byzantium switch block (nil no fork, 0 = already on + byzantium). + in: query + required: false + type: string + - name: trace_config.overrides.constantinople_block + description: >- + constantinople_block: Constantinople switch block (nil no fork, 0 = + already activated). + in: query + required: false + type: string + - name: trace_config.overrides.petersburg_block + description: >- + petersburg_block: Petersburg switch block (nil same as + Constantinople). + in: query + required: false + type: string + - name: trace_config.overrides.istanbul_block + description: >- + istanbul_block: Istanbul switch block (nil no fork, 0 = already on + istanbul). + in: query + required: false + type: string + - name: trace_config.overrides.muir_glacier_block + description: >- + muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, + 0 = already activated). + in: query + required: false + type: string + - name: trace_config.overrides.berlin_block + description: >- + berlin_block: Berlin switch block (nil = no fork, 0 = already on + berlin). + in: query + required: false + type: string + - name: trace_config.overrides.london_block + description: >- + london_block: London switch block (nil = no fork, 0 = already on + london). + in: query + required: false + type: string + - name: trace_config.overrides.arrow_glacier_block + description: >- + arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no + fork, 0 = already activated). + in: query + required: false + type: string + - name: trace_config.overrides.gray_glacier_block + description: >- + gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no + fork, 0 = already activated). + in: query + required: false + type: string + - name: trace_config.overrides.merge_netsplit_block + description: >- + merge_netsplit_block: Virtual fork after The Merge to use as a + network splitter. + in: query + required: false + type: string + - name: trace_config.overrides.shanghai_time + description: shanghai switch time (nil = no fork, 0 = already on shanghai). + in: query + required: false + type: string + - name: trace_config.overrides.cancun_time + description: cancun switch time (nil = no fork, 0 = already on cancun). + in: query + required: false + type: string + - name: trace_config.overrides.prague_time + description: prague switch time (nil = no fork, 0 = already on prague). + in: query + required: false + type: string + - name: trace_config.enable_memory + description: enable_memory switches memory capture. + in: query + required: false + type: boolean + - name: trace_config.enable_return_data + description: enable_return_data switches the capture of return data. + in: query + required: false + type: boolean + - name: trace_config.tracer_json_config + description: tracer_json_config configures the tracer using a JSON string. + in: query + required: false + type: string + - name: block_number + description: block_number of requested transaction. + in: query + required: false + type: string + format: int64 + - name: block_hash + description: block_hash of requested transaction. + in: query + required: false + type: string + - name: block_time + description: block_time of requested transaction. + in: query + required: false + type: string + format: date-time + - name: chain_id + description: >- + chain_id is the the eip155 chain id parsed from the requested block + header. + in: query + required: false + type: string + format: int64 + tags: + - Query /ethermint/evm/v1/trace_tx: get: summary: TraceTx implements the `debug_traceTransaction` rpc api @@ -3887,6 +4329,29 @@ definitions: format: byte title: include the block hash for json-rpc to use description: MsgEthereumTxResponse defines the Msg/EthereumTx response type. + ethermint.evm.v1.OverrideAccount: + type: object + properties: + nonce: + type: string + format: uint64 + code: + type: string + balance: + type: string + state: + type: object + additionalProperties: + type: string + state_diff: + type: object + additionalProperties: + type: string + description: >- + OverrideAccount indicates the overriding fields of account during the + execution of + + a message call. ethermint.evm.v1.Params: type: object properties: @@ -4232,6 +4697,14 @@ definitions: format: byte title: data is the response serialized in bytes title: QueryTraceBlockResponse defines TraceBlock response + ethermint.evm.v1.QueryTraceCallResponse: + type: object + properties: + data: + type: string + format: byte + title: data is the response serialized in bytes + title: QueryTraceCallResponse defines TraceCallResponse ethermint.evm.v1.QueryTraceTxResponse: type: object properties: @@ -4395,6 +4868,34 @@ definitions: tracer_json_config: type: string title: tracer_json_config configures the tracer using a JSON string + state_overrides: + type: object + additionalProperties: + type: object + properties: + nonce: + type: string + format: uint64 + code: + type: string + balance: + type: string + state: + type: object + additionalProperties: + type: string + state_diff: + type: object + additionalProperties: + type: string + description: >- + OverrideAccount indicates the overriding fields of account during + the execution of + + a message call. + title: >- + temporary state modifications to Geth in order to simulate the effects + of eth_call description: TraceConfig holds extra parameters to trace functions. google.protobuf.Any: type: object diff --git a/proto/ethermint/evm/v1/trace_config.proto b/proto/ethermint/evm/v1/trace_config.proto index cddfa9d42f..b5b8ef8045 100644 --- a/proto/ethermint/evm/v1/trace_config.proto +++ b/proto/ethermint/evm/v1/trace_config.proto @@ -6,6 +6,17 @@ import "ethermint/evm/v1/chain_config.proto"; option go_package = "github.com/evmos/ethermint/x/evm/types"; + +// OverrideAccount indicates the overriding fields of account during the execution of +// a message call. +message OverrideAccount { + uint64 nonce = 1; + string code = 2; + string balance = 3; + map state = 4; + map state_diff = 5 [(gogoproto.jsontag) = "stateDiff"]; +} + // TraceConfig holds extra parameters to trace functions. message TraceConfig { // DEPRECATED: DisableMemory and DisableReturnData have been renamed to @@ -36,4 +47,6 @@ message TraceConfig { 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"]; + // temporary state modifications to Geth in order to simulate the effects of eth_call + map state_overrides = 14 [(gogoproto.jsontag) = "stateOverrides"]; } \ No newline at end of file diff --git a/proto/ethermint/evm/v1/trace_config_v0.proto b/proto/ethermint/evm/v1/trace_config_v0.proto index 28c058199d..2f3657cad8 100644 --- a/proto/ethermint/evm/v1/trace_config_v0.proto +++ b/proto/ethermint/evm/v1/trace_config_v0.proto @@ -6,17 +6,6 @@ import "ethermint/evm/v1/chain_config_v0.proto"; option go_package = "github.com/evmos/ethermint/x/evm/types"; - -// OverrideAccount indicates the overriding fields of account during the execution of -// a message call. -message V0OverrideAccount { - uint64 nonce = 1; - string code = 2; - string balance = 3; - map state = 4; - map state_diff = 5 [(gogoproto.jsontag) = "stateDiff"]; -} - // V0TraceConfig holds extra parameters to trace functions. message V0TraceConfig { // DEPRECATED: DisableMemory and DisableReturnData have been renamed to @@ -47,6 +36,4 @@ message V0TraceConfig { 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"]; - // temporary state modifications to Geth in order to simulate the effects of eth_call - map state_overrides = 14 [(gogoproto.jsontag) = "stateOverrides"]; } diff --git a/x/evm/migrations/v0/types/trace_config_v0.pb.go b/x/evm/migrations/v0/types/trace_config_v0.pb.go index 7c5291ae44..20846f7761 100644 --- a/x/evm/migrations/v0/types/trace_config_v0.pb.go +++ b/x/evm/migrations/v0/types/trace_config_v0.pb.go @@ -23,84 +23,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// OverrideAccount indicates the overriding fields of account during the execution of -// a message call. -type V0OverrideAccount struct { - Nonce uint64 `protobuf:"varint,1,opt,name=nonce,proto3" json:"nonce,omitempty"` - Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` - Balance string `protobuf:"bytes,3,opt,name=balance,proto3" json:"balance,omitempty"` - State map[string]string `protobuf:"bytes,4,rep,name=state,proto3" json:"state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - StateDiff map[string]string `protobuf:"bytes,5,rep,name=state_diff,json=stateDiff,proto3" json:"stateDiff" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *V0OverrideAccount) Reset() { *m = V0OverrideAccount{} } -func (m *V0OverrideAccount) String() string { return proto.CompactTextString(m) } -func (*V0OverrideAccount) ProtoMessage() {} -func (*V0OverrideAccount) Descriptor() ([]byte, []int) { - return fileDescriptor_9e606038a9deeb16, []int{0} -} -func (m *V0OverrideAccount) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *V0OverrideAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_V0OverrideAccount.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 *V0OverrideAccount) XXX_Merge(src proto.Message) { - xxx_messageInfo_V0OverrideAccount.Merge(m, src) -} -func (m *V0OverrideAccount) XXX_Size() int { - return m.Size() -} -func (m *V0OverrideAccount) XXX_DiscardUnknown() { - xxx_messageInfo_V0OverrideAccount.DiscardUnknown(m) -} - -var xxx_messageInfo_V0OverrideAccount proto.InternalMessageInfo - -func (m *V0OverrideAccount) GetNonce() uint64 { - if m != nil { - return m.Nonce - } - return 0 -} - -func (m *V0OverrideAccount) GetCode() string { - if m != nil { - return m.Code - } - return "" -} - -func (m *V0OverrideAccount) GetBalance() string { - if m != nil { - return m.Balance - } - return "" -} - -func (m *V0OverrideAccount) GetState() map[string]string { - if m != nil { - return m.State - } - return nil -} - -func (m *V0OverrideAccount) GetStateDiff() map[string]string { - if m != nil { - return m.StateDiff - } - return nil -} - // V0TraceConfig holds extra parameters to trace functions. type V0TraceConfig struct { // tracer is a custom javascript tracer @@ -126,15 +48,13 @@ type V0TraceConfig struct { 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"` - // temporary state modifications to Geth in order to simulate the effects of eth_call - StateOverrides map[string]*V0OverrideAccount `protobuf:"bytes,14,rep,name=state_overrides,json=stateOverrides,proto3" json:"stateOverrides" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *V0TraceConfig) Reset() { *m = V0TraceConfig{} } func (m *V0TraceConfig) String() string { return proto.CompactTextString(m) } func (*V0TraceConfig) ProtoMessage() {} func (*V0TraceConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_9e606038a9deeb16, []int{1} + return fileDescriptor_9e606038a9deeb16, []int{0} } func (m *V0TraceConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -240,19 +160,8 @@ func (m *V0TraceConfig) GetTracerJsonConfig() string { return "" } -func (m *V0TraceConfig) GetStateOverrides() map[string]*V0OverrideAccount { - if m != nil { - return m.StateOverrides - } - return nil -} - func init() { - proto.RegisterType((*V0OverrideAccount)(nil), "ethermint.evm.v1.V0OverrideAccount") - proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.V0OverrideAccount.StateDiffEntry") - proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.V0OverrideAccount.StateEntry") proto.RegisterType((*V0TraceConfig)(nil), "ethermint.evm.v1.V0TraceConfig") - proto.RegisterMapType((map[string]*V0OverrideAccount)(nil), "ethermint.evm.v1.V0TraceConfig.StateOverridesEntry") } func init() { @@ -260,128 +169,35 @@ func init() { } var fileDescriptor_9e606038a9deeb16 = []byte{ - // 645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x4f, 0xdb, 0x4e, - 0x10, 0xc5, 0x60, 0x43, 0xb2, 0x21, 0xe0, 0xdf, 0x82, 0x7e, 0x5a, 0xe5, 0x90, 0x44, 0x54, 0x42, - 0x39, 0x39, 0x10, 0x54, 0x89, 0xfe, 0x55, 0x1b, 0xe8, 0x05, 0xa9, 0xaa, 0xb4, 0x54, 0x1c, 0x7a, - 0x49, 0x37, 0xf6, 0xda, 0xb8, 0xc4, 0x5e, 0xb4, 0x5e, 0x5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, 0x08, 0xc5, 0x65, 0x3a, - 0x74, 0x5c, 0x16, 0xc9, 0xd7, 0x8b, 0x25, 0xdd, 0xf2, 0x35, 0xbb, 0x51, 0xef, 0x99, 0x18, 0x5f, - 0xd3, 0x64, 0xb8, 0xae, 0xde, 0xb0, 0xa3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xa5, 0xa6, - 0xe7, 0x3d, 0x05, 0x00, 0x00, -} - -func (m *V0OverrideAccount) 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 *V0OverrideAccount) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *V0OverrideAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StateDiff) > 0 { - for k := range m.StateDiff { - v := m.StateDiff[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = encodeVarintTraceConfigV0(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTraceConfigV0(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTraceConfigV0(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x2a - } - } - if len(m.State) > 0 { - for k := range m.State { - v := m.State[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = encodeVarintTraceConfigV0(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTraceConfigV0(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTraceConfigV0(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x22 - } - } - if len(m.Balance) > 0 { - i -= len(m.Balance) - copy(dAtA[i:], m.Balance) - i = encodeVarintTraceConfigV0(dAtA, i, uint64(len(m.Balance))) - i-- - dAtA[i] = 0x1a - } - if len(m.Code) > 0 { - i -= len(m.Code) - copy(dAtA[i:], m.Code) - i = encodeVarintTraceConfigV0(dAtA, i, uint64(len(m.Code))) - i-- - dAtA[i] = 0x12 - } - if m.Nonce != 0 { - i = encodeVarintTraceConfigV0(dAtA, i, uint64(m.Nonce)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil + // 446 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x92, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x6b, 0x68, 0xbb, 0xd4, 0x5b, 0x21, 0x32, 0x15, 0xb2, 0x76, 0x48, 0x23, 0x0e, 0x53, + 0x4e, 0x49, 0x07, 0xe2, 0x84, 0x40, 0xa8, 0xe3, 0x54, 0x89, 0x8b, 0x41, 0x3b, 0x70, 0x89, 0xdc, + 0xf4, 0x25, 0x35, 0x2c, 0xf1, 0xe4, 0xb8, 0xd1, 0xf6, 0x2d, 0xf8, 0x10, 0x7c, 0x18, 0x8e, 0x3b, + 0x72, 0xaa, 0x50, 0x7b, 0xeb, 0xa7, 0x40, 0xb6, 0xd3, 0x76, 0xeb, 0x6e, 0xf9, 0xbd, 0x8f, 0x9f, + 0xbc, 0x7f, 0xf1, 0x19, 0xe8, 0x39, 0xa8, 0x42, 0x94, 0x3a, 0x81, 0xba, 0x48, 0xea, 0xf3, 0x44, + 0x2b, 0x9e, 0x41, 0x9a, 0xc9, 0xf2, 0xbb, 0xc8, 0xd3, 0x7a, 0x14, 0x5f, 0x2b, 0xa9, 0x25, 0xf1, + 0x77, 0xef, 0x62, 0xa8, 0x8b, 0xb8, 0x3e, 0x3f, 0x1d, 0xe4, 0x32, 0x97, 0x56, 0x4c, 0xcc, 0x97, + 0x7b, 0x77, 0xfa, 0xf8, 0x7f, 0xd9, 0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, 0x8c, 0x6b, 0x4e, + 0x4f, 0xac, 0x77, 0xb0, 0x59, 0x0e, 0x7d, 0xa7, 0x32, 0x2b, 0x7e, 0xe2, 0x9a, 0xb3, 0x47, 0x11, + 0xf2, 0x01, 0x13, 0xb7, 0x95, 0xf4, 0x47, 0x25, 0xb7, 0x4b, 0xa5, 0x7d, 0xb3, 0x16, 0x97, 0xdf, + 0xa9, 0x4d, 0xcd, 0xbe, 0xa3, 0x49, 0x25, 0x9b, 0x2e, 0x26, 0x6d, 0xaf, 0xed, 0x77, 0x26, 0x6d, + 0xef, 0xc8, 0xf7, 0x76, 0x13, 0x6c, 0xba, 0x60, 0x2f, 0xb6, 0x7c, 0xaf, 0xbc, 0xf1, 0xc7, 0x3f, + 0xab, 0x00, 0xdd, 0xad, 0x02, 0xf4, 0x6f, 0x15, 0xa0, 0x5f, 0xeb, 0xa0, 0x75, 0xb7, 0x0e, 0x5a, + 0x7f, 0xd7, 0x41, 0xeb, 0xdb, 0x59, 0x2e, 0xf4, 0x7c, 0x31, 0x8d, 0x33, 0x59, 0x98, 0x4b, 0x93, + 0x55, 0xb2, 0xbf, 0xbc, 0x1b, 0x7b, 0x7b, 0xfa, 0xf6, 0x1a, 0xaa, 0x69, 0xd7, 0xde, 0xdb, 0x9b, + 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x90, 0x46, 0xa8, 0xc4, 0xe9, 0x02, 0x00, 0x00, } func (m *V0TraceConfig) Marshal() (dAtA []byte, err error) { @@ -404,32 +220,6 @@ func (m *V0TraceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.StateOverrides) > 0 { - for k := range m.StateOverrides { - v := m.StateOverrides[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTraceConfigV0(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTraceConfigV0(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTraceConfigV0(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x72 - } - } if len(m.TracerJsonConfig) > 0 { i -= len(m.TracerJsonConfig) copy(dAtA[i:], m.TracerJsonConfig) @@ -537,42 +327,6 @@ func encodeVarintTraceConfigV0(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *V0OverrideAccount) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Nonce != 0 { - n += 1 + sovTraceConfigV0(uint64(m.Nonce)) - } - l = len(m.Code) - if l > 0 { - n += 1 + l + sovTraceConfigV0(uint64(l)) - } - l = len(m.Balance) - if l > 0 { - n += 1 + l + sovTraceConfigV0(uint64(l)) - } - if len(m.State) > 0 { - for k, v := range m.State { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovTraceConfigV0(uint64(len(k))) + 1 + len(v) + sovTraceConfigV0(uint64(len(v))) - n += mapEntrySize + 1 + sovTraceConfigV0(uint64(mapEntrySize)) - } - } - if len(m.StateDiff) > 0 { - for k, v := range m.StateDiff { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovTraceConfigV0(uint64(len(k))) + 1 + len(v) + sovTraceConfigV0(uint64(len(v))) - n += mapEntrySize + 1 + sovTraceConfigV0(uint64(mapEntrySize)) - } - } - return n -} - func (m *V0TraceConfig) Size() (n int) { if m == nil { return 0 @@ -616,19 +370,6 @@ func (m *V0TraceConfig) Size() (n int) { if l > 0 { n += 1 + l + sovTraceConfigV0(uint64(l)) } - if len(m.StateOverrides) > 0 { - for k, v := range m.StateOverrides { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovTraceConfigV0(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovTraceConfigV0(uint64(len(k))) + l - n += mapEntrySize + 1 + sovTraceConfigV0(uint64(mapEntrySize)) - } - } return n } @@ -638,393 +379,6 @@ func sovTraceConfigV0(x uint64) (n int) { func sozTraceConfigV0(x uint64) (n int) { return sovTraceConfigV0(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *V0OverrideAccount) 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 ErrIntOverflowTraceConfigV0 - } - 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: V0OverrideAccount: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: V0OverrideAccount: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) - } - m.Nonce = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Code = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Balance = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.State == nil { - m.State = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := skipTraceConfigV0(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.State[mapkey] = mapvalue - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StateDiff", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.StateDiff == nil { - m.StateDiff = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := skipTraceConfigV0(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.StateDiff[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTraceConfigV0(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *V0TraceConfig) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1324,135 +678,6 @@ func (m *V0TraceConfig) Unmarshal(dAtA []byte) error { } m.TracerJsonConfig = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StateOverrides", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.StateOverrides == nil { - m.StateOverrides = make(map[string]*V0OverrideAccount) - } - var mapkey string - var mapvalue *V0OverrideAccount - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfigV0 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthTraceConfigV0 - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &V0OverrideAccount{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipTraceConfigV0(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfigV0 - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.StateOverrides[mapkey] = mapvalue - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTraceConfigV0(dAtA[iNdEx:]) From 80175f11a89e0988b47c90fdc164e2cb5436ee8a Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 9 Jan 2024 18:17:59 +0800 Subject: [PATCH 03/18] add block overrides --- client/docs/swagger-ui/swagger.yaml | 121 +++++ proto/ethermint/evm/v1/trace_config.proto | 16 +- rpc/backend/tracing.go | 1 + rpc/types/types.go | 40 ++ x/evm/keeper/grpc_query.go | 21 +- x/evm/keeper/state_transition.go | 54 +- x/evm/keeper/state_transition_test.go | 2 +- x/evm/types/trace_config.pb.go | 631 ++++++++++++++++++++-- 8 files changed, 820 insertions(+), 66 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 63250bb35f..84d56814d2 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -2658,6 +2658,34 @@ paths: in: query required: false type: string + - name: trace_config.block_overrides.number + in: query + required: false + type: string + - name: trace_config.block_overrides.difficulty + in: query + required: false + type: string + - name: trace_config.block_overrides.time + in: query + required: false + type: string + - name: trace_config.block_overrides.gas_limit + in: query + required: false + type: string + - name: trace_config.block_overrides.coinbase + in: query + required: false + type: string + - name: trace_config.block_overrides.random + in: query + required: false + type: string + - name: trace_config.block_overrides.base_fee + in: query + required: false + type: string - name: block_number description: block_number of the traced block. in: query @@ -3106,6 +3134,34 @@ paths: in: query required: false type: string + - name: trace_config.block_overrides.number + in: query + required: false + type: string + - name: trace_config.block_overrides.difficulty + in: query + required: false + type: string + - name: trace_config.block_overrides.time + in: query + required: false + type: string + - name: trace_config.block_overrides.gas_limit + in: query + required: false + type: string + - name: trace_config.block_overrides.coinbase + in: query + required: false + type: string + - name: trace_config.block_overrides.random + in: query + required: false + type: string + - name: trace_config.block_overrides.base_fee + in: query + required: false + type: string - name: block_number description: block_number of requested transaction. in: query @@ -3617,6 +3673,34 @@ paths: in: query required: false type: string + - name: trace_config.block_overrides.number + in: query + required: false + type: string + - name: trace_config.block_overrides.difficulty + in: query + required: false + type: string + - name: trace_config.block_overrides.time + in: query + required: false + type: string + - name: trace_config.block_overrides.gas_limit + in: query + required: false + type: string + - name: trace_config.block_overrides.coinbase + in: query + required: false + type: string + - name: trace_config.block_overrides.random + in: query + required: false + type: string + - name: trace_config.block_overrides.base_fee + in: query + required: false + type: string - name: block_number description: block_number of requested transaction. in: query @@ -3880,6 +3964,24 @@ paths: tags: - Query definitions: + ethermint.evm.v1.BlockOverrides: + type: object + properties: + number: + type: string + difficulty: + type: string + time: + type: string + gas_limit: + type: string + coinbase: + type: string + random: + type: string + base_fee: + type: string + description: BlockOverrides is a set of header fields to override. ethermint.evm.v1.ChainConfig: type: object properties: @@ -4896,6 +4998,25 @@ definitions: title: >- temporary state modifications to Geth in order to simulate the effects of eth_call + block_overrides: + title: overrides block context fields + type: object + properties: + number: + type: string + difficulty: + type: string + time: + type: string + gas_limit: + type: string + coinbase: + type: string + random: + type: string + base_fee: + type: string + description: BlockOverrides is a set of header fields to override. description: TraceConfig holds extra parameters to trace functions. google.protobuf.Any: type: object diff --git a/proto/ethermint/evm/v1/trace_config.proto b/proto/ethermint/evm/v1/trace_config.proto index b5b8ef8045..134feb71d0 100644 --- a/proto/ethermint/evm/v1/trace_config.proto +++ b/proto/ethermint/evm/v1/trace_config.proto @@ -6,17 +6,27 @@ import "ethermint/evm/v1/chain_config.proto"; option go_package = "github.com/evmos/ethermint/x/evm/types"; - // OverrideAccount indicates the overriding fields of account during the execution of // a message call. message OverrideAccount { - uint64 nonce = 1; + uint64 nonce = 1; string code = 2; string balance = 3; map state = 4; map state_diff = 5 [(gogoproto.jsontag) = "stateDiff"]; } +// BlockOverrides is a set of header fields to override. +message BlockOverrides { + string number = 1; + string difficulty = 2; + string time = 3; + string gas_limit = 4 [(gogoproto.jsontag) = "gasLimit"]; + string coinbase = 5; + string random = 6; + string base_fee = 7 [(gogoproto.jsontag) = "baseFee"]; +} + // TraceConfig holds extra parameters to trace functions. message TraceConfig { // DEPRECATED: DisableMemory and DisableReturnData have been renamed to @@ -49,4 +59,6 @@ message TraceConfig { string tracer_json_config = 13 [(gogoproto.jsontag) = "tracerConfig"]; // temporary state modifications to Geth in order to simulate the effects of eth_call map state_overrides = 14 [(gogoproto.jsontag) = "stateOverrides"]; + // overrides block context fields + BlockOverrides block_overrides = 15 [(gogoproto.jsontag) = "blockOverrides"]; } \ No newline at end of file diff --git a/rpc/backend/tracing.go b/rpc/backend/tracing.go index 2f7f821197..34a10a1600 100644 --- a/rpc/backend/tracing.go +++ b/rpc/backend/tracing.go @@ -135,6 +135,7 @@ func (b *Backend) convertConfig(config *rpctypes.TraceConfig) *evmtypes.TraceCon } cfg := config.TraceConfig cfg.TracerJsonConfig = string(config.TracerConfig) + cfg.BlockOverrides = config.BlockOverrides return &cfg } diff --git a/rpc/types/types.go b/rpc/types/types.go index 11043b52ae..907de87254 100644 --- a/rpc/types/types.go +++ b/rpc/types/types.go @@ -23,6 +23,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" ) @@ -109,6 +110,45 @@ func (diff *StateOverride) Apply(db *statedb.StateDB) error { return nil } +// BlockOverrides is a set of header fields to override. +type BlockOverrides struct { + Number *hexutil.Big + Difficulty *hexutil.Big + Time *hexutil.Uint64 + GasLimit *hexutil.Uint64 + Coinbase *common.Address + Random *common.Hash + BaseFee *hexutil.Big +} + +// Apply overrides the given header fields into the given block context. +func (diff *BlockOverrides) Apply(blockCtx *vm.BlockContext) { + if diff == nil { + return + } + if diff.Number != nil { + blockCtx.BlockNumber = diff.Number.ToInt() + } + if diff.Difficulty != nil { + blockCtx.Difficulty = diff.Difficulty.ToInt() + } + if diff.Time != nil { + blockCtx.Time = uint64(*diff.Time) + } + if diff.GasLimit != nil { + blockCtx.GasLimit = uint64(*diff.GasLimit) + } + if diff.Coinbase != nil { + blockCtx.Coinbase = *diff.Coinbase + } + if diff.Random != nil { + blockCtx.Random = diff.Random + } + if diff.BaseFee != nil { + blockCtx.BaseFee = diff.BaseFee.ToInt() + } +} + // OverrideAccount indicates the overriding fields of account during the execution of // a message call. // Note, state and stateDiff can't be specified at the same time. If state is diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 95f8eabd27..bb033985ed 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -267,7 +267,7 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) // pass false to not commit StateDB - res, err := k.ApplyMessageWithConfig(ctx, msg, nil, false, cfg, txConfig, &overrides, false) + res, err := k.ApplyMessageWithConfig(ctx, msg, nil, false, cfg, txConfig, &overrides, nil, false) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -362,7 +362,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type } // pass false to not commit StateDB - rsp, err = k.ApplyMessageWithConfig(ctx, msg, nil, false, cfg, txConfig, nil, false) + rsp, err = k.ApplyMessageWithConfig(ctx, msg, nil, false, cfg, txConfig, nil, nil, false) if err != nil { if errors.Is(err, core.ErrIntrinsicGas) { return true, nil, nil // Special case, raise gas limit @@ -444,7 +444,7 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ } txConfig.TxHash = ethTx.Hash() txConfig.TxIndex = uint(i) - rsp, err := k.ApplyMessageWithConfig(ctx, *msg, types.NewNoOpTracer(), true, cfg, txConfig, nil, true) + rsp, err := k.ApplyMessageWithConfig(ctx, *msg, types.NewNoOpTracer(), true, cfg, txConfig, nil, nil, true) if err != nil { continue } @@ -686,8 +686,19 @@ func (k *Keeper) traceMsg( return nil, 0, status.Error(codes.InvalidArgument, err.Error()) } } + var blockOverrides rpctypes.BlockOverrides + if traceConfig.BlockOverrides != nil { + config, err := json.Marshal(traceConfig.BlockOverrides) + if err != nil { + return nil, 0, status.Error(codes.InvalidArgument, err.Error()) + } + + if err := json.Unmarshal(config, &blockOverrides); err != nil { + return nil, 0, status.Error(codes.InvalidArgument, err.Error()) + } + } - res, err := k.ApplyMessageWithConfig(ctx, msg, tracer, commitMessage, cfg, txConfig, &stateOverrides, true) + res, err := k.ApplyMessageWithConfig(ctx, msg, tracer, commitMessage, cfg, txConfig, &stateOverrides, &blockOverrides, true) if err != nil { return nil, 0, status.Error(codes.Internal, err.Error()) } @@ -794,7 +805,7 @@ func (k *Keeper) traceTx( } } - res, err := k.ApplyMessageWithConfig(ctx, *msg, tracer, commitMessage, cfg, txConfig, &stateOverrides, true) + res, err := k.ApplyMessageWithConfig(ctx, *msg, tracer, commitMessage, cfg, txConfig, &stateOverrides, nil, true) if err != nil { return nil, 0, status.Error(codes.Internal, err.Error()) } diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 6c9b17085e..956130f088 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -39,6 +39,21 @@ import ( "github.com/ethereum/go-ethereum/params" ) +func (k *Keeper) NewEVMBlockContext(ctx sdk.Context, cfg *statedb.EVMConfig) vm.BlockContext { + return vm.BlockContext{ + CanTransfer: core.CanTransfer, + Transfer: core.Transfer, + GetHash: k.GetHashFn(ctx), + Coinbase: cfg.CoinBase, + GasLimit: ethermint.BlockGasLimit(ctx), + BlockNumber: big.NewInt(ctx.BlockHeight()), + Time: uint64(ctx.BlockHeader().Time.Unix()), + Difficulty: big.NewInt(0), // unused. Only required in PoW context + BaseFee: cfg.BaseFee, + Random: nil, // not supported + } +} + // NewEVM generates a go-ethereum VM from the provided Message fields and the chain parameters // (ChainConfig and module Params). It additionally sets the validator operator address as the // coinbase address to make it available for the COINBASE opcode, even though there is no @@ -47,7 +62,6 @@ import ( // NOTE: the RANDOM opcode is currently not supported since it requires // RANDAO implementation. See https://github.com/evmos/ethermint/pull/1520#pullrequestreview-1200504697 // for more information. - func (k *Keeper) NewEVM( ctx sdk.Context, msg core.Message, @@ -55,18 +69,18 @@ func (k *Keeper) NewEVM( tracer vm.EVMLogger, stateDB vm.StateDB, ) *vm.EVM { - blockCtx := vm.BlockContext{ - CanTransfer: core.CanTransfer, - Transfer: core.Transfer, - GetHash: k.GetHashFn(ctx), - Coinbase: cfg.CoinBase, - GasLimit: ethermint.BlockGasLimit(ctx), - BlockNumber: big.NewInt(ctx.BlockHeight()), - Time: uint64(ctx.BlockHeader().Time.Unix()), - Difficulty: big.NewInt(0), // unused. Only required in PoW context - BaseFee: cfg.BaseFee, - Random: nil, // not supported - } + blockCtx := k.NewEVMBlockContext(ctx, cfg) + return k.NewEVMWithBlockCtx(ctx, msg, cfg, tracer, stateDB, blockCtx) +} + +func (k *Keeper) NewEVMWithBlockCtx( + ctx sdk.Context, + msg core.Message, + cfg *statedb.EVMConfig, + tracer vm.EVMLogger, + stateDB vm.StateDB, + blockCtx vm.BlockContext, +) *vm.EVM { txCtx := core.NewEVMTxContext(&msg) if tracer == nil { tracer = k.Tracer(ctx, msg, cfg.ChainConfig) @@ -196,7 +210,7 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, msgEth *types.MsgEthereumTx) } // pass true to commit the StateDB - res, err := k.ApplyMessageWithConfig(tmpCtx, msg, nil, true, cfg, txConfig, nil, false) + res, err := k.ApplyMessageWithConfig(tmpCtx, msg, nil, true, cfg, txConfig, nil, nil, false) if err != nil { return nil, errorsmod.Wrap(err, "failed to apply ethereum core message") } @@ -288,7 +302,7 @@ func (k *Keeper) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLo } txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())) - return k.ApplyMessageWithConfig(ctx, msg, tracer, commit, cfg, txConfig, nil, false) + return k.ApplyMessageWithConfig(ctx, msg, tracer, commit, cfg, txConfig, nil, nil, false) } // ApplyMessageWithConfig computes the new state by applying the given message against the existing state. @@ -345,6 +359,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, cfg *statedb.EVMConfig, txConfig statedb.TxConfig, overrides *rpctypes.StateOverride, + blockOverrides *rpctypes.BlockOverrides, debugTrace bool, ) (*types.MsgEthereumTxResponse, error) { var ( @@ -360,13 +375,20 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, } stateDB := statedb.NewWithParams(ctx, k, txConfig, cfg.Params) + var evm *vm.EVM if overrides != nil { if err := overrides.Apply(stateDB); err != nil { return nil, errorsmod.Wrap(err, "failed to apply state override") } } + if debugTrace && blockOverrides != nil { + blockCtx := k.NewEVMBlockContext(ctx, cfg) + blockOverrides.Apply(&blockCtx) + evm = k.NewEVMWithBlockCtx(ctx, msg, cfg, tracer, stateDB, blockCtx) + } else { + evm = k.NewEVM(ctx, msg, cfg, tracer, stateDB) + } - evm := k.NewEVM(ctx, msg, cfg, tracer, stateDB) leftoverGas := msg.GasLimit sender := vm.AccountRef(msg.From) // Allow the tracer captures the tx level events, mainly the gas consumption. diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 26b1e96e10..ed5508110f 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -657,7 +657,7 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { txConfig = suite.app.EvmKeeper.TxConfig(suite.ctx, common.Hash{}) tc.malleate() - res, err := suite.app.EvmKeeper.ApplyMessageWithConfig(suite.ctx, msg, nil, true, config, txConfig, nil, false) + res, err := suite.app.EvmKeeper.ApplyMessageWithConfig(suite.ctx, msg, nil, true, config, txConfig, nil, nil, false) if tc.expErr { suite.Require().Error(err) diff --git a/x/evm/types/trace_config.pb.go b/x/evm/types/trace_config.pb.go index b463dfb823..0de526674d 100644 --- a/x/evm/types/trace_config.pb.go +++ b/x/evm/types/trace_config.pb.go @@ -101,6 +101,99 @@ func (m *OverrideAccount) GetStateDiff() map[string]string { return nil } +// BlockOverrides is a set of header fields to override. +type BlockOverrides struct { + Number string `protobuf:"bytes,1,opt,name=number,proto3" json:"number,omitempty"` + Difficulty string `protobuf:"bytes,2,opt,name=difficulty,proto3" json:"difficulty,omitempty"` + Time string `protobuf:"bytes,3,opt,name=time,proto3" json:"time,omitempty"` + GasLimit string `protobuf:"bytes,4,opt,name=gas_limit,json=gasLimit,proto3" json:"gasLimit"` + Coinbase string `protobuf:"bytes,5,opt,name=coinbase,proto3" json:"coinbase,omitempty"` + Random string `protobuf:"bytes,6,opt,name=random,proto3" json:"random,omitempty"` + BaseFee string `protobuf:"bytes,7,opt,name=base_fee,json=baseFee,proto3" json:"baseFee"` +} + +func (m *BlockOverrides) Reset() { *m = BlockOverrides{} } +func (m *BlockOverrides) String() string { return proto.CompactTextString(m) } +func (*BlockOverrides) ProtoMessage() {} +func (*BlockOverrides) Descriptor() ([]byte, []int) { + return fileDescriptor_8f7fb70914ae5a53, []int{1} +} +func (m *BlockOverrides) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BlockOverrides) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BlockOverrides.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 *BlockOverrides) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlockOverrides.Merge(m, src) +} +func (m *BlockOverrides) XXX_Size() int { + return m.Size() +} +func (m *BlockOverrides) XXX_DiscardUnknown() { + xxx_messageInfo_BlockOverrides.DiscardUnknown(m) +} + +var xxx_messageInfo_BlockOverrides proto.InternalMessageInfo + +func (m *BlockOverrides) GetNumber() string { + if m != nil { + return m.Number + } + return "" +} + +func (m *BlockOverrides) GetDifficulty() string { + if m != nil { + return m.Difficulty + } + return "" +} + +func (m *BlockOverrides) GetTime() string { + if m != nil { + return m.Time + } + return "" +} + +func (m *BlockOverrides) GetGasLimit() string { + if m != nil { + return m.GasLimit + } + return "" +} + +func (m *BlockOverrides) GetCoinbase() string { + if m != nil { + return m.Coinbase + } + return "" +} + +func (m *BlockOverrides) GetRandom() string { + if m != nil { + return m.Random + } + return "" +} + +func (m *BlockOverrides) GetBaseFee() string { + if m != nil { + return m.BaseFee + } + return "" +} + // TraceConfig holds extra parameters to trace functions. type TraceConfig struct { // tracer is a custom javascript tracer @@ -128,13 +221,15 @@ type TraceConfig struct { TracerJsonConfig string `protobuf:"bytes,13,opt,name=tracer_json_config,json=tracerJsonConfig,proto3" json:"tracerConfig"` // temporary state modifications to Geth in order to simulate the effects of eth_call StateOverrides map[string]*OverrideAccount `protobuf:"bytes,14,rep,name=state_overrides,json=stateOverrides,proto3" json:"stateOverrides" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // overrides block context fields + BlockOverrides *BlockOverrides `protobuf:"bytes,15,opt,name=block_overrides,json=blockOverrides,proto3" json:"blockOverrides"` } 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_8f7fb70914ae5a53, []int{1} + return fileDescriptor_8f7fb70914ae5a53, []int{2} } func (m *TraceConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -247,10 +342,18 @@ func (m *TraceConfig) GetStateOverrides() map[string]*OverrideAccount { return nil } +func (m *TraceConfig) GetBlockOverrides() *BlockOverrides { + if m != nil { + return m.BlockOverrides + } + return nil +} + func init() { proto.RegisterType((*OverrideAccount)(nil), "ethermint.evm.v1.OverrideAccount") proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.OverrideAccount.StateDiffEntry") proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.OverrideAccount.StateEntry") + proto.RegisterType((*BlockOverrides)(nil), "ethermint.evm.v1.BlockOverrides") proto.RegisterType((*TraceConfig)(nil), "ethermint.evm.v1.TraceConfig") proto.RegisterMapType((map[string]*OverrideAccount)(nil), "ethermint.evm.v1.TraceConfig.StateOverridesEntry") } @@ -260,47 +363,56 @@ func init() { } var fileDescriptor_8f7fb70914ae5a53 = []byte{ - // 638 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6f, 0xd3, 0x30, - 0x14, 0x5e, 0xb6, 0x64, 0x6b, 0xdd, 0xfd, 0x88, 0xbc, 0x09, 0x59, 0x95, 0x68, 0xc3, 0x90, 0x50, - 0x0e, 0x28, 0x65, 0x43, 0x88, 0x89, 0x21, 0x04, 0xdd, 0xb8, 0x4c, 0x42, 0x48, 0x1e, 0x27, 0x0e, - 0x54, 0x6e, 0xe2, 0x66, 0x61, 0x4d, 0x3c, 0x39, 0x4e, 0xb4, 0xfe, 0x17, 0xfc, 0x59, 0x1c, 0x77, - 0xe4, 0x54, 0xa1, 0xed, 0xd6, 0x1b, 0x17, 0xce, 0xc8, 0x76, 0xd2, 0xf4, 0xc7, 0x24, 0xe0, 0xf6, - 0xbe, 0xf7, 0xde, 0xf7, 0xec, 0xf7, 0xde, 0x67, 0x83, 0xc7, 0x54, 0x5c, 0x50, 0x1e, 0x47, 0x89, - 0xe8, 0xd0, 0x3c, 0xee, 0xe4, 0x07, 0x1d, 0xc1, 0x89, 0x4f, 0x7b, 0x3e, 0x4b, 0x06, 0x51, 0xe8, - 0x5d, 0x71, 0x26, 0x18, 0xb4, 0xa7, 0x49, 0x1e, 0xcd, 0x63, 0x2f, 0x3f, 0x68, 0xee, 0x85, 0x2c, - 0x64, 0x2a, 0xd8, 0x91, 0x96, 0xce, 0x6b, 0x2e, 0x17, 0xf3, 0x2f, 0x48, 0x94, 0xcc, 0x15, 0xdb, - 0xff, 0xb5, 0x0a, 0x76, 0x3e, 0xe6, 0x94, 0xf3, 0x28, 0xa0, 0xef, 0x7c, 0x9f, 0x65, 0x89, 0x80, - 0x7b, 0xc0, 0x4a, 0x58, 0xe2, 0x53, 0x64, 0x38, 0x86, 0x6b, 0x62, 0x0d, 0x20, 0x04, 0xa6, 0xcf, - 0x02, 0x8a, 0x56, 0x1d, 0xc3, 0xad, 0x63, 0x65, 0x43, 0x04, 0x36, 0xfa, 0x64, 0x48, 0x64, 0xee, - 0x9a, 0x72, 0x97, 0x10, 0x76, 0x81, 0x95, 0x0a, 0x22, 0x28, 0x32, 0x9d, 0x35, 0xb7, 0x71, 0xf8, - 0xd4, 0x5b, 0xbc, 0xb4, 0xb7, 0x70, 0xaa, 0x77, 0x2e, 0xd3, 0xdf, 0x27, 0x82, 0x8f, 0xb0, 0xa6, - 0xc2, 0x2f, 0x00, 0x28, 0xa3, 0x17, 0x44, 0x83, 0x01, 0xb2, 0x54, 0xa1, 0x67, 0xff, 0x58, 0xe8, - 0x34, 0x1a, 0x0c, 0x54, 0xb1, 0xee, 0xd6, 0x64, 0xdc, 0xae, 0xa7, 0xa5, 0x0f, 0x57, 0x66, 0xf3, - 0x08, 0x80, 0xea, 0x50, 0x68, 0x83, 0xb5, 0x4b, 0x3a, 0x52, 0x3d, 0xd7, 0xb1, 0x34, 0xe5, 0x1c, - 0x72, 0x32, 0xcc, 0xca, 0x96, 0x35, 0x78, 0xb5, 0x7a, 0x64, 0x34, 0x5f, 0x83, 0xed, 0xf9, 0x53, - 0xfe, 0x87, 0xbd, 0xff, 0xdb, 0x02, 0x8d, 0x4f, 0x72, 0xaf, 0x27, 0x6a, 0x13, 0xf0, 0x01, 0x58, - 0x57, 0x6b, 0xe6, 0x05, 0xbd, 0x40, 0x72, 0xba, 0x22, 0x8a, 0x29, 0xcb, 0x44, 0x51, 0xa3, 0x84, - 0x92, 0xc1, 0x29, 0xbd, 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55, 0xf7, 0xdb, 0x4a, 0xce, 0x07, 0xcb, - 0xdd, 0xcf, 0x28, 0x43, 0x4b, 0xb9, 0xd4, 0x77, 0xaa, 0xf5, 0xac, 0x76, 0x92, 0xce, 0x05, 0xf0, - 0x02, 0x6e, 0x06, 0x60, 0xf7, 0x1e, 0xea, 0x3d, 0x22, 0x7d, 0x39, 0x2b, 0xd2, 0xc6, 0xe1, 0xa3, - 0xbf, 0xbe, 0xae, 0x19, 0x1d, 0x9f, 0x99, 0x35, 0xd3, 0xb6, 0xce, 0xcc, 0xda, 0x86, 0x5d, 0x9b, - 0xaa, 0xa2, 0xd8, 0x0d, 0xde, 0x2d, 0xf1, 0xcc, 0xd0, 0xbb, 0x6f, 0xbf, 0xdf, 0xb6, 0x8c, 0x9b, - 0xdb, 0x96, 0xf1, 0xf3, 0xb6, 0x65, 0x7c, 0xbb, 0x6b, 0xad, 0xdc, 0xdc, 0xb5, 0x56, 0x7e, 0xdc, - 0xb5, 0x56, 0x3e, 0x3f, 0x09, 0x23, 0x71, 0x91, 0xf5, 0x3d, 0x9f, 0xc5, 0xf2, 0xb3, 0x62, 0x69, - 0xa7, 0xfa, 0xbc, 0xae, 0xd5, 0xf7, 0x25, 0x46, 0x57, 0x34, 0xed, 0xaf, 0xab, 0x5f, 0xeb, 0xf9, - 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0xae, 0x65, 0x40, 0x29, 0x05, 0x00, 0x00, + // 773 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4f, 0x6b, 0xdb, 0x4a, + 0x10, 0x8f, 0x12, 0xd9, 0x96, 0xc7, 0x89, 0x6d, 0x36, 0xe1, 0x21, 0x0c, 0xcf, 0xf6, 0xcb, 0x83, + 0xe0, 0x07, 0x0f, 0xbb, 0x49, 0x29, 0x0d, 0x4d, 0x29, 0xad, 0x92, 0xf6, 0x10, 0x5a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, 0x19, 0xf2, 0x68, 0x8c, 0x95, 0x2b, 0xfa, 0x08, 0x20, 0x85, 0xbe, 0xeb, 0x0f, 0x06, 0x66, + 0x41, 0x06, 0x7a, 0xf0, 0x9b, 0x81, 0xce, 0xfc, 0xc1, 0x40, 0x06, 0xb3, 0x76, 0x66, 0x93, 0x56, + 0x39, 0xce, 0x74, 0x78, 0x21, 0x36, 0x8e, 0x01, 0x16, 0x49, 0x51, 0x1d, 0xb6, 0xae, 0xe8, 0x58, + 0x72, 0x2e, 0x63, 0x21, 0x8a, 0x7b, 0x18, 0x91, 0x61, 0x92, 0x51, 0x56, 0xe0, 0xc9, 0xe6, 0xb1, + 0xd6, 0x78, 0x0a, 0xd5, 0x7c, 0x96, 0x3f, 0xf1, 0xde, 0x9f, 0x6a, 0x50, 0xb5, 0x86, 0xcc, 0xb9, + 0xca, 0x2a, 0x8f, 0xd1, 0x5f, 0x50, 0x0c, 0x93, 0xc0, 0xa6, 0x51, 0x1a, 0x21, 0x45, 0xa8, 0x09, + 0x20, 0xc8, 0xfb, 0x4e, 0x32, 0xe4, 0xe3, 0x34, 0xd2, 0x92, 0x46, 0x34, 0x85, 0xfb, 0x41, 0x76, + 0xfb, 0x52, 0x46, 0xff, 0x41, 0xd9, 0x23, 0x71, 0x7f, 0xe8, 0x07, 0x3e, 0x37, 0x75, 0x61, 0xb0, + 0xb6, 0x67, 0x93, 0x96, 0xe1, 0x91, 0xf8, 0xb5, 0xd0, 0xe1, 0xb9, 0x84, 0x1a, 0x60, 0x38, 0xcc, + 0x0f, 0x6d, 0x12, 0x53, 0xb3, 0x20, 0x43, 0xcc, 0xb1, 0x28, 0x29, 0x22, 0xa1, 0xcb, 0x02, 0xb3, + 0xa8, 0x4a, 0x52, 0x08, 0x1d, 0x80, 0x21, 0xec, 0xfd, 0x01, 0xa5, 0x66, 0x49, 0x46, 0xaf, 0xcc, + 0x26, 0xad, 0x92, 0xd0, 0xbd, 0xa2, 0x14, 0x67, 0xc2, 0xfe, 0xd7, 0x22, 0x54, 0xde, 0x89, 0xe9, + 0x3d, 0x95, 0xf3, 0x26, 0xe2, 0xc9, 0x61, 0x9e, 0x53, 0x54, 0x48, 0xcc, 0x90, 0x28, 0x9b, 0x25, + 0x3c, 0xe5, 0x97, 0x41, 0x59, 0x01, 0xa5, 0x37, 0xd4, 0x91, 0xf4, 0x74, 0x9c, 0x22, 0xf4, 0x08, + 0x76, 0x5c, 0x3f, 0x26, 0xf6, 0x90, 0xf6, 0x63, 0x4e, 0x9c, 0x2b, 0x59, 0xba, 0x61, 0xd5, 0x67, + 0x93, 0xd6, 0x76, 0x6a, 0xb8, 0x10, 0x7a, 0x9c, 0x43, 0xe8, 0x04, 0x6a, 0x0b, 0x37, 0x16, 0x11, + 0x8f, 0x4a, 0x66, 0x86, 0x85, 0x66, 0x93, 0x56, 0x75, 0x7e, 0x54, 0x5a, 0xf0, 0x0a, 0x16, 0xdd, + 0x74, 0xa9, 0x9d, 0x78, 0xa6, 0x21, 0x5c, 0xb0, 0x02, 0x42, 0xab, 0xae, 0xb9, 0xdc, 0xd6, 0x3a, + 0x05, 0xac, 0x00, 0x3a, 0x81, 0x32, 0xcb, 0x3a, 0x6b, 0x42, 0x5b, 0xeb, 0x54, 0x8e, 0xfe, 0x5e, + 0x1f, 0xdb, 0x53, 0xb1, 0x8c, 0xea, 0x6e, 0xf0, 0xe2, 0xbc, 0x20, 0x47, 0x43, 0x59, 0x64, 0x40, + 0x03, 0x16, 0x8d, 0xcd, 0xca, 0x82, 0x9c, 0x32, 0xbc, 0x91, 0x7a, 0x9c, 0x43, 0xc8, 0x02, 0x94, + 0xba, 0x45, 0x94, 0x27, 0x51, 0xd8, 0x77, 0x09, 0x27, 0xe6, 0xb6, 0xf4, 0xdd, 0x9b, 0x4d, 0x5a, + 0x75, 0x65, 0xc5, 0xd2, 0x78, 0x46, 0x38, 0xc1, 0x6b, 0x1a, 0xf4, 0x0c, 0x90, 0xea, 0x49, 0xff, + 0x53, 0xcc, 0xb2, 0x77, 0xc2, 0xdc, 0x91, 0x3d, 0x96, 0xf9, 0x95, 0x35, 0xad, 0xb9, 0xae, 0xd0, + 0x79, 0xcc, 0x52, 0x16, 0x28, 0x84, 0x9a, 0xda, 0xd7, 0x05, 0xfb, 0xaa, 0x5c, 0xda, 0xc3, 0x75, + 0xf6, 0x4b, 0x93, 0xa1, 0x16, 0x76, 0xbe, 0x0b, 0x6a, 0x6b, 0x65, 0x4f, 0xe2, 0x9c, 0x01, 0xaf, + 0x60, 0xf4, 0x01, 0x6a, 0xb6, 0x58, 0xa3, 0xa5, 0x7c, 0x35, 0x79, 0xdb, 0xed, 0xf5, 0x7c, 0xf9, + 0x7d, 0x53, 0xe1, 0xed, 0x9c, 0x0e, 0xaf, 0xe0, 0x86, 0x0b, 0xbb, 0xf7, 0x54, 0x76, 0xcf, 0xa6, + 0x3f, 0x5e, 0xde, 0xf4, 0xca, 0xd1, 0x3f, 0xbf, 0x7c, 0xa2, 0x96, 0x1e, 0x83, 0x73, 0xdd, 0xd0, + 0xeb, 0x85, 0x73, 0xdd, 0x28, 0xd5, 0x8d, 0xf9, 0xd0, 0xa5, 0xad, 0xc7, 0xbb, 0x19, 0x5e, 0xea, + 0xa9, 0xf5, 0xfc, 0xcb, 0x5d, 0x53, 0xbb, 0xbd, 0x6b, 0x6a, 0xdf, 0xef, 0x9a, 0xda, 0xe7, 0x69, + 0x73, 0xe3, 0x76, 0xda, 0xdc, 0xf8, 0x36, 0x6d, 0x6e, 0xbc, 0x3f, 0xf0, 0x7c, 0x7e, 0x99, 0xd8, + 0x5d, 0x87, 0x05, 0xe2, 0xc5, 0x67, 0x71, 0x6f, 0xf1, 0x03, 0xdc, 0xc8, 0x3f, 0x80, 0x8f, 0xaf, + 0x69, 0x6c, 0x17, 0xe5, 0xd3, 0xff, 0xf0, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0x67, 0x17, + 0x25, 0x6e, 0x06, 0x00, 0x00, } func (m *OverrideAccount) Marshal() (dAtA []byte, err error) { @@ -383,6 +495,78 @@ func (m *OverrideAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *BlockOverrides) 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 *BlockOverrides) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BlockOverrides) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BaseFee) > 0 { + i -= len(m.BaseFee) + copy(dAtA[i:], m.BaseFee) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.BaseFee))) + i-- + dAtA[i] = 0x3a + } + if len(m.Random) > 0 { + i -= len(m.Random) + copy(dAtA[i:], m.Random) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Random))) + i-- + dAtA[i] = 0x32 + } + if len(m.Coinbase) > 0 { + i -= len(m.Coinbase) + copy(dAtA[i:], m.Coinbase) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Coinbase))) + i-- + dAtA[i] = 0x2a + } + if len(m.GasLimit) > 0 { + i -= len(m.GasLimit) + copy(dAtA[i:], m.GasLimit) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.GasLimit))) + i-- + dAtA[i] = 0x22 + } + if len(m.Time) > 0 { + i -= len(m.Time) + copy(dAtA[i:], m.Time) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Time))) + i-- + dAtA[i] = 0x1a + } + if len(m.Difficulty) > 0 { + i -= len(m.Difficulty) + copy(dAtA[i:], m.Difficulty) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Difficulty))) + i-- + dAtA[i] = 0x12 + } + if len(m.Number) > 0 { + i -= len(m.Number) + copy(dAtA[i:], m.Number) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Number))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *TraceConfig) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -403,6 +587,18 @@ func (m *TraceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.BlockOverrides != nil { + { + size, err := m.BlockOverrides.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTraceConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x7a + } if len(m.StateOverrides) > 0 { for k := range m.StateOverrides { v := m.StateOverrides[k] @@ -572,6 +768,43 @@ func (m *OverrideAccount) Size() (n int) { return n } +func (m *BlockOverrides) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Number) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) + } + l = len(m.Difficulty) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) + } + l = len(m.Time) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) + } + l = len(m.GasLimit) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) + } + l = len(m.Coinbase) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) + } + l = len(m.Random) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) + } + l = len(m.BaseFee) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) + } + return n +} + func (m *TraceConfig) Size() (n int) { if m == nil { return 0 @@ -628,6 +861,10 @@ func (m *TraceConfig) Size() (n int) { n += mapEntrySize + 1 + sovTraceConfig(uint64(mapEntrySize)) } } + if m.BlockOverrides != nil { + l = m.BlockOverrides.Size() + n += 1 + l + sovTraceConfig(uint64(l)) + } return n } @@ -1024,6 +1261,280 @@ func (m *OverrideAccount) Unmarshal(dAtA []byte) error { } return nil } +func (m *BlockOverrides) 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 ErrIntOverflowTraceConfig + } + 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: BlockOverrides: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BlockOverrides: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Number = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Difficulty", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Difficulty = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Time = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GasLimit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coinbase", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Coinbase = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Random", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Random = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseFee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTraceConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTraceConfig + } + 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 @@ -1452,6 +1963,42 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { } m.StateOverrides[mapkey] = mapvalue iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockOverrides", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraceConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTraceConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTraceConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BlockOverrides == nil { + m.BlockOverrides = &BlockOverrides{} + } + if err := m.BlockOverrides.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTraceConfig(dAtA[iNdEx:]) From 00bce7c239895fc4ebc782cf9a0af404700db7d6 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 10 Jan 2024 09:43:43 +0800 Subject: [PATCH 04/18] add execTrace --- x/evm/keeper/grpc_query.go | 207 ++++++++++++++++++++----------------- 1 file changed, 113 insertions(+), 94 deletions(-) diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index bb033985ed..a0081718d0 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "math/big" + "reflect" "time" "github.com/ethereum/go-ethereum/eth/tracers" @@ -402,20 +403,43 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type return &types.EstimateGasResponse{Gas: hi}, nil } -// TraceTx configures a new tracer according to the provided configuration, and -// executes the given message in the provided environment. The return value will -// be tracer dependent. -func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*types.QueryTraceTxResponse, error) { - if req == nil { +type traceRequest interface { + GetTraceConfig() *types.TraceConfig + GetBlockNumber() int64 + GetBlockTime() time.Time + GetBlockHash() string + GetChainId() int64 + GetProposerAddress() sdk.ConsAddress +} + +func (k Keeper) execTrace( + c context.Context, + req traceRequest, + msgCb func( + ctx sdk.Context, + cfg *statedb.EVMConfig, + txConfig *statedb.TxConfig, + ) (*core.Message, error), + traceFn func( + ctx sdk.Context, + cfg *statedb.EVMConfig, + txConfig statedb.TxConfig, + msg core.Message, + traceConfig *types.TraceConfig, + commitMessage bool, + ) (*interface{}, uint, error), +) ([]byte, error) { + // typed nil check for interface + if reflect.ValueOf(req).IsNil() { return nil, status.Error(codes.InvalidArgument, "empty request") } - if req.TraceConfig != nil && req.TraceConfig.Limit < 0 { - return nil, status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit) + if traceConfig := req.GetTraceConfig(); traceConfig != nil && traceConfig.Limit < 0 { + return nil, status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", traceConfig.Limit) } // get the context of block beginning - contextHeight := req.BlockNumber + contextHeight := req.GetBlockNumber() if contextHeight < 1 { // 0 is a special value in `ContextWithHeight` contextHeight = 1 @@ -423,41 +447,25 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ ctx := sdk.UnwrapSDKContext(c) ctx = ctx.WithBlockHeight(contextHeight) - ctx = ctx.WithBlockTime(req.BlockTime) - ctx = ctx.WithHeaderHash(common.Hex2Bytes(req.BlockHash)) - chainID, err := getChainID(ctx, req.ChainId) + ctx = ctx.WithBlockTime(req.GetBlockTime()) + ctx = ctx.WithHeaderHash(common.Hex2Bytes(req.GetBlockHash())) + + chainID, err := getChainID(ctx, req.GetChainId()) if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - cfg, err := k.EVMConfig(ctx, GetProposerAddress(ctx, req.ProposerAddress), chainID) + cfg, err := k.EVMConfig(ctx, GetProposerAddress(ctx, req.GetProposerAddress()), chainID) if err != nil { return nil, status.Errorf(codes.Internal, "failed to load evm config: %s", err.Error()) } - signer := ethtypes.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) - for i, tx := range req.Predecessors { - ethTx := tx.AsTransaction() - msg, err := core.TransactionToMessage(ethTx, signer, cfg.BaseFee) - if err != nil { - continue - } - txConfig.TxHash = ethTx.Hash() - txConfig.TxIndex = uint(i) - rsp, err := k.ApplyMessageWithConfig(ctx, *msg, types.NewNoOpTracer(), true, cfg, txConfig, nil, nil, true) - if err != nil { - continue - } - txConfig.LogIndex += uint(len(rsp.Logs)) - } - - tx := req.Msg.AsTransaction() - txConfig.TxHash = tx.Hash() - if len(req.Predecessors) > 0 { - txConfig.TxIndex++ + msg, err := msgCb(ctx, cfg, &txConfig) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) } - result, _, err := k.traceTx(ctx, cfg, txConfig, signer, tx, req.TraceConfig, false) + result, _, err := traceFn(ctx, cfg, txConfig, *msg, req.GetTraceConfig(), false) if err != nil { // error will be returned with detail status from traceTx return nil, err @@ -468,6 +476,47 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ return nil, status.Error(codes.Internal, err.Error()) } + return resultData, nil +} + +// TraceTx configures a new tracer according to the provided configuration, and +// executes the given message in the provided environment. The return value will +// be tracer dependent. +func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*types.QueryTraceTxResponse, error) { + resultData, err := k.execTrace( + c, + req, + func(ctx sdk.Context, cfg *statedb.EVMConfig, txConfig *statedb.TxConfig) (*core.Message, error) { + signer := ethtypes.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) + for i, tx := range req.Predecessors { + ethTx := tx.AsTransaction() + msg, err := core.TransactionToMessage(ethTx, signer, cfg.BaseFee) + if err != nil { + continue + } + txConfig.TxHash = ethTx.Hash() + txConfig.TxIndex = uint(i) + rsp, err := k.ApplyMessageWithConfig(ctx, *msg, types.NewNoOpTracer(), true, cfg, *txConfig, nil, nil, true) + if err != nil { + continue + } + txConfig.LogIndex += uint(len(rsp.Logs)) + } + + tx := req.Msg.AsTransaction() + txConfig.TxHash = tx.Hash() + if len(req.Predecessors) > 0 { + txConfig.TxIndex++ + } + + return core.TransactionToMessage(tx, signer, cfg.BaseFee) + }, + k.traceTx, + ) + if err != nil { + return nil, err + } + return &types.QueryTraceTxResponse{ Data: resultData, }, nil @@ -515,12 +564,17 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) ethTx := tx.AsTransaction() txConfig.TxHash = ethTx.Hash() txConfig.TxIndex = uint(i) - traceResult, logIndex, err := k.traceTx(ctx, cfg, txConfig, signer, ethTx, req.TraceConfig, true) + msg, err := core.TransactionToMessage(ethTx, signer, cfg.BaseFee) if err != nil { - result.Error = err.Error() + result.Error = status.Error(codes.Internal, err.Error()).Error() } else { - txConfig.LogIndex = logIndex - result.Result = traceResult + traceResult, logIndex, err := k.traceTx(ctx, cfg, txConfig, *msg, req.TraceConfig, true) + if err != nil { + result.Error = err.Error() + } else { + txConfig.LogIndex = logIndex + result.Result = traceResult + } } results = append(results, &result) } @@ -539,62 +593,32 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) // executes the given call in the provided environment. The return value will // be tracer dependent. func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) (*types.QueryTraceCallResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if req.TraceConfig != nil && req.TraceConfig.Limit < 0 { - return nil, status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit) - } - - // get the context of block beginning - contextHeight := req.BlockNumber - if contextHeight < 1 { - // 0 is a special value in `ContextWithHeight` - contextHeight = 1 - } - - ctx := sdk.UnwrapSDKContext(c) - ctx = ctx.WithBlockHeight(contextHeight) - ctx = ctx.WithBlockTime(req.BlockTime) - ctx = ctx.WithHeaderHash(common.Hex2Bytes(req.BlockHash)) - - var args types.TransactionArgs - err := json.Unmarshal(req.Args, &args) - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - chainID, err := getChainID(ctx, req.ChainId) - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - cfg, err := k.EVMConfig(ctx, GetProposerAddress(ctx, req.ProposerAddress), chainID) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - txConfig := statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())) - - // ApplyMessageWithConfig expect correct nonce set in msg - nonce := k.GetNonce(ctx, args.GetFrom()) - args.Nonce = (*hexutil.Uint64)(&nonce) + resultData, err := k.execTrace( + c, + req, + func(ctx sdk.Context, cfg *statedb.EVMConfig, txConfig *statedb.TxConfig) (*core.Message, error) { + var args types.TransactionArgs + err := json.Unmarshal(req.Args, &args) + if err != nil { + return nil, err + } - msg, err := args.ToMessage(req.GasCap, cfg.BaseFee) - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } + // ApplyMessageWithConfig expect correct nonce set in msg + nonce := k.GetNonce(ctx, args.GetFrom()) + args.Nonce = (*hexutil.Uint64)(&nonce) - result, _, err := k.traceMsg(ctx, cfg, txConfig, msg, req.TraceConfig, false) + msg, err := args.ToMessage(req.GasCap, cfg.BaseFee) + if err != nil { + return nil, err + } + return &msg, nil + }, + k.traceMsg, + ) if err != nil { - // error will be returned with detail status from traceTx return nil, err } - resultData, err := json.Marshal(result) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - return &types.QueryTraceCallResponse{ Data: resultData, }, nil @@ -723,8 +747,7 @@ func (k *Keeper) traceTx( ctx sdk.Context, cfg *statedb.EVMConfig, txConfig statedb.TxConfig, - signer ethtypes.Signer, - tx *ethtypes.Transaction, + msg core.Message, traceConfig *types.TraceConfig, commitMessage bool, ) (*interface{}, uint, error) { @@ -735,10 +758,6 @@ func (k *Keeper) traceTx( err error timeout = defaultTraceTimeout ) - msg, err := core.TransactionToMessage(tx, signer, cfg.BaseFee) - if err != nil { - return nil, 0, status.Error(codes.Internal, err.Error()) - } if traceConfig == nil { traceConfig = &types.TraceConfig{} @@ -805,7 +824,7 @@ func (k *Keeper) traceTx( } } - res, err := k.ApplyMessageWithConfig(ctx, *msg, tracer, commitMessage, cfg, txConfig, &stateOverrides, nil, true) + res, err := k.ApplyMessageWithConfig(ctx, msg, tracer, commitMessage, cfg, txConfig, &stateOverrides, nil, true) if err != nil { return nil, 0, status.Error(codes.Internal, err.Error()) } From 85293ba2038ab55d6c694c23871353535e9854c5 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 10 Jan 2024 09:43:49 +0800 Subject: [PATCH 05/18] cleanup --- CHANGELOG.md | 2 +- scripts/protoc-swagger-gen.sh | 1 + tests/integration_tests/test_tracers.py | 9 +- x/evm/keeper/grpc_query.go | 112 ++---------------------- 4 files changed, 15 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3a4166fa1..eb71238be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (statedb) [#333](https://github.com/crypto-org-chain/ethermint/pull/333) Support native action in statedb, prepare for precompiles. * (rpc) [#369](https://github.com/crypto-org-chain/ethermint/pull/369) Support state overrides in eth_call. * (precompile) [#371](https://github.com/crypto-org-chain/ethermint/pull/371) Add StateDB itself into native context for precompiles to emit evm logs directly. -* (rpc) [#](https://github.com/crypto-org-chain/ethermint/pull/) Support block overrides in debug_traceCall. +* (rpc) [#392](https://github.com/crypto-org-chain/ethermint/pull/392) Support block overrides in debug_traceCall. ### State Machine Breaking diff --git a/scripts/protoc-swagger-gen.sh b/scripts/protoc-swagger-gen.sh index 60dfade346..a0bfd0eaa8 100755 --- a/scripts/protoc-swagger-gen.sh +++ b/scripts/protoc-swagger-gen.sh @@ -22,3 +22,4 @@ swagger-combine ./client/docs/config.json -o ./client/docs/swagger-ui/swagger.ya # clean swagger files rm -rf ./tmp-swagger-gen +rm -rf github.com diff --git a/tests/integration_tests/test_tracers.py b/tests/integration_tests/test_tracers.py index c932afcde1..1943c76cb0 100644 --- a/tests/integration_tests/test_tracers.py +++ b/tests/integration_tests/test_tracers.py @@ -464,7 +464,14 @@ def test_debug_tracecall_block_overrides(ethermint, geth): # https://github.com/ethereum/go-ethereum/blob/v1.11.6/core/vm/opcodes.go#L95 tx = {"from": ADDRS["validator"], "input": "0x43", "gas": gas, "gasPrice": price} future_blk = "0x1337" - tracer = {"blockOverrides": {"number": future_blk}} + tracer = {"blockOverrides": { + "number": future_blk, + "coinbase": "0x1111111111111111111111111111111111111111", + "difficulty": hex(2), + "time": hex(3), + "baseLimit": hex(4), + "baseFee": hex(5), + }} def process(w3): w3_wait_for_new_blocks(w3, 1) diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index a0081718d0..3804878006 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -511,7 +511,7 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ return core.TransactionToMessage(tx, signer, cfg.BaseFee) }, - k.traceTx, + k.prepareTrace, ) if err != nil { return nil, err @@ -568,7 +568,7 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) if err != nil { result.Error = status.Error(codes.Internal, err.Error()).Error() } else { - traceResult, logIndex, err := k.traceTx(ctx, cfg, txConfig, *msg, req.TraceConfig, true) + traceResult, logIndex, err := k.prepareTrace(ctx, cfg, txConfig, *msg, req.TraceConfig, true) if err != nil { result.Error = err.Error() } else { @@ -613,7 +613,7 @@ func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) ( } return &msg, nil }, - k.traceMsg, + k.prepareTrace, ) if err != nil { return nil, err @@ -624,8 +624,8 @@ func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) ( }, nil } -// traceMsg do trace on one Ethereum message, it returns a tuple: (traceResult, nextLogIndex, error). -func (k *Keeper) traceMsg( +// prepareTrace prepare trace on one Ethereum message, it returns a tuple: (traceResult, nextLogIndex, error). +func (k *Keeper) prepareTrace( ctx sdk.Context, cfg *statedb.EVMConfig, txConfig statedb.TxConfig, @@ -742,108 +742,6 @@ func (k *Keeper) traceMsg( return &result, txConfig.LogIndex + uint(len(res.Logs)), nil } -// traceMsg do trace on one Ethereum message, it returns a tuple: (traceResult, nextLogIndex, error). -func (k *Keeper) traceTx( - ctx sdk.Context, - cfg *statedb.EVMConfig, - txConfig statedb.TxConfig, - msg core.Message, - traceConfig *types.TraceConfig, - commitMessage bool, -) (*interface{}, uint, error) { - // Assemble the structured logger or the JavaScript tracer - var ( - tracer tracers.Tracer - overrides *ethparams.ChainConfig - err error - timeout = defaultTraceTimeout - ) - - if traceConfig == nil { - traceConfig = &types.TraceConfig{} - } - - if traceConfig.Overrides != nil { - overrides = traceConfig.Overrides.EthereumConfig(cfg.ChainConfig.ChainID) - } - - logConfig := logger.Config{ - EnableMemory: traceConfig.EnableMemory, - DisableStorage: traceConfig.DisableStorage, - DisableStack: traceConfig.DisableStack, - EnableReturnData: traceConfig.EnableReturnData, - Debug: traceConfig.Debug, - Limit: int(traceConfig.Limit), - Overrides: overrides, - } - - tracer = logger.NewStructLogger(&logConfig) - - tCtx := &tracers.Context{ - BlockHash: txConfig.BlockHash, - TxIndex: int(txConfig.TxIndex), - TxHash: txConfig.TxHash, - } - if traceConfig.Tracer != "" { - var cfg json.RawMessage - if traceConfig.TracerJsonConfig != "" { - cfg = json.RawMessage(traceConfig.TracerJsonConfig) - } - if tracer, err = tracers.DefaultDirectory.New(traceConfig.Tracer, tCtx, cfg); err != nil { - return nil, 0, status.Error(codes.Internal, err.Error()) - } - } - - // 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()) - } - } - - // 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")) - } - }() - - var stateOverrides rpctypes.StateOverride - if traceConfig.StateOverrides != nil { - config, err := json.Marshal(traceConfig.StateOverrides) - if err != nil { - return nil, 0, status.Error(codes.InvalidArgument, err.Error()) - } - - if err := json.Unmarshal(config, &stateOverrides); err != nil { - return nil, 0, status.Error(codes.InvalidArgument, err.Error()) - } - } - - res, err := k.ApplyMessageWithConfig(ctx, msg, tracer, commitMessage, cfg, txConfig, &stateOverrides, nil, true) - if err != nil { - return nil, 0, status.Error(codes.Internal, err.Error()) - } - - if res.VmError != "" { - if res.VmError != vm.ErrExecutionReverted.Error() { - return nil, 0, status.Error(codes.Internal, res.VmError) - } - } - - var result interface{} - 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 -} - // BaseFee implements the Query/BaseFee gRPC method func (k Keeper) BaseFee(c context.Context, _ *types.QueryBaseFeeRequest) (*types.QueryBaseFeeResponse, error) { ctx := sdk.UnwrapSDKContext(c) From 31e78f03b5261067faa69535eae53258cfade7df Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 10 Jan 2024 10:42:22 +0800 Subject: [PATCH 06/18] check in generic --- x/evm/keeper/grpc_query.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 3804878006..ddd3b2f71a 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "math/big" - "reflect" "time" "github.com/ethereum/go-ethereum/eth/tracers" @@ -404,6 +403,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type } type traceRequest interface { + comparable GetTraceConfig() *types.TraceConfig GetBlockNumber() int64 GetBlockTime() time.Time @@ -412,9 +412,10 @@ type traceRequest interface { GetProposerAddress() sdk.ConsAddress } -func (k Keeper) execTrace( +func execTrace[T traceRequest]( c context.Context, - req traceRequest, + req T, + k Keeper, msgCb func( ctx sdk.Context, cfg *statedb.EVMConfig, @@ -429,8 +430,8 @@ func (k Keeper) execTrace( commitMessage bool, ) (*interface{}, uint, error), ) ([]byte, error) { - // typed nil check for interface - if reflect.ValueOf(req).IsNil() { + var zero T + if req == zero { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -483,9 +484,10 @@ func (k Keeper) execTrace( // executes the given message in the provided environment. The return value will // be tracer dependent. func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*types.QueryTraceTxResponse, error) { - resultData, err := k.execTrace( + resultData, err := execTrace( c, req, + k, func(ctx sdk.Context, cfg *statedb.EVMConfig, txConfig *statedb.TxConfig) (*core.Message, error) { signer := ethtypes.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) for i, tx := range req.Predecessors { @@ -593,9 +595,10 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) // executes the given call in the provided environment. The return value will // be tracer dependent. func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) (*types.QueryTraceCallResponse, error) { - resultData, err := k.execTrace( + resultData, err := execTrace( c, req, + k, func(ctx sdk.Context, cfg *statedb.EVMConfig, txConfig *statedb.TxConfig) (*core.Message, error) { var args types.TransactionArgs err := json.Unmarshal(req.Args, &args) From a3b757eb7c4714f21c7b734ed0ffbb494192f483 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 10 Jan 2024 14:07:47 +0800 Subject: [PATCH 07/18] Update rpc/backend/tracing.go Co-authored-by: Xinyu <91446598+XinyuCRO@users.noreply.github.com> Signed-off-by: mmsqe --- rpc/backend/tracing.go | 1 - 1 file changed, 1 deletion(-) diff --git a/rpc/backend/tracing.go b/rpc/backend/tracing.go index 34a10a1600..2f7f821197 100644 --- a/rpc/backend/tracing.go +++ b/rpc/backend/tracing.go @@ -135,7 +135,6 @@ func (b *Backend) convertConfig(config *rpctypes.TraceConfig) *evmtypes.TraceCon } cfg := config.TraceConfig cfg.TracerJsonConfig = string(config.TracerConfig) - cfg.BlockOverrides = config.BlockOverrides return &cfg } From 10b3b8a0175a561fcbb6c82e2d4492dc758365d8 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 10 Jan 2024 21:35:07 +0800 Subject: [PATCH 08/18] rm extra tracer --- x/evm/keeper/config.go | 8 ++++---- x/evm/keeper/state_transition.go | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/x/evm/keeper/config.go b/x/evm/keeper/config.go index 9928d15e72..1e85e001a6 100644 --- a/x/evm/keeper/config.go +++ b/x/evm/keeper/config.go @@ -83,18 +83,18 @@ func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) statedb.TxConfig // 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, _ core.Message, cfg *EVMConfig, tracer vm.EVMLogger) vm.Config { +func (k Keeper) VMConfig(ctx sdk.Context, _ core.Message, cfg *EVMConfig) vm.Config { noBaseFee := true if types.IsLondon(cfg.ChainConfig, ctx.BlockHeight()) { noBaseFee = k.feeMarketKeeper.GetParams(ctx).NoBaseFee } - if _, ok := tracer.(types.NoOpTracer); ok { - tracer = nil + if _, ok := cfg.Tracer.(types.NoOpTracer); ok { + cfg.Tracer = nil } return vm.Config{ - Tracer: tracer, + Tracer: cfg.Tracer, NoBaseFee: noBaseFee, ExtraEips: cfg.Params.EIPs(), } diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 63eace95df..56b56b224a 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -65,26 +65,24 @@ func (k *Keeper) NewEVM( ctx sdk.Context, msg core.Message, cfg *EVMConfig, - tracer vm.EVMLogger, stateDB vm.StateDB, ) *vm.EVM { blockCtx := k.NewEVMBlockContext(ctx, cfg) - return k.NewEVMWithBlockCtx(ctx, msg, cfg, tracer, stateDB, blockCtx) + return k.NewEVMWithBlockCtx(ctx, msg, cfg, stateDB, blockCtx) } func (k *Keeper) NewEVMWithBlockCtx( ctx sdk.Context, msg core.Message, cfg *EVMConfig, - tracer vm.EVMLogger, stateDB vm.StateDB, blockCtx vm.BlockContext, ) *vm.EVM { txCtx := core.NewEVMTxContext(&msg) - if tracer == nil { - tracer = k.Tracer(ctx, msg, cfg.ChainConfig) + if cfg.Tracer == nil { + cfg.Tracer = k.Tracer(ctx, msg, cfg.ChainConfig) } - vmConfig := k.VMConfig(ctx, msg, cfg, tracer) + vmConfig := k.VMConfig(ctx, msg, cfg) rules := cfg.ChainConfig.Rules(big.NewInt(ctx.BlockHeight()), cfg.ChainConfig.MergeNetsplitBlock != nil, blockCtx.Time) contracts := make(map[common.Address]vm.PrecompiledContract) active := make([]common.Address, 0) @@ -378,9 +376,9 @@ func (k *Keeper) ApplyMessageWithConfig( if cfg.DebugTrace && cfg.BlockOverrides != nil { blockCtx := k.NewEVMBlockContext(ctx, cfg) cfg.BlockOverrides.Apply(&blockCtx) - evm = k.NewEVMWithBlockCtx(ctx, msg, cfg, cfg.Tracer, stateDB, blockCtx) + evm = k.NewEVMWithBlockCtx(ctx, msg, cfg, stateDB, blockCtx) } else { - evm = k.NewEVM(ctx, msg, cfg, cfg.Tracer, stateDB) + evm = k.NewEVM(ctx, msg, cfg, stateDB) } leftoverGas := msg.GasLimit From e1b80148a70e576029dd8fe6a00e7f72f14780f1 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 10 Jan 2024 21:46:19 +0800 Subject: [PATCH 09/18] rm traceFn --- x/evm/keeper/grpc_query.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index abeb424211..356f5fa3ea 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -417,13 +417,6 @@ func execTrace[T traceRequest]( ctx sdk.Context, cfg *EVMConfig, ) (*core.Message, error), - traceFn func( - ctx sdk.Context, - cfg *EVMConfig, - msg core.Message, - traceConfig *types.TraceConfig, - commitMessage bool, - ) (*interface{}, uint, error), ) ([]byte, error) { var zero T if req == zero { @@ -460,7 +453,7 @@ func execTrace[T traceRequest]( return nil, status.Error(codes.Internal, err.Error()) } - result, _, err := traceFn(ctx, cfg, *msg, req.GetTraceConfig(), false) + result, _, err := k.prepareTrace(ctx, cfg, *msg, req.GetTraceConfig(), false) if err != nil { // error will be returned with detail status from traceTx return nil, err @@ -507,7 +500,6 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ return core.TransactionToMessage(tx, signer, cfg.BaseFee) }, - k.prepareTrace, ) if err != nil { return nil, err @@ -609,7 +601,6 @@ func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) ( } return &msg, nil }, - k.prepareTrace, ) if err != nil { return nil, err From 442203ba2e012f97dbe1eb95dad47d4625e879da Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 11 Jan 2024 09:12:47 +0800 Subject: [PATCH 10/18] fix resolve --- x/evm/keeper/grpc_query.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 356f5fa3ea..301ed97384 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -477,6 +477,7 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ k, func(ctx sdk.Context, cfg *EVMConfig) (*core.Message, error) { signer := ethtypes.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) + cfg.Tracer = types.NewNoOpTracer() for i, tx := range req.Predecessors { ethTx := tx.AsTransaction() msg, err := core.TransactionToMessage(ethTx, signer, cfg.BaseFee) From dfe71a4b8bb03c5d5785fb67dd6600004a345859 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 11 Jan 2024 20:44:05 +0800 Subject: [PATCH 11/18] fasten test --- tests/integration_tests/network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration_tests/network.py b/tests/integration_tests/network.py index b500ae26f8..3fa25ba56d 100644 --- a/tests/integration_tests/network.py +++ b/tests/integration_tests/network.py @@ -73,9 +73,9 @@ def __init__(self, w3): def setup_ethermint(path, base_port, long_timeout_commit=False): cfg = Path(__file__).parent / ( - "configs/default.jsonnet" + "configs/long_timeout_commit.jsonnet" if long_timeout_commit - else "configs/long_timeout_commit.jsonnet" + else "configs/default.jsonnet" ) yield from setup_custom_ethermint(path, base_port, cfg) From 91f2c5260820909c21350a29cbcc4d68fc3d6ff8 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 11 Jan 2024 20:44:09 +0800 Subject: [PATCH 12/18] update proto --- client/docs/swagger-ui/swagger.yaml | 123 +---- proto/ethermint/evm/v1/trace_config.proto | 15 +- x/evm/types/trace_config.pb.go | 609 +++------------------- 3 files changed, 73 insertions(+), 674 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 84d56814d2..d44936dc00 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -2658,34 +2658,12 @@ paths: in: query required: false type: string - - name: trace_config.block_overrides.number - in: query - required: false - type: string - - name: trace_config.block_overrides.difficulty - in: query - required: false - type: string - - name: trace_config.block_overrides.time - in: query - required: false - type: string - - name: trace_config.block_overrides.gas_limit - in: query - required: false - type: string - - name: trace_config.block_overrides.coinbase - in: query - required: false - type: string - - name: trace_config.block_overrides.random - in: query - required: false - type: string - - name: trace_config.block_overrides.base_fee + - name: trace_config.block_overrides + description: block overrides block context fields encoded as json. in: query required: false type: string + format: byte - name: block_number description: block_number of the traced block. in: query @@ -3134,34 +3112,12 @@ paths: in: query required: false type: string - - name: trace_config.block_overrides.number - in: query - required: false - type: string - - name: trace_config.block_overrides.difficulty - in: query - required: false - type: string - - name: trace_config.block_overrides.time - in: query - required: false - type: string - - name: trace_config.block_overrides.gas_limit - in: query - required: false - type: string - - name: trace_config.block_overrides.coinbase - in: query - required: false - type: string - - name: trace_config.block_overrides.random - in: query - required: false - type: string - - name: trace_config.block_overrides.base_fee + - name: trace_config.block_overrides + description: block overrides block context fields encoded as json. in: query required: false type: string + format: byte - name: block_number description: block_number of requested transaction. in: query @@ -3673,34 +3629,12 @@ paths: in: query required: false type: string - - name: trace_config.block_overrides.number - in: query - required: false - type: string - - name: trace_config.block_overrides.difficulty - in: query - required: false - type: string - - name: trace_config.block_overrides.time - in: query - required: false - type: string - - name: trace_config.block_overrides.gas_limit - in: query - required: false - type: string - - name: trace_config.block_overrides.coinbase - in: query - required: false - type: string - - name: trace_config.block_overrides.random - in: query - required: false - type: string - - name: trace_config.block_overrides.base_fee + - name: trace_config.block_overrides + description: block overrides block context fields encoded as json. in: query required: false type: string + format: byte - name: block_number description: block_number of requested transaction. in: query @@ -3964,24 +3898,6 @@ paths: tags: - Query definitions: - ethermint.evm.v1.BlockOverrides: - type: object - properties: - number: - type: string - difficulty: - type: string - time: - type: string - gas_limit: - type: string - coinbase: - type: string - random: - type: string - base_fee: - type: string - description: BlockOverrides is a set of header fields to override. ethermint.evm.v1.ChainConfig: type: object properties: @@ -4999,24 +4915,9 @@ definitions: temporary state modifications to Geth in order to simulate the effects of eth_call block_overrides: - title: overrides block context fields - type: object - properties: - number: - type: string - difficulty: - type: string - time: - type: string - gas_limit: - type: string - coinbase: - type: string - random: - type: string - base_fee: - type: string - description: BlockOverrides is a set of header fields to override. + type: string + format: byte + title: block overrides block context fields encoded as json description: TraceConfig holds extra parameters to trace functions. google.protobuf.Any: type: object diff --git a/proto/ethermint/evm/v1/trace_config.proto b/proto/ethermint/evm/v1/trace_config.proto index 134feb71d0..948af10be3 100644 --- a/proto/ethermint/evm/v1/trace_config.proto +++ b/proto/ethermint/evm/v1/trace_config.proto @@ -16,17 +16,6 @@ message OverrideAccount { map state_diff = 5 [(gogoproto.jsontag) = "stateDiff"]; } -// BlockOverrides is a set of header fields to override. -message BlockOverrides { - string number = 1; - string difficulty = 2; - string time = 3; - string gas_limit = 4 [(gogoproto.jsontag) = "gasLimit"]; - string coinbase = 5; - string random = 6; - string base_fee = 7 [(gogoproto.jsontag) = "baseFee"]; -} - // TraceConfig holds extra parameters to trace functions. message TraceConfig { // DEPRECATED: DisableMemory and DisableReturnData have been renamed to @@ -59,6 +48,6 @@ message TraceConfig { string tracer_json_config = 13 [(gogoproto.jsontag) = "tracerConfig"]; // temporary state modifications to Geth in order to simulate the effects of eth_call map state_overrides = 14 [(gogoproto.jsontag) = "stateOverrides"]; - // overrides block context fields - BlockOverrides block_overrides = 15 [(gogoproto.jsontag) = "blockOverrides"]; + // block overrides block context fields encoded as json + bytes block_overrides = 15 [(gogoproto.jsontag) = "blockOverrides"]; } \ No newline at end of file diff --git a/x/evm/types/trace_config.pb.go b/x/evm/types/trace_config.pb.go index 0de526674d..4fdad993f4 100644 --- a/x/evm/types/trace_config.pb.go +++ b/x/evm/types/trace_config.pb.go @@ -101,99 +101,6 @@ func (m *OverrideAccount) GetStateDiff() map[string]string { return nil } -// BlockOverrides is a set of header fields to override. -type BlockOverrides struct { - Number string `protobuf:"bytes,1,opt,name=number,proto3" json:"number,omitempty"` - Difficulty string `protobuf:"bytes,2,opt,name=difficulty,proto3" json:"difficulty,omitempty"` - Time string `protobuf:"bytes,3,opt,name=time,proto3" json:"time,omitempty"` - GasLimit string `protobuf:"bytes,4,opt,name=gas_limit,json=gasLimit,proto3" json:"gasLimit"` - Coinbase string `protobuf:"bytes,5,opt,name=coinbase,proto3" json:"coinbase,omitempty"` - Random string `protobuf:"bytes,6,opt,name=random,proto3" json:"random,omitempty"` - BaseFee string `protobuf:"bytes,7,opt,name=base_fee,json=baseFee,proto3" json:"baseFee"` -} - -func (m *BlockOverrides) Reset() { *m = BlockOverrides{} } -func (m *BlockOverrides) String() string { return proto.CompactTextString(m) } -func (*BlockOverrides) ProtoMessage() {} -func (*BlockOverrides) Descriptor() ([]byte, []int) { - return fileDescriptor_8f7fb70914ae5a53, []int{1} -} -func (m *BlockOverrides) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BlockOverrides) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockOverrides.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 *BlockOverrides) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockOverrides.Merge(m, src) -} -func (m *BlockOverrides) XXX_Size() int { - return m.Size() -} -func (m *BlockOverrides) XXX_DiscardUnknown() { - xxx_messageInfo_BlockOverrides.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockOverrides proto.InternalMessageInfo - -func (m *BlockOverrides) GetNumber() string { - if m != nil { - return m.Number - } - return "" -} - -func (m *BlockOverrides) GetDifficulty() string { - if m != nil { - return m.Difficulty - } - return "" -} - -func (m *BlockOverrides) GetTime() string { - if m != nil { - return m.Time - } - return "" -} - -func (m *BlockOverrides) GetGasLimit() string { - if m != nil { - return m.GasLimit - } - return "" -} - -func (m *BlockOverrides) GetCoinbase() string { - if m != nil { - return m.Coinbase - } - return "" -} - -func (m *BlockOverrides) GetRandom() string { - if m != nil { - return m.Random - } - return "" -} - -func (m *BlockOverrides) GetBaseFee() string { - if m != nil { - return m.BaseFee - } - return "" -} - // TraceConfig holds extra parameters to trace functions. type TraceConfig struct { // tracer is a custom javascript tracer @@ -221,15 +128,15 @@ type TraceConfig struct { TracerJsonConfig string `protobuf:"bytes,13,opt,name=tracer_json_config,json=tracerJsonConfig,proto3" json:"tracerConfig"` // temporary state modifications to Geth in order to simulate the effects of eth_call StateOverrides map[string]*OverrideAccount `protobuf:"bytes,14,rep,name=state_overrides,json=stateOverrides,proto3" json:"stateOverrides" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // overrides block context fields - BlockOverrides *BlockOverrides `protobuf:"bytes,15,opt,name=block_overrides,json=blockOverrides,proto3" json:"blockOverrides"` + // block overrides block context fields encoded as json + BlockOverrides []byte `protobuf:"bytes,15,opt,name=block_overrides,json=blockOverrides,proto3" json:"blockOverrides"` } 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_8f7fb70914ae5a53, []int{2} + return fileDescriptor_8f7fb70914ae5a53, []int{1} } func (m *TraceConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -342,7 +249,7 @@ func (m *TraceConfig) GetStateOverrides() map[string]*OverrideAccount { return nil } -func (m *TraceConfig) GetBlockOverrides() *BlockOverrides { +func (m *TraceConfig) GetBlockOverrides() []byte { if m != nil { return m.BlockOverrides } @@ -353,7 +260,6 @@ func init() { proto.RegisterType((*OverrideAccount)(nil), "ethermint.evm.v1.OverrideAccount") proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.OverrideAccount.StateDiffEntry") proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.OverrideAccount.StateEntry") - proto.RegisterType((*BlockOverrides)(nil), "ethermint.evm.v1.BlockOverrides") proto.RegisterType((*TraceConfig)(nil), "ethermint.evm.v1.TraceConfig") proto.RegisterMapType((map[string]*OverrideAccount)(nil), "ethermint.evm.v1.TraceConfig.StateOverridesEntry") } @@ -363,56 +269,49 @@ func init() { } var fileDescriptor_8f7fb70914ae5a53 = []byte{ - // 773 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4f, 0x6b,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 0x4d, 0x86, 0x44, 0x9c, 0xdd, 0x92, 0xea, 0x0c, 0x22, 0x0b, 0x0a, 0x31, 0x27, 0x9c, 0x9a, - 0x7a, 0x7b, 0xab, 0x53, 0x39, 0xfa, 0xbf, 0xbb, 0x5a, 0x74, 0x77, 0x25, 0x6b, 0xf7, 0x42, 0x1c, - 0x7f, 0x19, 0xf2, 0x68, 0x8c, 0x95, 0x2b, 0xfa, 0x08, 0x20, 0x85, 0xbe, 0xeb, 0x0f, 0x06, 0x66, - 0x41, 0x06, 0x7a, 0xf0, 0x9b, 0x81, 0xce, 0xfc, 0xc1, 0x40, 0x06, 0xb3, 0x76, 0x66, 0x93, 0x56, - 0x39, 0xce, 0x74, 0x78, 0x21, 0x36, 0x8e, 0x01, 0x16, 0x49, 0x51, 0x1d, 0xb6, 0xae, 0xe8, 0x58, - 0x72, 0x2e, 0x63, 0x21, 0x8a, 0x7b, 0x18, 0x91, 0x61, 0x92, 0x51, 0x56, 0xe0, 0xc9, 0xe6, 0xb1, - 0xd6, 0x78, 0x0a, 0xd5, 0x7c, 0x96, 0x3f, 0xf1, 0xde, 0x9f, 0x6a, 0x50, 0xb5, 0x86, 0xcc, 0xb9, - 0xca, 0x2a, 0x8f, 0xd1, 0x5f, 0x50, 0x0c, 0x93, 0xc0, 0xa6, 0x51, 0x1a, 0x21, 0x45, 0xa8, 0x09, - 0x20, 0xc8, 0xfb, 0x4e, 0x32, 0xe4, 0xe3, 0x34, 0xd2, 0x92, 0x46, 0x34, 0x85, 0xfb, 0x41, 0x76, - 0xfb, 0x52, 0x46, 0xff, 0x41, 0xd9, 0x23, 0x71, 0x7f, 0xe8, 0x07, 0x3e, 0x37, 0x75, 0x61, 0xb0, - 0xb6, 0x67, 0x93, 0x96, 0xe1, 0x91, 0xf8, 0xb5, 0xd0, 0xe1, 0xb9, 0x84, 0x1a, 0x60, 0x38, 0xcc, - 0x0f, 0x6d, 0x12, 0x53, 0xb3, 0x20, 0x43, 0xcc, 0xb1, 0x28, 0x29, 0x22, 0xa1, 0xcb, 0x02, 0xb3, - 0xa8, 0x4a, 0x52, 0x08, 0x1d, 0x80, 0x21, 0xec, 0xfd, 0x01, 0xa5, 0x66, 0x49, 0x46, 0xaf, 0xcc, - 0x26, 0xad, 0x92, 0xd0, 0xbd, 0xa2, 0x14, 0x67, 0xc2, 0xfe, 0xd7, 0x22, 0x54, 0xde, 0x89, 0xe9, - 0x3d, 0x95, 0xf3, 0x26, 0xe2, 0xc9, 0x61, 0x9e, 0x53, 0x54, 0x48, 0xcc, 0x90, 0x28, 0x9b, 0x25, - 0x3c, 0xe5, 0x97, 0x41, 0x59, 0x01, 0xa5, 0x37, 0xd4, 0x91, 0xf4, 0x74, 0x9c, 0x22, 0xf4, 0x08, - 0x76, 0x5c, 0x3f, 0x26, 0xf6, 0x90, 0xf6, 0x63, 0x4e, 0x9c, 0x2b, 0x59, 0xba, 0x61, 0xd5, 0x67, - 0x93, 0xd6, 0x76, 0x6a, 0xb8, 0x10, 0x7a, 0x9c, 0x43, 0xe8, 0x04, 0x6a, 0x0b, 0x37, 0x16, 0x11, - 0x8f, 0x4a, 0x66, 0x86, 0x85, 0x66, 0x93, 0x56, 0x75, 0x7e, 0x54, 0x5a, 0xf0, 0x0a, 0x16, 0xdd, - 0x74, 0xa9, 0x9d, 0x78, 0xa6, 0x21, 0x5c, 0xb0, 0x02, 0x42, 0xab, 0xae, 0xb9, 0xdc, 0xd6, 0x3a, - 0x05, 0xac, 0x00, 0x3a, 0x81, 0x32, 0xcb, 0x3a, 0x6b, 0x42, 0x5b, 0xeb, 0x54, 0x8e, 0xfe, 0x5e, - 0x1f, 0xdb, 0x53, 0xb1, 0x8c, 0xea, 0x6e, 0xf0, 0xe2, 0xbc, 0x20, 0x47, 0x43, 0x59, 0x64, 0x40, - 0x03, 0x16, 0x8d, 0xcd, 0xca, 0x82, 0x9c, 0x32, 0xbc, 0x91, 0x7a, 0x9c, 0x43, 0xc8, 0x02, 0x94, - 0xba, 0x45, 0x94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6f, 0xf1, 0x03, 0xdc, 0xc8, 0x3f, 0x80, 0x8f, 0xaf, - 0x69, 0x6c, 0x17, 0xe5, 0xd3, 0xff, 0xf0, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0x67, 0x17, - 0x25, 0x6e, 0x06, 0x00, 0x00, + // 658 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0x5e, 0xb6, 0xb4, 0x6b, 0xdd, 0x6d, 0x8d, 0xbc, 0x09, 0x59, 0x95, 0x68, 0xc3, 0x90, 0x50, + 0x0e, 0x28, 0x65, 0x43, 0x88, 0x89, 0x21, 0x04, 0xdd, 0xb8, 0x4c, 0x42, 0x48, 0x1e, 0x27, 0x0e, + 0x54, 0x6e, 0xe2, 0x76, 0x61, 0x4d, 0x3c, 0x39, 0x6e, 0xb4, 0xfe, 0x0b, 0xfe, 0x0b, 0x7f, 0x82, + 0xe3, 0x8e, 0x9c, 0x2a, 0xb4, 0xdd, 0x7a, 0xe3, 0x1f, 0x20, 0xdb, 0x49, 0x93, 0xb4, 0x93, 0x80, + 0xdb, 0xfb, 0xde, 0x7b, 0xdf, 0x7b, 0x7e, 0xfe, 0x9e, 0x0d, 0x1e, 0x53, 0x71, 0x41, 0x79, 0x18, + 0x44, 0xa2, 0x4b, 0x93, 0xb0, 0x9b, 0x1c, 0x74, 0x05, 0x27, 0x1e, 0xed, 0x7b, 0x2c, 0x1a, 0x06, + 0x23, 0xf7, 0x8a, 0x33, 0xc1, 0xa0, 0xb5, 0x48, 0x72, 0x69, 0x12, 0xba, 0xc9, 0x41, 0x6b, 0x6f, + 0xc4, 0x46, 0x4c, 0x05, 0xbb, 0xd2, 0xd2, 0x79, 0xad, 0xd5, 0x62, 0xde, 0x05, 0x09, 0xa2, 0x52, + 0xb1, 0xfd, 0xdf, 0xeb, 0xa0, 0xf9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, 0xc2, 0x66, 0xe8, 0x55, 0xce, 0xf6, 0x3b, 0xd6, 0xfb, 0xac, 0x34, 0x89, 0x4b, + 0x01, 0xbc, 0x84, 0xa5, 0xa0, 0x83, 0x31, 0xf3, 0x2e, 0x0b, 0xfd, 0x9a, 0xb6, 0xe1, 0x6c, 0x69, + 0xb2, 0x0a, 0x15, 0xc8, 0x65, 0xdc, 0xf2, 0xc1, 0xee, 0x3d, 0x7d, 0xef, 0xd9, 0xf0, 0x97, 0xc5, + 0x0d, 0x6f, 0x1c, 0x3e, 0xfa, 0xeb, 0xd3, 0x2c, 0x3c, 0x82, 0x33, 0xb3, 0x66, 0x5a, 0x95, 0x33, + 0xb3, 0xb6, 0x69, 0xd5, 0x16, 0x2b, 0x95, 0x0a, 0x8b, 0x77, 0x33, 0x5c, 0x50, 0xac, 0xf7, 0xf6, + 0xc7, 0x6d, 0xdb, 0xb8, 0xb9, 0x6d, 0x1b, 0xbf, 0x6e, 0xdb, 0xc6, 0xb7, 0xbb, 0xf6, 0xda, 0xcd, + 0x5d, 0x7b, 0xed, 0xe7, 0x5d, 0x7b, 0xed, 0xf3, 0x93, 0x51, 0x20, 0x2e, 0x26, 0x03, 0xd7, 0x63, + 0xa1, 0xfc, 0xe9, 0x58, 0xdc, 0xcd, 0x7f, 0xbe, 0x6b, 0xf5, 0xf7, 0x89, 0xe9, 0x15, 0x8d, 0x07, + 0x55, 0xf5, 0xe5, 0x3d, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x49, 0x14, 0xa1, 0x66, 0x05, + 0x00, 0x00, } func (m *OverrideAccount) Marshal() (dAtA []byte, err error) { @@ -495,78 +394,6 @@ func (m *OverrideAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *BlockOverrides) 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 *BlockOverrides) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockOverrides) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BaseFee) > 0 { - i -= len(m.BaseFee) - copy(dAtA[i:], m.BaseFee) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.BaseFee))) - i-- - dAtA[i] = 0x3a - } - if len(m.Random) > 0 { - i -= len(m.Random) - copy(dAtA[i:], m.Random) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Random))) - i-- - dAtA[i] = 0x32 - } - if len(m.Coinbase) > 0 { - i -= len(m.Coinbase) - copy(dAtA[i:], m.Coinbase) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Coinbase))) - i-- - dAtA[i] = 0x2a - } - if len(m.GasLimit) > 0 { - i -= len(m.GasLimit) - copy(dAtA[i:], m.GasLimit) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.GasLimit))) - i-- - dAtA[i] = 0x22 - } - if len(m.Time) > 0 { - i -= len(m.Time) - copy(dAtA[i:], m.Time) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Time))) - i-- - dAtA[i] = 0x1a - } - if len(m.Difficulty) > 0 { - i -= len(m.Difficulty) - copy(dAtA[i:], m.Difficulty) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Difficulty))) - i-- - dAtA[i] = 0x12 - } - if len(m.Number) > 0 { - i -= len(m.Number) - copy(dAtA[i:], m.Number) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Number))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *TraceConfig) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -587,15 +414,10 @@ func (m *TraceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.BlockOverrides != nil { - { - size, err := m.BlockOverrides.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTraceConfig(dAtA, i, uint64(size)) - } + if len(m.BlockOverrides) > 0 { + i -= len(m.BlockOverrides) + copy(dAtA[i:], m.BlockOverrides) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.BlockOverrides))) i-- dAtA[i] = 0x7a } @@ -768,43 +590,6 @@ func (m *OverrideAccount) Size() (n int) { return n } -func (m *BlockOverrides) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Number) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - l = len(m.Difficulty) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - l = len(m.Time) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - l = len(m.GasLimit) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - l = len(m.Coinbase) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - l = len(m.Random) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - l = len(m.BaseFee) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - return n -} - func (m *TraceConfig) Size() (n int) { if m == nil { return 0 @@ -861,8 +646,8 @@ func (m *TraceConfig) Size() (n int) { n += mapEntrySize + 1 + sovTraceConfig(uint64(mapEntrySize)) } } - if m.BlockOverrides != nil { - l = m.BlockOverrides.Size() + l = len(m.BlockOverrides) + if l > 0 { n += 1 + l + sovTraceConfig(uint64(l)) } return n @@ -1261,280 +1046,6 @@ func (m *OverrideAccount) Unmarshal(dAtA []byte) error { } return nil } -func (m *BlockOverrides) 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 ErrIntOverflowTraceConfig - } - 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: BlockOverrides: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockOverrides: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Number = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Difficulty", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Difficulty = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Time = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.GasLimit = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coinbase", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Coinbase = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Random", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Random = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BaseFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BaseFee = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTraceConfig(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfig - } - 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 @@ -1967,7 +1478,7 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlockOverrides", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTraceConfig @@ -1977,26 +1488,24 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTraceConfig } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTraceConfig } if postIndex > l { return io.ErrUnexpectedEOF } + m.BlockOverrides = append(m.BlockOverrides[:0], dAtA[iNdEx:postIndex]...) if m.BlockOverrides == nil { - m.BlockOverrides = &BlockOverrides{} - } - if err := m.BlockOverrides.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.BlockOverrides = []byte{} } iNdEx = postIndex default: From b2e0acdeffc28f8bf7532f35d8a1944f793fd769 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 11 Jan 2024 20:44:13 +0800 Subject: [PATCH 13/18] add json raw msg --- rpc/backend/tracing.go | 1 + rpc/types/types.go | 3 ++- x/evm/keeper/grpc_query.go | 7 +------ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/rpc/backend/tracing.go b/rpc/backend/tracing.go index a6feaa03fc..a2c067c093 100644 --- a/rpc/backend/tracing.go +++ b/rpc/backend/tracing.go @@ -135,6 +135,7 @@ func (b *Backend) convertConfig(config *rpctypes.TraceConfig) *evmtypes.TraceCon } cfg := config.TraceConfig cfg.TracerJsonConfig = string(config.TracerConfig) + cfg.BlockOverrides = []byte(config.BlockOverrides) return &cfg } diff --git a/rpc/types/types.go b/rpc/types/types.go index 907de87254..86a4b40dc1 100644 --- a/rpc/types/types.go +++ b/rpc/types/types.go @@ -184,5 +184,6 @@ type OneFeeHistory struct { type TraceConfig struct { evmtypes.TraceConfig - TracerConfig json.RawMessage `json:"tracerConfig"` + TracerConfig json.RawMessage `json:"tracerConfig"` + BlockOverrides json.RawMessage `json:"blockOverrides"` } diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 301ed97384..4ec8f8cc72 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -703,12 +703,7 @@ func (k *Keeper) prepareTrace( if traceConfig.BlockOverrides != nil { var blockOverrides rpctypes.BlockOverrides - config, err := json.Marshal(traceConfig.BlockOverrides) - if err != nil { - return nil, 0, status.Error(codes.InvalidArgument, err.Error()) - } - - if err := json.Unmarshal(config, &blockOverrides); err != nil { + if err := json.Unmarshal(traceConfig.BlockOverrides, &blockOverrides); err != nil { return nil, 0, status.Error(codes.InvalidArgument, err.Error()) } From 8bc71f097f3777b4a8461bb75922b0cb77407239 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 11 Jan 2024 20:44:16 +0800 Subject: [PATCH 14/18] apply state --- client/docs/swagger-ui/swagger.yaml | 73 +- proto/ethermint/evm/v1/trace_config.proto | 12 +- rpc/backend/tracing.go | 1 + rpc/types/types.go | 1 + x/evm/keeper/grpc_query.go | 7 +- x/evm/types/trace_config.pb.go | 816 ++-------------------- 6 files changed, 78 insertions(+), 832 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index d44936dc00..e8c1d48c18 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -2658,6 +2658,14 @@ paths: in: query required: false type: string + - name: trace_config.state_overrides + description: >- + temporary state modifications to Geth in order to simulate the + effects of eth_call. + in: query + required: false + type: string + format: byte - name: trace_config.block_overrides description: block overrides block context fields encoded as json. in: query @@ -3112,6 +3120,14 @@ paths: in: query required: false type: string + - name: trace_config.state_overrides + description: >- + temporary state modifications to Geth in order to simulate the + effects of eth_call. + in: query + required: false + type: string + format: byte - name: trace_config.block_overrides description: block overrides block context fields encoded as json. in: query @@ -3629,6 +3645,14 @@ paths: in: query required: false type: string + - name: trace_config.state_overrides + description: >- + temporary state modifications to Geth in order to simulate the + effects of eth_call. + in: query + required: false + type: string + format: byte - name: trace_config.block_overrides description: block overrides block context fields encoded as json. in: query @@ -4347,29 +4371,6 @@ definitions: format: byte title: include the block hash for json-rpc to use description: MsgEthereumTxResponse defines the Msg/EthereumTx response type. - ethermint.evm.v1.OverrideAccount: - type: object - properties: - nonce: - type: string - format: uint64 - code: - type: string - balance: - type: string - state: - type: object - additionalProperties: - type: string - state_diff: - type: object - additionalProperties: - type: string - description: >- - OverrideAccount indicates the overriding fields of account during the - execution of - - a message call. ethermint.evm.v1.Params: type: object properties: @@ -4887,30 +4888,8 @@ definitions: type: string title: tracer_json_config configures the tracer using a JSON string state_overrides: - type: object - additionalProperties: - type: object - properties: - nonce: - type: string - format: uint64 - code: - type: string - balance: - type: string - state: - type: object - additionalProperties: - type: string - state_diff: - type: object - additionalProperties: - type: string - description: >- - OverrideAccount indicates the overriding fields of account during - the execution of - - a message call. + type: string + format: byte title: >- temporary state modifications to Geth in order to simulate the effects of eth_call diff --git a/proto/ethermint/evm/v1/trace_config.proto b/proto/ethermint/evm/v1/trace_config.proto index 948af10be3..946ed7ce53 100644 --- a/proto/ethermint/evm/v1/trace_config.proto +++ b/proto/ethermint/evm/v1/trace_config.proto @@ -6,16 +6,6 @@ import "ethermint/evm/v1/chain_config.proto"; option go_package = "github.com/evmos/ethermint/x/evm/types"; -// OverrideAccount indicates the overriding fields of account during the execution of -// a message call. -message OverrideAccount { - uint64 nonce = 1; - string code = 2; - string balance = 3; - map state = 4; - map state_diff = 5 [(gogoproto.jsontag) = "stateDiff"]; -} - // TraceConfig holds extra parameters to trace functions. message TraceConfig { // DEPRECATED: DisableMemory and DisableReturnData have been renamed to @@ -47,7 +37,7 @@ message TraceConfig { // tracer_json_config configures the tracer using a JSON string string tracer_json_config = 13 [(gogoproto.jsontag) = "tracerConfig"]; // temporary state modifications to Geth in order to simulate the effects of eth_call - map state_overrides = 14 [(gogoproto.jsontag) = "stateOverrides"]; + bytes state_overrides = 14 [(gogoproto.jsontag) = "stateOverrides"]; // block overrides block context fields encoded as json bytes block_overrides = 15 [(gogoproto.jsontag) = "blockOverrides"]; } \ No newline at end of file diff --git a/rpc/backend/tracing.go b/rpc/backend/tracing.go index a2c067c093..2b80baba1d 100644 --- a/rpc/backend/tracing.go +++ b/rpc/backend/tracing.go @@ -135,6 +135,7 @@ func (b *Backend) convertConfig(config *rpctypes.TraceConfig) *evmtypes.TraceCon } cfg := config.TraceConfig cfg.TracerJsonConfig = string(config.TracerConfig) + cfg.StateOverrides = []byte(config.StateOverrides) cfg.BlockOverrides = []byte(config.BlockOverrides) return &cfg } diff --git a/rpc/types/types.go b/rpc/types/types.go index 86a4b40dc1..5fdf4ce408 100644 --- a/rpc/types/types.go +++ b/rpc/types/types.go @@ -185,5 +185,6 @@ type OneFeeHistory struct { type TraceConfig struct { evmtypes.TraceConfig TracerConfig json.RawMessage `json:"tracerConfig"` + StateOverrides json.RawMessage `json:"stateOverrides"` BlockOverrides json.RawMessage `json:"blockOverrides"` } diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 4ec8f8cc72..6d5c46e8da 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -689,12 +689,7 @@ func (k *Keeper) prepareTrace( if traceConfig.StateOverrides != nil { var stateOverrides rpctypes.StateOverride - config, err := json.Marshal(traceConfig.StateOverrides) - if err != nil { - return nil, 0, status.Error(codes.InvalidArgument, err.Error()) - } - - if err := json.Unmarshal(config, &stateOverrides); err != nil { + if err := json.Unmarshal(traceConfig.StateOverrides, &stateOverrides); err != nil { return nil, 0, status.Error(codes.InvalidArgument, err.Error()) } diff --git a/x/evm/types/trace_config.pb.go b/x/evm/types/trace_config.pb.go index 4fdad993f4..1f354505f2 100644 --- a/x/evm/types/trace_config.pb.go +++ b/x/evm/types/trace_config.pb.go @@ -23,84 +23,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// OverrideAccount indicates the overriding fields of account during the execution of -// a message call. -type OverrideAccount struct { - Nonce uint64 `protobuf:"varint,1,opt,name=nonce,proto3" json:"nonce,omitempty"` - Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` - Balance string `protobuf:"bytes,3,opt,name=balance,proto3" json:"balance,omitempty"` - State map[string]string `protobuf:"bytes,4,rep,name=state,proto3" json:"state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - StateDiff map[string]string `protobuf:"bytes,5,rep,name=state_diff,json=stateDiff,proto3" json:"stateDiff" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *OverrideAccount) Reset() { *m = OverrideAccount{} } -func (m *OverrideAccount) String() string { return proto.CompactTextString(m) } -func (*OverrideAccount) ProtoMessage() {} -func (*OverrideAccount) Descriptor() ([]byte, []int) { - return fileDescriptor_8f7fb70914ae5a53, []int{0} -} -func (m *OverrideAccount) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *OverrideAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_OverrideAccount.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 *OverrideAccount) XXX_Merge(src proto.Message) { - xxx_messageInfo_OverrideAccount.Merge(m, src) -} -func (m *OverrideAccount) XXX_Size() int { - return m.Size() -} -func (m *OverrideAccount) XXX_DiscardUnknown() { - xxx_messageInfo_OverrideAccount.DiscardUnknown(m) -} - -var xxx_messageInfo_OverrideAccount proto.InternalMessageInfo - -func (m *OverrideAccount) GetNonce() uint64 { - if m != nil { - return m.Nonce - } - return 0 -} - -func (m *OverrideAccount) GetCode() string { - if m != nil { - return m.Code - } - return "" -} - -func (m *OverrideAccount) GetBalance() string { - if m != nil { - return m.Balance - } - return "" -} - -func (m *OverrideAccount) GetState() map[string]string { - if m != nil { - return m.State - } - return nil -} - -func (m *OverrideAccount) GetStateDiff() map[string]string { - if m != nil { - return m.StateDiff - } - return nil -} - // TraceConfig holds extra parameters to trace functions. type TraceConfig struct { // tracer is a custom javascript tracer @@ -127,7 +49,7 @@ type TraceConfig struct { // 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"` // temporary state modifications to Geth in order to simulate the effects of eth_call - StateOverrides map[string]*OverrideAccount `protobuf:"bytes,14,rep,name=state_overrides,json=stateOverrides,proto3" json:"stateOverrides" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + StateOverrides []byte `protobuf:"bytes,14,opt,name=state_overrides,json=stateOverrides,proto3" json:"stateOverrides"` // block overrides block context fields encoded as json BlockOverrides []byte `protobuf:"bytes,15,opt,name=block_overrides,json=blockOverrides,proto3" json:"blockOverrides"` } @@ -136,7 +58,7 @@ 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_8f7fb70914ae5a53, []int{1} + return fileDescriptor_8f7fb70914ae5a53, []int{0} } func (m *TraceConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -242,7 +164,7 @@ func (m *TraceConfig) GetTracerJsonConfig() string { return "" } -func (m *TraceConfig) GetStateOverrides() map[string]*OverrideAccount { +func (m *TraceConfig) GetStateOverrides() []byte { if m != nil { return m.StateOverrides } @@ -257,11 +179,7 @@ func (m *TraceConfig) GetBlockOverrides() []byte { } func init() { - proto.RegisterType((*OverrideAccount)(nil), "ethermint.evm.v1.OverrideAccount") - proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.OverrideAccount.StateDiffEntry") - proto.RegisterMapType((map[string]string)(nil), "ethermint.evm.v1.OverrideAccount.StateEntry") proto.RegisterType((*TraceConfig)(nil), "ethermint.evm.v1.TraceConfig") - proto.RegisterMapType((map[string]*OverrideAccount)(nil), "ethermint.evm.v1.TraceConfig.StateOverridesEntry") } func init() { @@ -269,129 +187,37 @@ func init() { } var fileDescriptor_8f7fb70914ae5a53 = []byte{ - // 658 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x5e, 0xb6, 0xb4, 0x6b, 0xdd, 0x6d, 0x8d, 0xbc, 0x09, 0x59, 0x95, 0x68, 0xc3, 0x90, 0x50, - 0x0e, 0x28, 0x65, 0x43, 0x88, 0x89, 0x21, 0x04, 0xdd, 0xb8, 0x4c, 0x42, 0x48, 0x1e, 0x27, 0x0e, - 0x54, 0x6e, 0xe2, 0x76, 0x61, 0x4d, 0x3c, 0x39, 0x6e, 0xb4, 0xfe, 0x0b, 0xfe, 0x0b, 0x7f, 0x82, - 0xe3, 0x8e, 0x9c, 0x2a, 0xb4, 0xdd, 0x7a, 0xe3, 0x1f, 0x20, 0xdb, 0x49, 0x93, 0xb4, 0x93, 0x80, - 0xdb, 0xfb, 0xde, 0x7b, 0xdf, 0x7b, 0x7e, 0xfe, 0x9e, 0x0d, 0x1e, 0x53, 0x71, 0x41, 0x79, 0x18, - 0x44, 0xa2, 0x4b, 0x93, 0xb0, 0x9b, 0x1c, 0x74, 0x05, 0x27, 0x1e, 0xed, 0x7b, 0x2c, 0x1a, 0x06, - 0x23, 0xf7, 0x8a, 0x33, 0xc1, 0xa0, 0xb5, 0x48, 0x72, 0x69, 0x12, 0xba, 0xc9, 0x41, 0x6b, 0x6f, - 0xc4, 0x46, 0x4c, 0x05, 0xbb, 0xd2, 0xd2, 0x79, 0xad, 0xd5, 0x62, 0xde, 0x05, 0x09, 0xa2, 0x52, - 0xb1, 0xfd, 0xdf, 0xeb, 0xa0, 0xf9, 0x31, 0xa1, 0x9c, 0x07, 0x3e, 0x7d, 0xe7, 0x79, 0x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fb, 0xac, 0x34, 0x89, 0x4b, - 0x01, 0xbc, 0x84, 0xa5, 0xa0, 0x83, 0x31, 0xf3, 0x2e, 0x0b, 0xfd, 0x9a, 0xb6, 0xe1, 0x6c, 0x69, - 0xb2, 0x0a, 0x15, 0xc8, 0x65, 0xdc, 0xf2, 0xc1, 0xee, 0x3d, 0x7d, 0xef, 0xd9, 0xf0, 0x97, 0xc5, - 0x0d, 0x6f, 0x1c, 0x3e, 0xfa, 0xeb, 0xd3, 0x2c, 0x3c, 0x82, 0x33, 0xb3, 0x66, 0x5a, 0x95, 0x33, - 0xb3, 0xb6, 0x69, 0xd5, 0x16, 0x2b, 0x95, 0x0a, 0x8b, 0x77, 0x33, 0x5c, 0x50, 0xac, 0xf7, 0xf6, - 0xc7, 0x6d, 0xdb, 0xb8, 0xb9, 0x6d, 0x1b, 0xbf, 0x6e, 0xdb, 0xc6, 0xb7, 0xbb, 0xf6, 0xda, 0xcd, - 0x5d, 0x7b, 0xed, 0xe7, 0x5d, 0x7b, 0xed, 0xf3, 0x93, 0x51, 0x20, 0x2e, 0x26, 0x03, 0xd7, 0x63, - 0xa1, 0xfc, 0xe9, 0x58, 0xdc, 0xcd, 0x7f, 0xbe, 0x6b, 0xf5, 0xf7, 0x89, 0xe9, 0x15, 0x8d, 0x07, - 0x55, 0xf5, 0xe5, 0x3d, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x49, 0x14, 0xa1, 0x66, 0x05, - 0x00, 0x00, -} - -func (m *OverrideAccount) 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 *OverrideAccount) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *OverrideAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StateDiff) > 0 { - for k := range m.StateDiff { - v := m.StateDiff[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTraceConfig(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x2a - } - } - if len(m.State) > 0 { - for k := range m.State { - v := m.State[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTraceConfig(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x22 - } - } - if len(m.Balance) > 0 { - i -= len(m.Balance) - copy(dAtA[i:], m.Balance) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Balance))) - i-- - dAtA[i] = 0x1a - } - if len(m.Code) > 0 { - i -= len(m.Code) - copy(dAtA[i:], m.Code) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.Code))) - i-- - dAtA[i] = 0x12 - } - if m.Nonce != 0 { - i = encodeVarintTraceConfig(dAtA, i, uint64(m.Nonce)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil + // 477 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x92, 0x41, 0x6b, 0xdb, 0x30, + 0x14, 0xc7, 0xa3, 0x2d, 0x49, 0x13, 0x25, 0x6d, 0x8d, 0x16, 0x86, 0x28, 0xcc, 0x31, 0x1b, 0x0c, + 0x9f, 0x1c, 0xba, 0xb1, 0x53, 0x61, 0x8c, 0x74, 0xa7, 0xc0, 0x18, 0x68, 0x3b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2f, 0xb6, 0xbc, 0x17, 0xcc, 0xf8, 0xd3, 0xdf, 0x95, + 0x8b, 0x1e, 0x56, 0x2e, 0xfa, 0xbf, 0x72, 0xd1, 0xef, 0xb5, 0xdb, 0x78, 0x58, 0xbb, 0x8d, 0x7f, + 0x6b, 0xb7, 0xf1, 0xe3, 0x6d, 0x92, 0xaa, 0xd9, 0x22, 0x0a, 0x62, 0x91, 0xe9, 0xe5, 0x16, 0xc5, + 0xa8, 0x5e, 0xf6, 0x3b, 0xb3, 0xee, 0xea, 0xfe, 0x16, 0x8a, 0xa8, 0x6d, 0xb6, 0xfc, 0xfd, 0x63, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xb8, 0x15, 0x05, 0x59, 0x03, 0x00, 0x00, } func (m *TraceConfig) Marshal() (dAtA []byte, err error) { @@ -422,30 +248,11 @@ func (m *TraceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x7a } if len(m.StateOverrides) > 0 { - for k := range m.StateOverrides { - v := m.StateOverrides[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTraceConfig(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTraceConfig(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTraceConfig(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x72 - } + i -= len(m.StateOverrides) + copy(dAtA[i:], m.StateOverrides) + i = encodeVarintTraceConfig(dAtA, i, uint64(len(m.StateOverrides))) + i-- + dAtA[i] = 0x72 } if len(m.TracerJsonConfig) > 0 { i -= len(m.TracerJsonConfig) @@ -554,42 +361,6 @@ func encodeVarintTraceConfig(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *OverrideAccount) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Nonce != 0 { - n += 1 + sovTraceConfig(uint64(m.Nonce)) - } - l = len(m.Code) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - l = len(m.Balance) - if l > 0 { - n += 1 + l + sovTraceConfig(uint64(l)) - } - if len(m.State) > 0 { - for k, v := range m.State { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovTraceConfig(uint64(len(k))) + 1 + len(v) + sovTraceConfig(uint64(len(v))) - n += mapEntrySize + 1 + sovTraceConfig(uint64(mapEntrySize)) - } - } - if len(m.StateDiff) > 0 { - for k, v := range m.StateDiff { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovTraceConfig(uint64(len(k))) + 1 + len(v) + sovTraceConfig(uint64(len(v))) - n += mapEntrySize + 1 + sovTraceConfig(uint64(mapEntrySize)) - } - } - return n -} - func (m *TraceConfig) Size() (n int) { if m == nil { return 0 @@ -633,18 +404,9 @@ func (m *TraceConfig) Size() (n int) { if l > 0 { n += 1 + l + sovTraceConfig(uint64(l)) } - if len(m.StateOverrides) > 0 { - for k, v := range m.StateOverrides { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovTraceConfig(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovTraceConfig(uint64(len(k))) + l - n += mapEntrySize + 1 + sovTraceConfig(uint64(mapEntrySize)) - } + l = len(m.StateOverrides) + if l > 0 { + n += 1 + l + sovTraceConfig(uint64(l)) } l = len(m.BlockOverrides) if l > 0 { @@ -659,393 +421,6 @@ func sovTraceConfig(x uint64) (n int) { func sozTraceConfig(x uint64) (n int) { return sovTraceConfig(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *OverrideAccount) 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 ErrIntOverflowTraceConfig - } - 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: OverrideAccount: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: OverrideAccount: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) - } - m.Nonce = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Code = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Balance = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.State == nil { - m.State = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthTraceConfig - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthTraceConfig - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return ErrInvalidLengthTraceConfig - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return ErrInvalidLengthTraceConfig - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := skipTraceConfig(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfig - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.State[mapkey] = mapvalue - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StateDiff", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTraceConfig - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.StateDiff == nil { - m.StateDiff = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthTraceConfig - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthTraceConfig - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return ErrInvalidLengthTraceConfig - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return ErrInvalidLengthTraceConfig - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := skipTraceConfig(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfig - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.StateDiff[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTraceConfig(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfig - } - 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 @@ -1349,7 +724,7 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StateOverrides", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTraceConfig @@ -1359,120 +734,25 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTraceConfig } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTraceConfig } if postIndex > l { return io.ErrUnexpectedEOF } + m.StateOverrides = append(m.StateOverrides[:0], dAtA[iNdEx:postIndex]...) if m.StateOverrides == nil { - m.StateOverrides = make(map[string]*OverrideAccount) - } - var mapkey string - var mapvalue *OverrideAccount - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthTraceConfig - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthTraceConfig - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceConfig - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthTraceConfig - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthTraceConfig - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &OverrideAccount{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipTraceConfig(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceConfig - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } + m.StateOverrides = []byte{} } - m.StateOverrides[mapkey] = mapvalue iNdEx = postIndex case 15: if wireType != 2 { From e080ed45f23752edb93a440961d9b11357c6c148 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 11 Jan 2024 20:52:07 +0800 Subject: [PATCH 15/18] test staticcall --- .../hardhat/contracts/Calculator.sol | 11 ++++ .../hardhat/contracts/Caller.sol | 17 ++++++ tests/integration_tests/test_tracers.py | 57 +++++++++++++++++++ tests/integration_tests/utils.py | 17 ++++++ 4 files changed, 102 insertions(+) create mode 100644 tests/integration_tests/hardhat/contracts/Calculator.sol create mode 100644 tests/integration_tests/hardhat/contracts/Caller.sol diff --git a/tests/integration_tests/hardhat/contracts/Calculator.sol b/tests/integration_tests/hardhat/contracts/Calculator.sol new file mode 100644 index 0000000000..efa03eda1c --- /dev/null +++ b/tests/integration_tests/hardhat/contracts/Calculator.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract Calculator { + uint public x = 20; + uint public y = 20; + + function getSum() public view returns (uint256) { + return x + y; + } +} diff --git a/tests/integration_tests/hardhat/contracts/Caller.sol b/tests/integration_tests/hardhat/contracts/Caller.sol new file mode 100644 index 0000000000..625568ab24 --- /dev/null +++ b/tests/integration_tests/hardhat/contracts/Caller.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "./Calculator.sol"; + +contract Caller { + Calculator calculator; + + constructor(address _calc) { + calculator = Calculator(_calc); + } + + // call the getSum function in the calculator contract + function callCalculator() public view returns (uint sum) { + sum = calculator.getSum(); + } +} diff --git a/tests/integration_tests/test_tracers.py b/tests/integration_tests/test_tracers.py index 7b90f9f8ea..78f884de9f 100644 --- a/tests/integration_tests/test_tracers.py +++ b/tests/integration_tests/test_tracers.py @@ -19,6 +19,7 @@ derive_new_account, derive_random_account, send_transaction, + sign_transaction, w3_wait_for_new_blocks, ) @@ -434,3 +435,59 @@ def process(w3): res = [future.result() for future in as_completed(tasks)] assert len(res) == len(providers) assert (res[0] == res[-1] == EXPECTED_BLOCK_OVERRIDES_TRACERS), res + + +def test_trace_staticcall(ethermint, geth): + method = "debug_traceTransaction" + tracer = {"tracer": "callTracer"} + acc = derive_new_account(6) + sender = acc.address + price = 58500000000 + func = "callCalculator()" + selector = f"0x{Web3.keccak(text=func).hex()[2:10]}" + x = "0x0000000000000000000000000000000000000000000000000000000000000000" + y = "0x0000000000000000000000000000000000000000000000000000000000000001" + + def process(w3): + fund_acc(w3, acc) + calculator, _ = deploy_contract(w3, CONTRACTS["Calculator"], key=acc.key) + caller, _ = deploy_contract( + w3, CONTRACTS["Caller"], (calculator.address,), key=acc.key, + ) + w3_wait_for_new_blocks(w3, 1, sleep=0.1) + txhashes = [] + total = 3 + nonce = w3.eth.get_transaction_count(sender) + for n in range(total): + tx = { + "to": caller.address, + "data": selector, + "nonce": nonce + n, + "gasPrice": price, + } + if n == 1: + tx["accessList"] = [{ + "address": calculator.address, + "storageKeys": (x, y), + }] + + signed = sign_transaction(w3, tx, acc.key) + txhash = w3.eth.send_raw_transaction(signed.rawTransaction) + txhashes.append(txhash) + for txhash in txhashes: + w3.eth.wait_for_transaction_receipt(txhash, timeout=10) + res = [] + call = w3.provider.make_request + with ThreadPoolExecutor(len(txhashes)) as exec: + params = [[(tx_hash.hex())] + [tracer] for tx_hash in txhashes] + exec_map = exec.map(call, itertools.repeat(method), params) + for resp in exec_map: + res = [json.dumps(resp["result"], sort_keys=True)] + return res + + providers = [ethermint.w3, geth.w3] + with ThreadPoolExecutor(len(providers)) as exec: + tasks = [exec.submit(process, w3) for w3 in providers] + res = [future.result() for future in as_completed(tasks)] + assert len(res) == len(providers) + assert res[0] == res[-1], res diff --git a/tests/integration_tests/utils.py b/tests/integration_tests/utils.py index 4b9a75ab21..2c648e1d71 100644 --- a/tests/integration_tests/utils.py +++ b/tests/integration_tests/utils.py @@ -38,6 +38,8 @@ "TestExploitContract": "TestExploitContract.sol", "TestRevert": "TestRevert.sol", "TestMessageCall": "TestMessageCall.sol", + "Calculator": "Calculator.sol", + "Caller": "Caller.sol", } @@ -195,6 +197,21 @@ def send_transaction(w3, tx, key=KEYS["validator"], i=0): return send_transaction(w3, tx, key, i + 1) +def send_txs(w3, cli, to, keys, params): + tx = {"to": to, "value": 10000} | params + # use different sender accounts to be able be send concurrently + raw_transactions = [] + for key_from in keys: + signed = sign_transaction(w3, tx, key_from) + raw_transactions.append(signed.rawTransaction) + # wait block update + block_num = wait_for_new_blocks(cli, 1, sleep=0.1) + print(f"block number start: {block_num}") + # send transactions + sended_hash_set = send_raw_transactions(w3, raw_transactions) + return block_num, sended_hash_set + + def send_successful_transaction(w3, i=0): if i > 3: raise TimeExhausted From 68cc28b0a277c08dfd47596eae1569ea786ae6d2 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 12 Jan 2024 09:17:03 +0800 Subject: [PATCH 16/18] Update x/evm/keeper/state_transition.go Co-authored-by: yihuang Signed-off-by: mmsqe --- x/evm/keeper/state_transition.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 56b56b224a..44b184824f 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -373,13 +373,11 @@ func (k *Keeper) ApplyMessageWithConfig( return nil, errorsmod.Wrap(err, "failed to apply state override") } } - if cfg.DebugTrace && cfg.BlockOverrides != nil { - blockCtx := k.NewEVMBlockContext(ctx, cfg) + blockCtx := k.NewEVMBlockContext(ctx, cfg) + if cfg.BlockOverrides != nil { cfg.BlockOverrides.Apply(&blockCtx) - evm = k.NewEVMWithBlockCtx(ctx, msg, cfg, stateDB, blockCtx) - } else { - evm = k.NewEVM(ctx, msg, cfg, stateDB) } + evm = k.NewEVMWithBlockCtx(ctx, msg, cfg, stateDB, blockCtx) leftoverGas := msg.GasLimit sender := vm.AccountRef(msg.From) From 9cc948d4d696536ef8e40d64e51202b50b3b5d0e Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 12 Jan 2024 09:30:26 +0800 Subject: [PATCH 17/18] Apply suggestions from code review --- x/evm/keeper/state_transition.go | 48 +++++++++++--------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 44b184824f..ff12f0accd 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -38,21 +38,6 @@ import ( "github.com/ethereum/go-ethereum/params" ) -func (k *Keeper) NewEVMBlockContext(ctx sdk.Context, cfg *EVMConfig) vm.BlockContext { - return vm.BlockContext{ - CanTransfer: core.CanTransfer, - Transfer: core.Transfer, - GetHash: k.GetHashFn(ctx), - Coinbase: cfg.CoinBase, - GasLimit: ethermint.BlockGasLimit(ctx), - BlockNumber: big.NewInt(ctx.BlockHeight()), - Time: uint64(ctx.BlockHeader().Time.Unix()), - Difficulty: big.NewInt(0), // unused. Only required in PoW context - BaseFee: cfg.BaseFee, - Random: nil, // not supported - } -} - // NewEVM generates a go-ethereum VM from the provided Message fields and the chain parameters // (ChainConfig and module Params). It additionally sets the validator operator address as the // coinbase address to make it available for the COINBASE opcode, even though there is no @@ -67,17 +52,21 @@ func (k *Keeper) NewEVM( cfg *EVMConfig, stateDB vm.StateDB, ) *vm.EVM { - blockCtx := k.NewEVMBlockContext(ctx, cfg) - return k.NewEVMWithBlockCtx(ctx, msg, cfg, stateDB, blockCtx) -} - -func (k *Keeper) NewEVMWithBlockCtx( - ctx sdk.Context, - msg core.Message, - cfg *EVMConfig, - stateDB vm.StateDB, - blockCtx vm.BlockContext, -) *vm.EVM { + blockCtx := vm.BlockContext{ + CanTransfer: core.CanTransfer, + Transfer: core.Transfer, + GetHash: k.GetHashFn(ctx), + Coinbase: cfg.CoinBase, + GasLimit: ethermint.BlockGasLimit(ctx), + BlockNumber: big.NewInt(ctx.BlockHeight()), + Time: uint64(ctx.BlockHeader().Time.Unix()), + Difficulty: big.NewInt(0), // unused. Only required in PoW context + BaseFee: cfg.BaseFee, + Random: nil, // not supported + } + if cfg.BlockOverrides != nil { + cfg.BlockOverrides.Apply(&blockCtx) + } txCtx := core.NewEVMTxContext(&msg) if cfg.Tracer == nil { cfg.Tracer = k.Tracer(ctx, msg, cfg.ChainConfig) @@ -373,12 +362,7 @@ func (k *Keeper) ApplyMessageWithConfig( return nil, errorsmod.Wrap(err, "failed to apply state override") } } - blockCtx := k.NewEVMBlockContext(ctx, cfg) - if cfg.BlockOverrides != nil { - cfg.BlockOverrides.Apply(&blockCtx) - } - evm = k.NewEVMWithBlockCtx(ctx, msg, cfg, stateDB, blockCtx) - + evm = k.NewEVM(ctx, msg, cfg, stateDB) leftoverGas := msg.GasLimit sender := vm.AccountRef(msg.From) // Allow the tracer captures the tx level events, mainly the gas consumption. From 855366130b9ae149f3a0522427d0b403cbb6423f Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 12 Jan 2024 09:31:14 +0800 Subject: [PATCH 18/18] fix noop trace check this bug was introduced in https://github.com/evmos/ethermint/commit/d4621f3e822f202067c34d33ebceb6eaae5d803c --- x/evm/keeper/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/evm/keeper/config.go b/x/evm/keeper/config.go index 1e85e001a6..068501fce5 100644 --- a/x/evm/keeper/config.go +++ b/x/evm/keeper/config.go @@ -89,7 +89,7 @@ func (k Keeper) VMConfig(ctx sdk.Context, _ core.Message, cfg *EVMConfig) vm.Con noBaseFee = k.feeMarketKeeper.GetParams(ctx).NoBaseFee } - if _, ok := cfg.Tracer.(types.NoOpTracer); ok { + if _, ok := cfg.Tracer.(*types.NoOpTracer); ok { cfg.Tracer = nil }