Skip to content

Commit

Permalink
feat(protocol): Add parent's metaHash to assignment (#15498)
Browse files Browse the repository at this point in the history
Co-authored-by: David <david@taiko.xyz>
  • Loading branch information
adaki2004 and davidtaikocha authored Jan 18, 2024
1 parent 99dd1d2 commit 267e9a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/protocol/contracts/L1/hooks/AssignmentHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ contract AssignmentHook is EssentialContract, IHook {
uint64 maxBlockId;
uint64 maxProposedIn;
bytes32 metaHash;
bytes32 parentMetaHash;
TaikoData.TierFee[] tierFees;
bytes signature;
}
Expand Down Expand Up @@ -82,6 +83,7 @@ contract AssignmentHook is EssentialContract, IHook {
if (
block.timestamp > assignment.expiry
|| assignment.metaHash != 0 && blk.metaHash != assignment.metaHash
|| assignment.parentMetaHash != 0 && meta.parentMetaHash != assignment.parentMetaHash
|| assignment.maxBlockId != 0 && meta.id > assignment.maxBlockId
|| assignment.maxProposedIn != 0 && block.number > assignment.maxProposedIn
) {
Expand Down Expand Up @@ -161,6 +163,7 @@ contract AssignmentHook is EssentialContract, IHook {
taikoL1Address,
address(this),
assignment.metaHash,
assignment.parentMetaHash,
blobHash,
assignment.feeToken,
assignment.expiry,
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ library LibProposing {
revert L1_TOO_MANY_BLOCKS();
}

TaikoData.Block storage parent =
state.blocks[(b.numBlocks - 1) % config.blockRingBufferSize];
bytes32 parentMetaHash =
state.blocks[(b.numBlocks - 1) % config.blockRingBufferSize].metaHash;

// Check if parent block has the right meta hash
if (params.parentMetaHash != 0 && parent.metaHash != params.parentMetaHash) {
if (params.parentMetaHash != 0 && parentMetaHash != params.parentMetaHash) {
revert L1_UNEXPECTED_PARENT();
}

Expand Down Expand Up @@ -124,7 +124,7 @@ library LibProposing {
txListByteSize: 0, // to be initialized below
minTier: 0, // to be initialized below
blobUsed: txList.length == 0,
parentMetaHash: parent.metaHash
parentMetaHash: parentMetaHash
});
}

Expand Down
1 change: 1 addition & 0 deletions packages/protocol/test/L1/TaikoL1TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ abstract contract TaikoL1TestBase is TaikoTest {
maxBlockId: 0,
maxProposedIn: 0,
metaHash: 0,
parentMetaHash: 0,
signature: new bytes(0)
});

Expand Down

2 comments on commit 267e9a0

@vercel
Copy link

@vercel vercel bot commented on 267e9a0 Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bridge-ui-v2-a6 – ./packages/bridge-ui-v2

bridge-ui-v2-a6-taikoxyz.vercel.app
bridge-ui-v2-a6-git-alpha-6-taikoxyz.vercel.app
bridge-ui-v2-a6.vercel.app
bridge.katla.taiko.xyz

@vercel
Copy link

@vercel vercel bot commented on 267e9a0 Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bridge-ui-v2-internal – ./packages/bridge-ui-v2

bridge-ui-v2-internal-git-alpha-6-taikoxyz.vercel.app
bridge-ui-v2-internal-taikoxyz.vercel.app
bridge-ui-v2-internal.vercel.app

Please sign in to comment.