Skip to content

Commit

Permalink
fix(protocol): change transition ID from uint16 to uint32 (#14620)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Aug 31, 2023
1 parent 456c6db commit c8969b6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ library TaikoData {
struct Block {
bytes32 metaHash; // slot 1
address prover; // slot 2
uint64 proposedAt;
uint16 nextTransitionId;
uint16 verifiedTransitionId;
uint64 blockId; // slot 3
uint96 proofBond;
uint64 blockId; // slot 3
uint64 proposedAt;
uint32 nextTransitionId;
uint32 verifiedTransitionId;
uint16 proofWindow;
}

Expand Down Expand Up @@ -187,9 +187,9 @@ library TaikoData {
// Ring buffer for proposed blocks and a some recent verified blocks.
mapping(uint64 blockId_mode_blockRingBufferSize => Block) blocks;
mapping(
uint64 blockId => mapping(bytes32 parentHash => uint16 transitionId)
uint64 blockId => mapping(bytes32 parentHash => uint32 transitionId)
) transitionIds;
mapping(uint64 blockId => mapping(uint16 transitionId => Transition))
mapping(uint64 blockId => mapping(uint32 transitionId => Transition))
transitions;
mapping(bytes32 txListHash => TxListInfo) txListInfo;
mapping(uint256 depositId_mode_ethDepositRingBufferSize => uint256)
Expand Down
5 changes: 3 additions & 2 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ library LibProposing {
// Init the block
TaikoData.Block storage blk =
state.blocks[b.numBlocks % config.blockRingBufferSize];

blk.metaHash = LibUtils.hashMetadata(meta);
blk.prover = assignment.prover;
blk.proofBond = config.proofBond;
blk.blockId = meta.id;
blk.proposedAt = meta.timestamp;
blk.nextTransitionId = 1;
blk.verifiedTransitionId = 0;
blk.blockId = meta.id;
blk.proofBond = config.proofBond;
blk.proofWindow = config.proofWindow;

emit BlockProposed({
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ library LibProving {
}

TaikoData.Transition storage tz;
uint16 tid =
uint32 tid =
LibUtils.getTransitionId(state, blk, blockId, evidence.parentHash);

if (tid == 0) {
Expand Down Expand Up @@ -152,7 +152,7 @@ library LibProving {
state.blocks[blockId % config.blockRingBufferSize];
if (blk.blockId != blockId) revert L1_BLOCK_ID_MISMATCH();

uint16 tid = LibUtils.getTransitionId(state, blk, blockId, parentHash);
uint32 tid = LibUtils.getTransitionId(state, blk, blockId, parentHash);
if (tid == 0) revert L1_TRANSITION_NOT_FOUND();

tz = state.transitions[blockId][tid];
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ library LibUtils {
)
internal
view
returns (uint16 tid)
returns (uint32 tid)
{
if (state.transitions[blk.blockId][1].key == parentHash) {
tid = 1;
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibVerifying.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ library LibVerifying {
state.blocks[blockId % config.blockRingBufferSize];
if (blk.blockId != blockId) revert L1_BLOCK_ID_MISMATCH();

uint16 tid = blk.verifiedTransitionId;
uint32 tid = blk.verifiedTransitionId;
if (tid == 0) revert L1_UNEXPECTED_TRANSITION_ID();

bytes32 blockHash = state.transitions[blockId][tid].blockHash;
Expand Down

0 comments on commit c8969b6

Please sign in to comment.