Skip to content

Commit c3f55fa

Browse files
authored
refactor: aztec l1 contracts deployed w/ forge (#18622)
Part of https://linear.app/aztec-labs/issue/A-316/consolidate-contract-deployments This PR refactors the deployment pipeline for governance and rollup contracts. The typescript deployment mechanism is fully replaced with Forge. The forge scripts take configuration using environment variables. They write their deployed contract addresses to a JSON file, parsed by the caller. The results are intended to be exactly the same, barring minor things (e.g. deploying the mock zkpassport verifier in more cases). Core files added: - DeployAztecL1Contracts.s.sol - Full deployment (fresh network) - DeployRollupForUpgrade.s.sol - Upgrade-only deployment - DeployRollupLib.sol - Shared rollup deployment library - DeploymentConfiguration.sol - Full deployment config. Reads env vars, provides defaults based on network label - RollupConfiguration.sol - Rollup-specific config (genesis state, staking stuff, initial validators etc.) Then lots of work making sure the right glue was in place for the typescript side. # Why move to Forge for deployments? L1 contract deployment was being done in TypeScript but clearly from the network launching using foundry scripts, this was not ideal. Benefits: - forge --verify automatically posts to etherscan for us, avoiding the complicated custom logic we had to implement - forge simulation means we catch any problems in the entire deployment flow early. Stuff like the previous validateConfig() that guarded against reverts are now redundant. - forge is able to broadcast these in transaction batches, I got 2-3 slots on Sepolia for a deploy (24-40s) - better separation of concerns, l1-contracts now can fully own the deployment - foundry tests are very effective at asserting things about our deployments under different conditions Weirdness: - we work around a problem in solidity where MockBlobLib was not deployable through forge but it feels a bit hacky. I think it's preferable to needing to rebuild with a different forge profile like ignition-monorepo did. Cut features: - Deploying with a salt is no longer supported. While nice for deterministic deployments, the reason the salt was useful before was mainly to batch deployments. We do this with Forge, so forego the complexity of supporting this. This is feasible to bring back if it comes up, just would add a bunch of conditionality to the script. Comments on future work: - It feels like the definition of networks is a bit sprawling and a bit hard to analyze, as the env vars that trigger deployment can be set very high up in the stack, in e.g. test scenario YAMLs. It would be best IMO to make each value only defined in a specific module. Given our limited set of distinct scenarios, we could lean in to the network label approach like in previous ethereum/config.ts (and now DeploymentConfiguration). In that world, l1-contracts would choose the parameters based on a network label and no other part of the stack could inject values thru env vars, making analysis easier. This would be more like the ignition-monorepo deploys (but they had fewer variations to contend with). For now it is a bit of a mix as network-specific governance configuration definitions (local, staging, testnet, mainnet) from TypeScript's config.ts have been moved to DeploymentConfiguration.sol but it allows for a lot to be overridden with env variables.
2 parents 058a007 + 77140b1 commit c3f55fa

File tree

104 files changed

+2473
-3663
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+2473
-3663
lines changed

.github/ci3.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function main {
134134
exit 0
135135
fi
136136
check_cache
137-
echo_header "Run CI"
137+
echo_header "Run ${CI_MODE} CI"
138138
exec ./ci.sh "${CI_MODE}"
139139
}
140140

docs/developer_versioned_docs/version-v3.0.0-nightly.20251212/docs/aztec-cli/cli_reference.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,10 +1418,6 @@ Options:
14181418
Mnemonic for L1 accounts. Will be used
14191419
*Environment: `$MNEMONIC`*
14201420

1421-
- `--local-network.deployAztecContractsSalt <value>`
1422-
Numeric salt for deploying L1 Aztec contracts before starting the local network. Needs mnemonic or private key to be set.
1423-
*Environment: `$DEPLOY_AZTEC_CONTRACTS_SALT`*
1424-
14251421
**API**
14261422

14271423
- `--port <value>` (default: `8080`)

docs/docs-developers/docs/aztec-cli/cli_reference.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ Options:
617617
deployment (default: 0)
618618
-c, --l1-chain-id <number> Chain ID of the ethereum host (default:
619619
31337, env: L1_CHAIN_ID)
620-
--salt <number> The optional salt to use in deployment
621620
--json Output the contract addresses in JSON
622621
format
623622
--test-accounts Populate genesis state with initial fee
@@ -1418,10 +1417,6 @@ Options:
14181417
Mnemonic for L1 accounts. Will be used
14191418
*Environment: `$MNEMONIC`*
14201419

1421-
- `--local-network.deployAztecContractsSalt <value>`
1422-
Numeric salt for deploying L1 Aztec contracts before starting the local network. Needs mnemonic or private key to be set.
1423-
*Environment: `$DEPLOY_AZTEC_CONTRACTS_SALT`*
1424-
14251420
**API**
14261421

14271422
- `--port <value>` (default: `8080`)

docs/docs-network/reference/cli_reference.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ tags:
5757
--local-network.l1Mnemonic <value> (default: test test test test test test test test test test test junk)($MNEMONIC)
5858
Mnemonic for L1 accounts. Will be used
5959

60-
--local-network.deployAztecContractsSalt <value> ($DEPLOY_AZTEC_CONTRACTS_SALT)
61-
Numeric salt for deploying L1 Aztec contracts before starting the local network. Needs mnemonic or private key to be set.
62-
6360
API
6461

6562
--port <value> (default: 8080) ($AZTEC_PORT)

l1-contracts/bootstrap.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ function build_src {
6161
git submodule update --init --recursive ./lib
6262

6363
# Compile contracts
64-
# Build everything in src and test (except tests that need generated verifier).
65-
forge build $(find src test -name '*.sol' ! -name 'shouting.t.sol')
64+
# Build everything in src and test (except scripts that need generated verifier).
65+
forge build $(find src test -name '*.sol' ! -name 'shouting.t.sol' ! -path 'test/script/*' )
6666

6767
# Output storage information for the rollup contract.
6868
forge inspect --json src/core/Rollup.sol:Rollup storage > ./out/Rollup.sol/storage.json
6969

70-
cache_upload $artifact out
70+
cache_upload $artifact out cache
7171
fi
7272
}
7373

@@ -87,15 +87,14 @@ function build_verifier {
8787
fi
8888

8989
# Build the generated verifier contract with optimization.
90-
forge build $(find generated -name '*.sol') \
91-
--optimize \
92-
--optimizer-runs 1 \
93-
--no-metadata
94-
95-
# Build the one test that imports the verifier.
96-
forge build test/shouting.t.sol
97-
98-
cache_upload $artifact out generated
90+
# Build the scripts that rely on the verifier. These are mutually exclusive with the build in build_src.
91+
forge build \
92+
$(find generated -name '*.sol') \
93+
test/shouting.t.sol \
94+
script/deploy/*.s.sol \
95+
tests/scripts/*.t.sol
96+
97+
cache_upload $artifact out cache generated
9998
fi
10099
}
101100

l1-contracts/foundry.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ libs = ['lib']
99
solc = "./solc-0.8.27"
1010
evm_version = 'prague'
1111
optimizer = true
12-
1312
match_path = "test/**/*.t.sol"
1413
# Helper to get all the contract names in the src/governance and src/core directories
1514
# find ./src/governance ./src/core -type f -name "*.sol" -exec grep -h "^contract [A-Za-z]" {} \; | sed -E 's/contract ([A-Za-z0-9_]+).*/"\1"/' | tr "\n" ", "
@@ -60,9 +59,8 @@ fs_permissions = [
6059
{ access = "read", path = "./test/staking_asset_handler/zkpassport/fixtures/valid_public_inputs.json" },
6160
{ access = "read", path = "./test/fixtures/boosted_rewards/shares.json" },
6261
{ access = "read", path = "./test/fixtures/boosted_rewards/activity_scores.json" },
63-
{ access = "read", path = "./script/registration_data.json" },
62+
{ access = "read", path = "./script/registration_data.json" }
6463
]
65-
6664
no_match_contract = "(ScreamAndShoutTest|UniswapPortalTest|MerkleCheck)"
6765

6866
[fmt]
@@ -78,7 +76,6 @@ ignore = ["./lib/**"]
7876
exclude_lints = [
7977
"unused-import", # Mostly in test code
8078
"incorrect-shift", # Throws warnings on construction of bitmasks
81-
8279
"asm-keccak256", # https://github.com/AztecProtocol/aztec-packages/issues/16808
8380

8481
# Silencing due to just being style changes
@@ -91,7 +88,6 @@ exclude_lints = [
9188
[rpc_endpoints]
9289
mainnet_fork = "https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c"
9390

94-
9591
[profile.production]
9692
remappings = [
9793
"@oz/=lib/openzeppelin-contracts/contracts/",

0 commit comments

Comments
 (0)