returnnil,BlockInsertPrestateErr,fmt.Errorf("pre-block-creation forkchoice update was inconsistent with engine, need reset to resolve: %w",inputErr.Unwrap())
caseeth.InvalidPayloadAttributes:
returnnil,BlockInsertPayloadErr,fmt.Errorf("payload attributes are not valid, cannot build block: %w",inputErr.Unwrap())
default:
returnnil,BlockInsertPrestateErr,fmt.Errorf("unexpected error code in forkchoice-updated response: %w",err)
}
}else{
returnnil,BlockInsertTemporaryErr,fmt.Errorf("failed to create new block via forkchoice: %w",err)
returnnil,errors.New("nil id in forkchoice result when expecting a valid ID"),nil
returnnil,BlockInsertTemporaryErr,errors.New("nil id in forkchoice result when expecting a valid ID")
}
}
payload,err:=eng.GetPayload(ctx,*id)
payload,err:=eng.GetPayload(ctx,*id)
iferr!=nil{
iferr!=nil{
returnnil,fmt.Errorf("failed to get execution payload: %w",err),nil
// even if it is an input-error (unknown payload ID), it is temporary, since we will re-attempt the full payload building, not just the retrieval of the payload.
returnnil,BlockInsertTemporaryErr,fmt.Errorf("failed to get execution payload: %w",err)
}
}
iferr:=sanityCheckPayload(payload);err!=nil{
iferr:=sanityCheckPayload(payload);err!=nil{
returnnil,nil,err
returnnil,BlockInsertPayloadErr,err
}
}
status,err:=eng.NewPayload(ctx,payload)
status,err:=eng.NewPayload(ctx,payload)
iferr!=nil{
iferr!=nil{
returnnil,fmt.Errorf("failed to insert execution payload: %w",err),nil
returnnil,BlockInsertTemporaryErr,fmt.Errorf("failed to insert execution payload: %w",err)
@@ -110,14 +136,25 @@ func InsertHeadBlock(ctx context.Context, log log.Logger, eng Engine, fc eth.For
...
@@ -110,14 +136,25 @@ func InsertHeadBlock(ctx context.Context, log log.Logger, eng Engine, fc eth.For
}
}
fcRes,err=eng.ForkchoiceUpdate(ctx,&fc,nil)
fcRes,err=eng.ForkchoiceUpdate(ctx,&fc,nil)
iferr!=nil{
iferr!=nil{
returnnil,fmt.Errorf("failed to make the new L2 block canonical via forkchoice: %w",err),nil
varinputErreth.InputError
iferrors.As(err,&inputErr){
switchinputErr.Code{
caseeth.InvalidForkchoiceState:
// if we succeed to update the forkchoice pre-payload, but fail post-payload, then it is a payload error
returnnil,BlockInsertPayloadErr,fmt.Errorf("post-block-creation forkchoice update was inconsistent with engine, need reset to resolve: %w",inputErr.Unwrap())
default:
returnnil,BlockInsertPrestateErr,fmt.Errorf("unexpected error code in forkchoice-updated response: %w",err)
}
}else{
returnnil,BlockInsertTemporaryErr,fmt.Errorf("failed to make the new L2 block canonical via forkchoice: %w",err)