From 7c342175ba4370a0ca8ecefdaf96b176ba01fdbd Mon Sep 17 00:00:00 2001 From: rianhughes Date: Thu, 12 Oct 2023 12:51:49 +0300 Subject: [PATCH 1/5] rpcv05 update transaction trace types --- rpc/types_trace.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/rpc/types_trace.go b/rpc/types_trace.go index 9520a56d..76fc045d 100644 --- a/rpc/types_trace.go +++ b/rpc/types_trace.go @@ -37,28 +37,35 @@ var _ TxnTrace = L1HandlerTxnTrace{} type InvokeTxnTrace struct { ValidateInvocation FnInvocation `json:"validate_invocation"` //the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) - ExecuteInvocation FnInvocation `json:"execute_invocation"` - FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"` + ExecuteInvocation FnInvocation `json:"execute_invocation"` + FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"` + StateDiff StateDiff `json:"state_diff"` + Type TransactionType `json:"type"` } // the execution trace of a declare transaction type DeclareTxnTrace struct { - ValidateInvocation FnInvocation `json:"validate_invocation"` - FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"` + ValidateInvocation FnInvocation `json:"validate_invocation"` + FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"` + StateDiff StateDiff `json:"state_diff"` + Type TransactionType `json:"type"` } // the execution trace of a deploy account transaction type DeployAccountTxnTrace struct { ValidateInvocation FnInvocation `json:"validate_invocation"` //the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) - ConstructorInvocation FnInvocation `json:"constructor_invocation"` - FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"` + ConstructorInvocation FnInvocation `json:"constructor_invocation"` + FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"` + StateDiff StateDiff `json:"state_diff"` + Type TransactionType `json:"type"` } // the execution trace of an L1 handler transaction type L1HandlerTxnTrace struct { //the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) - FunctionInvocation FnInvocation `json:"function_invocation"` + FunctionInvocation FnInvocation `json:"function_invocation"` + Type TransactionType `json:"type"` } type EntryPointType string From 6811599883406a3a804fefadb4d9061e904d2864 Mon Sep 17 00:00:00 2001 From: rianhughes Date: Thu, 12 Oct 2023 12:58:53 +0300 Subject: [PATCH 2/5] fix rpc workflow error --- rpc/trace.go | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/rpc/trace.go b/rpc/trace.go index 167c4ee3..9842d245 100644 --- a/rpc/trace.go +++ b/rpc/trace.go @@ -3,6 +3,7 @@ package rpc import ( "context" "encoding/json" + "errors" "github.com/NethermindEth/juno/core/felt" ) @@ -22,28 +23,29 @@ func (provider *Provider) TransactionTrace(ctx context.Context, transactionHash return nil, err } - // if execute_invocation exists, then it's an InvokeTxnTrace type - if _, exists := rawTxnTrace["execute_invocation"]; exists { + switch rawTxnTrace["type"] { + case TransactionType_Invoke: var trace InvokeTxnTrace err = json.Unmarshal(rawTraceByte, &trace) if err != nil { return nil, err } return trace, nil - } - - // if constructor_invocation exists, then it's a DeployAccountTxnTrace type - if _, exists := rawTxnTrace["constructor_invocation"]; exists { + case TransactionType_Declare: + var trace DeclareTxnTrace + err = json.Unmarshal(rawTraceByte, &trace) + if err != nil { + return nil, err + } + return trace, nil + case TransactionType_DeployAccount: var trace DeployAccountTxnTrace err = json.Unmarshal(rawTraceByte, &trace) if err != nil { return nil, err } return trace, nil - } - - // if function_invocation exists, then it's an L1HandlerTxnTrace type - if _, exists := rawTxnTrace["function_invocation"]; exists { + case TransactionType_L1Handler: var trace L1HandlerTxnTrace err = json.Unmarshal(rawTraceByte, &trace) if err != nil { @@ -51,14 +53,8 @@ func (provider *Provider) TransactionTrace(ctx context.Context, transactionHash } return trace, nil } + return nil, errors.New("Unknown transaction type") - // the other possible choice is for it to be a DeclareTxnTrace type - var trace DeclareTxnTrace - err = json.Unmarshal(rawTraceByte, &trace) - if err != nil { - return nil, err - } - return trace, nil } // Retrieve traces for all transactions in the given block From 939bcd79e42ba01aede8279fd5672d723f44b415 Mon Sep 17 00:00:00 2001 From: rianhughes Date: Thu, 12 Oct 2023 15:42:19 +0300 Subject: [PATCH 3/5] update traceTransaction name --- account/account.go | 4 +- mocks/mock_account.go | 127 +++++++++++++++++++++++++++++++++---- mocks/mock_rpc_provider.go | 30 ++++----- rpc/provider.go | 2 +- rpc/trace.go | 2 +- rpc/trace_test.go | 2 +- 6 files changed, 135 insertions(+), 32 deletions(-) diff --git a/account/account.go b/account/account.go index 0ab8c708..1dface8a 100644 --- a/account/account.go +++ b/account/account.go @@ -401,8 +401,8 @@ func (account *Account) TransactionReceipt(ctx context.Context, transactionHash return account.provider.TransactionReceipt(ctx, transactionHash) } -func (account *Account) TransactionTrace(ctx context.Context, transactionHash *felt.Felt) (rpc.TxnTrace, error) { - return account.provider.TransactionTrace(ctx, transactionHash) +func (account *Account) TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (rpc.TxnTrace, error) { + return account.provider.TraceTransaction(ctx, transactionHash) } func (account *Account) TransactionByBlockIdAndIndex(ctx context.Context, blockID rpc.BlockID, index uint64) (rpc.Transaction, error) { diff --git a/mocks/mock_account.go b/mocks/mock_account.go index 373cf36f..d4df8b8d 100644 --- a/mocks/mock_account.go +++ b/mocks/mock_account.go @@ -7,6 +7,7 @@ package mocks import ( context "context" reflect "reflect" + time "time" felt "github.com/NethermindEth/juno/core/felt" rpc "github.com/NethermindEth/starknet.go/rpc" @@ -36,32 +37,134 @@ func (m *MockAccountInterface) EXPECT() *MockAccountInterfaceMockRecorder { return m.recorder } -// Call mocks base method. -func (m *MockAccountInterface) Call(ctx context.Context, call rpc.FunctionCall) ([]*felt.Felt, error) { +// PrecomputeAddress mocks base method. +func (m *MockAccountInterface) PrecomputeAddress(deployerAddress, salt, classHash *felt.Felt, constructorCalldata []*felt.Felt) (*felt.Felt, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Call", ctx, call) + ret := m.ctrl.Call(m, "PrecomputeAddress", deployerAddress, salt, classHash, constructorCalldata) + ret0, _ := ret[0].(*felt.Felt) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PrecomputeAddress indicates an expected call of PrecomputeAddress. +func (mr *MockAccountInterfaceMockRecorder) PrecomputeAddress(deployerAddress, salt, classHash, constructorCalldata interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrecomputeAddress", reflect.TypeOf((*MockAccountInterface)(nil).PrecomputeAddress), deployerAddress, salt, classHash, constructorCalldata) +} + +// Sign mocks base method. +func (m *MockAccountInterface) Sign(ctx context.Context, msg *felt.Felt) ([]*felt.Felt, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Sign", ctx, msg) ret0, _ := ret[0].([]*felt.Felt) ret1, _ := ret[1].(error) return ret0, ret1 } -// Call indicates an expected call of Call. -func (mr *MockAccountInterfaceMockRecorder) Call(ctx, call interface{}) *gomock.Call { +// Sign indicates an expected call of Sign. +func (mr *MockAccountInterfaceMockRecorder) Sign(ctx, msg interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sign", reflect.TypeOf((*MockAccountInterface)(nil).Sign), ctx, msg) +} + +// SignDeclareTransaction mocks base method. +func (m *MockAccountInterface) SignDeclareTransaction(ctx context.Context, tx *rpc.DeclareTxnV2) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SignDeclareTransaction", ctx, tx) + ret0, _ := ret[0].(error) + return ret0 +} + +// SignDeclareTransaction indicates an expected call of SignDeclareTransaction. +func (mr *MockAccountInterfaceMockRecorder) SignDeclareTransaction(ctx, tx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignDeclareTransaction", reflect.TypeOf((*MockAccountInterface)(nil).SignDeclareTransaction), ctx, tx) +} + +// SignDeployAccountTransaction mocks base method. +func (m *MockAccountInterface) SignDeployAccountTransaction(ctx context.Context, tx *rpc.DeployAccountTxn, precomputeAddress *felt.Felt) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SignDeployAccountTransaction", ctx, tx, precomputeAddress) + ret0, _ := ret[0].(error) + return ret0 +} + +// SignDeployAccountTransaction indicates an expected call of SignDeployAccountTransaction. +func (mr *MockAccountInterfaceMockRecorder) SignDeployAccountTransaction(ctx, tx, precomputeAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignDeployAccountTransaction", reflect.TypeOf((*MockAccountInterface)(nil).SignDeployAccountTransaction), ctx, tx, precomputeAddress) +} + +// SignInvokeTransaction mocks base method. +func (m *MockAccountInterface) SignInvokeTransaction(ctx context.Context, tx *rpc.InvokeTxnV1) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SignInvokeTransaction", ctx, tx) + ret0, _ := ret[0].(error) + return ret0 +} + +// SignInvokeTransaction indicates an expected call of SignInvokeTransaction. +func (mr *MockAccountInterfaceMockRecorder) SignInvokeTransaction(ctx, tx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockAccountInterface)(nil).Call), ctx, call) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignInvokeTransaction", reflect.TypeOf((*MockAccountInterface)(nil).SignInvokeTransaction), ctx, tx) } -// TransactionHash mocks base method. -func (m *MockAccountInterface) TransactionHash(calls rpc.FunctionCall, txDetails rpc.TxDetails) (*felt.Felt, error) { +// TransactionHashDeclare mocks base method. +func (m *MockAccountInterface) TransactionHashDeclare(tx rpc.DeclareTxnType) (*felt.Felt, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TransactionHash", calls, txDetails) + ret := m.ctrl.Call(m, "TransactionHashDeclare", tx) ret0, _ := ret[0].(*felt.Felt) ret1, _ := ret[1].(error) return ret0, ret1 } -// TransactionHash indicates an expected call of TransactionHash. -func (mr *MockAccountInterfaceMockRecorder) TransactionHash(calls, txDetails interface{}) *gomock.Call { +// TransactionHashDeclare indicates an expected call of TransactionHashDeclare. +func (mr *MockAccountInterfaceMockRecorder) TransactionHashDeclare(tx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionHashDeclare", reflect.TypeOf((*MockAccountInterface)(nil).TransactionHashDeclare), tx) +} + +// TransactionHashDeployAccount mocks base method. +func (m *MockAccountInterface) TransactionHashDeployAccount(tx rpc.DeployAccountTxn, contractAddress *felt.Felt) (*felt.Felt, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TransactionHashDeployAccount", tx, contractAddress) + ret0, _ := ret[0].(*felt.Felt) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// TransactionHashDeployAccount indicates an expected call of TransactionHashDeployAccount. +func (mr *MockAccountInterfaceMockRecorder) TransactionHashDeployAccount(tx, contractAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionHashDeployAccount", reflect.TypeOf((*MockAccountInterface)(nil).TransactionHashDeployAccount), tx, contractAddress) +} + +// TransactionHashInvoke mocks base method. +func (m *MockAccountInterface) TransactionHashInvoke(invokeTxn rpc.InvokeTxnType) (*felt.Felt, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TransactionHashInvoke", invokeTxn) + ret0, _ := ret[0].(*felt.Felt) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// TransactionHashInvoke indicates an expected call of TransactionHashInvoke. +func (mr *MockAccountInterfaceMockRecorder) TransactionHashInvoke(invokeTxn interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionHashInvoke", reflect.TypeOf((*MockAccountInterface)(nil).TransactionHashInvoke), invokeTxn) +} + +// WaitForTransactionReceipt mocks base method. +func (m *MockAccountInterface) WaitForTransactionReceipt(ctx context.Context, transactionHash *felt.Felt, pollInterval time.Duration) (*rpc.TransactionReceipt, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WaitForTransactionReceipt", ctx, transactionHash, pollInterval) + ret0, _ := ret[0].(*rpc.TransactionReceipt) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WaitForTransactionReceipt indicates an expected call of WaitForTransactionReceipt. +func (mr *MockAccountInterfaceMockRecorder) WaitForTransactionReceipt(ctx, transactionHash, pollInterval interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionHash", reflect.TypeOf((*MockAccountInterface)(nil).TransactionHash), calls, txDetails) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForTransactionReceipt", reflect.TypeOf((*MockAccountInterface)(nil).WaitForTransactionReceipt), ctx, transactionHash, pollInterval) } diff --git a/mocks/mock_rpc_provider.go b/mocks/mock_rpc_provider.go index 59d50f11..ab5a7f04 100644 --- a/mocks/mock_rpc_provider.go +++ b/mocks/mock_rpc_provider.go @@ -366,6 +366,21 @@ func (mr *MockRpcProviderMockRecorder) TraceBlockTransactions(ctx, blockHash int return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TraceBlockTransactions", reflect.TypeOf((*MockRpcProvider)(nil).TraceBlockTransactions), ctx, blockHash) } +// TraceTransaction mocks base method. +func (m *MockRpcProvider) TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (rpc.TxnTrace, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TraceTransaction", ctx, transactionHash) + ret0, _ := ret[0].(rpc.TxnTrace) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// TraceTransaction indicates an expected call of TraceTransaction. +func (mr *MockRpcProviderMockRecorder) TraceTransaction(ctx, transactionHash interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TraceTransaction", reflect.TypeOf((*MockRpcProvider)(nil).TraceTransaction), ctx, transactionHash) +} + // TransactionByBlockIdAndIndex mocks base method. func (m *MockRpcProvider) TransactionByBlockIdAndIndex(ctx context.Context, blockID rpc.BlockID, index uint64) (rpc.Transaction, error) { m.ctrl.T.Helper() @@ -410,18 +425,3 @@ func (mr *MockRpcProviderMockRecorder) TransactionReceipt(ctx, transactionHash i mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionReceipt", reflect.TypeOf((*MockRpcProvider)(nil).TransactionReceipt), ctx, transactionHash) } - -// TransactionTrace mocks base method. -func (m *MockRpcProvider) TransactionTrace(ctx context.Context, transactionHash *felt.Felt) (rpc.TxnTrace, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TransactionTrace", ctx, transactionHash) - ret0, _ := ret[0].(rpc.TxnTrace) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// TransactionTrace indicates an expected call of TransactionTrace. -func (mr *MockRpcProviderMockRecorder) TransactionTrace(ctx, transactionHash interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionTrace", reflect.TypeOf((*MockRpcProvider)(nil).TransactionTrace), ctx, transactionHash) -} diff --git a/rpc/provider.go b/rpc/provider.go index 262c608c..20babd44 100644 --- a/rpc/provider.go +++ b/rpc/provider.go @@ -51,7 +51,7 @@ type RpcProvider interface { TransactionByBlockIdAndIndex(ctx context.Context, blockID BlockID, index uint64) (Transaction, error) TransactionByHash(ctx context.Context, hash *felt.Felt) (Transaction, error) TransactionReceipt(ctx context.Context, transactionHash *felt.Felt) (TransactionReceipt, error) - TransactionTrace(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, error) + TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, error) } var _ RpcProvider = &Provider{} diff --git a/rpc/trace.go b/rpc/trace.go index 9842d245..7c98ae4c 100644 --- a/rpc/trace.go +++ b/rpc/trace.go @@ -9,7 +9,7 @@ import ( ) // For a given executed transaction, return the trace of its execution, including internal calls -func (provider *Provider) TransactionTrace(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, error) { +func (provider *Provider) TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, error) { var rawTxnTrace map[string]any if err := do(ctx, provider.c, "starknet_traceTransaction", &rawTxnTrace, transactionHash); err != nil { if noTraceAvailableError, ok := isErrNoTraceAvailableError(err); ok { diff --git a/rpc/trace_test.go b/rpc/trace_test.go index f75f23cc..b8b152cf 100644 --- a/rpc/trace_test.go +++ b/rpc/trace_test.go @@ -63,7 +63,7 @@ func TestTransactionTrace(t *testing.T) { }[testEnv] for _, test := range testSet { - resp, err := testConfig.provider.TransactionTrace(context.Background(), test.TransactionHash) + resp, err := testConfig.provider.TraceTransaction(context.Background(), test.TransactionHash) if err != nil { require.Equal(t, test.ExpectedError, err) } else { From 05b0d50a8c9c2999cf1f0a0be5cd0b7e0a7c7296 Mon Sep 17 00:00:00 2001 From: rianhughes Date: Thu, 12 Oct 2023 15:50:21 +0300 Subject: [PATCH 4/5] update trace test data to pass test --- ...5f876cb4b608868e8549b5f6a90a21d4d6329.json | 78 +++++++++++++++++++ rpc/trace.go | 8 +- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/rpc/tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json b/rpc/tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json index 9f8edf11..5d6ae2c8 100644 --- a/rpc/tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json +++ b/rpc/tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json @@ -170,6 +170,7 @@ "calls": [], "events": [ { + "order": 0, "keys": [ "0x134692b230b9e1ffa39098904722134159652b09c5bc41d88d6698779d228ff" ], @@ -287,6 +288,7 @@ "calls": [], "events": [ { + "order": 1, "keys": [ "0x134692b230b9e1ffa39098904722134159652b09c5bc41d88d6698779d228ff" ], @@ -298,6 +300,7 @@ ] }, { + "order": 2, "keys": [ "0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9" ], @@ -345,6 +348,7 @@ "calls": [], "events": [ { + "order": 3, "keys": [ "0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9" ], @@ -396,6 +400,7 @@ "calls": [], "events": [ { + "order": 4, "keys": [ "0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9" ], @@ -424,6 +429,7 @@ ], "events": [ { + "order": 5, "keys": [ "0x5ad857f66a5b55f1301ff1ed7e098ac6d4433148f0b72ebc4a2945ab85ad53" ], @@ -482,6 +488,7 @@ "calls": [], "events": [ { + "order": 0, "keys": [ "0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9" ], @@ -498,6 +505,77 @@ ], "events": [], "messages": [] + }, + "type": "INVOKE", + "state_diff": { + "storage_diffs": [ + { + "address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", + "storage_entries": [ + { + "key": "0x49a8ef79cab313360767015d427d0307368eff5c2c81b019aff018ec638eef2", + "value": "0x763b821506b19086e9" + }, + { + "key": "0x625da4622cb73a56b1f10ac489e48b4e8af830a368fb3e21db8b7868c315ff0", + "value": "0x19094ba60d592b" + }, + { + "key": "0x5496768776e3db30053404f18067d81a6e06f5a2b0de326e21298fd9d569a9a", + "value": "0x11e93b002a1d5c717d" + } + ] + }, + { + "address": "0x10884171baf1914edc28d7afb619b40a4051cfae78a094a55d230f19e944a28", + "storage_entries": [ + { + "key": "0x2487f67598912d31ab84d8fa97c9e78332d00795ecdad092ea09f9c9c14a9a3", + "value": "0x1e226129b7e" + }, + { + "key": "0x2487f67598912d31ab84d8fa97c9e78332d00795ecdad092ea09f9c9c14a9a0", + "value": "0x4477606da4ac2b7bef" + } + ] + }, + { + "address": "0x22b05f9396d2c48183f6deaf138a57522bcc8b35b67dee919f76403d1783136", + "storage_entries": [ + { + "key": "0x110e2f729c9c2b988559994a3daccd838cf52faf88e18101373e67dd061455a", + "value": "0x7743be9a9d8fae" + }, + { + "key": "0x625da4622cb73a56b1f10ac489e48b4e8af830a368fb3e21db8b7868c315ff0", + "value": "0x631cb839" + } + ] + }, + { + "address": "0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8", + "storage_entries": [ + { + "key": "0x625da4622cb73a56b1f10ac489e48b4e8af830a368fb3e21db8b7868c315ff0", + "value": "0x17fc5" + }, + { + "key": "0x49a8ef79cab313360767015d427d0307368eff5c2c81b019aff018ec638eef2", + "value": "0x257875e1c11" + } + ] + } + ], + "nonces": [ + { + "contract_address": "0x61d862eb8baf0dc8e14159d0dd16abcff933c798ecf252ce81685d74c237516", + "nonce": "0x58" + } + ], + "deployed_contracts": [], + "deprecated_declared_classes": [], + "declared_classes": [], + "replaced_classes": [] } }, "id": 1 diff --git a/rpc/trace.go b/rpc/trace.go index 7c98ae4c..ee5607cf 100644 --- a/rpc/trace.go +++ b/rpc/trace.go @@ -24,28 +24,28 @@ func (provider *Provider) TraceTransaction(ctx context.Context, transactionHash } switch rawTxnTrace["type"] { - case TransactionType_Invoke: + case string(TransactionType_Invoke): var trace InvokeTxnTrace err = json.Unmarshal(rawTraceByte, &trace) if err != nil { return nil, err } return trace, nil - case TransactionType_Declare: + case string(TransactionType_Declare): var trace DeclareTxnTrace err = json.Unmarshal(rawTraceByte, &trace) if err != nil { return nil, err } return trace, nil - case TransactionType_DeployAccount: + case string(TransactionType_DeployAccount): var trace DeployAccountTxnTrace err = json.Unmarshal(rawTraceByte, &trace) if err != nil { return nil, err } return trace, nil - case TransactionType_L1Handler: + case string(TransactionType_L1Handler): var trace L1HandlerTxnTrace err = json.Unmarshal(rawTraceByte, &trace) if err != nil { From 8ba573694bcb468aa537f07f119528b26feb6106 Mon Sep 17 00:00:00 2001 From: Carmen Cabrera Date: Wed, 25 Oct 2023 02:02:50 -0400 Subject: [PATCH 5/5] add rever reason to execution trace --- rpc/types_trace.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rpc/types_trace.go b/rpc/types_trace.go index 76fc045d..9a7874a8 100644 --- a/rpc/types_trace.go +++ b/rpc/types_trace.go @@ -37,7 +37,7 @@ var _ TxnTrace = L1HandlerTxnTrace{} type InvokeTxnTrace struct { ValidateInvocation FnInvocation `json:"validate_invocation"` //the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) - ExecuteInvocation FnInvocation `json:"execute_invocation"` + ExecuteInvocation ExecInvocation `json:"execute_invocation"` FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"` StateDiff StateDiff `json:"state_diff"` Type TransactionType `json:"type"` @@ -114,3 +114,8 @@ type Trace struct { TraceRoot TxnTrace `json:"trace_root,omitempty"` TxnHash *felt.Felt `json:"transaction_hash,omitempty"` } + +type ExecInvocation struct { + FunctionInvocation FnInvocation `json:"function_invocation,omitempty"` + RevertReason string `json:"revert_reason,omitempty"` +}