Skip to content

Commit ff35052

Browse files
committed
fix: optionally verify contracts
1 parent 0046f64 commit ff35052

File tree

7 files changed

+39
-15
lines changed

7 files changed

+39
-15
lines changed

spartan/environments/tps-scenario.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ LABS_INFRA_MNEMONIC="test test test test test test test test test test test junk
1212
FUNDING_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
1313
# CREATE_CHAOS_MESH=true
1414

15+
CREATE_ROLLUP_CONTRACTS=true
1516
REDEPLOY_ROLLUP_CONTRACTS=true
17+
VERIFY_CONTRACTS=false
1618
DESTROY_AZTEC_INFRA=true
1719

1820
AZTEC_LAG_IN_EPOCHS=1

spartan/scripts/deploy_network.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ fi
272272
# Deploy rollup contracts
273273
# -------------------------------
274274

275+
if [[ "${VERIFY_CONTRACTS:-}" == "true" && "${ETHEREUM_CHAIN_ID}" == "1337" ]]; then
276+
die "Cannot verify contracts deployed to eth-devnet"
277+
fi
278+
275279
if [[ "${VERIFY_CONTRACTS:-}" == "true" && "${CREATE_ROLLUP_CONTRACTS}" == "true" ]]; then
276280
if [ -z "$ETHERSCAN_API_KEY" ]; then
277281
echo "Error: ETHERSCAN_API_KEY is not set, but VERIFY_CONTRACTS=true. Cannot verify contracts without Etherscan API key (i.e. we need API access to the verification service)."
@@ -329,6 +333,7 @@ NETWORK = ${NETWORK_TF}
329333
JOB_NAME = "deploy-rollup-contracts"
330334
JOB_BACKOFF_LIMIT = 3
331335
JOB_TTL_SECONDS_AFTER_FINISHED = 3600
336+
VERIFY_CONTRACTS = ${VERIFY_CONTRACTS:-false}
332337
EOF
333338

334339
# Check terraform state for existing contract addresses

spartan/terraform/deploy-rollup-contracts/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ locals {
2828
["--json"], # Always output JSON for easier parsing
2929
var.SPONSORED_FPC ? ["--sponsored-fpc"] : [],
3030
var.TEST_ACCOUNTS ? ["--test-accounts"] : [],
31-
var.REAL_VERIFIER ? ["--real-verifier"] : []
31+
var.REAL_VERIFIER ? ["--real-verifier"] : [],
32+
var.VERIFY_CONTRACTS ? ["--verify-contracts"] : []
3233
)
3334

3435

spartan/terraform/deploy-rollup-contracts/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,8 @@ variable "NETWORK" {
228228
nullable = true
229229
}
230230

231+
variable "VERIFY_CONTRACTS" {
232+
description = "Verify contracts on Etherscan"
233+
type = bool
234+
default = false
235+
}

yarn-project/cli/src/cmds/l1/deploy_l1_contracts_cmd.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export async function deployL1ContractsCmd(
2525
initialValidators: EthAddress[],
2626
realVerifier: boolean,
2727
existingToken: EthAddress | undefined,
28+
verifyContracts: boolean | undefined,
2829
log: LogFn,
2930
debugLogger: Logger,
3031
) {
@@ -59,19 +60,25 @@ export async function deployL1ContractsCmd(
5960
debugLogger.info('Deploying L1 contracts via Forge...');
6061

6162
// Deploy using l1-contracts Forge scripts
62-
const { l1ContractAddresses, rollupVersion } = await deployAztecL1Contracts(rpcUrls[0], deployerPrivateKey, chainId, {
63-
// Initial validators to add during deployment
64-
initialValidators: initialValidatorOperators,
65-
// Genesis config
66-
vkTreeRoot,
67-
protocolContractsHash,
68-
genesisArchiveRoot,
69-
// Deployment options
70-
realVerifier,
71-
...config,
72-
feeJuicePortalInitialBalance: fundingNeeded,
73-
existingTokenAddress: existingToken,
74-
});
63+
const { l1ContractAddresses, rollupVersion } = await deployAztecL1Contracts(
64+
rpcUrls[0],
65+
deployerPrivateKey,
66+
chainId,
67+
{
68+
// Initial validators to add during deployment
69+
initialValidators: initialValidatorOperators,
70+
// Genesis config
71+
vkTreeRoot,
72+
protocolContractsHash,
73+
genesisArchiveRoot,
74+
// Deployment options
75+
realVerifier,
76+
...config,
77+
feeJuicePortalInitialBalance: fundingNeeded,
78+
existingTokenAddress: existingToken,
79+
},
80+
verifyContracts,
81+
);
7582

7683
debugLogger.info('Forge deployment complete', { rollupVersion });
7784

yarn-project/cli/src/cmds/l1/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
4444
.option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract')
4545
.option('--real-verifier', 'Deploy the real verifier', false)
4646
.option('--existing-token <address>', 'Use an existing ERC20 for both fee and staking', parseEthereumAddress)
47+
.option('--verify-contracts', 'Verify deployed contracts on Etherscan', false)
4748
.action(async options => {
4849
const { deployL1ContractsCmd } = await import('./deploy_l1_contracts_cmd.js');
4950

@@ -61,6 +62,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
6162
initialValidators,
6263
options.realVerifier,
6364
options.existingToken,
65+
options.verifyContracts,
6466
log,
6567
debugLogger,
6668
);

yarn-project/ethereum/src/deploy_aztec_l1_contracts.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export async function deployAztecL1Contracts(
203203
privateKey: `0x${string}`,
204204
chainId: number,
205205
args: DeployAztecL1ContractsArgs,
206+
verifyContracts = false,
206207
): Promise<DeployAztecL1ContractsReturnType> {
207208
logger.info(`Deploying L1 contracts with config: ${jsonStringify(args)}`);
208209
if (args.initialValidators && args.initialValidators.length > 0 && args.existingTokenAddress) {
@@ -260,7 +261,8 @@ export async function deployAztecL1Contracts(
260261
'--rpc-url',
261262
rpcUrl,
262263
'--broadcast',
263-
...(chainId === foundry.id ? ['--batch-size', MAGIC_ANVIL_BATCH_SIZE.toString()] : ['--verify']),
264+
...(chainId === foundry.id ? ['--batch-size', MAGIC_ANVIL_BATCH_SIZE.toString()] : []),
265+
...(verifyContracts ? ['--verify'] : []),
264266
];
265267
const forgeEnv = {
266268
// Protect against root leaving deployment files in docker that cannot be used later.

0 commit comments

Comments
 (0)