Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/builder/payload_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,24 @@ func (b *PayloadBuilder) BuildPayloadFromAttributes(
// Pre-Gloas: use validator registrations (fee_recipient from the proposer's registerValidator message).
// Fallback: use the builder's configured fee recipient.
proposerFeeRecipient := b.feeRecipient
var targetGasLimit uint64

if b.isGloas != nil && b.isGloas() {
// Gloas: prefer proposer preferences from cache, fall back to payload_attributes suggested fee recipient.
if b.propPrefCache != nil {
if prefs, ok := b.propPrefCache.Get(attrs.ProposalSlot); ok && prefs.Message != nil {
proposerFeeRecipient = common.Address(prefs.Message.FeeRecipient)
targetGasLimit = prefs.Message.GasLimit
b.log.WithFields(logrus.Fields{
"proposer_index": attrs.ProposerIndex,
"fee_recipient": proposerFeeRecipient.Hex(),
"gas_limit": prefs.Message.GasLimit,
}).Debug("Using fee recipient and gas limit from proposer preferences")
}
}
if targetGasLimit == 0 {
targetGasLimit = attrs.TargetGasLimit
}

// If we still have the default fee recipient, use SuggestedFeeRecipient from payload_attributes.
// This ensures bids match the proposer's expected fee recipient even when preferences
Expand Down Expand Up @@ -196,6 +201,7 @@ func (b *PayloadBuilder) BuildPayloadFromAttributes(
Withdrawals: engineWithdrawals,
ParentBeaconBlockRoot: &parentBeaconRoot,
SlotNumber: uint64(attrs.ProposalSlot),
TargetGasLimit: targetGasLimit,
},
)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/rpc/beacon/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type PayloadAttributesEvent struct {
SuggestedFeeRecipient common.Address
Withdrawals []*capella.Withdrawal
ParentBeaconBlockRoot phase0.Root
TargetGasLimit uint64
}

// payloadAttributesEventJSON is used for JSON unmarshaling of payload_attributes events.
Expand All @@ -105,6 +106,7 @@ type payloadAttributesEventJSON struct {
Amount string `json:"amount"`
} `json:"withdrawals"`
ParentBeaconBlockRoot string `json:"parent_beacon_block_root"`
TargetGasLimit string `json:"target_gas_limit"`
} `json:"payload_attributes"`
} `json:"data"`
}
Expand Down Expand Up @@ -747,6 +749,8 @@ func parsePayloadAttributesEvent(raw *payloadAttributesEventJSON) (*PayloadAttri
return nil, fmt.Errorf("invalid parent_beacon_block_root: %w", err)
}

targetGasLimit, _ := strconv.ParseUint(raw.Data.PayloadAttributes.TargetGasLimit, 10, 64)

// Parse withdrawals
withdrawals := make([]*capella.Withdrawal, len(raw.Data.PayloadAttributes.Withdrawals))
for i, w := range raw.Data.PayloadAttributes.Withdrawals {
Expand Down Expand Up @@ -780,6 +784,7 @@ func parsePayloadAttributesEvent(raw *payloadAttributesEventJSON) (*PayloadAttri
SuggestedFeeRecipient: common.HexToAddress(raw.Data.PayloadAttributes.SuggestedFeeRecipient),
Withdrawals: withdrawals,
ParentBeaconBlockRoot: parentBeaconBlockRoot,
TargetGasLimit: targetGasLimit,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/rpc/engine/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type PayloadAttributes struct {
Withdrawals []*types.Withdrawal
ParentBeaconBlockRoot *common.Hash
SlotNumber uint64 // Amsterdam (PayloadAttributesV4); zero before activation
TargetGasLimit uint64 // Amsterdam (PayloadAttributesV4); zero before activation
}

// ExecutionPayload represents an execution layer payload (typed, with JSON marshal/unmarshal for API).
Expand Down Expand Up @@ -462,6 +463,7 @@ func (c *Client) RequestPayloadBuild(
attrsV4 := make(map[string]any, len(attrsMap)+1)
maps.Copy(attrsV4, attrsMap)
attrsV4["slotNumber"] = fmt.Sprintf("0x%x", attrs.SlotNumber)
attrsV4["targetGasLimit"] = fmt.Sprintf("0x%x", attrs.TargetGasLimit)

c.log.WithFields(logrus.Fields{
"attrs_map": attrsV4,
Expand All @@ -475,6 +477,7 @@ func (c *Client) RequestPayloadBuild(
"withdrawals": len(attrs.Withdrawals),
"parent_beacon_block_root": attrs.ParentBeaconBlockRoot.Hex(),
"slot_number": attrs.SlotNumber,
"target_gas_limit": attrs.TargetGasLimit,
}).Info("Payload attributes being sent to forkchoiceUpdated")

var response ForkchoiceUpdatedResponse
Expand Down