Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Faster L1 deployment #8234

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion yarn-project/aztec/src/cli/aztec_start_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,18 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
},
{
flag: '--node.deployAztecContracts',
description: 'Deploys L1 Aztec contracts before starting the node. Needs mnemonic or private key to be set',
description: 'Deploys L1 Aztec contracts before starting the node. Needs mnemonic or private key to be set.',
envVar: 'DEPLOY_AZTEC_CONTRACTS',
...booleanConfigHelper(),
},
{
flag: '--node.deployAztecContractsSalt',
description:
'Numeric salt for deploying L1 Aztec contracts before starting the node. Needs mnemonic or private key to be set. Implies --node.deployAztecContracts.',
envVar: 'DEPLOY_AZTEC_CONTRACTS_SALT',
defaultValue: undefined,
parseVal: (val: string) => (val ? parseInt(val) : undefined),
},
{
flag: '--node.assumeProvenUntilBlockNumber',
description:
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const startNode = async (
}

// Deploy contracts if needed
if (nodeSpecificOptions.deployAztecContracts) {
if (nodeSpecificOptions.deployAztecContracts || nodeSpecificOptions.deployAztecContractsSalt) {
let account;
if (nodeSpecificOptions.publisherPrivateKey) {
account = privateKeyToAccount(nodeSpecificOptions.publisherPrivateKey);
Expand All @@ -48,6 +48,7 @@ export const startNode = async (
}
await deployContractsToL1(nodeConfig, account!, undefined, {
assumeProvenUntilBlockNumber: nodeSpecificOptions.assumeProvenUntilBlockNumber,
salt: nodeSpecificOptions.deployAztecContractsSalt,
});
}

Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec/src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function deployContractsToL1(
aztecNodeConfig: AztecNodeConfig,
hdAccount: HDAccount | PrivateKeyAccount,
contractDeployLogger = logger,
opts: { assumeProvenUntilBlockNumber?: number } = {},
opts: { assumeProvenUntilBlockNumber?: number; salt?: number } = {},
) {
const l1Artifacts: L1ContractArtifactsForDeployment = {
registry: {
Expand Down Expand Up @@ -132,7 +132,7 @@ export async function deployContractsToL1(
l2FeeJuiceAddress: FeeJuiceAddress,
vkTreeRoot: getVKTreeRoot(),
assumeProvenUntil: opts.assumeProvenUntilBlockNumber,
salt: undefined,
salt: opts.salt,
}),
);

Expand Down
14 changes: 12 additions & 2 deletions yarn-project/cli/src/cmds/devnet/bootstrap_network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,18 @@ async function deployERC20({ walletClient, publicClient }: L1Clients) {
contractBytecode: TokenPortalBytecode,
};

const erc20Address = await deployL1Contract(walletClient, publicClient, erc20.contractAbi, erc20.contractBytecode);
const portalAddress = await deployL1Contract(walletClient, publicClient, portal.contractAbi, portal.contractBytecode);
const { address: erc20Address } = await deployL1Contract(
walletClient,
publicClient,
erc20.contractAbi,
erc20.contractBytecode,
);
const { address: portalAddress } = await deployL1Contract(
walletClient,
publicClient,
portal.contractAbi,
portal.contractBytecode,
);

return {
erc20Address,
Expand Down
9 changes: 7 additions & 2 deletions yarn-project/cli/src/cmds/l1/deploy_l1_verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function deployUltraHonkVerifier(
createEthereumChain(ethRpcUrl, l1ChainId).chainInfo,
);

const verifierAddress = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`);
const { address: verifierAddress } = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`);
log(`Deployed HonkVerifier at ${verifierAddress.toString()}`);

const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
Expand Down Expand Up @@ -100,7 +100,12 @@ export async function deployMockVerifier(
);
const { MockVerifierAbi, MockVerifierBytecode, RollupAbi } = await import('@aztec/l1-artifacts');

const mockVerifierAddress = await deployL1Contract(walletClient, publicClient, MockVerifierAbi, MockVerifierBytecode);
const { address: mockVerifierAddress } = await deployL1Contract(
walletClient,
publicClient,
MockVerifierAbi,
MockVerifierBytecode,
);
log(`Deployed MockVerifier at ${mockVerifierAddress.toString()}`);

const pxe = await createCompatibleClient(pxeRpcUrl, debugLogger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('proof_verification', () => {
const abi = output.contracts['UltraHonkVerifier.sol']['HonkVerifier'].abi;
const bytecode: string = output.contracts['UltraHonkVerifier.sol']['HonkVerifier'].evm.bytecode.object;

const verifierAddress = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`);
const { address: verifierAddress } = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`);
verifierContract = getContract({
address: verifierAddress.toString(),
client: publicClient,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class FullProverTest {
const abi = output.contracts['UltraHonkVerifier.sol']['HonkVerifier'].abi;
const bytecode: string = output.contracts['UltraHonkVerifier.sol']['HonkVerifier'].evm.bytecode.object;

const verifierAddress = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`);
const { address: verifierAddress } = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`);

this.logger.info(`Deployed Real verifier at ${verifierAddress}`);

Expand Down
18 changes: 14 additions & 4 deletions yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
underlyingERC20: any;
}> {
if (!underlyingERC20Address) {
underlyingERC20Address = await deployL1Contract(walletClient, publicClient, PortalERC20Abi, PortalERC20Bytecode);
underlyingERC20Address = await deployL1Contract(
walletClient,
publicClient,
PortalERC20Abi,
PortalERC20Bytecode,
).then(({ address }) => address);
}
const underlyingERC20 = getContract({
address: underlyingERC20Address.toString(),
address: underlyingERC20Address!.toString(),
abi: PortalERC20Abi,
client: walletClient,
});

// deploy the token portal
const tokenPortalAddress = await deployL1Contract(walletClient, publicClient, TokenPortalAbi, TokenPortalBytecode);
const { address: tokenPortalAddress } = await deployL1Contract(
walletClient,
publicClient,
TokenPortalAbi,
TokenPortalBytecode,
);
const tokenPortal = getContract({
address: tokenPortalAddress.toString(),
abi: TokenPortalAbi,
Expand Down Expand Up @@ -120,7 +130,7 @@ export async function deployAndInitializeTokenAndBridgeContracts(

// initialize portal
await tokenPortal.write.initialize(
[rollupRegistryAddress.toString(), underlyingERC20Address.toString(), bridge.address.toString()],
[rollupRegistryAddress.toString(), underlyingERC20Address!.toString(), bridge.address.toString()],
{} as any,
);

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const uniswapL1L2TestSuite = (
publicClient,
UniswapPortalAbi,
UniswapPortalBytecode,
);
).then(({ address }) => address);

uniswapPortal = getContract({
address: uniswapPortalAddress.toString(),
Expand Down
Loading
Loading