Skip to content

Commit

Permalink
fix: cli l1-chain-id option (#7490)
Browse files Browse the repository at this point in the history
Please read [contributing guidelines](CONTRIBUTING.md) and remove this
line.
  • Loading branch information
spypsy authored Jul 16, 2024
1 parent f1216a7 commit 307bc57
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 28 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
script: |
const { execSync } = require('child_process');
const changedFiles = execSync('git diff --name-only ${{ github.event.before }} ${{ github.sha }}').toString().split('\n');
const fileChanged = changedFiles.includes('l1-contracts/REDEPLOY');
const fileChanged = changedFiles.some(file => file.startsWith('l1-contracts'));
return fileChanged
- name: Check if mainnet fork needs deployment
Expand All @@ -77,6 +77,12 @@ jobs:
const fileChanged = changedFiles.some(file => file.startsWith('iac/mainnet-fork'));
return fileChanged
- name: Build & push mainnet fork image
if: steps.check_fork_changes.outputs.result == 'true'
run: |
earthly-ci \
--no-output --push ./iac/mainnet-fork+export-mainnet-fork --DIST_TAG=${{ env.DEPLOY_TAG }}
terraform_deploy:
runs-on: ubuntu-latest
needs: build
Expand Down Expand Up @@ -116,7 +122,7 @@ jobs:
docker run aztecprotocol/aztec:${{ env.DEPLOY_TAG }} deploy-l1-contracts \
--private-key ${{ secrets.SEQ_1_PUBLISHER_PRIVATE_KEY }} \
--rpc-url https://${{ env.DEPLOY_TAG }}-mainnet-fork.aztec.network:8545/${{ secrets.FORK_API_KEY }} \
--chain-id ${{ env.L1_CHAIN_ID }} \
--l1-chain-id ${{ env.L1_CHAIN_ID }} \
| tee ${{ env.FILE_PATH }}
./.github/scripts/extract_l1_addresses.sh ${{ env.FILE_PATH }}
Expand Down
2 changes: 1 addition & 1 deletion iac/mainnet-fork/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ build:

export-mainnet-fork:
FROM +build
ARG DIST_TAG="aztec-dev"
ARG DIST_TAG="devnet"
ARG ARCH
SAVE IMAGE --push aztecprotocol/mainnet-fork:${DIST_TAG}${ARCH:+-$ARCH}
2 changes: 1 addition & 1 deletion iac/mainnet-fork/scripts/run_nginx_anvil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo "stripping double quotations from the mnemonic seed phrase: ${MNEMONIC:0:10
MNEMONIC_STRIPPED=${MNEMONIC//\"/}
echo "result: ${MNEMONIC_STRIPPED:0:10}..."

# Data directory for anvil state
# Data directory for anvil state.
mkdir -p /data

# Run anvil silently
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/REDEPLOY
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Change value to force redeploy
2
1
2 changes: 1 addition & 1 deletion yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class Archiver implements ArchiveSource {
telemetry: TelemetryClient,
blockUntilSynced = true,
): Promise<Archiver> {
const chain = createEthereumChain(config.rpcUrl);
const chain = createEthereumChain(config.rpcUrl, config.l1ChainId);
const publicClient = createPublicClient({
chain: chain.chainInfo,
transport: http(chain.rpcUrl),
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/archiver/src/archiver/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface ArchiverConfig {
/**
* The L1 chain's ID
*/
l1ChainId?: number;
l1ChainId: number;

/**
* The polling interval in ms for retrieving new L2 blocks and encrypted logs.
Expand Down
7 changes: 3 additions & 4 deletions yarn-project/aztec/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
let services: ServerList = [];

if (options.sandbox) {
// If no CLI arguments were provided, run aztec full node for sandbox usage.
userLog(`${splash}\n${github}\n\n`);
userLog(`Setting up Aztec Sandbox, please stand by...`);
const { aztecNodeConfig, node, pxe, stop } = await createSandbox({
Expand Down Expand Up @@ -108,12 +107,12 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
program.addHelpText(
'after',
`
Additional commands:
test [options]: starts a dockerized TXE node via
test [options]: starts a dockerized TXE node via
$ aztec start --txe
then runs
then runs
$ aztec-nargo test --silence-warnings --use-legacy --oracle-resolver=<TXE_ADDRESS> [options]
`,
);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ aztec-cli deploy-l1-contracts [rpcUrl] [options]
Options:
- `-a, --chain-id <string>`: Chain ID for the Ethereum host.
- `-a, --l1-chain-id <string>`: Chain ID for the Ethereum host.
- `-p, --private-key <string>`: The private key to use for deployment.
- `-m, --mnemonic <string>`: The mnemonic to use in deployment. Default: `test test test test test test test test test test test junk`.
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/cli/src/cmds/infrastructure/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const waitOpts: WaitOpts = {
interval: 1,
};

export async function bootstrap(rpcUrl: string, log: LogFn) {
export async function bootstrap(rpcUrl: string, l1ChainId: number, log: LogFn) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment
const { GasTokenContract, KeyRegistryContract } = await import('@aztec/noir-contracts.js');

const pxe = createPXEClient(rpcUrl, makeFetch([], true));
const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(31337, 1));
const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(l1ChainId, 1));

const canonicalKeyRegistry = getCanonicalKeyRegistry();
const keyRegistryDeployParams = {
Expand Down
9 changes: 5 additions & 4 deletions yarn-project/cli/src/cmds/infrastructure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { type DebugLogger, type LogFn } from '@aztec/foundation/log';

import { type Command } from 'commander';

import { ETHEREUM_HOST, chainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js';
import { ETHEREUM_HOST, l1ChainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js';

export function injectCommands(program: Command, log: LogFn, debugLogger: DebugLogger) {
program
.command('bootstrap')
.description('Bootstrap the blockchain')
.addOption(pxeOption)
.addOption(l1ChainIdOption)
.action(async options => {
const { bootstrap } = await import('./bootstrap.js');
await bootstrap(options.rpcUrl, log);
await bootstrap(options.rpcUrl, options.l1ChainId, log);
});

program
Expand All @@ -31,7 +32,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
)
.option('--block-number <number>', 'Block number to query next sequencer for', parseOptionalInteger)
.addOption(pxeOption)
.addOption(chainIdOption)
.addOption(l1ChainIdOption)
.action(async (command, who, options) => {
const { sequencers } = await import('./sequencers.js');
await sequencers({
Expand All @@ -40,7 +41,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
mnemonic: options.mnemonic,
rpcUrl: options.rpcUrl,
l1RpcUrl: options.l1RpcUrl,
chainId: options.chainId ?? '',
chainId: options.l1ChainId,
blockNumber: options.blockNumber,
log,
debugLogger,
Expand Down
21 changes: 14 additions & 7 deletions yarn-project/cli/src/cmds/l1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type Command } from 'commander';
import {
ETHEREUM_HOST,
PRIVATE_KEY,
chainIdOption,
l1ChainIdOption,
parseAztecAddress,
parseBigint,
parseEthereumAddress,
Expand All @@ -27,10 +27,17 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
'The mnemonic to use in deployment',
'test test test test test test test test test test test junk',
)
.addOption(chainIdOption)
.addOption(l1ChainIdOption)
.action(async options => {
const { deployL1Contracts } = await import('./deploy_l1_contracts.js');
await deployL1Contracts(options.rpcUrl, options.chainId, options.privateKey, options.mnemonic, log, debugLogger);
await deployL1Contracts(
options.rpcUrl,
options.l1ChainId,
options.privateKey,
options.mnemonic,
log,
debugLogger,
);
});

program
Expand Down Expand Up @@ -92,15 +99,15 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
'test test test test test test test test test test test junk',
)
.addOption(pxeOption)
.addOption(chainIdOption)
.addOption(l1ChainIdOption)
.action(async (amount, recipient, options) => {
const { bridgeL1Gas } = await import('./bridge_l1_gas.js');
await bridgeL1Gas(
amount,
recipient,
options.rpcUrl,
options.l1RpcUrl,
options.chainId,
options.l1ChainId,
options.mnemonic,
log,
debugLogger,
Expand All @@ -117,10 +124,10 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
ETHEREUM_HOST,
)
.addOption(pxeOption)
.addOption(chainIdOption)
.addOption(l1ChainIdOption)
.action(async (who, options) => {
const { getL1Balance } = await import('./get_l1_balance.js');
await getL1Balance(who, options.rpcUrl, options.l1RpcUrl, options.chainId, log, debugLogger);
await getL1Balance(who, options.rpcUrl, options.l1RpcUrl, options.l1ChainId, log, debugLogger);
});

return program;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/src/utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const pxeOption = new Option('-u, --rpc-url <string>', 'URL of the PXE')
.default(`http://${LOCALHOST}:8080`)
.makeOptionMandatory(true);

export const chainIdOption = new Option('-c, --l1-chain-id <number>', 'Chain ID of the ethereum host')
export const l1ChainIdOption = new Option('-c, --l1-chain-id <number>', 'Chain ID of the ethereum host')
.env('L1_CHAIN_ID')
.default('31337')
.argParser(value => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe('L1Publisher integration', () => {
l1Contracts: l1ContractAddresses,
publisherPrivateKey: sequencerPK,
l1BlockPublishRetryIntervalMS: 100,
l1ChainId: 31337,
});

coinbase = config.coinbase || EthAddress.random();
Expand Down
8 changes: 7 additions & 1 deletion yarn-project/ethereum/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ export * from './constants.js';
* @param rpcUrl - The rpc url of the chain or a chain identifier (e.g. 'testnet')
* @param apiKey - An optional API key for the chain client.
*/
export function createEthereumChain(rpcUrl: string, chainId?: number) {
export function createEthereumChain(rpcUrl: string, _chainId: number | string) {
let chainId: number;
if (typeof _chainId === 'string') {
chainId = +_chainId;
} else {
chainId = _chainId;
}
if (chainId) {
return {
chainInfo: {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/sequencer-client/src/publisher/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface TxSenderConfig {
/**
* The chain ID of the ethereum host.
*/
l1ChainId?: number;
l1ChainId: number;

/**
* The number of confirmations required.
Expand Down

0 comments on commit 307bc57

Please sign in to comment.