Skip to content

Commit

Permalink
add chain id to public values
Browse files Browse the repository at this point in the history
  • Loading branch information
zobront committed Jun 28, 2024
1 parent 1d4b1bf commit edc066b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/contracts-bedrock/src/dispute/OptimisticZKGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,16 @@ contract OptimisticZKGame is IOptimisticZKGame, Clone, SP1Verifier {
// 3) The real L2 block number being proven matches the passed L2 block number.
if (challenge.right.outputRoot.l2BlockNumber != _publicValues.l2BlockNumber) revert InvalidPublicInput();

// 4) The real chain ID matches the passed chain ID.
if (block.chainId != _publicValues.chainId) revert InvalidPublicInput();

if (challenge.right.status == IntermediateClaimStatus.CHALLENGED) {
// 4a) If the right root has been challenged by the proposer, the challenger must prove that we CAN transition from left to right.
// 5a) If the right root has been challenged by the proposer, the challenger must prove that we CAN transition from left to right.
// Therefore, prove that the real right root matches the passed l2PostRoot.
if (challenge.right.outputRoot.root.raw() != _publicValues.l2PostRoot) revert InvalidPublicInput();
verifyProof(VKEY, abi.encode(_publicValues), _proofBytes);
} else {
// 4b) If the right root is ACCEPTED, it means nothing has been challenged.
// 5b) If the right root is ACCEPTED, it means nothing has been challenged.
// The proposer is claiming that left (proposed block minus 1) DOES transition to right (proposed block).
// Therefore, the challenger must prove a block with an l2PostRoot that does NOT match the right root in the game.
if (challenge.right.outputRoot.root.raw() == _publicValues.l2PostRoot) revert InvalidPublicInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface IOptimisticZKGame is IBlockDisputeGame {
bytes32 l2PreRoot;
bytes32 l2PostRoot;
uint256 l2BlockNumber;
uint256 chainId;
}

error Unauthorized();
Expand Down

0 comments on commit edc066b

Please sign in to comment.