diff --git a/spartan/scripts/upgrade_rollup_with_cli.sh b/spartan/scripts/upgrade_rollup_with_cli.sh index 5255252b6a90..8518694b13d4 100755 --- a/spartan/scripts/upgrade_rollup_with_cli.sh +++ b/spartan/scripts/upgrade_rollup_with_cli.sh @@ -18,18 +18,12 @@ set -exu # ./upgrade_rollup_with_cli.sh \ # --aztec-docker-image aztecprotocol/aztec:c5e2b43044862882a68de47cac07b7116e74e51e \ # --registry 0x29f815e32efdef19883cf2b92a766b7aebadd326 \ -# --address 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 \ -# --deposit-amount 200000000000000000000000 \ -# --mint \ # --test-accounts \ # --sponsored-fpc # # where: # - aztec-docker-tag is the tag of the aztec docker image to use. # - registry is the address of the registry contract. -# - address is the address that corresponds to whatever mnemonic/private key you are using. -# - deposit-amount is optional, and if provided, will deposit the specified amount of governance tokens to the address. -# - mint is optional, and if provided, will mint the governance tokens to the address before depositing. # - test-accounts is optional, and if provided, will initialise the genesis state with funded test accounts. # - sponsored-fpc is optional, and if provided, will initialise the genesis state with a funded FPC. # @@ -41,15 +35,10 @@ set -exu # ./spartan/scripts/upgrade_rollup_with_cli.sh \ # --aztec-bin $AZTEC_BIN \ # --registry 0x29f815e32efdef19883cf2b92a766b7aebadd326 \ -# --address 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 \ -# --deposit-amount 10000000000000000 \ -# --mint # --test-accounts \ # --sponsored-fpc # First set from environment variables if they exist -DEPOSIT_AMOUNT="" -MINT="" SALT=$((RANDOM % 1000000)) # The default path to the aztec binary within the docker image AZTEC_BIN="/usr/src/yarn-project/aztec/dest/bin/index.js" @@ -68,10 +57,6 @@ while [[ $# -gt 0 ]]; do AZTEC_BIN="$2" shift 2 ;; - --deposit-amount) - DEPOSIT_AMOUNT="$2" - shift 2 - ;; --salt) SALT="$2" shift 2 @@ -80,14 +65,10 @@ while [[ $# -gt 0 ]]; do REGISTRY="$2" shift 2 ;; - --address) - MY_ADDR="$2" + --l1-chain-id) + L1_CHAIN_ID="$2" shift 2 ;; - --mint) - MINT="--mint" - shift 1 - ;; --test-accounts) TEST_ACCOUNTS="--test-accounts" shift 1 @@ -109,11 +90,6 @@ if [ -z "$REGISTRY" ]; then exit 1 fi -if [ -z "$MY_ADDR" ]; then - echo "Error: --address argument is required" - exit 1 -fi - # Only need this in the docker case cleanup() { # Add error handling and force removal diff --git a/yarn-project/aztec/src/cli/cmds/start_node.ts b/yarn-project/aztec/src/cli/cmds/start_node.ts index 154ac35f6f5d..cddcd53536de 100644 --- a/yarn-project/aztec/src/cli/cmds/start_node.ts +++ b/yarn-project/aztec/src/cli/cmds/start_node.ts @@ -86,6 +86,7 @@ export async function startNode( nodeConfig.l1Contracts.registryAddress, nodeConfig.l1RpcUrls, nodeConfig.l1ChainId, + nodeConfig.rollupVersion, ); // TODO(#12272): will clean this up. diff --git a/yarn-project/aztec/src/cli/cmds/start_prover_broker.ts b/yarn-project/aztec/src/cli/cmds/start_prover_broker.ts index f2064cbab4d7..dbc994f0d294 100644 --- a/yarn-project/aztec/src/cli/cmds/start_prover_broker.ts +++ b/yarn-project/aztec/src/cli/cmds/start_prover_broker.ts @@ -33,9 +33,15 @@ export async function startProverBroker( throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option'); } - const { addresses } = await getL1Config(config.l1Contracts.registryAddress, config.l1RpcUrls, config.l1ChainId); + const { addresses, config: rollupConfig } = await getL1Config( + config.l1Contracts.registryAddress, + config.l1RpcUrls, + config.l1ChainId, + config.rollupVersion, + ); config.l1Contracts = addresses; + config.rollupVersion = rollupConfig.rollupVersion; const client = initTelemetryClient(getTelemetryClientConfig()); const broker = await createAndStartProvingBroker(config, client); diff --git a/yarn-project/aztec/src/cli/cmds/start_prover_node.ts b/yarn-project/aztec/src/cli/cmds/start_prover_node.ts index 659ce4ab29c9..706af1913488 100644 --- a/yarn-project/aztec/src/cli/cmds/start_prover_node.ts +++ b/yarn-project/aztec/src/cli/cmds/start_prover_node.ts @@ -74,6 +74,7 @@ export async function startProverNode( proverConfig.l1Contracts.registryAddress, proverConfig.l1RpcUrls, proverConfig.l1ChainId, + proverConfig.rollupVersion, ); proverConfig.l1Contracts = addresses; proverConfig = { ...proverConfig, ...config }; diff --git a/yarn-project/aztec/src/cli/get_l1_config.ts b/yarn-project/aztec/src/cli/get_l1_config.ts index 80335d810c5b..282415172862 100644 --- a/yarn-project/aztec/src/cli/get_l1_config.ts +++ b/yarn-project/aztec/src/cli/get_l1_config.ts @@ -5,9 +5,10 @@ export async function getL1Config( registryAddress: EthAddress, l1RpcUrls: string[], l1ChainId: number, + rollupVersion: number | 'canonical' = 'canonical', ): Promise<{ addresses: L1ContractAddresses; config: Awaited> }> { const publicClient = getPublicClient({ l1RpcUrls, l1ChainId }); - const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress, 'canonical'); + const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress, rollupVersion); const config = await getL1ContractsConfig(publicClient, addresses); diff --git a/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts b/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts index 0080535a82b9..812a2d47e7d5 100644 --- a/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts +++ b/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts @@ -66,6 +66,7 @@ export async function deployL1Contracts( log(`Governance Address: ${l1ContractAddresses.governanceAddress.toString()}`); log(`SlashFactory Address: ${l1ContractAddresses.slashFactoryAddress?.toString()}`); log(`FeeAssetHandler Address: ${l1ContractAddresses.feeAssetHandlerAddress?.toString()}`); + log(`StakingAssetHandler Address: ${l1ContractAddresses.stakingAssetHandlerAddress?.toString()}`); log(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`); log(`Initial validators: ${initialValidators.map(a => a.toString()).join(', ')}`); log(`Genesis block hash: ${genesisBlockHash.toString()}`); diff --git a/yarn-project/cli/src/cmds/l1/index.ts b/yarn-project/cli/src/cmds/l1/index.ts index 629f97ef3909..5aa8687ddb87 100644 --- a/yarn-project/cli/src/cmds/l1/index.ts +++ b/yarn-project/cli/src/cmds/l1/index.ts @@ -5,6 +5,7 @@ import { type Command, Option } from 'commander'; import { ETHEREUM_HOSTS, + MNEMONIC, PRIVATE_KEY, l1ChainIdOption, makePxeOption, @@ -74,7 +75,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger .option( '-m, --mnemonic ', 'The mnemonic to use in deployment', - 'test test test test test test test test test test test junk', + MNEMONIC ?? 'test test test test test test test test test test test junk', ) .option('-i, --mnemonic-index ', 'The index of the mnemonic to use in deployment', arg => parseInt(arg), 0) .addOption(l1ChainIdOption) diff --git a/yarn-project/cli/src/utils/aztec.ts b/yarn-project/cli/src/utils/aztec.ts index a4fa5c46e9e8..46f51aeebd48 100644 --- a/yarn-project/cli/src/utils/aztec.ts +++ b/yarn-project/cli/src/utils/aztec.ts @@ -1,4 +1,4 @@ -import type { EthAddress, PXE } from '@aztec/aztec.js'; +import { EthAddress, type PXE } from '@aztec/aztec.js'; import { type ContractArtifact, type FunctionAbi, @@ -6,7 +6,12 @@ import { getAllFunctionAbis, loadContractArtifact, } from '@aztec/aztec.js/abi'; -import type { DeployL1ContractsReturnType, L1ContractsConfig, RollupContract } from '@aztec/ethereum'; +import { + type DeployL1ContractsReturnType, + type L1ContractsConfig, + RegistryContract, + RollupContract, +} from '@aztec/ethereum'; import type { Fr } from '@aztec/foundation/fields'; import type { LogFn, Logger } from '@aztec/foundation/log'; import type { NoirPackageConfig } from '@aztec/foundation/noir'; @@ -107,6 +112,13 @@ export async function deployNewRollupContracts( const chain = createEthereumChain(rpcUrls, chainId); const clients = createL1Clients(rpcUrls, account, chain.chainInfo, mnemonicIndex); + if (!initialValidators || initialValidators.length === 0) { + const registry = new RegistryContract(clients.publicClient, registryAddress); + const rollup = new RollupContract(clients.publicClient, await registry.getCanonicalAddress()); + initialValidators = (await rollup.getAttesters()).map(str => EthAddress.fromString(str)); + logger.info('Initializing new rollup with old attesters', { initialValidators }); + } + const { rollup, slashFactoryAddress } = await deployRollupForUpgrade( clients, { diff --git a/yarn-project/cli/src/utils/commands.ts b/yarn-project/cli/src/utils/commands.ts index ebbe95895539..16c6d69956fd 100644 --- a/yarn-project/cli/src/utils/commands.ts +++ b/yarn-project/cli/src/utils/commands.ts @@ -22,7 +22,7 @@ export const getLocalhost = () => .catch(() => 'localhost'); export const LOCALHOST = await getLocalhost(); -export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, API_KEY, CLI_VERSION } = process.env; +export const { ETHEREUM_HOSTS = `http://${LOCALHOST}:8545`, PRIVATE_KEY, MNEMONIC, API_KEY, CLI_VERSION } = process.env; export function addOptions(program: Command, options: Option[]) { options.forEach(option => program.addOption(option)); diff --git a/yarn-project/end-to-end/src/spartan/upgrade_via_cli.test.ts b/yarn-project/end-to-end/src/spartan/upgrade_via_cli.test.ts index 064a89d63980..b1f88f342ea9 100644 --- a/yarn-project/end-to-end/src/spartan/upgrade_via_cli.test.ts +++ b/yarn-project/end-to-end/src/spartan/upgrade_via_cli.test.ts @@ -1,5 +1,5 @@ import { type PXE, createCompatibleClient } from '@aztec/aztec.js'; -import { GovernanceContract, RegistryContract, createEthereumChain, createL1Clients } from '@aztec/ethereum'; +import { RegistryContract, createEthereumChain, createL1Clients } from '@aztec/ethereum'; import { createLogger } from '@aztec/foundation/log'; import type { ChildProcess } from 'child_process'; @@ -55,37 +55,14 @@ describe('upgrade via cli', () => { const info = await pxe.getNodeInfo(); const chain = createEthereumChain([ETHEREUM_HOSTS], info.l1ChainId); - const { walletClient: l1WalletClient, publicClient: l1PublicClient } = createL1Clients( - [ETHEREUM_HOSTS], - MNEMONIC, - chain.chainInfo, - ); - - const governance = new GovernanceContract( - info.l1ContractAddresses.governanceAddress.toString(), - l1PublicClient, - l1WalletClient, - ); - const { minimumVotes, proposeConfig } = await governance.getConfiguration(); - - const depositAmount = proposeConfig.lockAmount + minimumVotes; + const { publicClient: l1PublicClient } = createL1Clients([ETHEREUM_HOSTS], MNEMONIC, chain.chainInfo); const registry = new RegistryContract(l1PublicClient, info.l1ContractAddresses.registryAddress.toString()); const oldNumberOfVersions = await registry.getNumberOfVersions(); const exitCode = await runProjectScript( 'spartan/scripts/upgrade_rollup_with_cli.sh', - [ - '--aztec-bin', - getAztecBin(), - '--registry', - info.l1ContractAddresses.registryAddress.toString(), - '--address', - l1WalletClient.account.address, - '--deposit-amount', - depositAmount.toString(), - '--mint', - ], + ['--aztec-bin', getAztecBin(), '--registry', info.l1ContractAddresses.registryAddress.toString()], debugLogger, { MNEMONIC, diff --git a/yarn-project/ethereum/src/contracts/registry.test.ts b/yarn-project/ethereum/src/contracts/registry.test.ts index a1016aa8f509..96af9d8d54f9 100644 --- a/yarn-project/ethereum/src/contracts/registry.test.ts +++ b/yarn-project/ethereum/src/contracts/registry.test.ts @@ -54,7 +54,12 @@ describe('Registry', () => { genesisBlockHash: Fr.random(), }); // Since the registry cannot "see" the slash factory, we omit it from the addresses for this test - deployedAddresses = omit(deployed.l1ContractAddresses, 'slashFactoryAddress', 'feeAssetHandlerAddress'); + deployedAddresses = omit( + deployed.l1ContractAddresses, + 'slashFactoryAddress', + 'feeAssetHandlerAddress', + 'stakingAssetHandlerAddress', + ); registry = new RegistryContract(publicClient, deployedAddresses.registryAddress); const rollup = new RollupContract(publicClient, deployedAddresses.rollupAddress); diff --git a/yarn-project/ethereum/src/deploy_l1_contracts.ts b/yarn-project/ethereum/src/deploy_l1_contracts.ts index b4f0821916bc..ce84968b26fb 100644 --- a/yarn-project/ethereum/src/deploy_l1_contracts.ts +++ b/yarn-project/ethereum/src/deploy_l1_contracts.ts @@ -860,8 +860,14 @@ export const deployL1Contracts = async ( txUtilsConfig, ); - const { feeAssetAddress, feeAssetHandlerAddress, stakingAssetAddress, registryAddress, rewardDistributorAddress } = - await deploySharedContracts(clients, deployer, args, logger); + const { + feeAssetAddress, + feeAssetHandlerAddress, + stakingAssetAddress, + stakingAssetHandlerAddress, + registryAddress, + rewardDistributorAddress, + } = await deploySharedContracts(clients, deployer, args, logger); const { rollup, slashFactoryAddress } = await deployRollup( clients, deployer, @@ -913,6 +919,7 @@ export const deployL1Contracts = async ( ...l1Contracts, slashFactoryAddress, feeAssetHandlerAddress, + stakingAssetHandlerAddress, }, }; }; diff --git a/yarn-project/ethereum/src/queries.ts b/yarn-project/ethereum/src/queries.ts index 0de45ae33605..44b2dc98f138 100644 --- a/yarn-project/ethereum/src/queries.ts +++ b/yarn-project/ethereum/src/queries.ts @@ -13,7 +13,13 @@ import type { ViemPublicClient } from './types.js'; export async function getL1ContractsConfig( publicClient: ViemPublicClient, addresses: { governanceAddress: EthAddress; rollupAddress?: EthAddress }, -): Promise & { l1StartBlock: bigint; l1GenesisTime: bigint }> { +): Promise< + Omit & { + l1StartBlock: bigint; + l1GenesisTime: bigint; + rollupVersion: number; + } +> { const governance = new GovernanceContract(addresses.governanceAddress.toString(), publicClient, undefined); const governanceProposerAddress = await governance.getGovernanceProposerAddress(); const governanceProposer = new GovernanceProposerContract(publicClient, governanceProposerAddress.toString()); @@ -35,6 +41,7 @@ export async function getL1ContractsConfig( slashingRoundSize, manaTarget, provingCostPerMana, + rollupVersion, ] = await Promise.all([ rollup.getL1StartBlock(), rollup.getL1GenesisTime(), @@ -49,6 +56,7 @@ export async function getL1ContractsConfig( slasherProposer.getRoundSize(), rollup.getManaTarget(), rollup.getProvingCostPerMana(), + rollup.getVersion(), ] as const); return { @@ -65,6 +73,7 @@ export async function getL1ContractsConfig( slashingRoundSize: Number(slashingRoundSize), manaTarget: manaTarget, provingCostPerMana: provingCostPerMana, + rollupVersion: Number(rollupVersion), }; } diff --git a/yarn-project/prover-client/src/proving_broker/config.ts b/yarn-project/prover-client/src/proving_broker/config.ts index dad53850d0aa..a58ed748aa3a 100644 --- a/yarn-project/prover-client/src/proving_broker/config.ts +++ b/yarn-project/prover-client/src/proving_broker/config.ts @@ -5,7 +5,9 @@ import { getDefaultConfig, numberConfigHelper, } from '@aztec/foundation/config'; +import { pickConfigMappings } from '@aztec/foundation/config'; import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config'; +import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config'; import { ProvingRequestType } from '@aztec/stdlib/proofs'; import { z } from 'zod'; @@ -33,7 +35,8 @@ export const ProverBrokerConfig = z.object({ export type ProverBrokerConfig = z.infer & Pick & - L1ReaderConfig; + L1ReaderConfig & + Pick; export const proverBrokerConfigMappings: ConfigMappingsType = { proverBrokerJobTimeoutMs: { @@ -73,6 +76,7 @@ export const proverBrokerConfigMappings: ConfigMappingsType }, ...dataConfigMappings, ...l1ReaderConfigMappings, + ...pickConfigMappings(chainConfigMappings, ['rollupVersion']), }; export const defaultProverBrokerConfig: ProverBrokerConfig = getDefaultConfig(proverBrokerConfigMappings); diff --git a/yarn-project/prover-client/src/proving_broker/proving_broker_database/broker_persisted_database.test.ts b/yarn-project/prover-client/src/proving_broker/proving_broker_database/broker_persisted_database.test.ts index ceab680e98b1..012ec8bb99f7 100644 --- a/yarn-project/prover-client/src/proving_broker/proving_broker_database/broker_persisted_database.test.ts +++ b/yarn-project/prover-client/src/proving_broker/proving_broker_database/broker_persisted_database.test.ts @@ -35,6 +35,7 @@ describe('ProvingBrokerPersistedDatabase', () => { l1RpcUrls: [], l1ChainId: 42, viemPollingIntervalMS: 100, + rollupVersion: 42, }; db = await KVBrokerDatabase.new(config); }); @@ -342,6 +343,7 @@ describe('ProvingBrokerPersistedDatabase', () => { l1RpcUrls: [], l1ChainId: 42, viemPollingIntervalMS: 100, + rollupVersion: 42, }; db = await KVBrokerDatabase.new(config); commitSpy = jest.spyOn(db, 'commitWrites');