diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 612223426a70..b3f0db13e556 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 6c88251805d5..217df42dab63 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 675db4c278aa..f6604d8c6f2e 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 1ab04d4c58e6..d132e23af902 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/http-node.test.ts b/yarn-project/aztec-node/src/aztec-node/http-node.test.ts index fdf5d2b5522e..42ad91c27f8a 100644 --- a/yarn-project/aztec-node/src/aztec-node/http-node.test.ts +++ b/yarn-project/aztec-node/src/aztec-node/http-node.test.ts @@ -159,6 +159,19 @@ describe('HttpNode', () => { }); }); + describe('getRegistryAddress', () => { + it('should fetch and return the registry address', async () => { + const addr = EthAddress.random(); + const response = { registryAddress: addr.toString() }; + setFetchMock(response); + + const result = await httpNode.getRegistryAddress(); + + expect(fetch).toHaveBeenCalledWith(`${TEST_URL}get-registry-address`); + expect(result).toEqual(addr); + }); + }); + describe('getExtendedContractData', () => { it('should fetch and return contract public data', async () => { const extendedContractData = ExtendedContractData.random(); diff --git a/yarn-project/aztec-node/src/aztec-node/http-node.ts b/yarn-project/aztec-node/src/aztec-node/http-node.ts index 52f1d898cfa9..b0500b0b8918 100644 --- a/yarn-project/aztec-node/src/aztec-node/http-node.ts +++ b/yarn-project/aztec-node/src/aztec-node/http-node.ts @@ -109,6 +109,13 @@ export class HttpNode implements AztecNode { return EthAddress.fromString(respJson.rollupAddress); } + public async getRegistryAddress(): Promise { + const url = new URL(`${this.baseUrl}/get-registry-address`); + const response = await fetch(url.toString()); + const respJson = await response.json(); + return EthAddress.fromString(respJson.registryAddress); + } + /** * Method to fetch the chain id of the base-layer for the rollup. * @returns The chain id. diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index f457247f9dbb..82c75cdd940a 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 fe754f7c6521..86555d6392b9 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 8d25be5a2007..227cc7f6edbd 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 1df16e7de1f8..a095b316b571 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 5ec2453ae2a4..68897f60a53d 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 df49c2dc438b..4c8d570e9873 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 2ad33406c216..13bcd08e7608 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 e98a3c42a62c..7face89993ed 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/rollup-provider/src/app.ts b/yarn-project/rollup-provider/src/app.ts index 7b1cf70ca746..5a870b5b28ac 100644 --- a/yarn-project/rollup-provider/src/app.ts +++ b/yarn-project/rollup-provider/src/app.ts @@ -114,6 +114,14 @@ export function appFactory(node: AztecNode, prefix: string) { ctx.status = 200; }); + router.get('/get-registry-address', async (ctx: Koa.Context) => { + ctx.set('content-type', 'application/json'); + ctx.body = { + registryAddress: (await node.getRegistryAddress()).toString(), + }; + ctx.status = 200; + }); + router.get('/contract-data-and-bytecode', async (ctx: Koa.Context) => { const address = ctx.query.address; ctx.set('content-type', 'application/json'); diff --git a/yarn-project/sequencer-client/src/config.ts b/yarn-project/sequencer-client/src/config.ts index 9060a659c269..3a5540f97b33 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 ed61b46a11df..bac696c38502 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 4037d4917ed8..6c10d6b5ef86 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 3a9b9b772335..a85fb0f889ac 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 4541f730b0ad..5da437eafebe 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.