mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Fall back to uncached getPaylod if first time outs (#11404)
* Fall back to uncached getPaylod if first time outs * Skip only deadline error. Unit test Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -68,11 +68,14 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx
|
||||
copy(pid[:], payloadId[:])
|
||||
payloadIDCacheHit.Inc()
|
||||
payload, err := vs.ExecutionEngineCaller.GetPayload(ctx, pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
switch {
|
||||
case err == nil:
|
||||
warnIfFeeRecipientDiffers(payload, feeRecipient)
|
||||
return payload, nil
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
default:
|
||||
return nil, errors.Wrap(err, "could not get cached payload from execution client")
|
||||
}
|
||||
warnIfFeeRecipientDiffers(payload, feeRecipient)
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
st, err := vs.HeadFetcher.HeadState(ctx)
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestServer_getExecutionPayload(t *testing.T) {
|
||||
validatorIndx: 1,
|
||||
},
|
||||
{
|
||||
name: "transition completed, happy case, payload ID cached)",
|
||||
name: "transition completed, happy case, (payload ID cached)",
|
||||
st: transitionSt,
|
||||
validatorIndx: 100,
|
||||
},
|
||||
@@ -134,6 +134,36 @@ func TestServer_getExecutionPayload(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_getExecutionPayloadContextTimeout(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
nonTransitionSt, _ := util.DeterministicGenesisStateBellatrix(t, 1)
|
||||
b1pb := util.NewBeaconBlock()
|
||||
b1r, err := b1pb.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
util.SaveBlock(t, context.Background(), beaconDB, b1pb)
|
||||
require.NoError(t, nonTransitionSt.SetFinalizedCheckpoint(ðpb.Checkpoint{
|
||||
Root: b1r[:],
|
||||
}))
|
||||
|
||||
require.NoError(t, beaconDB.SaveFeeRecipientsByValidatorIDs(context.Background(), []types.ValidatorIndex{0}, []common.Address{{}}))
|
||||
|
||||
cfg := params.BeaconConfig().Copy()
|
||||
cfg.TerminalBlockHash = common.Hash{'a'}
|
||||
cfg.TerminalBlockHashActivationEpoch = 1
|
||||
params.OverrideBeaconConfig(cfg)
|
||||
|
||||
vs := &Server{
|
||||
ExecutionEngineCaller: &powtesting.EngineClient{PayloadIDBytes: &pb.PayloadIDBytes{}, ErrGetPayload: context.DeadlineExceeded},
|
||||
HeadFetcher: &chainMock.ChainService{State: nonTransitionSt},
|
||||
BeaconDB: beaconDB,
|
||||
ProposerSlotIndexCache: cache.NewProposerPayloadIDsCache(),
|
||||
}
|
||||
vs.ProposerSlotIndexCache.SetProposerAndPayloadIDs(nonTransitionSt.Slot(), 100, [8]byte{100}, [32]byte{'a'})
|
||||
|
||||
_, err = vs.getExecutionPayload(context.Background(), nonTransitionSt.Slot(), 100, [32]byte{'a'})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestServer_getExecutionPayload_UnexpectedFeeRecipient(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
|
||||
Reference in New Issue
Block a user