From 0f3b716b7e7d31a18a210594a939d49180e5b17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20I=C3=B1aki=20Bilbao?= Date: Tue, 23 Sep 2025 10:34:53 -0300 Subject: [PATCH 1/3] Add VK upgrade functions --- crates/l2/contracts/src/l1/OnChainProposer.sol | 10 ++++++++++ crates/l2/contracts/src/l1/based/OnChainProposer.sol | 10 ++++++++++ .../src/l1/based/interfaces/IOnChainProposer.sol | 9 +++++++++ .../contracts/src/l1/interfaces/IOnChainProposer.sol | 9 +++++++++ 4 files changed, 38 insertions(+) diff --git a/crates/l2/contracts/src/l1/OnChainProposer.sol b/crates/l2/contracts/src/l1/OnChainProposer.sol index 8a6f952f0b..4dfc57af63 100644 --- a/crates/l2/contracts/src/l1/OnChainProposer.sol +++ b/crates/l2/contracts/src/l1/OnChainProposer.sol @@ -179,6 +179,16 @@ contract OnChainProposer is BRIDGE = bridge; } + /// @inheritdoc IOnChainProposer + function upgradeSP1VerificationKey(bytes32 new_vk) public onlyOwner { + SP1_VERIFICATION_KEY = new_vk; + } + + /// @inheritdoc IOnChainProposer + function upgradeRISC0VerificationKey(bytes32 new_vk) public onlyOwner { + RISC0_VERIFICATION_KEY = new_vk; + } + /// @inheritdoc IOnChainProposer function commitBatch( uint256 batchNumber, diff --git a/crates/l2/contracts/src/l1/based/OnChainProposer.sol b/crates/l2/contracts/src/l1/based/OnChainProposer.sol index 98242be151..a0147d3fc7 100644 --- a/crates/l2/contracts/src/l1/based/OnChainProposer.sol +++ b/crates/l2/contracts/src/l1/based/OnChainProposer.sol @@ -227,6 +227,16 @@ contract OnChainProposer is BRIDGE = bridge; } + /// @inheritdoc IOnChainProposer + function upgradeSP1VerificationKey(bytes32 new_vk) public onlyOwner { + SP1_VERIFICATION_KEY = new_vk; + } + + /// @inheritdoc IOnChainProposer + function upgradeRISC0VerificationKey(bytes32 new_vk) public onlyOwner { + RISC0_VERIFICATION_KEY = new_vk; + } + /// @inheritdoc IOnChainProposer function commitBatch( uint256 batchNumber, diff --git a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol index ee99942dac..515c955014 100644 --- a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol @@ -30,6 +30,14 @@ interface IOnChainProposer { /// @param bridge the address of the bridge contract. function initializeBridgeAddress(address bridge) external; + /// @notice Upgrades the SP1 verification key that represents the sequencer's code. + /// @param new_vk new verification key for SP1 verifier + function upgradeSP1VerificationKey(bytes32 new_vk) public; + + /// @notice Upgrades the RISC0 verification key that represents the sequencer's code. + /// @param new_vk new verification key for RISC0 verifier + function upgradeRISC0VerificationKey(bytes32 new_vk) public; + /// @notice Commits to a batch of L2 blocks. /// @dev Committing to an L2 batch means to store the batch's commitment /// and to publish withdrawals if any. @@ -75,6 +83,7 @@ interface IOnChainProposer { bytes calldata tdxPublicValues, bytes memory tdxSignature ) external; + // TODO: imageid, programvkey and riscvvkey should be constants // TODO: organize each zkvm proof arguments in their own structs diff --git a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol index 149e2ad004..7496505fac 100644 --- a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol @@ -34,6 +34,14 @@ interface IOnChainProposer { /// @param bridge the address of the bridge contract. function initializeBridgeAddress(address bridge) external; + /// @notice Upgrades the SP1 verification key that represents the sequencer's code. + /// @param new_vk new verification key for SP1 verifier + function upgradeSP1VerificationKey(bytes32 new_vk) public; + + /// @notice Upgrades the RISC0 verification key that represents the sequencer's code. + /// @param new_vk new verification key for RISC0 verifier + function upgradeRISC0VerificationKey(bytes32 new_vk) public; + /// @notice Commits to a batch of L2 blocks. /// @dev Committing to an L2 batch means to store the batch's commitment /// and to publish withdrawals if any. @@ -77,6 +85,7 @@ interface IOnChainProposer { bytes calldata tdxPublicValues, bytes memory tdxSignature ) external; + // TODO: imageid, programvkey and riscvvkey should be constants // TODO: organize each zkvm proof arguments in their own structs From c356f0ad30013ea57303ea014a053858feca69c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20I=C3=B1aki=20Bilbao?= Date: Tue, 23 Sep 2025 11:26:08 -0300 Subject: [PATCH 2/3] Use external instead of public --- .../l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol | 4 ++-- crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol index 515c955014..0969a720da 100644 --- a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol @@ -32,11 +32,11 @@ interface IOnChainProposer { /// @notice Upgrades the SP1 verification key that represents the sequencer's code. /// @param new_vk new verification key for SP1 verifier - function upgradeSP1VerificationKey(bytes32 new_vk) public; + function upgradeSP1VerificationKey(bytes32 new_vk) external; /// @notice Upgrades the RISC0 verification key that represents the sequencer's code. /// @param new_vk new verification key for RISC0 verifier - function upgradeRISC0VerificationKey(bytes32 new_vk) public; + function upgradeRISC0VerificationKey(bytes32 new_vk) external; /// @notice Commits to a batch of L2 blocks. /// @dev Committing to an L2 batch means to store the batch's commitment diff --git a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol index 7496505fac..91979ecc70 100644 --- a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol @@ -36,11 +36,11 @@ interface IOnChainProposer { /// @notice Upgrades the SP1 verification key that represents the sequencer's code. /// @param new_vk new verification key for SP1 verifier - function upgradeSP1VerificationKey(bytes32 new_vk) public; + function upgradeSP1VerificationKey(bytes32 new_vk) external; /// @notice Upgrades the RISC0 verification key that represents the sequencer's code. /// @param new_vk new verification key for RISC0 verifier - function upgradeRISC0VerificationKey(bytes32 new_vk) public; + function upgradeRISC0VerificationKey(bytes32 new_vk) external; /// @notice Commits to a batch of L2 blocks. /// @dev Committing to an L2 batch means to store the batch's commitment From 95d65801442734ec42f9e82c2874314d9b460328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20I=C3=B1aki=20Bilbao?= Date: Tue, 23 Sep 2025 11:58:18 -0300 Subject: [PATCH 3/3] Emit event on upgrade --- crates/l2/contracts/src/l1/OnChainProposer.sol | 2 ++ crates/l2/contracts/src/l1/based/OnChainProposer.sol | 2 ++ .../contracts/src/l1/based/interfaces/IOnChainProposer.sol | 6 ++++++ crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/crates/l2/contracts/src/l1/OnChainProposer.sol b/crates/l2/contracts/src/l1/OnChainProposer.sol index 4dfc57af63..4a2d8ef711 100644 --- a/crates/l2/contracts/src/l1/OnChainProposer.sol +++ b/crates/l2/contracts/src/l1/OnChainProposer.sol @@ -182,11 +182,13 @@ contract OnChainProposer is /// @inheritdoc IOnChainProposer function upgradeSP1VerificationKey(bytes32 new_vk) public onlyOwner { SP1_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("SP1", new_vk); } /// @inheritdoc IOnChainProposer function upgradeRISC0VerificationKey(bytes32 new_vk) public onlyOwner { RISC0_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("RISC0", new_vk); } /// @inheritdoc IOnChainProposer diff --git a/crates/l2/contracts/src/l1/based/OnChainProposer.sol b/crates/l2/contracts/src/l1/based/OnChainProposer.sol index a0147d3fc7..c2f9522e95 100644 --- a/crates/l2/contracts/src/l1/based/OnChainProposer.sol +++ b/crates/l2/contracts/src/l1/based/OnChainProposer.sol @@ -230,11 +230,13 @@ contract OnChainProposer is /// @inheritdoc IOnChainProposer function upgradeSP1VerificationKey(bytes32 new_vk) public onlyOwner { SP1_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("SP1", new_vk); } /// @inheritdoc IOnChainProposer function upgradeRISC0VerificationKey(bytes32 new_vk) public onlyOwner { RISC0_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("RISC0", new_vk); } /// @inheritdoc IOnChainProposer diff --git a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol index 0969a720da..07abc3bd9a 100644 --- a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol @@ -23,6 +23,12 @@ interface IOnChainProposer { /// @dev Event emitted when a batch is verified. event BatchVerified(uint256 indexed lastVerifiedBatch); + /// @notice A verification key has been upgraded. + /// @dev Event emitted when a verification key is upgraded. + /// @param verifier The name of the verifier whose key was upgraded. + /// @param newVerificationKey The new verification key. + event VerificationKeyUpgraded(string verifier, bytes32 newVerificationKey); + /// @notice Set the bridge address for the first time. /// @dev This method is separated from initialize because both the CommonBridge /// and the OnChainProposer need to know the address of the other. This solves diff --git a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol index 91979ecc70..be6696c86d 100644 --- a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol @@ -27,6 +27,12 @@ interface IOnChainProposer { /// @dev Event emitted when a batch is reverted. event BatchReverted(bytes32 indexed newStateRoot); + /// @notice A verification key has been upgraded. + /// @dev Event emitted when a verification key is upgraded. + /// @param verifier The name of the verifier whose key was upgraded. + /// @param newVerificationKey The new verification key. + event VerificationKeyUpgraded(string verifier, bytes32 newVerificationKey); + /// @notice Set the bridge address for the first time. /// @dev This method is separated from initialize because both the CommonBridge /// and the OnChainProposer need to know the address of the other. This solves