Skip to content

Commit adf229e

Browse files
fix(rpc): handle updated entry point not found error format (#2650)
After the blockifier update, the format of the `entry_point_not_found` error has changed to return only the error's code. This change affected the behavior of RPC v7. To address this, explicit error handling has been implemented to properly manage the new error format.
1 parent 1c29310 commit adf229e

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

rpc/rpccore/rpccore.go

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
ThrottledVMErr = "VM throughput limit reached"
1919
MaxBlocksBack = 1024
2020
EntrypointNotFoundFelt string = "0x454e545259504f494e545f4e4f545f464f554e44"
21+
ErrEPSNotFound = "Entry point EntryPointSelector(%s) not found in contract."
2122
)
2223

2324
//go:generate mockgen -destination=../mocks/mock_gateway_handler.go -package=mocks github.com/NethermindEth/juno/rpc Gateway

rpc/v6/trace.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"errors"
7+
"fmt"
78
"net/http"
89
"slices"
910

@@ -304,7 +305,10 @@ func (h *Handler) Call(funcCall *FunctionCall, id *BlockID) ([]*felt.Felt, *json
304305
var strErr string
305306
if len(res.Result) != 0 {
306307
if res.Result[0].String() == rpccore.EntrypointNotFoundFelt {
307-
strErr = rpccore.ErrEntrypointNotFound.Message
308+
strErr = fmt.Sprintf(
309+
rpccore.ErrEPSNotFound,
310+
funcCall.EntryPointSelector.String(),
311+
)
308312
} else {
309313
strErr = utils.FeltArrToString(res.Result)
310314
}

rpc/v6/trace_test.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"errors"
7+
"fmt"
78
"testing"
89

910
"github.com/NethermindEth/juno/blockchain"
@@ -1158,7 +1159,13 @@ func TestCall(t *testing.T) {
11581159
}
11591160
expectedErr := rpccore.ErrContractError
11601161
expectedErr.Data = rpc.ContractErrorData{
1161-
RevertError: json.RawMessage(`"` + rpccore.ErrEntrypointNotFound.Message + `"`),
1162+
RevertError: json.RawMessage(`"` +
1163+
fmt.Sprintf(
1164+
rpccore.ErrEPSNotFound,
1165+
selector.String(),
1166+
) +
1167+
`"`,
1168+
),
11621169
}
11631170

11641171
headsHeader := &core.Header{

rpc/v7/trace.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"errors"
7+
"fmt"
78
"net/http"
89
"slices"
910
"strconv"
@@ -357,7 +358,10 @@ func (h *Handler) Call(funcCall FunctionCall, id BlockID) ([]*felt.Felt, *jsonrp
357358
var strErr string
358359
if len(res.Result) != 0 {
359360
if res.Result[0].String() == rpccore.EntrypointNotFoundFelt {
360-
strErr = rpccore.ErrEntrypointNotFound.Message
361+
strErr = fmt.Sprintf(
362+
rpccore.ErrEPSNotFound,
363+
funcCall.EntryPointSelector.String(),
364+
)
361365
} else {
362366
strErr = utils.FeltArrToString(res.Result)
363367
}

rpc/v7/trace_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,13 @@ func TestCall(t *testing.T) {
15421542
}
15431543
expectedErr := rpccore.ErrContractError
15441544
expectedErr.Data = rpcv7.ContractErrorData{
1545-
RevertError: json.RawMessage(`"` + rpccore.ErrEntrypointNotFound.Message + `"`),
1545+
RevertError: json.RawMessage(`"` +
1546+
fmt.Sprintf(
1547+
rpccore.ErrEPSNotFound,
1548+
selector.String(),
1549+
) +
1550+
`"`,
1551+
),
15461552
}
15471553

15481554
headsHeader := &core.Header{

0 commit comments

Comments
 (0)