Skip to content

Commit

Permalink
fix(protocol): fix a new bug in LibProposing (#18328)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Oct 28, 2024
1 parent 4288fb6 commit 7436bae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
13 changes: 6 additions & 7 deletions packages/protocol/contracts/layer1/based/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,14 @@ library LibProposing {
local.params.coinbase = local.params.proposer;
}

if (local.params.anchorBlockId == 0) {
unchecked {
local.params.anchorBlockId =
local.postFork ? uint64(block.number - 1) : uint64(block.number);
unchecked {
if (local.params.anchorBlockId == 0) {
local.params.anchorBlockId = uint64(block.number - 1);
}
}

if (local.params.timestamp == 0) {
local.params.timestamp = uint64(block.timestamp);
if (local.params.timestamp == 0) {
local.params.timestamp = uint64(block.timestamp);
}
}

// Verify params against the parent block.
Expand Down
2 changes: 0 additions & 2 deletions packages/protocol/contracts/layer1/based/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,12 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
/// @param _blockId Index of the block.
/// @return blk_ The block.
function getBlock(uint64 _blockId) external view returns (TaikoData.Block memory blk_) {
require(_blockId < getConfig().ontakeForkHeight, L1_INVALID_PARAMS());
(TaikoData.BlockV2 memory blk,) = LibUtils.getBlock(state, getConfig(), _blockId);
blk_ = LibData.blockV2toV1(blk);
}

/// @inheritdoc ITaikoL1
function getBlockV2(uint64 _blockId) external view returns (TaikoData.BlockV2 memory blk_) {
require(_blockId >= getConfig().ontakeForkHeight, L1_INVALID_PARAMS());
(blk_,) = LibUtils.getBlock(state, getConfig(), _blockId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract TaikoL1TestGroupA1 is TaikoL1TestGroupBase {
assertTrue(blk.livenessBond > 0);
assertEq(blk.assignedProver, address(0));
assertEq(blk.proposedAt, block.timestamp);
assertEq(blk.proposedIn, block.number);
assertEq(blk.proposedIn, block.number - 1);

// Prove the block
bytes32 blockHash = bytes32(uint256(10_000 + i));
Expand Down

0 comments on commit 7436bae

Please sign in to comment.