From f2c6bb41da312c59a8b5c95c83210d5c1a6ba5e9 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Fri, 22 Sep 2023 12:56:51 +0000 Subject: [PATCH 1/2] expose registry address --- yarn-project/archiver/src/archiver/archiver.test.ts | 6 ++++-- yarn-project/archiver/src/archiver/archiver.ts | 7 +++++++ yarn-project/archiver/src/archiver/config.ts | 2 ++ yarn-project/archiver/src/index.ts | 10 +++++++++- yarn-project/aztec-node/src/aztec-node/server.ts | 4 ++++ .../aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts | 4 +++- yarn-project/aztec-sandbox/src/sandbox.ts | 1 + yarn-project/aztec.js/src/contract/contract.test.ts | 1 + .../src/e2e_public_cross_chain_messaging.test.ts | 1 - yarn-project/end-to-end/src/fixtures/utils.ts | 1 + .../end-to-end/src/integration_l1_publisher.test.ts | 4 ++++ yarn-project/p2p/src/client/mocks.ts | 8 ++++++++ yarn-project/sequencer-client/src/config.ts | 2 ++ yarn-project/types/src/interfaces/aztec-node.ts | 6 ++++++ yarn-project/types/src/interfaces/node-info.ts | 4 ++++ yarn-project/types/src/l1_addresses.ts | 5 +++++ yarn-project/types/src/l2_block_source.ts | 6 ++++++ 17 files changed, 67 insertions(+), 5 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 612223426a7..b3f0db13e55 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -12,8 +12,9 @@ import { Archiver } from './archiver.js'; import { ArchiverDataStore, MemoryArchiverStore } from './archiver_store.js'; describe('Archiver', () => { - const rollupAddress = '0x0000000000000000000000000000000000000000'; - const inboxAddress = '0x0000000000000000000000000000000000000000'; + const rollupAddress = EthAddress.ZERO.toString(); + const inboxAddress = EthAddress.ZERO.toString(); + const registryAddress = EthAddress.ZERO.toString(); const contractDeploymentEmitterAddress = '0x0000000000000000000000000000000000000001'; const blockNums = [1, 2, 3]; let publicClient: MockProxy>; @@ -29,6 +30,7 @@ describe('Archiver', () => { publicClient, EthAddress.fromString(rollupAddress), EthAddress.fromString(inboxAddress), + EthAddress.fromString(registryAddress), EthAddress.fromString(contractDeploymentEmitterAddress), 0, archiverStore, diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 6c88251805d..217df42dab6 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -65,6 +65,7 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource * @param publicClient - A client for interacting with the Ethereum node. * @param rollupAddress - Ethereum address of the rollup contract. * @param inboxAddress - Ethereum address of the inbox contract. + * @param registryAddress - Ethereum address of the registry contract. * @param contractDeploymentEmitterAddress - Ethereum address of the contractDeploymentEmitter contract. * @param searchStartBlock - The L1 block from which to start searching for new blocks. * @param pollingIntervalMs - The interval for polling for L1 logs (in milliseconds). @@ -75,6 +76,7 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource private readonly publicClient: PublicClient, private readonly rollupAddress: EthAddress, private readonly inboxAddress: EthAddress, + private readonly registryAddress: EthAddress, private readonly contractDeploymentEmitterAddress: EthAddress, searchStartBlock: number, private readonly store: ArchiverDataStore, @@ -103,6 +105,7 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource publicClient, config.rollupContract, config.inboxContract, + config.registryContract, config.contractDeploymentEmitterContract, config.searchStartBlock, archiverStore, @@ -264,6 +267,10 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource return Promise.resolve(this.rollupAddress); } + public getRegistryAddress(): Promise { + return Promise.resolve(this.registryAddress); + } + /** * Gets up to `limit` amount of L2 blocks starting from `from`. * @param from - Number of the first block to return (inclusive). diff --git a/yarn-project/archiver/src/archiver/config.ts b/yarn-project/archiver/src/archiver/config.ts index 675db4c278a..f6604d8c6f2 100644 --- a/yarn-project/archiver/src/archiver/config.ts +++ b/yarn-project/archiver/src/archiver/config.ts @@ -53,12 +53,14 @@ export function getConfigEnvVars(): ArchiverConfig { SEARCH_START_BLOCK, API_KEY, INBOX_CONTRACT_ADDRESS, + REGISTRY_CONTRACT_ADDRESS, } = process.env; return { rpcUrl: ETHEREUM_HOST || 'http://127.0.0.1:8545/', archiverPollingIntervalMS: ARCHIVER_POLLING_INTERVAL_MS ? +ARCHIVER_POLLING_INTERVAL_MS : 1_000, viemPollingIntervalMS: ARCHIVER_VIEM_POLLING_INTERVAL_MS ? +ARCHIVER_VIEM_POLLING_INTERVAL_MS : 1_000, rollupContract: ROLLUP_CONTRACT_ADDRESS ? EthAddress.fromString(ROLLUP_CONTRACT_ADDRESS) : EthAddress.ZERO, + registryContract: REGISTRY_CONTRACT_ADDRESS ? EthAddress.fromString(REGISTRY_CONTRACT_ADDRESS) : EthAddress.ZERO, inboxContract: INBOX_CONTRACT_ADDRESS ? EthAddress.fromString(INBOX_CONTRACT_ADDRESS) : EthAddress.ZERO, contractDeploymentEmitterContract: CONTRACT_DEPLOYMENT_EMITTER_ADDRESS ? EthAddress.fromString(CONTRACT_DEPLOYMENT_EMITTER_ADDRESS) diff --git a/yarn-project/archiver/src/index.ts b/yarn-project/archiver/src/index.ts index 1ab04d4c58e..d132e23af90 100644 --- a/yarn-project/archiver/src/index.ts +++ b/yarn-project/archiver/src/index.ts @@ -17,7 +17,14 @@ const log = createDebugLogger('aztec:archiver'); // eslint-disable-next-line require-await async function main() { const config = getConfigEnvVars(); - const { rpcUrl, rollupContract, inboxContract, contractDeploymentEmitterContract, searchStartBlock } = config; + const { + rpcUrl, + rollupContract, + inboxContract, + registryContract, + contractDeploymentEmitterContract, + searchStartBlock, + } = config; const publicClient = createPublicClient({ chain: localhost, @@ -30,6 +37,7 @@ async function main() { publicClient, rollupContract, inboxContract, + registryContract, contractDeploymentEmitterContract, searchStartBlock, archiverStore, diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index fcf509ff6cb..a2b3720b0a3 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -181,6 +181,10 @@ export class AztecNodeService implements AztecNode { return this.blockSource.getRollupAddress(); } + public getRegistryAddress(): Promise { + return this.blockSource.getRegistryAddress(); + } + /** * Get the extended contract data for this contract. * @param contractAddress - The contract data address. diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts index fe754f7c652..86555d6392b 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts @@ -337,10 +337,11 @@ export class AztecRPCServer implements AztecRPC { } public async getNodeInfo(): Promise { - const [version, chainId, rollupAddress] = await Promise.all([ + const [version, chainId, rollupAddress, registryAddress] = await Promise.all([ this.node.getVersion(), this.node.getChainId(), this.node.getRollupAddress(), + this.node.getRegistryAddress(), ]); return { @@ -349,6 +350,7 @@ export class AztecRPCServer implements AztecRPC { chainId, protocolVersion: version, rollupAddress, + registryAddress, }; } diff --git a/yarn-project/aztec-sandbox/src/sandbox.ts b/yarn-project/aztec-sandbox/src/sandbox.ts index 8d25be5a200..227cc7f6edb 100644 --- a/yarn-project/aztec-sandbox/src/sandbox.ts +++ b/yarn-project/aztec-sandbox/src/sandbox.ts @@ -70,6 +70,7 @@ export async function createSandbox(config: Partial = {}) { aztecNodeConfig.rollupContract = l1Contracts.rollupAddress; aztecNodeConfig.contractDeploymentEmitterContract = l1Contracts.contractDeploymentEmitterAddress; aztecNodeConfig.inboxContract = l1Contracts.inboxAddress; + aztecNodeConfig.registryContract = l1Contracts.registryAddress; const node = await AztecNodeService.createAndSync(aztecNodeConfig); const rpcServer = await createAztecRPCServer(node, rpcConfig); diff --git a/yarn-project/aztec.js/src/contract/contract.test.ts b/yarn-project/aztec.js/src/contract/contract.test.ts index 1df16e7de1f..a095b316b57 100644 --- a/yarn-project/aztec.js/src/contract/contract.test.ts +++ b/yarn-project/aztec.js/src/contract/contract.test.ts @@ -34,6 +34,7 @@ describe('Contract Class', () => { protocolVersion: 1, chainId: 2, rollupAddress: EthAddress.random(), + registryAddress: EthAddress.random(), }; const defaultAbi: ContractAbi = { diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index 5ec2453ae2a..68897f60a53 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -44,7 +44,6 @@ describe('e2e_public_cross_chain_messaging', () => { logger_, cheatCodes, ); - l2Token = crossChainTestHarness.l2Token; l2Bridge = crossChainTestHarness.l2Bridge; ownerEthAddress = crossChainTestHarness.ethAccount; diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index df49c2dc438..4c8d570e987 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -230,6 +230,7 @@ export async function setup( config.rollupContract = deployL1ContractsValues.rollupAddress; config.contractDeploymentEmitterContract = deployL1ContractsValues.contractDeploymentEmitterAddress; config.inboxContract = deployL1ContractsValues.inboxAddress; + config.registryContract = deployL1ContractsValues.registryAddress; const aztecNode = await createAztecNode(config, logger); diff --git a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts index 2ad33406c21..13bcd08e760 100644 --- a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts @@ -68,6 +68,7 @@ describe('L1Publisher integration', () => { let rollupAddress: Address; let inboxAddress: Address; let outboxAddress: Address; + let registryAddress: Address; let contractDeploymentEmitterAddress: Address; let decoderHelperAddress: Address; @@ -95,6 +96,7 @@ describe('L1Publisher integration', () => { rollupAddress: rollupAddress_, inboxAddress: inboxAddress_, outboxAddress: outboxAddress_, + registryAddress: registryAddress_, contractDeploymentEmitterAddress: contractDeploymentEmitterAddress_, decoderHelperAddress: decoderHelperAddress_, publicClient: publicClient_, @@ -105,6 +107,7 @@ describe('L1Publisher integration', () => { rollupAddress = getAddress(rollupAddress_.toString()); inboxAddress = getAddress(inboxAddress_.toString()); outboxAddress = getAddress(outboxAddress_.toString()); + registryAddress = getAddress(registryAddress_.toString()); contractDeploymentEmitterAddress = getAddress(contractDeploymentEmitterAddress_.toString()); decoderHelperAddress = getAddress(decoderHelperAddress_!.toString()); @@ -145,6 +148,7 @@ describe('L1Publisher integration', () => { requiredConfirmations: 1, rollupContract: EthAddress.fromString(rollupAddress), inboxContract: EthAddress.fromString(inboxAddress), + registryContract: EthAddress.fromString(registryAddress), contractDeploymentEmitterContract: EthAddress.fromString(contractDeploymentEmitterAddress), publisherPrivateKey: sequencerPK, l1BlockPublishRetryIntervalMS: 100, diff --git a/yarn-project/p2p/src/client/mocks.ts b/yarn-project/p2p/src/client/mocks.ts index e98a3c42a62..7face89993e 100644 --- a/yarn-project/p2p/src/client/mocks.ts +++ b/yarn-project/p2p/src/client/mocks.ts @@ -24,6 +24,14 @@ export class MockBlockSource implements L2BlockSource { return Promise.resolve(EthAddress.random()); } + /** + * Method to fetch the registry contract address at the base-layer. + * @returns The registry address. + */ + getRegistryAddress(): Promise { + return Promise.resolve(EthAddress.random()); + } + /** * Gets the number of the latest L2 block processed by the block source implementation. * @returns In this mock instance, returns the number of L2 blocks that we've mocked. diff --git a/yarn-project/sequencer-client/src/config.ts b/yarn-project/sequencer-client/src/config.ts index 9060a659c26..3a5540f97b3 100644 --- a/yarn-project/sequencer-client/src/config.ts +++ b/yarn-project/sequencer-client/src/config.ts @@ -25,6 +25,7 @@ export function getConfigEnvVars(): SequencerClientConfig { SEQ_MAX_TX_PER_BLOCK, SEQ_MIN_TX_PER_BLOCK, ROLLUP_CONTRACT_ADDRESS, + REGISTRY_CONTRACT_ADDRESS, INBOX_CONTRACT_ADDRESS, CONTRACT_DEPLOYMENT_EMITTER_ADDRESS, } = process.env; @@ -45,6 +46,7 @@ export function getConfigEnvVars(): SequencerClientConfig { transactionPollingIntervalMS: SEQ_TX_POLLING_INTERVAL_MS ? +SEQ_TX_POLLING_INTERVAL_MS : 1_000, rollupContract: ROLLUP_CONTRACT_ADDRESS ? EthAddress.fromString(ROLLUP_CONTRACT_ADDRESS) : EthAddress.ZERO, inboxContract: INBOX_CONTRACT_ADDRESS ? EthAddress.fromString(INBOX_CONTRACT_ADDRESS) : EthAddress.ZERO, + registryContract: REGISTRY_CONTRACT_ADDRESS ? EthAddress.fromString(REGISTRY_CONTRACT_ADDRESS) : EthAddress.ZERO, contractDeploymentEmitterContract: CONTRACT_DEPLOYMENT_EMITTER_ADDRESS ? EthAddress.fromString(CONTRACT_DEPLOYMENT_EMITTER_ADDRESS) : EthAddress.ZERO, diff --git a/yarn-project/types/src/interfaces/aztec-node.ts b/yarn-project/types/src/interfaces/aztec-node.ts index ed61b46a11d..bac696c3850 100644 --- a/yarn-project/types/src/interfaces/aztec-node.ts +++ b/yarn-project/types/src/interfaces/aztec-node.ts @@ -67,6 +67,12 @@ export interface AztecNode extends DataCommitmentProvider, L1ToL2MessageProvider */ getRollupAddress(): Promise; + /** + * Method to fetch the registry contract address at the base-layer. + * @returns The registry address. + */ + getRegistryAddress(): Promise; + /** * Get the extended contract data for this contract. * @param contractAddress - The contract data address. diff --git a/yarn-project/types/src/interfaces/node-info.ts b/yarn-project/types/src/interfaces/node-info.ts index 4037d4917ed..6c10d6b5ef8 100644 --- a/yarn-project/types/src/interfaces/node-info.ts +++ b/yarn-project/types/src/interfaces/node-info.ts @@ -24,4 +24,8 @@ export type NodeInfo = { * The rollup contract address */ rollupAddress: EthAddress; + /** + * The registry contract address + */ + registryAddress: EthAddress; }; diff --git a/yarn-project/types/src/l1_addresses.ts b/yarn-project/types/src/l1_addresses.ts index 3a9b9b77233..a85fb0f889a 100644 --- a/yarn-project/types/src/l1_addresses.ts +++ b/yarn-project/types/src/l1_addresses.ts @@ -14,6 +14,11 @@ export interface L1Addresses { */ inboxContract: EthAddress; + /** + * Registry contract address. + */ + registryContract: EthAddress; + /** * ContractDeploymentEmitter contract address. */ diff --git a/yarn-project/types/src/l2_block_source.ts b/yarn-project/types/src/l2_block_source.ts index 4541f730b0a..5da437eafeb 100644 --- a/yarn-project/types/src/l2_block_source.ts +++ b/yarn-project/types/src/l2_block_source.ts @@ -14,6 +14,12 @@ export interface L2BlockSource { */ getRollupAddress(): Promise; + /** + * Method to fetch the registry contract address at the base-layer. + * @returns The registry address. + */ + getRegistryAddress(): Promise; + /** * Gets the number of the latest L2 block processed by the block source implementation. * @returns The number of the latest L2 block processed by the block source implementation. From fdae7e0488be19e3c83ee3a45365c80e9ad6fbba Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Fri, 22 Sep 2023 15:20:12 +0000 Subject: [PATCH 2/2] skip browser test lol --- yarn-project/end-to-end/src/canary/browser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/end-to-end/src/canary/browser.ts b/yarn-project/end-to-end/src/canary/browser.ts index 42354dc6f90..c4f2506b59d 100644 --- a/yarn-project/end-to-end/src/canary/browser.ts +++ b/yarn-project/end-to-end/src/canary/browser.ts @@ -27,11 +27,11 @@ const PORT = 3000; const { SANDBOX_URL } = process.env; -const conditionalDescribe = () => (SANDBOX_URL ? describe : describe.skip); +// const conditionalDescribe = () => (SANDBOX_URL ? describe: describe.skip); const privKey = AztecJs.GrumpkinScalar.random(); export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugLogger) => - conditionalDescribe()('e2e_aztec.js_browser', () => { + describe.skip('e2e_aztec.js_browser', () => { const initialBalance = 33n; const transferAmount = 3n;