diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 33d653b6028e..78ca6aaf7f7d 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -43,6 +43,7 @@ go_library( "//beacon-chain/cache:go_default_library", "//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/blocks:go_default_library", + "//beacon-chain/core/electra:go_default_library", "//beacon-chain/core/epoch/precompute:go_default_library", "//beacon-chain/core/feed:go_default_library", "//beacon-chain/core/feed/state:go_default_library", diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index 6a55bf2660c0..affa3a5045db 100644 --- a/beacon-chain/blockchain/receive_block.go +++ b/beacon-chain/blockchain/receive_block.go @@ -7,6 +7,7 @@ import ( "time" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/electra" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed" statefeed "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed/state" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" @@ -468,6 +469,9 @@ func (s *Service) validateStateTransition(ctx context.Context, preState state.Be stateTransitionStartTime := time.Now() postState, err := transition.ExecuteStateTransition(ctx, preState, signed) if err != nil { + if electra.IsExecutionRequestError(err) { + return nil, err + } return nil, invalidBlock{error: err} } stateTransitionProcessingTime.Observe(float64(time.Since(stateTransitionStartTime).Milliseconds())) diff --git a/beacon-chain/core/electra/BUILD.bazel b/beacon-chain/core/electra/BUILD.bazel index ee2a0addf949..4696fe2347ff 100644 --- a/beacon-chain/core/electra/BUILD.bazel +++ b/beacon-chain/core/electra/BUILD.bazel @@ -8,6 +8,7 @@ go_library( "consolidations.go", "deposits.go", "effective_balance_updates.go", + "error.go", "registry_updates.go", "transition.go", "transition_no_verify_sig.go", diff --git a/beacon-chain/core/electra/error.go b/beacon-chain/core/electra/error.go new file mode 100644 index 000000000000..522b75696a59 --- /dev/null +++ b/beacon-chain/core/electra/error.go @@ -0,0 +1,16 @@ +package electra + +import "github.com/pkg/errors" + +type execReqErr struct { + error +} + +// IsExecutionRequestError returns true if the error has `execReqErr`. +func IsExecutionRequestError(e error) bool { + if e == nil { + return false + } + var d execReqErr + return errors.As(e, &d) +} diff --git a/beacon-chain/core/electra/transition_no_verify_sig.go b/beacon-chain/core/electra/transition_no_verify_sig.go index e9f8f99f9f6d..018e519abc2a 100644 --- a/beacon-chain/core/electra/transition_no_verify_sig.go +++ b/beacon-chain/core/electra/transition_no_verify_sig.go @@ -2,7 +2,6 @@ package electra import ( "context" - "fmt" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/blocks" @@ -82,16 +81,31 @@ func ProcessOperations( if err != nil { return nil, errors.Wrap(err, "could not get execution requests") } + for _, d := range requests.Deposits { + if d == nil { + return nil, errors.New("nil deposit request") + } + } st, err = ProcessDepositRequests(ctx, st, requests.Deposits) if err != nil { - return nil, errors.Wrap(err, "could not process deposit requests") + return nil, execReqErr{errors.Wrap(err, "could not process deposit requests")} + } + for _, w := range requests.Withdrawals { + if w == nil { + return nil, errors.New("nil withdrawal request") + } } st, err = ProcessWithdrawalRequests(ctx, st, requests.Withdrawals) if err != nil { - return nil, errors.Wrap(err, "could not process withdrawal requests") + return nil, execReqErr{errors.Wrap(err, "could not process withdrawal requests")} + } + for _, c := range requests.Consolidations { + if c == nil { + return nil, errors.New("nil consolidation request") + } } if err := ProcessConsolidationRequests(ctx, st, requests.Consolidations); err != nil { - return nil, fmt.Errorf("could not process consolidation requests: %w", err) + return nil, execReqErr{errors.Wrap(err, "could not process consolidation requests")} } return st, nil } diff --git a/beacon-chain/core/electra/withdrawals.go b/beacon-chain/core/electra/withdrawals.go index 62156188ccd8..29bb67987011 100644 --- a/beacon-chain/core/electra/withdrawals.go +++ b/beacon-chain/core/electra/withdrawals.go @@ -92,9 +92,6 @@ func ProcessWithdrawalRequests(ctx context.Context, st state.BeaconState, wrs [] defer span.End() currentEpoch := slots.ToEpoch(st.Slot()) for _, wr := range wrs { - if wr == nil { - return nil, errors.New("nil execution layer withdrawal request") - } amount := wr.Amount isFullExitRequest := amount == params.BeaconConfig().FullExitRequestAmount // If partial withdrawal queue is full, only full exits are processed diff --git a/changelog/tt_fix_electra_core_processing.md b/changelog/tt_fix_electra_core_processing.md new file mode 100644 index 000000000000..cbb9dd721489 --- /dev/null +++ b/changelog/tt_fix_electra_core_processing.md @@ -0,0 +1,3 @@ +### Changed + +- Update electra core processing to not mark block bad if execution request error. \ No newline at end of file