From 234d29dd66d9aeddfe5861c26f6dd3bbfcc22dfc Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 14 Feb 2023 16:33:51 -0800 Subject: [PATCH 1/3] Update head before block proposal --- beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go index b316aa014f02..e0a13039a343 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go @@ -58,6 +58,9 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) ( if err != nil { return nil, status.Errorf(codes.Internal, "Could not prepare block: %v", err) } + if err := vs.HeadUpdater.UpdateHead(ctx); err != nil { + log.WithError(err).Error("Could not process attestations and update head") + } parentRoot, err := vs.HeadFetcher.HeadRoot(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head root: %v", err) From 1aec16fd4bec7cc4b30b5523dd3a3cd1bfe7fb8b Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 15 Feb 2023 06:31:44 -0800 Subject: [PATCH 2/3] Move before opt sync --- beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go index e0a13039a343..74ce465bf9fa 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go @@ -47,6 +47,10 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) ( return nil, status.Error(codes.Unavailable, "Syncing to latest head, not ready to respond") } + if err := vs.HeadUpdater.UpdateHead(ctx); err != nil { + log.WithError(err).Error("Could not process attestations and update head") + } + // An optimistic validator MUST NOT produce a block (i.e., sign across the DOMAIN_BEACON_PROPOSER domain). if slots.ToEpoch(req.Slot) >= params.BeaconConfig().BellatrixForkEpoch { if err := vs.optimisticStatus(ctx); err != nil { @@ -58,9 +62,6 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) ( if err != nil { return nil, status.Errorf(codes.Internal, "Could not prepare block: %v", err) } - if err := vs.HeadUpdater.UpdateHead(ctx); err != nil { - log.WithError(err).Error("Could not process attestations and update head") - } parentRoot, err := vs.HeadFetcher.HeadRoot(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head root: %v", err) From eb555329052d23685d491aa828944789ec037a3f Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 15 Feb 2023 07:17:07 -0800 Subject: [PATCH 3/3] Fix test --- beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go index cccea7c51285..6d896785e7e8 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go @@ -442,6 +442,7 @@ func TestServer_GetBeaconBlock_Optimistic(t *testing.T) { proposerServer := &Server{ OptimisticModeFetcher: &mock.ChainService{Optimistic: true}, SyncChecker: &mockSync.Sync{}, + HeadUpdater: &mock.ChainService{}, TimeFetcher: &mock.ChainService{}} req := ðpb.BlockRequest{ Slot: bellatrixSlot + 1,