Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: include parent beacon block root for proposal payload uniquness #2967

Merged
merged 1 commit into from
Aug 17, 2023
Merged
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
18 changes: 13 additions & 5 deletions packages/client/src/miner/pendingBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,27 @@ export class PendingBlock {
withdrawals?: WithdrawalData[]
) {
const number = parentBlock.header.number + BigInt(1)
const { timestamp, mixHash } = headerData
const { timestamp, mixHash, parentBeaconBlockRoot } = headerData
const { gasLimit } = parentBlock.header

// payload is uniquely defined by timestamp, parent and mixHash, gasLimit can also be
// potentially included in the fcU in future and can be safely added in uniqueness calc
const timestampBuf = bigIntToUnpaddedBytes(toType(timestamp ?? 0, TypeOutput.BigInt))
const gasLimitBuf = bigIntToUnpaddedBytes(gasLimit)
const mixHashBuf = toType(mixHash!, TypeOutput.Uint8Array) ?? zeros(32)
const parentBeaconBlockRootBuf =
toType(parentBeaconBlockRoot!, TypeOutput.Uint8Array) ?? zeros(32)

const payloadIdBytes = toBytes(
keccak256(concatBytes(parentBlock.hash(), mixHashBuf, timestampBuf, gasLimitBuf)).subarray(
0,
8
)
keccak256(
concatBytes(
parentBlock.hash(),
mixHashBuf,
timestampBuf,
gasLimitBuf,
parentBeaconBlockRootBuf
)
).subarray(0, 8)
)
const payloadId = bytesToHex(payloadIdBytes)

Expand Down
Loading