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

fix(protocol): use block header's extraData for basefeeSharingPctg #17889

Merged
merged 1 commit into from
Aug 8, 2024
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
2 changes: 0 additions & 2 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ library TaikoData {

struct BlockParamsV2 {
address coinbase;
bytes32 extraData;
bytes32 parentMetaHash;
uint64 anchorBlockId; // NEW
uint64 timestamp; // NEW
Expand Down Expand Up @@ -125,7 +124,6 @@ library TaikoData {
uint32 blobTxListLength;
uint8 blobIndex;
uint8 basefeeAdjustmentQuotient;
uint8 basefeeSharingPctg;
uint32 gasIssuancePerSecond;
}

Expand Down
2 changes: 0 additions & 2 deletions packages/protocol/contracts/L1/libs/LibData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ library LibData {
{
return TaikoData.BlockParamsV2({
coinbase: _v1.coinbase,
extraData: _v1.extraData,
parentMetaHash: _v1.parentMetaHash,
anchorBlockId: 0,
timestamp: 0,
Expand Down Expand Up @@ -77,7 +76,6 @@ library LibData {
blobTxListLength: 0,
blobIndex: 0,
basefeeAdjustmentQuotient: 0,
basefeeSharingPctg: 0,
gasIssuancePerSecond: 0
});
}
Expand Down
17 changes: 14 additions & 3 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ library LibProposing {
ITierProvider tierProvider;
bytes32 parentMetaHash;
bool postFork;
bytes32 extraData;
}

/// @notice Emitted when a block is proposed.
Expand Down Expand Up @@ -96,7 +97,9 @@ library LibProposing {
// otherwise use a default BlockParamsV2 with 0 values
}
} else {
local.params = LibData.blockParamsV1ToV2(abi.decode(_data, (TaikoData.BlockParams)));
TaikoData.BlockParams memory paramsV1 = abi.decode(_data, (TaikoData.BlockParams));
local.params = LibData.blockParamsV1ToV2(paramsV1);
local.extraData = paramsV1.extraData;
}

if (local.params.coinbase == address(0)) {
Expand Down Expand Up @@ -158,7 +161,12 @@ library LibProposing {
anchorBlockHash: blockhash(local.params.anchorBlockId),
difficulty: keccak256(abi.encode("TAIKO_DIFFICULTY", local.b.numBlocks)),
blobHash: 0, // to be initialized below
extraData: local.params.extraData,
// To make sure each L2 block can be exexucated deterministiclly by the client
// without referering to its metadata on Ethereum, we need to encode
// config.basefeeSharingPctg into the extraData.
extraData: local.postFork
? _encodeGasConfigs(_config.basefeeSharingPctg)
: local.extraData,
coinbase: local.params.coinbase,
id: local.b.numBlocks,
gasLimit: _config.blockMaxGasLimit,
Expand All @@ -175,7 +183,6 @@ library LibProposing {
blobTxListLength: local.params.blobTxListLength,
blobIndex: local.params.blobIndex,
basefeeAdjustmentQuotient: _config.basefeeAdjustmentQuotient,
basefeeSharingPctg: _config.basefeeSharingPctg,
gasIssuancePerSecond: _config.gasIssuancePerSecond
});
}
Expand Down Expand Up @@ -262,4 +269,8 @@ library LibProposing {
revert L1_INVALID_PROPOSER();
}
}

function _encodeGasConfigs(uint8 _basefeeSharingPctg) private pure returns (bytes32) {
return bytes32(uint256(_basefeeSharingPctg));
}
}
5 changes: 0 additions & 5 deletions packages/protocol/test/L1/TaikoL1testGroupA2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ contract TaikoL1TestGroupA2 is TaikoL1TestGroupBase {
assertEq(meta.anchorBlockHash, blockhash(block.number - 1));
assertEq(meta.livenessBond, config.livenessBond);
assertEq(meta.coinbase, Alice);
assertEq(meta.extraData, params.extraData);

TaikoData.Block memory blk = L1.getBlock(i);
assertEq(blk.blockId, i);
Expand Down Expand Up @@ -104,7 +103,6 @@ contract TaikoL1TestGroupA2 is TaikoL1TestGroupBase {
// Propose the first block with default parameters
TaikoData.BlockParamsV2 memory params = TaikoData.BlockParamsV2({
coinbase: address(0),
extraData: 0,
parentMetaHash: 0,
anchorBlockId: 0,
timestamp: 0,
Expand All @@ -125,7 +123,6 @@ contract TaikoL1TestGroupA2 is TaikoL1TestGroupBase {
assertEq(meta.livenessBond, config.livenessBond);
assertEq(meta.coinbase, Alice);
assertEq(meta.parentMetaHash, bytes32(uint256(1)));
assertEq(meta.extraData, params.extraData);

TaikoData.Block memory blk = L1.getBlock(1);
assertEq(blk.blockId, 1);
Expand All @@ -145,7 +142,6 @@ contract TaikoL1TestGroupA2 is TaikoL1TestGroupBase {

params = TaikoData.BlockParamsV2({
coinbase: Bob,
extraData: bytes32(uint256(123)),
parentMetaHash: 0,
anchorBlockId: 90,
timestamp: uint64(block.timestamp - 100),
Expand All @@ -165,7 +161,6 @@ contract TaikoL1TestGroupA2 is TaikoL1TestGroupBase {
assertEq(meta.livenessBond, config.livenessBond);
assertEq(meta.coinbase, Bob);
assertEq(meta.parentMetaHash, blk.metaHash);
assertEq(meta.extraData, params.extraData);

blk = L1.getBlock(2);
assertEq(blk.blockId, 2);
Expand Down