diff --git a/rpc/handlers.go b/rpc/handlers.go index d5c8710f7f..22fd247f42 100644 --- a/rpc/handlers.go +++ b/rpc/handlers.go @@ -72,6 +72,7 @@ const ( maxEventChunkSize = 10240 maxEventFilterKeys = 1024 traceCacheSize = 128 + throttledVMErr = "VM throughput limit reached" ) type traceCacheKey struct { @@ -1262,7 +1263,7 @@ func (h *Handler) Call(call FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Er call.Calldata, header.Number, header.Timestamp, state, h.bcReader.Network(), h.callMaxSteps) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { - return nil, ErrInternal.CloneWithData(err.Error()) + return nil, ErrInternal.CloneWithData(throttledVMErr) } return nil, makeContractError(err) } @@ -1507,7 +1508,7 @@ func (h *Handler) simulateTransactions(id BlockID, transactions []BroadcastedTra header.GasPriceSTRK, legacyTraceJSON) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { - return nil, ErrInternal.CloneWithData(err.Error()) + return nil, ErrInternal.CloneWithData(throttledVMErr) } var txnExecutionError vm.TransactionExecutionError if errors.As(err, &txnExecutionError) { @@ -1650,7 +1651,7 @@ func (h *Handler) traceBlockTransactions(ctx context.Context, block *core.Block, block.Header.GasPriceSTRK, legacyJSON) if err != nil { if errors.Is(err, utils.ErrResourceBusy) { - return nil, ErrInternal.CloneWithData(err.Error()) + return nil, ErrInternal.CloneWithData(throttledVMErr) } // Since we are tracing an existing block, we know that there should be no errors during execution. If we encounter any, // report them as unexpected errors diff --git a/rpc/handlers_test.go b/rpc/handlers_test.go index aee1399e44..df9eb9685d 100644 --- a/rpc/handlers_test.go +++ b/rpc/handlers_test.go @@ -3741,19 +3741,20 @@ func TestThrottledVMError(t *testing.T) { handler := rpc.New(mockReader, nil, throttledVM, "", nil) mockState := mocks.NewMockStateHistoryReader(mockCtrl) + throttledErr := "VM throughput limit reached" t.Run("call", func(t *testing.T) { mockReader.EXPECT().HeadState().Return(mockState, nopCloser, nil) mockReader.EXPECT().HeadsHeader().Return(new(core.Header), nil) mockState.EXPECT().ContractClassHash(&felt.Zero).Return(new(felt.Felt), nil) _, rpcErr := handler.Call(rpc.FunctionCall{}, rpc.BlockID{Latest: true}) - assert.Equal(t, utils.ErrResourceBusy.Error(), rpcErr.Data) + assert.Equal(t, throttledErr, rpcErr.Data) }) t.Run("simulate", func(t *testing.T) { mockReader.EXPECT().HeadState().Return(mockState, nopCloser, nil) mockReader.EXPECT().HeadsHeader().Return(&core.Header{}, nil) _, rpcErr := handler.SimulateTransactions(rpc.BlockID{Latest: true}, []rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipFeeChargeFlag}) - assert.Equal(t, utils.ErrResourceBusy.Error(), rpcErr.Data) + assert.Equal(t, throttledErr, rpcErr.Data) }) t.Run("trace", func(t *testing.T) { @@ -3788,7 +3789,7 @@ func TestThrottledVMError(t *testing.T) { headState.EXPECT().Class(declareTx.ClassHash).Return(declaredClass, nil) mockReader.EXPECT().PendingState().Return(headState, nopCloser, nil) _, rpcErr := handler.TraceBlockTransactions(context.Background(), rpc.BlockID{Hash: blockHash}) - assert.Equal(t, utils.ErrResourceBusy.Error(), rpcErr.Data) + assert.Equal(t, throttledErr, rpcErr.Data) }) }