Compare commits

...

2 Commits

Author SHA1 Message Date
terence tsao
6e829d1edc Another way 2023-03-12 16:34:51 -07:00
terence tsao
7584aa87a3 Use correct head state in the event of reorg 2023-03-12 16:14:00 -07:00
2 changed files with 6 additions and 3 deletions

View File

@@ -122,7 +122,7 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (
vs.setSyncAggregate(ctx, sBlk)
// Set execution data. New in Bellatrix.
if err := vs.setExecutionData(ctx, sBlk, head); err != nil {
if err := vs.setExecutionData(ctx, sBlk); err != nil {
return nil, status.Errorf(codes.Internal, "Could not set execution data: %v", err)
}

View File

@@ -11,7 +11,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prysmaticlabs/prysm/v3/api/client/builder"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
"github.com/prysmaticlabs/prysm/v3/config/params"
consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
@@ -38,12 +37,16 @@ var builderGetPayloadMissCount = promauto.NewCounter(prometheus.CounterOpts{
const blockBuilderTimeout = 1 * time.Second
// Sets the execution data for the block. Execution data can come from local EL client or remote builder depends on validator registration and circuit breaker conditions.
func (vs *Server) setExecutionData(ctx context.Context, blk interfaces.SignedBeaconBlock, headState state.BeaconState) error {
func (vs *Server) setExecutionData(ctx context.Context, blk interfaces.SignedBeaconBlock) error {
idx := blk.Block().ProposerIndex()
slot := blk.Block().Slot()
if slots.ToEpoch(slot) < params.BeaconConfig().BellatrixForkEpoch {
return nil
}
headState, err := vs.StateGen.StateByRoot(ctx, blk.Block().ParentRoot())
if err != nil {
return errors.Wrap(err, "could not get head state")
}
canUseBuilder, err := vs.canUseBuilder(ctx, slot, idx)
if err != nil {