From eeb1626a54422c35dda683f6e3deae28b2307df1 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Wed, 15 Jan 2025 10:15:09 +0800 Subject: [PATCH] encode proposer address in l2 header --- .../contracts/layer1/based/TaikoInbox.sol | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/protocol/contracts/layer1/based/TaikoInbox.sol b/packages/protocol/contracts/layer1/based/TaikoInbox.sol index cebb75d4fc..67ee1cd880 100644 --- a/packages/protocol/contracts/layer1/based/TaikoInbox.sol +++ b/packages/protocol/contracts/layer1/based/TaikoInbox.sol @@ -128,7 +128,9 @@ abstract contract TaikoInbox is EssentialContract, ITaikoInbox, ITaiko, IFork { txListHash: calldataUsed ? keccak256(_txList) : _calcTxListHash(params.firstBlobIndex, params.numBlobs), - extraData: bytes32(uint256(config.baseFeeConfig.sharingPctg)), + // Ensure L2 block header has the proposer adddress so that blocks in p2p network can be + // verified based on the proposer address. + extraData: _encodeExtraData(config.baseFeeConfig.sharingPctg, params.proposer), coinbase: params.coinbase, batchId: stats2.numBatches, gasLimit: config.blockMaxGasLimit, @@ -670,6 +672,17 @@ abstract contract TaikoInbox is EssentialContract, ITaikoInbox, ITaiko, IFork { require(_params.blocks.length <= _maxBlocksPerBatch, TooManyBlocks()); } + function _encodeExtraData( + uint8 _baseFeeSharingPctg, + address _proposer + ) + private + pure + returns (bytes32) + { + return bytes32(uint256(_baseFeeSharingPctg) << 160 | uint160(_proposer)); + } + // Memory-only structs ---------------------------------------------------------------------- struct SyncBlock {