cleanup with self review

This commit is contained in:
james-prysm
2026-02-09 11:08:18 -06:00
parent 513b699036
commit ec0c47396c
2 changed files with 20 additions and 18 deletions

View File

@@ -45,11 +45,10 @@ func (vs *Server) setGloasExecutionData(
// Create execution payload bid from the local payload.
parentRoot := sBlk.Block().ParentRoot()
bid, err := vs.createSelfBuildExecutionPayloadBid(
local.ExecutionData,
local,
primitives.BuilderIndex(sBlk.Block().ProposerIndex()),
parentRoot[:],
sBlk.Block().Slot(),
local.BlobsBundler,
)
if err != nil {
return errors.Wrap(err, "could not create execution payload bid")
@@ -123,31 +122,31 @@ func (vs *Server) getPayloadAttestations(ctx context.Context, head state.BeaconS
}
// createSelfBuildExecutionPayloadBid creates an ExecutionPayloadBid for self-building,
// where the proposer acts as its own builder. Value and payment are zero, and the
// bid fields are derived directly from the local execution payload.
// where the proposer acts as its own builder. The value is the block value from the
// execution layer, and execution payment is zero since the proposer doesn't pay themselves.
func (vs *Server) createSelfBuildExecutionPayloadBid(
executionData interfaces.ExecutionData,
local *consensusblocks.GetPayloadResponse,
builderIndex primitives.BuilderIndex,
parentBlockRoot []byte,
slot primitives.Slot,
blobsBundler enginev1.BlobsBundler,
) (*ethpb.ExecutionPayloadBid, error) {
if executionData == nil || executionData.IsNil() {
ed := local.ExecutionData
if ed == nil || ed.IsNil() {
return nil, errors.New("execution data is nil")
}
return &ethpb.ExecutionPayloadBid{
ParentBlockHash: executionData.ParentHash(),
ParentBlockHash: ed.ParentHash(),
ParentBlockRoot: bytesutil.SafeCopyBytes(parentBlockRoot),
BlockHash: executionData.BlockHash(),
PrevRandao: executionData.PrevRandao(),
FeeRecipient: executionData.FeeRecipient(),
GasLimit: executionData.GasLimit(),
BlockHash: ed.BlockHash(),
PrevRandao: ed.PrevRandao(),
FeeRecipient: ed.FeeRecipient(),
GasLimit: ed.GasLimit(),
BuilderIndex: builderIndex,
Slot: slot,
Value: 0,
ExecutionPayment: 0,
BlobKzgCommitments: extractKzgCommitments(blobsBundler),
Value: primitives.WeiToGwei(local.Bid),
ExecutionPayment: 0, // Self-build: proposer doesn't pay themselves.
BlobKzgCommitments: extractKzgCommitments(local.BlobsBundler),
}, nil
}

View File

@@ -1,6 +1,7 @@
package validator
import (
"math/big"
"testing"
consensusblocks "github.com/OffchainLabs/prysm/v7/consensus-types/blocks"
@@ -40,9 +41,11 @@ func TestSetGloasExecutionData(t *testing.T) {
ed, err := consensusblocks.WrappedExecutionPayloadDeneb(payload)
require.NoError(t, err)
// 5 Gwei = 5,000,000,000 Wei
bidValue := big.NewInt(5_000_000_000)
local := &consensusblocks.GetPayloadResponse{
ExecutionData: ed,
Bid: primitives.ZeroWei(),
Bid: bidValue,
BlobsBundler: nil,
ExecutionRequests: &enginev1.ExecutionRequests{},
}
@@ -67,8 +70,8 @@ func TestSetGloasExecutionData(t *testing.T) {
require.Equal(t, slot, bid.Slot)
require.Equal(t, primitives.BuilderIndex(proposerIndex), bid.BuilderIndex)
require.DeepEqual(t, parentRoot[:], bid.ParentBlockRoot)
require.Equal(t, uint64(0), bid.Value)
require.Equal(t, uint64(0), bid.ExecutionPayment)
require.Equal(t, primitives.Gwei(5), bid.Value)
require.Equal(t, primitives.Gwei(0), bid.ExecutionPayment)
}
func TestSetGloasExecutionData_NilPayload(t *testing.T) {