From a2db03b9e953264d8674176184a8aff09cbe590c Mon Sep 17 00:00:00 2001 From: terencechain Date: Fri, 20 May 2022 13:08:00 -0700 Subject: [PATCH] Update engine API err codes (#10730) Co-authored-by: Raul Jordan --- beacon-chain/powchain/engine_client.go | 6 +++++- beacon-chain/powchain/engine_client_test.go | 12 +++++++++++- beacon-chain/powchain/errors.go | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index 2670d5403..2913a150f 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -320,8 +320,12 @@ func handleRPCError(err error) error { return ErrInvalidParams case -32603: return ErrInternal - case -32001: + case -38001: return ErrUnknownPayload + case -38002: + return ErrInvalidForkchoiceState + case -38003: + return ErrInvalidPayloadAttributes case -32000: // Only -32000 status codes are data errors in the RPC specification. errWithData, ok := err.(rpc.DataError) diff --git a/beacon-chain/powchain/engine_client_test.go b/beacon-chain/powchain/engine_client_test.go index 61958c5ad..af57fbdd4 100644 --- a/beacon-chain/powchain/engine_client_test.go +++ b/beacon-chain/powchain/engine_client_test.go @@ -688,7 +688,17 @@ func Test_handleRPCError(t *testing.T) { { name: "ErrUnknownPayload", expectedContains: ErrUnknownPayload.Error(), - given: &customError{code: -32001}, + given: &customError{code: -38001}, + }, + { + name: "ErrInvalidForkchoiceState", + expectedContains: ErrInvalidForkchoiceState.Error(), + given: &customError{code: -38002}, + }, + { + name: "ErrInvalidPayloadAttributes", + expectedContains: ErrInvalidPayloadAttributes.Error(), + given: &customError{code: -38003}, }, { name: "ErrServer unexpected no data", diff --git a/beacon-chain/powchain/errors.go b/beacon-chain/powchain/errors.go index a83551500..6899089dd 100644 --- a/beacon-chain/powchain/errors.go +++ b/beacon-chain/powchain/errors.go @@ -15,8 +15,12 @@ var ( ErrInternal = errors.New("internal JSON-RPC error") // ErrServer corresponds to JSON-RPC code -32000. ErrServer = errors.New("client error while processing request") - // ErrUnknownPayload corresponds to JSON-RPC code -32001. + // ErrUnknownPayload corresponds to JSON-RPC code -38001. ErrUnknownPayload = errors.New("payload does not exist or is not available") + // ErrInvalidForkchoiceState corresponds to JSON-RPC code -38002. + ErrInvalidForkchoiceState = errors.New("invalid forkchoice state") + // ErrInvalidPayloadAttributes corresponds to JSON-RPC code -38003. + ErrInvalidPayloadAttributes = errors.New("payload attributes are invalid / inconsistent") // ErrUnknownPayloadStatus when the payload status is unknown. ErrUnknownPayloadStatus = errors.New("unknown payload status") // ErrConfigMismatch when the execution node's terminal total difficulty or