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): check l1BlockHash & l1SignalRoot in anchortx #15035

Merged
merged 7 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ contract TaikoL2 is EssentialContract, TaikoL2Signer, ICrossChainSync {

error L2_BASEFEE_MISMATCH();
error L2_INVALID_CHAIN_ID();
error L2_INVALID_PARAM();
error L2_INVALID_SENDER();
error L2_PUBLIC_INPUT_HASH_MISMATCH();
error L2_TOO_LATE();
Expand Down Expand Up @@ -89,6 +90,11 @@ contract TaikoL2 is EssentialContract, TaikoL2Signer, ICrossChainSync {
)
external
{
if (
l1BlockHash == 0 || l1SignalRoot == 0 || l1Height == 0
|| (block.number != 1 && parentGasUsed == 0)
) revert L2_INVALID_PARAM();

if (msg.sender != GOLDEN_TOUCH_ADDRESS) revert L2_INVALID_SENDER();

uint256 parentId;
Expand All @@ -114,11 +120,9 @@ contract TaikoL2 is EssentialContract, TaikoL2Signer, ICrossChainSync {

// Store the L1's signal root as a signal to the local signal service to
// allow for multi-hop bridging.
if (l1SignalRoot != 0) {
ISignalService(resolve("signal_service", false)).sendSignal(
l1SignalRoot
);
}
ISignalService(resolve("signal_service", false)).sendSignal(
l1SignalRoot
);
emit CrossChainSynced(l1Height, l1BlockHash, l1SignalRoot);

// Update state variables
Expand Down
5 changes: 4 additions & 1 deletion packages/protocol/genesis/GenerateGenesis.g.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ contract TestGenerateGenesis is Test, AddressResolver {
uint256 gasLeftBefore = gasleft();

taikoL2.anchor(
bytes32(block.prevrandao), bytes32(block.prevrandao), i, i
keccak256(abi.encodePacked(block.timestamp, i)),
keccak256(abi.encodePacked(block.timestamp, i)),
i + 1,
i + 1
);

if (i == 299) {
Expand Down