Skip to content

Commit

Permalink
fix(protocol): disallow duplicate hooks (#15492)
Browse files Browse the repository at this point in the history
Co-authored-by: adaki2004 <keszeydani@gmail.com>
Co-authored-by: David <david@taiko.xyz>
Co-authored-by: D <51912515+adaki2004@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 13, 2024
1 parent a394abd commit 5bf916d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/protocol/contracts/L1/TaikoErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ abstract contract TaikoErrors {
error L1_INVALID_BLOCK_ID();
error L1_INVALID_CONFIG();
error L1_INVALID_ETH_DEPOSIT();
error L1_INVALID_HOOK();
error L1_INVALID_PARAM();
error L1_INVALID_PAUSE_STATUS();
error L1_INVALID_PROOF();
Expand Down
8 changes: 8 additions & 0 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ library LibProposing {
error L1_BLOB_FOR_DA_DISABLED();
error L1_BLOB_NOT_FOUND();
error L1_BLOB_NOT_REUSEABLE();
error L1_INVALID_HOOK();
error L1_INVALID_PARAM();
error L1_INVALID_PROVER();
error L1_LIVENESS_BOND_NOT_RECEIVED();
Expand Down Expand Up @@ -246,14 +247,21 @@ library LibProposing {
// Run all hooks.
// Note that address(this).balance has been updated with msg.value,
// prior to any code in this function has been executed.
address prevHook;
for (uint256 i; i < params.hookCalls.length; ++i) {
if (uint160(prevHook) >= uint160(params.hookCalls[i].hook)) {
revert L1_INVALID_HOOK();
}

// When a hook is called, all ether in this contract will be send to the hook.
// If the ether sent to the hook is not used entirely, the hook shall send the Ether
// back to this contract for the next hook to use.
// Proposers shall choose use extra hooks wisely.
IHook(params.hookCalls[i].hook).onBlockProposed{ value: address(this).balance }(
blk, meta, params.hookCalls[i].data
);

prevHook = params.hookCalls[i].hook;
}
// Refund Ether
if (address(this).balance != 0) {
Expand Down

2 comments on commit 5bf916d

@vercel
Copy link

@vercel vercel bot commented on 5bf916d Jan 13, 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.vercel.app
bridge-ui-v2-a6-taikoxyz.vercel.app
bridge-ui-v2-a6-git-alpha-6-taikoxyz.vercel.app
bridge.katla.taiko.xyz

@vercel
Copy link

@vercel vercel bot commented on 5bf916d Jan 13, 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-taikoxyz.vercel.app
bridge-ui-v2-internal.vercel.app
bridge-ui-v2-internal-git-alpha-6-taikoxyz.vercel.app

Please sign in to comment.