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..3b2faedff928 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 @@ -127,7 +127,7 @@ describe('HttpNode', () => { const response = { version: 5 }; setFetchMock(response); - const result = await httpNode.getVersion(); + const result = await httpNode.getL2ChainId(); expect(fetch).toHaveBeenCalledWith(`${TEST_URL}get-version`); expect(result).toBe(5); @@ -139,7 +139,7 @@ describe('HttpNode', () => { const response = { chainId: 1234 }; setFetchMock(response); - const result = await httpNode.getChainId(); + const result = await httpNode.getL1ChainId(); expect(fetch).toHaveBeenCalledWith(`${TEST_URL}get-chain-id`); expect(result).toBe(1234); 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..aed41124b909 100644 --- a/yarn-project/aztec-node/src/aztec-node/http-node.ts +++ b/yarn-project/aztec-node/src/aztec-node/http-node.ts @@ -95,7 +95,7 @@ export class HttpNode implements AztecNode { * Method to fetch the version of the rollup the node is connected to. * @returns The rollup version. */ - public async getVersion(): Promise { + public async getL2ChainId(): Promise { const url = new URL(`${this.baseUrl}/get-version`); const response = await fetch(url.toString()); const respJson = await response.json(); @@ -113,7 +113,7 @@ export class HttpNode implements AztecNode { * Method to fetch the chain id of the base-layer for the rollup. * @returns The chain id. */ - public async getChainId(): Promise { + public async getL1ChainId(): Promise { const url = new URL(`${this.baseUrl}/get-chain-id`); const response = await fetch(url.toString()); const respJson = await response.json(); diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index f457247f9dbb..e68d8efb5901 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -161,7 +161,7 @@ export class AztecNodeService implements AztecNode { * Method to fetch the version of the rollup the node is connected to. * @returns The rollup version. */ - public getVersion(): Promise { + public getL2ChainId(): Promise { return Promise.resolve(this.version); } @@ -169,7 +169,7 @@ export class AztecNodeService implements AztecNode { * Method to fetch the chain id of the base-layer for the rollup. * @returns The chain id. */ - public getChainId(): Promise { + public getL1ChainId(): Promise { return Promise.resolve(this.chainId); } 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 cd51cd006c27..6e603413d4ac 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 @@ -68,7 +68,7 @@ export class AztecRPCServer implements AztecRPC { private contractDataOracle: ContractDataOracle; private simulator: AcirSimulator; private log: DebugLogger; - private clientInfo: string; + private sandboxVersion: string; constructor( private keyStore: KeyStore, @@ -82,8 +82,7 @@ export class AztecRPCServer implements AztecRPC { this.contractDataOracle = new ContractDataOracle(db, node); this.simulator = getAcirSimulator(db, node, node, node, keyStore, this.contractDataOracle); - const { version, name } = getPackageInfo(); - this.clientInfo = `${name.split('/')[name.split('/').length - 1]}@${version}`; + this.sandboxVersion = getPackageInfo().version; } /** @@ -94,7 +93,9 @@ export class AztecRPCServer implements AztecRPC { public async start() { await this.synchroniser.start(INITIAL_L2_BLOCK_NUM, 1, this.config.l2BlockPollingIntervalMS); const info = await this.getNodeInfo(); - this.log.info(`Started RPC server connected to chain ${info.chainId} version ${info.version}`); + this.log.info( + `Started RPC server connected to L1 chain ${info.l1ChainId} and running L2 chain with id ${info.l2ChainId}`, + ); } /** @@ -338,18 +339,18 @@ export class AztecRPCServer implements AztecRPC { } public async getNodeInfo(): Promise { - const [version, chainId, rollupAddress] = await Promise.all([ - this.node.getVersion(), - this.node.getChainId(), + const [l2ChainId, l1ChainId, rollupAddress] = await Promise.all([ + this.node.getL2ChainId(), + this.node.getL1ChainId(), this.node.getRollupAddress(), ]); return { - version, - chainId, - rollupAddress, - client: this.clientInfo, + sandboxVersion: this.sandboxVersion, compatibleNargoVersion: NoirVersion.tag, + l1ChainId, + l2ChainId, + rollupAddress, }; } diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_server.test.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_server.test.ts index 99adad75081f..72c7731b02bc 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_server.test.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_server.test.ts @@ -19,8 +19,8 @@ async function createAztecRpcServer(): Promise { // Setup the relevant mocks node.getBlockNumber.mockResolvedValue(2); - node.getVersion.mockResolvedValue(1); - node.getChainId.mockResolvedValue(1); + node.getL2ChainId.mockResolvedValue(1); + node.getL1ChainId.mockResolvedValue(1); node.getRollupAddress.mockResolvedValue(EthAddress.random()); return new AztecRPCServer(keyStore, node, db, config); diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts index 1ebf9aea8af7..e033cdfaca94 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts @@ -133,8 +133,8 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise it('successfully gets node info', async () => { const nodeInfo = await rpc.getNodeInfo(); - expect(typeof nodeInfo.version).toEqual('number'); - expect(typeof nodeInfo.chainId).toEqual('number'); + expect(typeof nodeInfo.l2ChainId).toEqual('number'); + expect(typeof nodeInfo.l1ChainId).toEqual('number'); expect(nodeInfo.rollupAddress.toString()).toMatch(/0x[a-fA-F0-9]+/); }); diff --git a/yarn-project/aztec.js/src/account/defaults/default_interface.ts b/yarn-project/aztec.js/src/account/defaults/default_interface.ts index 515216ba3266..f9eae8bc8d29 100644 --- a/yarn-project/aztec.js/src/account/defaults/default_interface.ts +++ b/yarn-project/aztec.js/src/account/defaults/default_interface.ts @@ -14,13 +14,13 @@ export class DefaultAccountInterface implements AccountInterface { constructor( private authWitnessProvider: AuthWitnessProvider, private address: CompleteAddress, - nodeInfo: Pick, + nodeInfo: Pick, ) { this.entrypoint = new DefaultAccountEntrypoint( address.address, authWitnessProvider, - nodeInfo.chainId, - nodeInfo.version, + nodeInfo.l1ChainId, + nodeInfo.l2ChainId, ); } diff --git a/yarn-project/aztec.js/src/contract/contract.test.ts b/yarn-project/aztec.js/src/contract/contract.test.ts index 8c450c7429c0..ddbde9071bd3 100644 --- a/yarn-project/aztec.js/src/contract/contract.test.ts +++ b/yarn-project/aztec.js/src/contract/contract.test.ts @@ -29,11 +29,11 @@ describe('Contract Class', () => { const mockTxReceipt = { type: 'TxReceipt' } as any as TxReceipt; const mockViewResultValue = 1; const mockNodeInfo: NodeInfo = { - version: 1, - chainId: 2, - rollupAddress: EthAddress.random(), - client: '', + sandboxVersion: '', compatibleNargoVersion: 'vx.x.x-aztec.x', + l1ChainId: 2, + l2ChainId: 1, + rollupAddress: EthAddress.random(), }; const defaultAbi: ContractAbi = { diff --git a/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts b/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts index 34ad5bf71d4c..fd3802b7e481 100644 --- a/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts +++ b/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts @@ -60,7 +60,7 @@ export class DeployMethod extends Bas const portalContract = options.portalContract ?? EthAddress.ZERO; const contractAddressSalt = options.contractAddressSalt ?? Fr.random(); - const { chainId, version } = await this.rpc.getNodeInfo(); + const { l1ChainId, l2ChainId } = await this.rpc.getNodeInfo(); const { completeAddress, constructorHash, functionTreeRoot } = await getContractDeploymentInfo( this.abi, @@ -77,7 +77,7 @@ export class DeployMethod extends Bas portalContract, ); - const txContext = new TxContext(false, false, true, contractDeploymentData, new Fr(chainId), new Fr(version)); + const txContext = new TxContext(false, false, true, contractDeploymentData, new Fr(l1ChainId), new Fr(l2ChainId)); const args = encodeArguments(this.constructorAbi, this.args); const functionData = FunctionData.fromAbi(this.constructorAbi); const execution = { args, functionData, to: completeAddress.address }; diff --git a/yarn-project/aztec.js/src/wallet/signerless_wallet.ts b/yarn-project/aztec.js/src/wallet/signerless_wallet.ts index 6f98f8f9498c..cd37f5e9be73 100644 --- a/yarn-project/aztec.js/src/wallet/signerless_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/signerless_wallet.ts @@ -15,8 +15,8 @@ export class SignerlessWallet extends BaseWallet { const [execution] = executions; const wasm = await CircuitsWasm.get(); const packedArguments = await PackedArguments.fromArgs(execution.args, wasm); - const { chainId, version } = await this.rpc.getNodeInfo(); - const txContext = TxContext.empty(chainId, version); + const { l1ChainId, l2ChainId } = await this.rpc.getNodeInfo(); + const txContext = TxContext.empty(l1ChainId, l2ChainId); return Promise.resolve( new TxExecutionRequest( execution.to, diff --git a/yarn-project/cli/src/client.test.ts b/yarn-project/cli/src/client.test.ts index d4e6de3fdb94..10a8445acf93 100644 --- a/yarn-project/cli/src/client.test.ts +++ b/yarn-project/cli/src/client.test.ts @@ -13,19 +13,19 @@ describe('client', () => { }); it('checks versions match', async () => { - rpc.getNodeInfo.mockResolvedValue({ client: 'rpc@0.1.0-alpha47' } as NodeInfo); + rpc.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha47' } as NodeInfo); await checkServerVersion(rpc, '0.1.0-alpha47'); }); it('reports mismatch on older rpc version', async () => { - rpc.getNodeInfo.mockResolvedValue({ client: 'rpc@0.1.0-alpha47' } as NodeInfo); + rpc.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha47' } as NodeInfo); await expect(checkServerVersion(rpc, '0.1.0-alpha48')).rejects.toThrowError( /is older than the expected by this CLI/, ); }); it('reports mismatch on newer rpc version', async () => { - rpc.getNodeInfo.mockResolvedValue({ client: 'rpc@0.1.0-alpha48' } as NodeInfo); + rpc.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha48' } as NodeInfo); await expect(checkServerVersion(rpc, '0.1.0-alpha47')).rejects.toThrowError( /is newer than the expected by this CLI/, ); diff --git a/yarn-project/cli/src/client.ts b/yarn-project/cli/src/client.ts index 26dd39a44312..d2a297580a7e 100644 --- a/yarn-project/cli/src/client.ts +++ b/yarn-project/cli/src/client.ts @@ -51,25 +51,26 @@ class VersionMismatchError extends Error {} */ export async function checkServerVersion(rpc: AztecRPC, expectedVersionRange: string) { const serverName = 'Aztec Sandbox'; - const { client } = await rpc.getNodeInfo(); - if (!client) { + const { sandboxVersion } = await rpc.getNodeInfo(); + if (!sandboxVersion) { throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`); } - const version = client.split('@')[1]; - if (!version || !valid(version)) { - throw new VersionMismatchError(`Missing or invalid version identifier for ${serverName} (${version ?? 'empty'}).`); - } else if (!satisfies(version, expectedVersionRange)) { - if (gtr(version, expectedVersionRange)) { + if (!sandboxVersion || !valid(sandboxVersion)) { + throw new VersionMismatchError( + `Missing or invalid version identifier for ${serverName} (${sandboxVersion ?? 'empty'}).`, + ); + } else if (!satisfies(sandboxVersion, expectedVersionRange)) { + if (gtr(sandboxVersion, expectedVersionRange)) { throw new VersionMismatchError( - `${serverName} is running version ${version} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`, + `${serverName} is running version ${sandboxVersion} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`, ); - } else if (ltr(version, expectedVersionRange)) { + } else if (ltr(sandboxVersion, expectedVersionRange)) { throw new VersionMismatchError( - `${serverName} is running version ${version} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`, + `${serverName} is running version ${sandboxVersion} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`, ); } else { throw new VersionMismatchError( - `${serverName} is running version ${version} which does not match the expected by this CLI (${expectedVersionRange}).`, + `${serverName} is running version ${sandboxVersion} which does not match the expected by this CLI (${expectedVersionRange}).`, ); } } diff --git a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts index 0e4058a2015d..bc77058f089f 100644 --- a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts +++ b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts @@ -42,8 +42,8 @@ describe('e2e_sandbox_example', () => { logger('Aztec Sandbox Info ', nodeInfo); // docs:end:setup - expect(typeof nodeInfo.version).toBe('number'); - expect(typeof nodeInfo.chainId).toBe('number'); + expect(typeof nodeInfo.l2ChainId).toBe('number'); + expect(typeof nodeInfo.l1ChainId).toBe('number'); expect(typeof nodeInfo.rollupAddress).toBe('object'); // docs:start:Accounts diff --git a/yarn-project/rollup-provider/src/app.ts b/yarn-project/rollup-provider/src/app.ts index 7b1cf70ca746..73b49220fcb7 100644 --- a/yarn-project/rollup-provider/src/app.ts +++ b/yarn-project/rollup-provider/src/app.ts @@ -93,7 +93,7 @@ export function appFactory(node: AztecNode, prefix: string) { router.get('/get-version', async (ctx: Koa.Context) => { ctx.set('content-type', 'application/json'); ctx.body = { - version: await node.getVersion(), + version: await node.getL2ChainId(), }; ctx.status = 200; }); @@ -101,7 +101,7 @@ export function appFactory(node: AztecNode, prefix: string) { router.get('/get-chain-id', async (ctx: Koa.Context) => { ctx.set('content-type', 'application/json'); ctx.body = { - chainId: await node.getChainId(), + chainId: await node.getL1ChainId(), }; ctx.status = 200; }); diff --git a/yarn-project/types/src/interfaces/aztec-node.ts b/yarn-project/types/src/interfaces/aztec-node.ts index ed61b46a11df..ab7abeb484c9 100644 --- a/yarn-project/types/src/interfaces/aztec-node.ts +++ b/yarn-project/types/src/interfaces/aztec-node.ts @@ -50,16 +50,16 @@ export interface AztecNode extends DataCommitmentProvider, L1ToL2MessageProvider getBlockNumber(): Promise; /** - * Method to fetch the version of the rollup the node is connected to. - * @returns The rollup version. + * Method to fetch L2 chain id of the network the node is connected to. + * @returns The L2 chain id. */ - getVersion(): Promise; + getL2ChainId(): Promise; /** - * Method to fetch the chain id of the base-layer for the rollup. - * @returns The chain id. + * Method to fetch the chain id of L1 used for settlement. + * @returns The L1 chain id. */ - getChainId(): Promise; + getL1ChainId(): Promise; /** * Method to fetch the rollup contract address at the base-layer. diff --git a/yarn-project/types/src/interfaces/aztec_rpc.ts b/yarn-project/types/src/interfaces/aztec_rpc.ts index fbd009689252..79c66e1e7969 100644 --- a/yarn-project/types/src/interfaces/aztec_rpc.ts +++ b/yarn-project/types/src/interfaces/aztec_rpc.ts @@ -37,25 +37,25 @@ export interface DeployedContract { */ export type NodeInfo = { /** - * The version number of the node. + * Version as tracked in the aztec-packages repository. */ - version: number; + sandboxVersion: string; /** - * The network's chain id. + * The nargo version compatible with this sandbox version */ - chainId: number; + compatibleNargoVersion: string; /** - * The rollup contract address + * L1 chain id. */ - rollupAddress: EthAddress; + l1ChainId: number; /** - * Identifier of the client software. + * L2 chain id. */ - client: string; + l2ChainId: number; /** - * The nargo version compatible with this node. + * The rollup contract address */ - compatibleNargoVersion: string; + rollupAddress: EthAddress; }; /** Provides up to which block has been synced by different components. */