Skip to content
Closed
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
1 change: 1 addition & 0 deletions boxes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@aztec/bb.js": "portal:../barretenberg/ts",
"@aztec/circuit-types": "portal:../yarn-project/circuit-types",
"@aztec/ethereum": "portal:../yarn-project/ethereum",
"@aztec/l1-artifacts": "portal:../yarn-project/l1-artifacts",
"@aztec/types": "portal:../yarn-project/types"
}
}
11 changes: 10 additions & 1 deletion boxes/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ __metadata:
"@aztec/foundation": "workspace:^"
eslint: "npm:^8.35.0"
lodash.chunk: "npm:^4.2.0"
lodash.times: "npm:^4.3.2"
tslib: "npm:^2.4.0"
languageName: node
linkType: soft
Expand All @@ -265,6 +264,7 @@ __metadata:
resolution: "@aztec/ethereum@portal:../yarn-project/ethereum::locator=%40aztec%2Fboxes%40workspace%3A."
dependencies:
"@aztec/foundation": "workspace:^"
"@aztec/l1-artifacts": "workspace:^"
dotenv: "npm:^16.0.3"
tslib: "npm:^2.4.0"
viem: "npm:^1.2.5"
Expand Down Expand Up @@ -297,11 +297,20 @@ __metadata:
languageName: node
linkType: soft

"@aztec/l1-artifacts@portal:../yarn-project/l1-artifacts::locator=%40aztec%2Fboxes%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec/l1-artifacts@portal:../yarn-project/l1-artifacts::locator=%40aztec%2Fboxes%40workspace%3A."
dependencies:
tslib: "npm:^2.4.0"
languageName: node
linkType: soft

"@aztec/types@portal:../yarn-project/types::locator=%40aztec%2Fboxes%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec/types@portal:../yarn-project/types::locator=%40aztec%2Fboxes%40workspace%3A."
dependencies:
"@aztec/ethereum": "workspace:^"
"@aztec/foundation": "workspace:^"
languageName: node
linkType: soft

Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@aztec/ethereum": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/kv-store": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
"@aztec/merkle-tree": "workspace:^",
"@aztec/p2p": "workspace:^",
"@aztec/sequencer-client": "workspace:^",
Expand Down
3 changes: 0 additions & 3 deletions yarn-project/aztec-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
{
"path": "../kv-store"
},
{
"path": "../l1-artifacts"
},
{
"path": "../merkle-tree"
},
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@aztec/circuits.js": "workspace:^",
"@aztec/ethereum": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
"@aztec/noir-compiler": "workspace:^",
"@aztec/noir-contracts": "workspace:^",
"@aztec/p2p": "workspace:^",
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec-sandbox/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { dirname, resolve } from 'path';
import { mnemonicToAccount } from 'viem/accounts';

import { setupFileDebugLog } from '../logging.js';
import { MNEMONIC, createAztecNode, createAztecPXE, createSandbox, deployContractsToL1 } from '../sandbox.js';
import { MNEMONIC, createAztecNode, createAztecPXE, createSandbox, waitThenDeployL1Contracts } from '../sandbox.js';
import { github, splash } from '../splash.js';

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ async function main() {

// Deploy L1 Aztec Contracts if needed
if (deployAztecContracts) {
await deployContractsToL1(nodeConfig, hdAccount);
await waitThenDeployL1Contracts(nodeConfig, hdAccount);
if (nodeConfig.publisherPrivateKey === NULL_KEY) {
const privKey = hdAccount.getHdKey().privateKey;
nodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey!).toString('hex')}`;
Expand Down
74 changes: 8 additions & 66 deletions yarn-project/aztec-sandbox/src/sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
#!/usr/bin/env -S node --no-warnings
import { AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
import { AztecNode } from '@aztec/circuit-types';
import {
DeployL1Contracts,
L1ContractArtifactsForDeployment,
NULL_KEY,
createEthereumChain,
deployL1Contracts,
} from '@aztec/ethereum';
import { NULL_KEY, createEthereumChain, deployL1Contracts } from '@aztec/ethereum';
import { createDebugLogger } from '@aztec/foundation/log';
import { retryUntil } from '@aztec/foundation/retry';
import {
AvailabilityOracleAbi,
AvailabilityOracleBytecode,
ContractDeploymentEmitterAbi,
ContractDeploymentEmitterBytecode,
InboxAbi,
InboxBytecode,
OutboxAbi,
OutboxBytecode,
RegistryAbi,
RegistryBytecode,
RollupAbi,
RollupBytecode,
} from '@aztec/l1-artifacts';
import { PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';

import { HDAccount, createPublicClient, http as httpViemTransport } from 'viem';
Expand All @@ -37,9 +17,11 @@ const logger = createDebugLogger('aztec:sandbox');
const localAnvil = foundry;

/**
* Helper function that waits for the Ethereum RPC server to respond before deploying L1 contracts.
* Waits then deploys L1 contracts.
* @param config - The Aztec Node Config.
* @param hdAccount - Account for publishing L1 contracts.
*/
async function waitThenDeploy(config: AztecNodeConfig, deployFunction: () => Promise<DeployL1Contracts>) {
export async function waitThenDeployL1Contracts(config: AztecNodeConfig, hdAccount: HDAccount) {
const chain = createEthereumChain(config.rpcUrl, config.apiKey);
// wait for ETH RPC to respond to a request.
const publicClient = createPublicClient({
Expand All @@ -66,49 +48,9 @@ async function waitThenDeploy(config: AztecNodeConfig, deployFunction: () => Pro
}

// Deploy L1 contracts
return await deployFunction();
}

/**
* Function to deploy our L1 contracts to the sandbox L1
* @param aztecNodeConfig - The Aztec Node Config
* @param hdAccount - Account for publishing L1 contracts
*/
export async function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, hdAccount: HDAccount) {
const l1Artifacts: L1ContractArtifactsForDeployment = {
contractDeploymentEmitter: {
contractAbi: ContractDeploymentEmitterAbi,
contractBytecode: ContractDeploymentEmitterBytecode,
},
registry: {
contractAbi: RegistryAbi,
contractBytecode: RegistryBytecode,
},
inbox: {
contractAbi: InboxAbi,
contractBytecode: InboxBytecode,
},
outbox: {
contractAbi: OutboxAbi,
contractBytecode: OutboxBytecode,
},
availabilityOracle: {
contractAbi: AvailabilityOracleAbi,
contractBytecode: AvailabilityOracleBytecode,
},
rollup: {
contractAbi: RollupAbi,
contractBytecode: RollupBytecode,
},
};

aztecNodeConfig.l1Contracts = (
await waitThenDeploy(aztecNodeConfig, () =>
deployL1Contracts(aztecNodeConfig.rpcUrl, hdAccount, localAnvil, logger, l1Artifacts),
)
).l1ContractAddresses;
config.l1Contracts = (await deployL1Contracts(config.rpcUrl, hdAccount, localAnvil, logger)).l1ContractAddresses;

return aztecNodeConfig.l1Contracts;
return config.l1Contracts;
}

/** Sandbox settings. */
Expand All @@ -131,7 +73,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}) {
}

if (!aztecNodeConfig.p2pEnabled) {
await deployContractsToL1(aztecNodeConfig, hdAccount);
await waitThenDeployL1Contracts(aztecNodeConfig, hdAccount);
}

const node = await createAztecNode(aztecNodeConfig);
Expand Down
3 changes: 0 additions & 3 deletions yarn-project/aztec-sandbox/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../foundation"
},
{
"path": "../l1-artifacts"
},
{
"path": "../noir-compiler"
},
Expand Down
7 changes: 1 addition & 6 deletions yarn-project/aztec.js/src/api/ethereum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
export {
deployL1Contract,
deployL1Contracts,
DeployL1Contracts,
L1ContractArtifactsForDeployment,
} from '@aztec/ethereum';
export { deployL1Contract, deployL1Contracts, DeployL1Contracts } from '@aztec/ethereum';
7 changes: 1 addition & 6 deletions yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,7 @@ export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
export { makeFetch } from '@aztec/foundation/json-rpc/client';
export { FieldsOf } from '@aztec/foundation/types';

export {
DeployL1Contracts,
L1ContractArtifactsForDeployment,
deployL1Contract,
deployL1Contracts,
} from '@aztec/ethereum';
export { DeployL1Contracts, deployL1Contract, deployL1Contracts } from '@aztec/ethereum';

// Start of section that exports public api via granular api.
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
Expand Down
1 change: 0 additions & 1 deletion yarn-project/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@aztec/circuit-types": "workspace:^",
"@aztec/ethereum": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
"@aztec/noir-compiler": "workspace:^",
"@aztec/noir-contracts": "workspace:^",
"@aztec/types": "workspace:^",
Expand Down
18 changes: 14 additions & 4 deletions yarn-project/cli/src/cmds/deploy_l1_contracts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { DebugLogger, LogFn } from '@aztec/foundation/log';

import { deployAztecContracts } from '../utils.js';

/**
*
* Function to execute the 'deployRollupContracts' command.
* @param rpcUrl - The RPC URL of the ethereum node.
* @param apiKey - The api key of the ethereum node endpoint.
* @param privateKey - The private key to be used in contract deployment.
* @param mnemonic - The mnemonic to be used in contract deployment.
* @param log - The log function used to print out addresses.
* @param debugLogger - The debug logger passed to original deploy function.
*/
export async function deployL1Contracts(
rpcUrl: string,
Expand All @@ -13,13 +17,19 @@ export async function deployL1Contracts(
log: LogFn,
debugLogger: DebugLogger,
) {
const { l1ContractAddresses } = await deployAztecContracts(rpcUrl, apiKey, privateKey, mnemonic, debugLogger);
const { createEthereumChain, deployL1Contracts: deployL1ContractOriginal } = await import('@aztec/ethereum');
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');

const account = !privateKey ? mnemonicToAccount(mnemonic!) : privateKeyToAccount(`0x${privateKey}`);
const chain = createEthereumChain(rpcUrl, apiKey);
const { l1ContractAddresses } = await deployL1ContractOriginal(chain.rpcUrl, account, chain.chainInfo, debugLogger);

log('\n');
log(`Rollup Address: ${l1ContractAddresses.rollupAddress.toString()}`);
log(`Registry Address: ${l1ContractAddresses.registryAddress.toString()}`);
log(`L1 -> L2 Inbox Address: ${l1ContractAddresses.inboxAddress.toString()}`);
log(`L2 -> L1 Outbox address: ${l1ContractAddresses.outboxAddress.toString()}`);
log(`Contract Deployment Emitter Address: ${l1ContractAddresses.contractDeploymentEmitterAddress.toString()}`);
log(`Availability Oracle Address: ${l1ContractAddresses.availabilityOracleAddress.toString()}`);
log('\n');
}
64 changes: 1 addition & 63 deletions yarn-project/cli/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { type ContractArtifact, type FunctionArtifact } from '@aztec/aztec.js/abi';
import { AztecAddress } from '@aztec/aztec.js/aztec_address';
import { type L1ContractArtifactsForDeployment } from '@aztec/aztec.js/ethereum';
import { type PXE } from '@aztec/aztec.js/interfaces/pxe';
import { DebugLogger, LogFn } from '@aztec/foundation/log';
import { LogFn } from '@aztec/foundation/log';
import { NoirPackageConfig } from '@aztec/foundation/noir';
import { AvailabilityOracleAbi, AvailabilityOracleBytecode } from '@aztec/l1-artifacts';

import TOML from '@iarna/toml';
import { CommanderError, InvalidArgumentError } from 'commander';
Expand Down Expand Up @@ -33,66 +31,6 @@ export function getFunctionArtifact(artifact: ContractArtifact, fnName: string):
return fn;
}

/**
* Function to execute the 'deployRollupContracts' command.
* @param rpcUrl - The RPC URL of the ethereum node.
* @param apiKey - The api key of the ethereum node endpoint.
* @param privateKey - The private key to be used in contract deployment.
* @param mnemonic - The mnemonic to be used in contract deployment.
*/
export async function deployAztecContracts(
rpcUrl: string,
apiKey: string,
privateKey: string,
mnemonic: string,
debugLogger: DebugLogger,
) {
const {
ContractDeploymentEmitterAbi,
ContractDeploymentEmitterBytecode,
InboxAbi,
InboxBytecode,
OutboxAbi,
OutboxBytecode,
RegistryAbi,
RegistryBytecode,
RollupAbi,
RollupBytecode,
} = await import('@aztec/l1-artifacts');
const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum');
const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts');

const account = !privateKey ? mnemonicToAccount(mnemonic!) : privateKeyToAccount(`0x${privateKey}`);
const chain = createEthereumChain(rpcUrl, apiKey);
const l1Artifacts: L1ContractArtifactsForDeployment = {
contractDeploymentEmitter: {
contractAbi: ContractDeploymentEmitterAbi,
contractBytecode: ContractDeploymentEmitterBytecode,
},
registry: {
contractAbi: RegistryAbi,
contractBytecode: RegistryBytecode,
},
inbox: {
contractAbi: InboxAbi,
contractBytecode: InboxBytecode,
},
outbox: {
contractAbi: OutboxAbi,
contractBytecode: OutboxBytecode,
},
availabilityOracle: {
contractAbi: AvailabilityOracleAbi,
contractBytecode: AvailabilityOracleBytecode,
},
rollup: {
contractAbi: RollupAbi,
contractBytecode: RollupBytecode,
},
};
return await deployL1Contracts(chain.rpcUrl, account, chain.chainInfo, debugLogger, l1Artifacts);
}

/**
* Gets all contracts available in \@aztec/noir-contracts.
* @returns The contract ABIs.
Expand Down
3 changes: 0 additions & 3 deletions yarn-project/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
{
"path": "../foundation"
},
{
"path": "../l1-artifacts"
},
{
"path": "../noir-compiler"
},
Expand Down
Loading