diff --git a/mocks/mock_vm.go b/mocks/mock_vm.go index 7896b09d52..134c8bb952 100644 --- a/mocks/mock_vm.go +++ b/mocks/mock_vm.go @@ -43,24 +43,24 @@ func (m *MockVM) EXPECT() *MockVMMockRecorder { } // Call mocks base method. -func (m *MockVM) Call(arg0 *vm.CallInfo, arg1 *vm.BlockInfo, arg2 core.StateReader, arg3 *utils.Network, arg4 uint64) ([]*felt.Felt, error) { +func (m *MockVM) Call(arg0 *vm.CallInfo, arg1 *vm.BlockInfo, arg2 core.StateReader, arg3 *utils.Network, arg4 uint64, arg5 bool) ([]*felt.Felt, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Call", arg0, arg1, arg2, arg3, arg4) + ret := m.ctrl.Call(m, "Call", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].([]*felt.Felt) ret1, _ := ret[1].(error) return ret0, ret1 } // Call indicates an expected call of Call. -func (mr *MockVMMockRecorder) Call(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { +func (mr *MockVMMockRecorder) Call(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockVM)(nil).Call), arg0, arg1, arg2, arg3, arg4) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockVM)(nil).Call), arg0, arg1, arg2, arg3, arg4, arg5) } // Execute mocks base method. -func (m *MockVM) Execute(arg0 []core.Transaction, arg1 []core.Class, arg2 []*felt.Felt, arg3 *vm.BlockInfo, arg4 core.StateReader, arg5 *utils.Network, arg6, arg7, arg8 bool) ([]*felt.Felt, []*felt.Felt, []vm.TransactionTrace, error) { +func (m *MockVM) Execute(arg0 []core.Transaction, arg1 []core.Class, arg2 []*felt.Felt, arg3 *vm.BlockInfo, arg4 core.StateReader, arg5 *utils.Network, arg6, arg7, arg8, arg9 bool) ([]*felt.Felt, []*felt.Felt, []vm.TransactionTrace, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Execute", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) + ret := m.ctrl.Call(m, "Execute", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ret0, _ := ret[0].([]*felt.Felt) ret1, _ := ret[1].([]*felt.Felt) ret2, _ := ret[2].([]vm.TransactionTrace) @@ -69,7 +69,7 @@ func (m *MockVM) Execute(arg0 []core.Transaction, arg1 []core.Class, arg2 []*fel } // Execute indicates an expected call of Execute. -func (mr *MockVMMockRecorder) Execute(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 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) + 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 de9134976d..f502d134d9 100644 --- a/node/throttled_vm.go +++ b/node/throttled_vm.go @@ -20,18 +20,18 @@ func NewThrottledVM(res vm.VM, concurrenyBudget uint, maxQueueLen int32) *Thrott } func (tvm *ThrottledVM) Call(callInfo *vm.CallInfo, blockInfo *vm.BlockInfo, state core.StateReader, - network *utils.Network, maxSteps uint64, + network *utils.Network, maxSteps uint64, useBlobData bool, ) ([]*felt.Felt, error) { var ret []*felt.Felt return ret, tvm.Do(func(vm *vm.VM) error { var err error - ret, err = (*vm).Call(callInfo, blockInfo, state, network, maxSteps) + ret, err = (*vm).Call(callInfo, blockInfo, state, network, maxSteps, useBlobData) return err }) } func (tvm *ThrottledVM) Execute(txns []core.Transaction, declaredClasses []core.Class, paidFeesOnL1 []*felt.Felt, - blockInfo *vm.BlockInfo, state core.StateReader, network *utils.Network, skipChargeFee, skipValidate, errOnRevert bool, + blockInfo *vm.BlockInfo, state core.StateReader, network *utils.Network, skipChargeFee, skipValidate, errOnRevert, useBlobData bool, ) ([]*felt.Felt, []*felt.Felt, []vm.TransactionTrace, error) { var ret []*felt.Felt var traces []vm.TransactionTrace @@ -39,7 +39,7 @@ func (tvm *ThrottledVM) Execute(txns []core.Transaction, declaredClasses []core. return ret, dataGasConsumed, traces, tvm.Do(func(vm *vm.VM) error { var err error ret, dataGasConsumed, traces, err = (*vm).Execute(txns, declaredClasses, paidFeesOnL1, blockInfo, state, network, - skipChargeFee, skipValidate, errOnRevert) + skipChargeFee, skipValidate, errOnRevert, useBlobData) return err }) } diff --git a/rpc/handlers.go b/rpc/handlers.go index 00e077431f..a5b7468e9f 100644 --- a/rpc/handlers.go +++ b/rpc/handlers.go @@ -1318,7 +1318,15 @@ func (h *Handler) Version() (string, *jsonrpc.Error) { } // https://github.com/starkware-libs/starknet-specs/blob/e0b76ed0d8d8eba405e182371f9edac8b2bcbc5a/api/starknet_api_openrpc.json#L401-L445 -func (h *Handler) Call(call FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Error) { //nolint:gocritic +func (h *Handler) Call(funcCall FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Error) { //nolint:gocritic + return h.call(funcCall, id, true) +} + +func (h *Handler) CallV0_6(call FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Error) { //nolint:gocritic + return h.call(call, id, false) +} + +func (h *Handler) call(funcCall FunctionCall, id BlockID, useBlobData bool) ([]*felt.Felt, *jsonrpc.Error) { //nolint:gocritic state, closer, rpcErr := h.stateByBlockID(&id) if rpcErr != nil { return nil, rpcErr @@ -1330,7 +1338,7 @@ func (h *Handler) Call(call FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Er return nil, rpcErr } - classHash, err := state.ContractClassHash(&call.ContractAddress) + classHash, err := state.ContractClassHash(&funcCall.ContractAddress) if err != nil { return nil, ErrContractNotFound } @@ -1341,14 +1349,14 @@ func (h *Handler) Call(call FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Er } res, err := h.vm.Call(&vm.CallInfo{ - ContractAddress: &call.ContractAddress, - Selector: &call.EntryPointSelector, - Calldata: call.Calldata, + ContractAddress: &funcCall.ContractAddress, + Selector: &funcCall.EntryPointSelector, + Calldata: funcCall.Calldata, ClassHash: classHash, }, &vm.BlockInfo{ Header: header, BlockHashToBeRevealed: blockHashToBeRevealed, - }, state, h.bcReader.Network(), h.callMaxSteps) + }, state, h.bcReader.Network(), h.callMaxSteps, useBlobData) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { return nil, ErrInternal.CloneWithData(throttledVMErr) @@ -1451,6 +1459,27 @@ func (h *Handler) EstimateFeeV0_6(broadcastedTxns []BroadcastedTransaction, } func (h *Handler) EstimateMessageFee(msg MsgFromL1, id BlockID) (*FeeEstimate, *jsonrpc.Error) { //nolint:gocritic + return h.estimateMessageFee(msg, id, h.EstimateFee) +} + +func (h *Handler) EstimateMessageFeeV0_6(msg MsgFromL1, id BlockID) (*FeeEstimate, *jsonrpc.Error) { //nolint:gocritic + feeEstimate, rpcErr := h.estimateMessageFee(msg, id, h.EstimateFeeV0_6) + if rpcErr != nil { + return nil, rpcErr + } + + feeEstimate.v0_6Response = true + feeEstimate.DataGasPrice = nil + feeEstimate.DataGasConsumed = nil + + return feeEstimate, nil +} + +type estimateFeeHandler func(broadcastedTxns []BroadcastedTransaction, + simulationFlags []SimulationFlag, id BlockID, +) ([]FeeEstimate, *jsonrpc.Error) + +func (h *Handler) estimateMessageFee(msg MsgFromL1, id BlockID, f estimateFeeHandler) (*FeeEstimate, *jsonrpc.Error) { //nolint:gocritic calldata := make([]*felt.Felt, 0, len(msg.Payload)+1) // The order of the calldata parameters matters. msg.From must be prepended. calldata = append(calldata, new(felt.Felt).SetBytes(msg.From.Bytes())) @@ -1470,7 +1499,7 @@ func (h *Handler) EstimateMessageFee(msg MsgFromL1, id BlockID) (*FeeEstimate, * // Must be greater than zero to successfully execute transaction. PaidFeeOnL1: new(felt.Felt).SetUint64(1), } - estimates, rpcErr := h.EstimateFee([]BroadcastedTransaction{tx}, nil, id) + estimates, rpcErr := f([]BroadcastedTransaction{tx}, nil, id) if rpcErr != nil { if rpcErr.Code == ErrTransactionExecutionError.Code { data := rpcErr.Data.(TransactionExecutionErrorData) @@ -1481,19 +1510,6 @@ func (h *Handler) EstimateMessageFee(msg MsgFromL1, id BlockID) (*FeeEstimate, * return &estimates[0], nil } -func (h *Handler) EstimateMessageFeeV0_6(msg MsgFromL1, id BlockID) (*FeeEstimate, *jsonrpc.Error) { //nolint:gocritic - feeEstimate, err := h.EstimateMessageFee(msg, id) - if err != nil { - return nil, err - } - - feeEstimate.v0_6Response = true - feeEstimate.DataGasPrice = nil - feeEstimate.DataGasConsumed = nil - - return feeEstimate, nil -} - // TraceTransaction returns the trace for a given executed transaction, including internal calls // // It follows the specification defined here: @@ -1591,8 +1607,9 @@ func (h *Handler) simulateTransactions(id BlockID, transactions []BroadcastedTra Header: header, BlockHashToBeRevealed: blockHashToBeRevealed, } + useBlobData := !v0_6Response overallFees, dataGasConsumed, traces, err := h.vm.Execute(txns, classes, paidFeesOnL1, &blockInfo, - state, h.bcReader.Network(), skipFeeCharge, skipValidate, errOnRevert) + state, h.bcReader.Network(), skipFeeCharge, skipValidate, errOnRevert, useBlobData) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { return nil, ErrInternal.CloneWithData(throttledVMErr) @@ -1625,8 +1642,13 @@ func (h *Handler) simulateTransactions(id BlockID, transactions []BroadcastedTra } } - dataGasFee := new(felt.Felt).Mul(dataGasConsumed[i], dataGasPrice) - gasConsumed := new(felt.Felt).Sub(overallFee, dataGasFee) + var gasConsumed *felt.Felt + if !v0_6Response { + dataGasFee := new(felt.Felt).Mul(dataGasConsumed[i], dataGasPrice) + gasConsumed = new(felt.Felt).Sub(overallFee, dataGasFee) + } else { + gasConsumed = overallFee.Clone() + } gasConsumed = gasConsumed.Div(gasConsumed, gasPrice) // division by zero felt is zero felt estimate := FeeEstimate{ @@ -1758,8 +1780,9 @@ func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block, BlockHashToBeRevealed: blockHashToBeRevealed, } + useBlobData := !v0_6Response overallFees, dataGasConsumed, traces, err := h.vm.Execute(block.Transactions, classes, paidFeesOnL1, &blockInfo, state, network, false, - false, false) + false, false, useBlobData) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { return nil, ErrInternal.CloneWithData(throttledVMErr) @@ -2197,7 +2220,7 @@ func (h *Handler) MethodsV0_6() ([]jsonrpc.Method, string) { //nolint: funlen { Name: "starknet_call", Params: []jsonrpc.Parameter{{Name: "request"}, {Name: "block_id"}}, - Handler: h.Call, + Handler: h.CallV0_6, }, { Name: "starknet_estimateFee", diff --git a/rpc/handlers_test.go b/rpc/handlers_test.go index 98d6c06369..e2b4ebf137 100644 --- a/rpc/handlers_test.go +++ b/rpc/handlers_test.go @@ -2905,7 +2905,7 @@ func TestCall(t *testing.T) { ClassHash: classHash, Selector: selector, Calldata: calldata, - }, &vm.BlockInfo{Header: headsHeader}, gomock.Any(), &utils.Mainnet, uint64(1337)).Return(expectedRes, nil) + }, &vm.BlockInfo{Header: headsHeader}, gomock.Any(), &utils.Mainnet, uint64(1337), true).Return(expectedRes, nil) res, rpcErr := handler.Call(rpc.FunctionCall{ ContractAddress: *contractAddr, @@ -2953,7 +2953,7 @@ func TestEstimateMessageFee(t *testing.T) { expectedGasConsumed := new(felt.Felt).SetUint64(37) mockVM.EXPECT().Execute(gomock.Any(), gomock.Any(), gomock.Any(), &vm.BlockInfo{ Header: latestHeader, - }, gomock.Any(), &utils.Mainnet, gomock.Any(), false, true).DoAndReturn( + }, gomock.Any(), &utils.Mainnet, gomock.Any(), false, true, false).DoAndReturn( func(txns []core.Transaction, declaredClasses []core.Class, paidFeesOnL1 []*felt.Felt, blockInfo *vm.BlockInfo, state core.StateReader, network *utils.Network, skipChargeFee, skipValidate, errOnRevert bool, ) ([]*felt.Felt, []*felt.Felt, []vm.TransactionTrace, error) { @@ -3055,7 +3055,7 @@ func TestTraceTransaction(t *testing.T) { vmTrace := new(vm.TransactionTrace) require.NoError(t, json.Unmarshal(vmTraceJSON, vmTrace)) mockVM.EXPECT().Execute([]core.Transaction{tx}, []core.Class{declaredClass.Class}, []*felt.Felt{}, - &vm.BlockInfo{Header: header}, gomock.Any(), &utils.Mainnet, false, false, false).Return(nil, []vm.TransactionTrace{*vmTrace}, nil) + &vm.BlockInfo{Header: header}, gomock.Any(), &utils.Mainnet, false, false, false, false).Return(nil, []vm.TransactionTrace{*vmTrace}, nil) trace, err := handler.TraceTransaction(context.Background(), *hash) require.Nil(t, err) @@ -3085,7 +3085,7 @@ func TestSimulateTransactions(t *testing.T) { t.Run("ok with zero values, skip fee", func(t *testing.T) { mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &vm.BlockInfo{ Header: headsHeader, - }, mockState, &network, true, false, false). + }, mockState, &network, true, false, false, false). Return([]*felt.Felt{}, []vm.TransactionTrace{}, nil) _, err := handler.SimulateTransactions(rpc.BlockID{Latest: true}, []rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipFeeChargeFlag}) @@ -3095,7 +3095,7 @@ func TestSimulateTransactions(t *testing.T) { t.Run("ok with zero values, skip validate", func(t *testing.T) { mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &vm.BlockInfo{ Header: headsHeader, - }, mockState, &network, false, false, false). + }, mockState, &network, false, false, false, false). Return([]*felt.Felt{}, []vm.TransactionTrace{}, nil) _, err := handler.SimulateTransactions(rpc.BlockID{Latest: true}, []rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipValidateFlag}) @@ -3105,7 +3105,7 @@ func TestSimulateTransactions(t *testing.T) { t.Run("transaction execution error", func(t *testing.T) { mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &vm.BlockInfo{ Header: headsHeader, - }, mockState, &network, false, false, false). + }, mockState, &network, false, false, false, false). Return(nil, nil, vm.TransactionExecutionError{ Index: 44, Cause: errors.New("oops"), @@ -3119,7 +3119,7 @@ func TestSimulateTransactions(t *testing.T) { mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &vm.BlockInfo{ Header: headsHeader, - }, mockState, &network, false, true, true). + }, mockState, &network, false, true, true, false). Return(nil, nil, vm.TransactionExecutionError{ Index: 44, Cause: errors.New("oops"), @@ -3215,7 +3215,7 @@ func TestTraceBlockTransactions(t *testing.T) { vmTrace := vm.TransactionTrace{} require.NoError(t, json.Unmarshal(vmTraceJSON, &vmTrace)) mockVM.EXPECT().Execute(block.Transactions, []core.Class{declaredClass.Class}, paidL1Fees, &vm.BlockInfo{Header: header}, - gomock.Any(), &network, false, false, false).Return(nil, []vm.TransactionTrace{vmTrace, vmTrace}, nil) + gomock.Any(), &network, false, false, false, false).Return(nil, []vm.TransactionTrace{vmTrace, vmTrace}, nil) result, err := handler.TraceBlockTransactions(context.Background(), rpc.BlockID{Hash: blockHash}) require.Nil(t, err) @@ -3281,7 +3281,7 @@ func TestTraceBlockTransactions(t *testing.T) { vmTrace := vm.TransactionTrace{} require.NoError(t, json.Unmarshal(vmTraceJSON, &vmTrace)) mockVM.EXPECT().Execute([]core.Transaction{tx}, []core.Class{declaredClass.Class}, []*felt.Felt{}, &vm.BlockInfo{Header: header}, - gomock.Any(), &network, false, false, false).Return(nil, []vm.TransactionTrace{vmTrace}, nil) + gomock.Any(), &network, false, false, false, false).Return(nil, []vm.TransactionTrace{vmTrace}, nil) expectedResult := []rpc.TracedBlockTransaction{ { @@ -3651,7 +3651,7 @@ func TestEstimateFee(t *testing.T) { blockInfo := vm.BlockInfo{Header: &core.Header{}} t.Run("ok with zero values", func(t *testing.T) { - mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, true, true, false). + mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, true, true, false, false). Return([]*felt.Felt{}, []vm.TransactionTrace{}, nil) _, err := handler.EstimateFee([]rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{}, rpc.BlockID{Latest: true}) @@ -3659,7 +3659,7 @@ func TestEstimateFee(t *testing.T) { }) t.Run("ok with zero values, skip validate", func(t *testing.T) { - mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, true, true, false). + mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, true, true, false, false). Return([]*felt.Felt{}, []vm.TransactionTrace{}, nil) _, err := handler.EstimateFee([]rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipValidateFlag}, rpc.BlockID{Latest: true}) @@ -3667,7 +3667,7 @@ func TestEstimateFee(t *testing.T) { }) t.Run("transaction execution error", func(t *testing.T) { - mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, true, true, false). + mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, true, true, false, false). Return(nil, nil, vm.TransactionExecutionError{ Index: 44, Cause: errors.New("oops"), @@ -3679,7 +3679,7 @@ func TestEstimateFee(t *testing.T) { ExecutionError: "oops", }), err) - mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, false, true, true). + mockVM.EXPECT().Execute(nil, nil, []*felt.Felt{}, &blockInfo, mockState, &network, false, true, true, false). Return(nil, nil, vm.TransactionExecutionError{ Index: 44, Cause: errors.New("oops"), diff --git a/vm/vm.go b/vm/vm.go index b185d13595..3533e9b722 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -55,9 +55,9 @@ import ( //go:generate mockgen -destination=../mocks/mock_vm.go -package=mocks github.com/NethermindEth/juno/vm VM type VM interface { - Call(callInfo *CallInfo, blockInfo *BlockInfo, state core.StateReader, network *utils.Network, maxSteps uint64) ([]*felt.Felt, error) + Call(callInfo *CallInfo, blockInfo *BlockInfo, state core.StateReader, network *utils.Network, maxSteps uint64, useBlobData bool) ([]*felt.Felt, error) //nolint:lll Execute(txns []core.Transaction, declaredClasses []core.Class, paidFeesOnL1 []*felt.Felt, blockInfo *BlockInfo, - state core.StateReader, network *utils.Network, skipChargeFee, skipValidate, errOnRevert bool, + state core.StateReader, network *utils.Network, skipChargeFee, skipValidate, errOnRevert, useBlobData bool, ) ([]*felt.Felt, []*felt.Felt, []TransactionTrace, error) } @@ -187,7 +187,7 @@ func makeCCallInfo(callInfo *CallInfo) (C.CallInfo, runtime.Pinner) { return cCallInfo, pinner } -func makeCBlockInfo(blockInfo *BlockInfo) C.BlockInfo { +func makeCBlockInfo(blockInfo *BlockInfo, useBlobData bool) C.BlockInfo { var cBlockInfo C.BlockInfo cBlockInfo.block_number = C.ulonglong(blockInfo.Header.Number) @@ -200,13 +200,17 @@ func makeCBlockInfo(blockInfo *BlockInfo) C.BlockInfo { if blockInfo.Header.L1DAMode == core.Blob { copyFeltIntoCArray(blockInfo.Header.L1DataGasPrice.PriceInWei, &cBlockInfo.data_gas_price_wei[0]) copyFeltIntoCArray(blockInfo.Header.L1DataGasPrice.PriceInFri, &cBlockInfo.data_gas_price_fri[0]) - cBlockInfo.use_blob_data = 1 + if useBlobData { + cBlockInfo.use_blob_data = 1 + } else { + cBlockInfo.use_blob_data = 0 + } } return cBlockInfo } func (v *vm) Call(callInfo *CallInfo, blockInfo *BlockInfo, state core.StateReader, - network *utils.Network, maxSteps uint64, + network *utils.Network, maxSteps uint64, useBlobData bool, ) ([]*felt.Felt, error) { context := &callContext{ state: state, @@ -217,7 +221,7 @@ func (v *vm) Call(callInfo *CallInfo, blockInfo *BlockInfo, state core.StateRead defer handle.Delete() cCallInfo, callInfoPinner := makeCCallInfo(callInfo) - cBlockInfo := makeCBlockInfo(blockInfo) + cBlockInfo := makeCBlockInfo(blockInfo, useBlobData) chainID := C.CString(network.L2ChainID) C.cairoVMCall( &cCallInfo, @@ -239,7 +243,7 @@ func (v *vm) Call(callInfo *CallInfo, blockInfo *BlockInfo, state core.StateRead // Execute executes a given transaction set and returns the gas spent per transaction func (v *vm) Execute(txns []core.Transaction, declaredClasses []core.Class, paidFeesOnL1 []*felt.Felt, blockInfo *BlockInfo, state core.StateReader, network *utils.Network, - skipChargeFee, skipValidate, errOnRevert bool, + skipChargeFee, skipValidate, errOnRevert, useBlobData bool, ) ([]*felt.Felt, []*felt.Felt, []TransactionTrace, error) { context := &callContext{ state: state, @@ -277,7 +281,7 @@ func (v *vm) Execute(txns []core.Transaction, declaredClasses []core.Class, paid errOnRevertByte = 1 } - cBlockInfo := makeCBlockInfo(blockInfo) + cBlockInfo := makeCBlockInfo(blockInfo, useBlobData) chainID := C.CString(network.L2ChainID) C.cairoVMExecute(txnsJSONCstr, classesJSONCStr, diff --git a/vm/vm_test.go b/vm/vm_test.go index 05ff1f3963..c9d5eaf512 100644 --- a/vm/vm_test.go +++ b/vm/vm_test.go @@ -53,7 +53,7 @@ func TestV0Call(t *testing.T) { ContractAddress: contractAddr, ClassHash: classHash, Selector: entryPoint, - }, &BlockInfo{Header: &core.Header{}}, testState, &utils.Mainnet, 1_000_000) + }, &BlockInfo{Header: &core.Header{}}, testState, &utils.Mainnet, 1_000_000, true) require.NoError(t, err) assert.Equal(t, []*felt.Felt{&felt.Zero}, ret) @@ -73,7 +73,7 @@ func TestV0Call(t *testing.T) { ContractAddress: contractAddr, ClassHash: classHash, Selector: entryPoint, - }, &BlockInfo{Header: &core.Header{Number: 1}}, testState, &utils.Mainnet, 1_000_000) + }, &BlockInfo{Header: &core.Header{Number: 1}}, testState, &utils.Mainnet, 1_000_000, true) require.NoError(t, err) assert.Equal(t, []*felt.Felt{new(felt.Felt).SetUint64(1337)}, ret) } @@ -121,7 +121,7 @@ func TestV1Call(t *testing.T) { Calldata: []felt.Felt{ *storageLocation, }, - }, &BlockInfo{Header: &core.Header{}}, testState, &utils.Goerli, 1_000_000) + }, &BlockInfo{Header: &core.Header{}}, testState, &utils.Goerli, 1_000_000, true) require.NoError(t, err) assert.Equal(t, []*felt.Felt{&felt.Zero}, ret) @@ -143,7 +143,7 @@ func TestV1Call(t *testing.T) { Calldata: []felt.Felt{ *storageLocation, }, - }, &BlockInfo{Header: &core.Header{Number: 1}}, testState, &utils.Goerli, 1_000_000) + }, &BlockInfo{Header: &core.Header{Number: 1}}, testState, &utils.Goerli, 1_000_000, true) require.NoError(t, err) assert.Equal(t, []*felt.Felt{new(felt.Felt).SetUint64(37)}, ret) } @@ -169,7 +169,7 @@ func TestExecute(t *testing.T) { GasPriceSTRK: &felt.Zero, }, }, state, - &network, false, false, false) + &network, false, false, false, false) require.NoError(t, err) }) t.Run("zero data", func(t *testing.T) { @@ -179,7 +179,7 @@ func TestExecute(t *testing.T) { GasPrice: &felt.Zero, GasPriceSTRK: &felt.Zero, }, - }, state, &network, false, false, false) + }, state, &network, false, false, false, false) require.NoError(t, err) }) }