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: expose registry address in getNodeInfo #2478

Merged
merged 2 commits into from
Sep 22, 2023
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
6 changes: 4 additions & 2 deletions yarn-project/archiver/src/archiver/archiver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PublicClient<HttpTransport, Chain>>;
Expand All @@ -29,6 +30,7 @@ describe('Archiver', () => {
publicClient,
EthAddress.fromString(rollupAddress),
EthAddress.fromString(inboxAddress),
EthAddress.fromString(registryAddress),
EthAddress.fromString(contractDeploymentEmitterAddress),
0,
archiverStore,
Expand Down
7 changes: 7 additions & 0 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -75,6 +76,7 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource
private readonly publicClient: PublicClient<HttpTransport, Chain>,
private readonly rollupAddress: EthAddress,
private readonly inboxAddress: EthAddress,
private readonly registryAddress: EthAddress,
private readonly contractDeploymentEmitterAddress: EthAddress,
searchStartBlock: number,
private readonly store: ArchiverDataStore,
Expand Down Expand Up @@ -103,6 +105,7 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource
publicClient,
config.rollupContract,
config.inboxContract,
config.registryContract,
config.contractDeploymentEmitterContract,
config.searchStartBlock,
archiverStore,
Expand Down Expand Up @@ -264,6 +267,10 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource
return Promise.resolve(this.rollupAddress);
}

public getRegistryAddress(): Promise<EthAddress> {
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).
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/archiver/src/archiver/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/archiver/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -30,6 +37,7 @@ async function main() {
publicClient,
rollupContract,
inboxContract,
registryContract,
contractDeploymentEmitterContract,
searchStartBlock,
archiverStore,
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export class AztecNodeService implements AztecNode {
return this.blockSource.getRollupAddress();
}

public getRegistryAddress(): Promise<EthAddress> {
return this.blockSource.getRegistryAddress();
}

/**
* Get the extended contract data for this contract.
* @param contractAddress - The contract data address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,11 @@ export class AztecRPCServer implements AztecRPC {
}

public async getNodeInfo(): Promise<NodeInfo> {
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 {
Expand All @@ -349,6 +350,7 @@ export class AztecRPCServer implements AztecRPC {
chainId,
protocolVersion: version,
rollupAddress,
registryAddress,
};
}

Expand Down
1 change: 1 addition & 0 deletions yarn-project/aztec-sandbox/src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}) {
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);
Expand Down
1 change: 1 addition & 0 deletions yarn-project/aztec.js/src/contract/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Contract Class', () => {
protocolVersion: 1,
chainId: 2,
rollupAddress: EthAddress.random(),
registryAddress: EthAddress.random(),
};

const defaultAbi: ContractAbi = {
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/canary/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('e2e_public_cross_chain_messaging', () => {
logger_,
cheatCodes,
);

l2Token = crossChainTestHarness.l2Token;
l2Bridge = crossChainTestHarness.l2Bridge;
ownerEthAddress = crossChainTestHarness.ethAccount;
Expand Down
1 change: 1 addition & 0 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions yarn-project/end-to-end/src/integration_l1_publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -95,6 +96,7 @@ describe('L1Publisher integration', () => {
rollupAddress: rollupAddress_,
inboxAddress: inboxAddress_,
outboxAddress: outboxAddress_,
registryAddress: registryAddress_,
contractDeploymentEmitterAddress: contractDeploymentEmitterAddress_,
decoderHelperAddress: decoderHelperAddress_,
publicClient: publicClient_,
Expand All @@ -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());

Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions yarn-project/p2p/src/client/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EthAddress> {
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.
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/sequencer-client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions yarn-project/types/src/interfaces/aztec-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export interface AztecNode extends DataCommitmentProvider, L1ToL2MessageProvider
*/
getRollupAddress(): Promise<EthAddress>;

/**
* Method to fetch the registry contract address at the base-layer.
* @returns The registry address.
*/
getRegistryAddress(): Promise<EthAddress>;

/**
* Get the extended contract data for this contract.
* @param contractAddress - The contract data address.
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/types/src/interfaces/node-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ export type NodeInfo = {
* The rollup contract address
*/
rollupAddress: EthAddress;
/**
* The registry contract address
*/
registryAddress: EthAddress;
};
5 changes: 5 additions & 0 deletions yarn-project/types/src/l1_addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export interface L1Addresses {
*/
inboxContract: EthAddress;

/**
* Registry contract address.
*/
registryContract: EthAddress;

/**
* ContractDeploymentEmitter contract address.
*/
Expand Down
6 changes: 6 additions & 0 deletions yarn-project/types/src/l2_block_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export interface L2BlockSource {
*/
getRollupAddress(): Promise<EthAddress>;

/**
* Method to fetch the registry contract address at the base-layer.
* @returns The registry address.
*/
getRegistryAddress(): Promise<EthAddress>;

/**
* 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.
Expand Down