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): disallow duplicate hooks #15492

Merged
merged 14 commits into from
Jan 13, 2024
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();
davidtaikocha marked this conversation as resolved.
Show resolved Hide resolved
}

// 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
Loading