From 93daca47e11c31192aaa7f6db93d399a215164ad Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Fri, 17 Feb 2023 03:32:54 +0800 Subject: [PATCH] fix(protocol): use prevrandao for L2 mixHash (#13157) Co-authored-by: Jeffery Walsh Co-authored-by: David Co-authored-by: jeff <113397187+cyberhorsey@users.noreply.github.com> --- packages/protocol/contracts/L1/libs/LibProposing.sol | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/protocol/contracts/L1/libs/LibProposing.sol b/packages/protocol/contracts/L1/libs/LibProposing.sol index 3ce587aff3c..389762c1263 100644 --- a/packages/protocol/contracts/L1/libs/LibProposing.sol +++ b/packages/protocol/contracts/L1/libs/LibProposing.sol @@ -109,9 +109,13 @@ library LibProposing { meta.l1Hash = blockhash(block.number - 1); meta.timestamp = uint64(block.timestamp); - // if multiple L2 blocks included in the same L1 block, - // their block.mixHash fields for randomness will be the same. - meta.mixHash = bytes32(block.difficulty); + // After The Merge, L1 mixHash contains the prevrandao + // from the beacon chain. Since multiple Taiko blocks + // can be proposed in one Ethereum block, we need to + // add salt to this random number as L2 mixHash + meta.mixHash = keccak256( + abi.encodePacked(block.prevrandao, state.nextBlockId) + ); } uint256 deposit;