diff --git a/mocks/mock_vm.go b/mocks/mock_vm.go index a28e5d4b7d..a4f941383a 100644 --- a/mocks/mock_vm.go +++ b/mocks/mock_vm.go @@ -57,9 +57,9 @@ func (mr *MockVMMockRecorder) Call(arg0, arg1, arg2, arg3, arg4, arg5, arg6 any) } // Execute mocks base method. -func (m *MockVM) Execute(arg0 []core.Transaction, arg1 []core.Class, arg2, arg3 uint64, arg4 *felt.Felt, arg5 core.StateReader, arg6 utils.Network, arg7 []*felt.Felt, arg8 bool, arg9 *felt.Felt, arg10 bool) ([]*felt.Felt, []json.RawMessage, error) { +func (m *MockVM) Execute(arg0 []core.Transaction, arg1 []core.Class, arg2, arg3 uint64, arg4 *felt.Felt, arg5 core.StateReader, arg6 utils.Network, arg7 []*felt.Felt, arg8 bool, arg9 *felt.Felt) ([]*felt.Felt, []json.RawMessage, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Execute", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) + ret := m.ctrl.Call(m, "Execute", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ret0, _ := ret[0].([]*felt.Felt) ret1, _ := ret[1].([]json.RawMessage) ret2, _ := ret[2].(error) @@ -67,7 +67,7 @@ func (m *MockVM) Execute(arg0 []core.Transaction, arg1 []core.Class, arg2, arg3 } // Execute indicates an expected call of Execute. -func (mr *MockVMMockRecorder) Execute(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 any) *gomock.Call { +func (mr *MockVMMockRecorder) Execute(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Execute", reflect.TypeOf((*MockVM)(nil).Execute), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Execute", reflect.TypeOf((*MockVM)(nil).Execute), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) } diff --git a/node/throttled_vm.go b/node/throttled_vm.go index a84beb64ea..09e158d22c 100644 --- a/node/throttled_vm.go +++ b/node/throttled_vm.go @@ -31,7 +31,7 @@ func (tvm *ThrottledVM) Call(contractAddr, selector *felt.Felt, calldata []felt. func (tvm *ThrottledVM) Execute(txns []core.Transaction, declaredClasses []core.Class, blockNumber, blockTimestamp uint64, sequencerAddress *felt.Felt, state core.StateReader, network utils.Network, paidFeesOnL1 []*felt.Felt, - skipChargeFee bool, gasPrice *felt.Felt, legacyTraceJSON bool, + skipChargeFee bool, gasPrice *felt.Felt, ) ([]*felt.Felt, []json.RawMessage, error) { var ret []*felt.Felt var traces []json.RawMessage @@ -39,7 +39,7 @@ func (tvm *ThrottledVM) Execute(txns []core.Transaction, declaredClasses []core. return ret, traces, throttler.Do(func(vm *vm.VM) error { var err error ret, traces, err = (*vm).Execute(txns, declaredClasses, blockNumber, blockTimestamp, sequencerAddress, - state, network, paidFeesOnL1, skipChargeFee, gasPrice, legacyTraceJSON) + state, network, paidFeesOnL1, skipChargeFee, gasPrice) return err }) } diff --git a/rpc/handlers.go b/rpc/handlers.go index 90a07d0006..0d0455fe1a 100644 --- a/rpc/handlers.go +++ b/rpc/handlers.go @@ -73,7 +73,6 @@ const ( type traceCacheKey struct { blockHash felt.Felt - legacy bool } type Handler struct { @@ -1236,14 +1235,10 @@ func (h *Handler) EstimateMessageFee(msg MsgFromL1, id BlockID) (*FeeEstimate, * // It follows the specification defined here: // https://github.com/starkware-libs/starknet-specs/blob/1ae810e0137cc5d175ace4554892a4f43052be56/api/starknet_trace_api_openrpc.json#L11 func (h *Handler) TraceTransaction(ctx context.Context, hash felt.Felt) (json.RawMessage, *jsonrpc.Error) { - return h.traceTransaction(ctx, &hash, false) + return h.traceTransaction(ctx, &hash) } -func (h *Handler) LegacyTraceTransaction(ctx context.Context, hash felt.Felt) (json.RawMessage, *jsonrpc.Error) { - return h.traceTransaction(ctx, &hash, true) -} - -func (h *Handler) traceTransaction(ctx context.Context, hash *felt.Felt, legacyTraceJSON bool) (json.RawMessage, *jsonrpc.Error) { +func (h *Handler) traceTransaction(ctx context.Context, hash *felt.Felt) (json.RawMessage, *jsonrpc.Error) { _, _, blockNumber, err := h.bcReader.Receipt(hash) if err != nil { return nil, ErrInvalidTxHash @@ -1261,7 +1256,7 @@ func (h *Handler) traceTransaction(ctx context.Context, hash *felt.Felt, legacyT return nil, ErrTxnHashNotFound } - traceResults, traceBlockErr := h.traceBlockTransactions(ctx, block, legacyTraceJSON) + traceResults, traceBlockErr := h.traceBlockTransactions(ctx, block) if traceBlockErr != nil { return nil, traceBlockErr } @@ -1272,17 +1267,11 @@ func (h *Handler) traceTransaction(ctx context.Context, hash *felt.Felt, legacyT func (h *Handler) SimulateTransactions(id BlockID, transactions []BroadcastedTransaction, simulationFlags []SimulationFlag, ) ([]SimulatedTransaction, *jsonrpc.Error) { - return h.simulateTransactions(id, transactions, simulationFlags, false) -} - -func (h *Handler) LegacySimulateTransactions(id BlockID, transactions []BroadcastedTransaction, - simulationFlags []SimulationFlag, -) ([]SimulatedTransaction, *jsonrpc.Error) { - return h.simulateTransactions(id, transactions, simulationFlags, true) + return h.simulateTransactions(id, transactions, simulationFlags) } func (h *Handler) simulateTransactions(id BlockID, transactions []BroadcastedTransaction, - simulationFlags []SimulationFlag, legacyTraceJSON bool, + simulationFlags []SimulationFlag, ) ([]SimulatedTransaction, *jsonrpc.Error) { if slices.Contains(simulationFlags, SkipValidateFlag) { return nil, jsonrpc.Err(jsonrpc.InvalidParams, "Skip validate is not supported") @@ -1334,7 +1323,7 @@ func (h *Handler) simulateTransactions(id BlockID, transactions []BroadcastedTra sequencerAddress = core.NetworkBlockHashMetaInfo(h.network).FallBackSequencerAddress } overallFees, traces, err := h.vm.Execute(txns, classes, blockNumber, header.Timestamp, sequencerAddress, - state, h.network, paidFeesOnL1, skipFeeCharge, header.GasPrice, legacyTraceJSON) + state, h.network, paidFeesOnL1, skipFeeCharge, header.GasPrice) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { return nil, ErrUnexpectedError.CloneWithData(err.Error()) @@ -1364,22 +1353,12 @@ func (h *Handler) TraceBlockTransactions(ctx context.Context, id BlockID) ([]Tra return nil, ErrBlockNotFound } - return h.traceBlockTransactions(ctx, block, false) -} - -func (h *Handler) LegacyTraceBlockTransactions(ctx context.Context, hash felt.Felt) ([]TracedBlockTransaction, *jsonrpc.Error) { - block, err := h.bcReader.BlockByHash(&hash) - if err != nil { - return nil, ErrInvalidBlockHash - } - - return h.traceBlockTransactions(ctx, block, true) + return h.traceBlockTransactions(ctx, block) } var traceFallbackVersion = semver.MustParse("0.12.2") func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block, //nolint: gocyclo - legacyJSON bool, ) ([]TracedBlockTransaction, *jsonrpc.Error) { isPending := block.Hash == nil if !isPending { @@ -1387,12 +1366,11 @@ func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block, return nil, ErrUnexpectedError.CloneWithData(err.Error()) } else if blockVer.Compare(traceFallbackVersion) != 1 { // version <= 0.12.2 - return h.fetchTraces(ctx, block.Hash, legacyJSON) + return h.fetchTraces(ctx, block.Hash) } if trace, hit := h.blockTraceCache.Get(traceCacheKey{ blockHash: *block.Hash, - legacy: legacyJSON, }); hit { return trace, nil } @@ -1452,7 +1430,7 @@ func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block, } _, traces, err := h.vm.Execute(block.Transactions, classes, blockNumber, header.Timestamp, - sequencerAddress, state, h.network, paidFeesOnL1, false, header.GasPrice, legacyJSON) + sequencerAddress, state, h.network, paidFeesOnL1, false, header.GasPrice) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { return nil, ErrUnexpectedError.CloneWithData(err.Error()) @@ -1471,14 +1449,13 @@ func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block, if !isPending { h.blockTraceCache.Add(traceCacheKey{ blockHash: *block.Hash, - legacy: legacyJSON, }, result) } return result, nil } -func (h *Handler) fetchTraces(ctx context.Context, blockHash *felt.Felt, legacyTrace bool) ([]TracedBlockTransaction, *jsonrpc.Error) { +func (h *Handler) fetchTraces(ctx context.Context, blockHash *felt.Felt) ([]TracedBlockTransaction, *jsonrpc.Error) { rpcBlock, err := h.BlockWithTxs(BlockID{ Hash: blockHash, // known non-nil }) @@ -1491,7 +1468,7 @@ func (h *Handler) fetchTraces(ctx context.Context, blockHash *felt.Felt, legacyT return nil, ErrUnexpectedError.CloneWithData(fErr.Error()) } - traces, aErr := adaptBlockTrace(rpcBlock, blockTrace, legacyTrace) + traces, aErr := adaptBlockTrace(rpcBlock, blockTrace) if aErr != nil { return nil, ErrUnexpectedError.CloneWithData(aErr.Error()) } @@ -1861,17 +1838,17 @@ func (h *Handler) LegacyMethods() ([]jsonrpc.Method, string) { //nolint: funlen { Name: "starknet_traceTransaction", Params: []jsonrpc.Parameter{{Name: "transaction_hash"}}, - Handler: h.TraceTransaction, // TODO legacy meaning needs to change + Handler: h.TraceTransaction, }, { Name: "starknet_simulateTransactions", Params: []jsonrpc.Parameter{{Name: "block_id"}, {Name: "transactions"}, {Name: "simulation_flags"}}, - Handler: h.SimulateTransactions, // TODO legacy meaning needs to change + Handler: h.SimulateTransactions, }, { Name: "starknet_traceBlockTransactions", Params: []jsonrpc.Parameter{{Name: "block_id"}}, - Handler: h.TraceBlockTransactions, // TODO legacy meaning needs to change + Handler: h.TraceBlockTransactions, }, { Name: "starknet_specVersion", diff --git a/rpc/handlers_test.go b/rpc/handlers_test.go index 0081a9f96a..895329ac3f 100644 --- a/rpc/handlers_test.go +++ b/rpc/handlers_test.go @@ -2038,10 +2038,10 @@ func TestEstimateMessageFee(t *testing.T) { expectedGasConsumed := new(felt.Felt).SetUint64(37) mockVM.EXPECT().Execute(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), - gomock.Any(), utils.MAINNET, gomock.Any(), gomock.Any(), latestHeader.GasPrice, gomock.Any()).DoAndReturn( + gomock.Any(), utils.MAINNET, gomock.Any(), gomock.Any(), latestHeader.GasPrice).DoAndReturn( func(txns []core.Transaction, declaredClasses []core.Class, blockNumber, blockTimestamp uint64, sequencerAddress *felt.Felt, state core.StateReader, network utils.Network, paidFeesOnL1 []*felt.Felt, - skipChargeFee bool, gasPrice *felt.Felt, legacyTraceJson bool, + skipChargeFee bool, gasPrice *felt.Felt, ) ([]*felt.Felt, []json.RawMessage, error) { require.Len(t, txns, 1) assert.NotNil(t, txns[0].(*core.L1HandlerTransaction)) @@ -2121,7 +2121,7 @@ func TestTraceTransaction(t *testing.T) { "fee_transfer_invocation": {"contract_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", "entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e", "calldata": ["0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x2cb6", "0x0"], "caller_address": "0xd747220b2744d8d8d48c8a52bd3869fb98aea915665ab2485d5eadb49def6a", "class_hash": "0xd0e183745e9dae3e4e78a8ffedcce0903fc4900beace4e0abf192d4c202da3", "entry_point_type": "EXTERNAL", "call_type": "CALL", "result": ["0x1"], "calls": [{"contract_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", "entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e", "calldata": ["0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x2cb6", "0x0"], "caller_address": "0xd747220b2744d8d8d48c8a52bd3869fb98aea915665ab2485d5eadb49def6a", "class_hash": "0x2760f25d5a4fb2bdde5f561fd0b44a3dee78c28903577d37d669939d97036a0", "entry_point_type": "EXTERNAL", "call_type": "DELEGATE", "result": ["0x1"], "calls": [], "events": [{"keys": ["0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"], "data": ["0xd747220b2744d8d8d48c8a52bd3869fb98aea915665ab2485d5eadb49def6a", "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x2cb6", "0x0"]}], "messages": []}], "events": [], "messages": []} }`) mockVM.EXPECT().Execute([]core.Transaction{tx}, []core.Class{declaredClass.Class}, header.Number, header.Timestamp, header.SequencerAddress, - nil, utils.MAINNET, []*felt.Felt{}, false, gomock.Any(), false).Return(nil, []json.RawMessage{vmTrace}, nil) + nil, utils.MAINNET, []*felt.Felt{}, false, gomock.Any()).Return(nil, []json.RawMessage{vmTrace}, nil) trace, err := handler.TraceTransaction(context.Background(), *hash) require.Nil(t, err) @@ -2151,7 +2151,7 @@ func TestSimulateTransactions(t *testing.T) { mockReader.EXPECT().HeadsHeader().Return(&core.Header{}, nil) sequencerAddress := core.NetworkBlockHashMetaInfo(network).FallBackSequencerAddress - mockVM.EXPECT().Execute(nil, nil, uint64(0), uint64(0), sequencerAddress, mockState, network, []*felt.Felt{}, true, nil, false). + mockVM.EXPECT().Execute(nil, nil, uint64(0), uint64(0), sequencerAddress, mockState, network, []*felt.Felt{}, true, nil). Return([]*felt.Felt{}, []json.RawMessage{}, nil) _, err := handler.SimulateTransactions(rpc.BlockID{Latest: true}, []rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipFeeChargeFlag}) @@ -2220,7 +2220,7 @@ func TestTraceBlockTransactions(t *testing.T) { "fee_transfer_invocation": {} }`) mockVM.EXPECT().Execute(block.Transactions, []core.Class{declaredClass.Class}, height+1, header.Timestamp, sequencerAddress, - state, network, paidL1Fees, false, header.GasPrice, false).Return(nil, []json.RawMessage{vmTrace, vmTrace}, nil) + state, network, paidL1Fees, false, header.GasPrice).Return(nil, []json.RawMessage{vmTrace, vmTrace}, nil) result, err := handler.TraceBlockTransactions(context.Background(), rpc.BlockID{Hash: blockHash}) require.Nil(t, err) @@ -2264,7 +2264,7 @@ func TestTraceBlockTransactions(t *testing.T) { "fee_transfer_invocation":{"entry_point_selector":"0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e","calldata":["0x5dcd266a80b8a5f29f04d779c6b166b80150c24f2180a75e82427242dab20a9","0x15be","0x0"],"caller_address":"0xdac9bcffb3d967f19a7fe21002c98c984d5a9458a88e6fc5d1c478a97ed412","class_hash":"0xd0e183745e9dae3e4e78a8ffedcce0903fc4900beace4e0abf192d4c202da3","entry_point_type":"EXTERNAL","call_type":"CALL","result":["0x1"],"calls":[{"entry_point_selector":"0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e","calldata":["0x5dcd266a80b8a5f29f04d779c6b166b80150c24f2180a75e82427242dab20a9","0x15be","0x0"],"caller_address":"0xdac9bcffb3d967f19a7fe21002c98c984d5a9458a88e6fc5d1c478a97ed412","class_hash":"0x2760f25d5a4fb2bdde5f561fd0b44a3dee78c28903577d37d669939d97036a0","entry_point_type":"EXTERNAL","call_type":"DELEGATE","result":["0x1"],"calls":[],"events":[{"keys":["0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"],"data":["0xdac9bcffb3d967f19a7fe21002c98c984d5a9458a88e6fc5d1c478a97ed412","0x5dcd266a80b8a5f29f04d779c6b166b80150c24f2180a75e82427242dab20a9","0x15be","0x0"]}],"messages":[]}],"events":[],"messages":[]}} }`) mockVM.EXPECT().Execute([]core.Transaction{tx}, []core.Class{declaredClass.Class}, header.Number, header.Timestamp, header.SequencerAddress, - nil, network, []*felt.Felt{}, false, header.GasPrice, false).Return(nil, []json.RawMessage{vmTrace}, nil) + nil, network, []*felt.Felt{}, false, header.GasPrice).Return(nil, []json.RawMessage{vmTrace}, nil) expectedResult := []rpc.TracedBlockTransaction{ { diff --git a/rpc/trace.go b/rpc/trace.go index f8779ce8e8..2d74d0ff1d 100644 --- a/rpc/trace.go +++ b/rpc/trace.go @@ -49,7 +49,7 @@ type OrderedL2toL1Message struct { MsgToL1 } -func adaptBlockTrace(block *BlockWithTxs, blockTrace *starknet.BlockTrace, legacyTrace bool) ([]TracedBlockTransaction, error) { +func adaptBlockTrace(block *BlockWithTxs, blockTrace *starknet.BlockTrace) ([]TracedBlockTransaction, error) { if blockTrace == nil { return nil, nil } @@ -60,14 +60,12 @@ func adaptBlockTrace(block *BlockWithTxs, blockTrace *starknet.BlockTrace, legac for index := range blockTrace.Traces { feederTrace := &blockTrace.Traces[index] trace := TransactionTrace{} - if !legacyTrace { - trace.Type = block.Transactions[index].Type - } + trace.Type = block.Transactions[index].Type - trace.FeeTransferInvocation = adaptFunctionInvocation(feederTrace.FeeTransferInvocation, legacyTrace) - trace.ValidateInvocation = adaptFunctionInvocation(feederTrace.ValidateInvocation, legacyTrace) + trace.FeeTransferInvocation = adaptFunctionInvocation(feederTrace.FeeTransferInvocation) + trace.ValidateInvocation = adaptFunctionInvocation(feederTrace.ValidateInvocation) - fnInvocation := adaptFunctionInvocation(feederTrace.FunctionInvocation, legacyTrace) + fnInvocation := adaptFunctionInvocation(feederTrace.FunctionInvocation) switch block.Transactions[index].Type { case TxnDeploy: trace.ConstructorInvocation = fnInvocation @@ -97,18 +95,11 @@ func adaptBlockTrace(block *BlockWithTxs, blockTrace *starknet.BlockTrace, legac return traces, nil } -func adaptFunctionInvocation(snFnInvocation *starknet.FunctionInvocation, legacyTrace bool) *FunctionInvocation { +func adaptFunctionInvocation(snFnInvocation *starknet.FunctionInvocation) *FunctionInvocation { if snFnInvocation == nil { return nil } - orderPtr := func(o uint64) *uint64 { - if legacyTrace { - return nil - } - return &o - } - fnInvocation := FunctionInvocation{ ContractAddress: snFnInvocation.ContractAddress, EntryPointSelector: snFnInvocation.Selector, @@ -123,12 +114,12 @@ func adaptFunctionInvocation(snFnInvocation *starknet.FunctionInvocation, legacy Messages: make([]OrderedL2toL1Message, 0, len(snFnInvocation.Messages)), } for index := range snFnInvocation.InternalCalls { - fnInvocation.Calls = append(fnInvocation.Calls, *adaptFunctionInvocation(&snFnInvocation.InternalCalls[index], legacyTrace)) + fnInvocation.Calls = append(fnInvocation.Calls, *adaptFunctionInvocation(&snFnInvocation.InternalCalls[index])) } for index := range snFnInvocation.Events { snEvent := &snFnInvocation.Events[index] fnInvocation.Events = append(fnInvocation.Events, OrderedEvent{ - Order: orderPtr(snEvent.Order), + Order: &snEvent.Order, Event: Event{ Keys: utils.Map(snEvent.Keys, utils.Ptr[felt.Felt]), Data: utils.Map(snEvent.Data, utils.Ptr[felt.Felt]), @@ -138,7 +129,7 @@ func adaptFunctionInvocation(snFnInvocation *starknet.FunctionInvocation, legacy for index := range snFnInvocation.Messages { snMessage := &snFnInvocation.Messages[index] fnInvocation.Messages = append(fnInvocation.Messages, OrderedL2toL1Message{ - Order: orderPtr(snMessage.Order), + Order: &snMessage.Order, MsgToL1: MsgToL1{ Payload: utils.Map(snMessage.Payload, utils.Ptr[felt.Felt]), To: common.HexToAddress(snMessage.ToAddr), diff --git a/vm/rust/src/jsonrpc.rs b/vm/rust/src/jsonrpc.rs index 4fc90fdf40..e62872fe19 100644 --- a/vm/rust/src/jsonrpc.rs +++ b/vm/rust/src/jsonrpc.rs @@ -94,28 +94,6 @@ struct DeclaredClass { compiled_class_hash: StarkFelt, } -impl TransactionTrace { - pub fn make_legacy(&mut self) { - self.state_diff = None; - self.r#type = None; - if let Some(invocation) = &mut self.validate_invocation { - invocation.make_legacy() - } - if let Some(ExecuteInvocation::Ok(fn_invocation)) = &mut self.execute_invocation { - fn_invocation.make_legacy() - } - if let Some(invocation) = &mut self.fee_transfer_invocation { - invocation.make_legacy() - } - if let Some(invocation) = &mut self.constructor_invocation { - invocation.make_legacy() - } - if let Some(invocation) = &mut self.function_invocation { - invocation.make_legacy() - } - } -} - #[derive(Serialize)] #[serde(untagged)] pub enum ExecuteInvocation { @@ -257,20 +235,6 @@ pub struct FunctionInvocation { pub execution_resources: ExecutionResources, } -impl FunctionInvocation { - fn make_legacy(&mut self) { - for indx in 0..self.events.len() { - self.events[indx].order = None; - } - for indx in 0..self.messages.len() { - self.messages[indx].order = None; - } - for indx in 0..self.calls.len() { - self.calls[indx].make_legacy(); - } - } -} - type BlockifierCallInfo = blockifier::execution::entry_point::CallInfo; impl From for FunctionInvocation { fn from(val: BlockifierCallInfo) -> Self { diff --git a/vm/rust/src/lib.rs b/vm/rust/src/lib.rs index 96d4fb19d9..04a176e3dd 100644 --- a/vm/rust/src/lib.rs +++ b/vm/rust/src/lib.rs @@ -139,7 +139,6 @@ pub extern "C" fn cairoVMExecute( paid_fees_on_l1_json: *const c_char, skip_charge_fee: c_uchar, gas_price: *const c_uchar, - legacy_json: c_uchar, ) { let reader = JunoStateReader::new(reader_handle); let chain_id_str = unsafe { CStr::from_ptr(chain_id) }.to_str().unwrap(); @@ -260,7 +259,7 @@ pub extern "C" fn cairoVMExecute( } let actual_fee = t.actual_fee.0.into(); - let mut trace = jsonrpc::new_transaction_trace(txn_and_query_bit.txn, t, &mut txn_state); + let trace = jsonrpc::new_transaction_trace(txn_and_query_bit.txn, t, &mut txn_state); if trace.is_err() { report_error( reader_handle, @@ -276,9 +275,6 @@ pub extern "C" fn cairoVMExecute( unsafe { JunoAppendActualFee(reader_handle, felt_to_byte_array(&actual_fee).as_ptr()); } - if legacy_json == 1 { - trace.as_mut().unwrap().make_legacy() - } append_trace(reader_handle, trace.as_ref().unwrap(), &mut trace_buffer); } } diff --git a/vm/vm.go b/vm/vm.go index c08508db48..8eb2c0fd81 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -9,7 +9,7 @@ package vm // // extern void cairoVMExecute(char* txns_json, char* classes_json, uintptr_t readerHandle, unsigned long long block_number, // unsigned long long block_timestamp, char* chain_id, char* sequencer_address, char* paid_fees_on_l1_json, -// unsigned char skip_charge_fee, char* gas_price, unsigned char legacy_json); +// unsigned char skip_charge_fee, char* gas_price); // // #cgo vm_debug LDFLAGS: -L./rust/target/debug -ljuno_starknet_rs -lm -ldl // #cgo !vm_debug LDFLAGS: -L./rust/target/release -ljuno_starknet_rs -lm -ldl @@ -33,7 +33,7 @@ type VM interface { ) ([]*felt.Felt, error) Execute(txns []core.Transaction, declaredClasses []core.Class, blockNumber, blockTimestamp uint64, sequencerAddress *felt.Felt, state core.StateReader, network utils.Network, paidFeesOnL1 []*felt.Felt, - skipChargeFee bool, gasPrice *felt.Felt, legacyTraceJSON bool, + skipChargeFee bool, gasPrice *felt.Felt, ) ([]*felt.Felt, []json.RawMessage, error) } @@ -153,7 +153,7 @@ func (v *vm) Call(contractAddr, selector *felt.Felt, calldata []felt.Felt, block // Execute executes a given transaction set and returns the gas spent per transaction func (v *vm) Execute(txns []core.Transaction, declaredClasses []core.Class, blockNumber, blockTimestamp uint64, sequencerAddress *felt.Felt, state core.StateReader, network utils.Network, paidFeesOnL1 []*felt.Felt, - skipChargeFee bool, gasPrice *felt.Felt, legacyTraceJSON bool, + skipChargeFee bool, gasPrice *felt.Felt, ) ([]*felt.Felt, []json.RawMessage, error) { context := &callContext{ state: state, @@ -184,11 +184,6 @@ func (v *vm) Execute(txns []core.Transaction, declaredClasses []core.Class, bloc skipChargeFeeByte = 1 } - var legacyTraceJSONByte byte - if legacyTraceJSON { - legacyTraceJSONByte = 1 - } - chainID := C.CString(network.ChainIDString()) C.cairoVMExecute(txnsJSONCstr, classesJSONCStr, @@ -200,7 +195,6 @@ func (v *vm) Execute(txns []core.Transaction, declaredClasses []core.Class, bloc paidFeesOnL1CStr, C.uchar(skipChargeFeeByte), (*C.char)(unsafe.Pointer(&gasPriceBytes[0])), - C.uchar(legacyTraceJSONByte), ) C.free(unsafe.Pointer(classesJSONCStr)) diff --git a/vm/vm_test.go b/vm/vm_test.go index c2c5e0ca74..54ad63813c 100644 --- a/vm/vm_test.go +++ b/vm/vm_test.go @@ -158,11 +158,11 @@ func TestExecute(t *testing.T) { address = utils.HexToFelt(t, "0x46a89ae102987331d369645031b49c27738ed096f2789c24449966da4c6de6b") timestamp = uint64(1666877926) ) - _, _, err := New(nil).Execute([]core.Transaction{}, []core.Class{}, 0, timestamp, address, state, network, []*felt.Felt{}, false, &felt.Zero, false) + _, _, err := New(nil).Execute([]core.Transaction{}, []core.Class{}, 0, timestamp, address, state, network, []*felt.Felt{}, false, &felt.Zero) require.NoError(t, err) }) t.Run("zero data", func(t *testing.T) { - _, _, err := New(nil).Execute(nil, nil, 0, 0, &felt.Zero, state, network, []*felt.Felt{}, false, &felt.Zero, false) + _, _, err := New(nil).Execute(nil, nil, 0, 0, &felt.Zero, state, network, []*felt.Felt{}, false, &felt.Zero) require.NoError(t, err) }) }