Skip to content

Commit

Permalink
expose registry address
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-kothari committed Sep 22, 2023
1 parent 85e504c commit 2ccd3f5
Show file tree
Hide file tree
Showing 39 changed files with 539 additions and 439 deletions.
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
13 changes: 13 additions & 0 deletions yarn-project/aztec-node/src/aztec-node/http-node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions yarn-project/aztec-node/src/aztec-node/http-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ export class HttpNode implements AztecNode {
return EthAddress.fromString(respJson.rollupAddress);
}

public async getRegistryAddress(): Promise<EthAddress> {
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.
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
Original file line number Diff line number Diff line change
@@ -1,67 +1,66 @@
.input {
border: none;
outline-width: 0;
outline-color: rgba(0, 0, 0, 0);
padding: 2px 20px 0 20px;
width: 100%;
height: 45px;
color: #000;
border: 1px solid rgba(0, 0, 0, 0);
font-size: 16px;
text-align: left;
font-weight: 400;
border-radius: 10px;
text-align: left;
text-overflow: ellipsis;
transition: box-shadow .2s;
box-shadow: 0px 4px 10px rgba(0, 0, 0, .1);
background-color: white;
-webkit-appearance: none;
border: none;
outline-width: 0;
outline-color: rgba(0, 0, 0, 0);
padding: 2px 20px 0 20px;
width: 100%;
height: 45px;
color: #000;
border: 1px solid rgba(0, 0, 0, 0);
font-size: 16px;
text-align: left;
font-weight: 400;
border-radius: 10px;
text-align: left;
text-overflow: ellipsis;
transition: box-shadow 0.2s;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
background-color: white;
-webkit-appearance: none;


&:disabled {
color: #4a4a4a;
background-color: rgba(239, 239, 239, 0.3);
background: radial-gradient(rgba(239, 239, 239, 0.3), rgba(239, 239, 239, 0.3));
-webkit-text-fill-color: #4a4a4a;
cursor: not-allowed;
}
&:disabled {
color: #4a4a4a;
background-color: rgba(239, 239, 239, 0.3);
background: radial-gradient(rgba(239, 239, 239, 0.3), rgba(239, 239, 239, 0.3));
-webkit-text-fill-color: #4a4a4a;
cursor: not-allowed;
}
}

.label {
font-weight: 450;
font-size: 18px;
display: flex;
width: 100%;
flex-direction: column;
text-align: left;
margin-bottom: 15px;
justify-content: space-between;
font-weight: 450;
font-size: 18px;
display: flex;
width: 100%;
flex-direction: column;
text-align: left;
margin-bottom: 15px;
justify-content: space-between;
}

.inputWrapper {
width: 100%;
display: flex;
gap: 15px;
width: 100%;
display: flex;
gap: 15px;
}

.field {
display: flex;
justify-content: start;
flex-direction: column;
align-items: flex-start;
display: flex;
justify-content: start;
flex-direction: column;
align-items: flex-start;
}

.content {
display: flex;
justify-content: space-between;
flex-direction: column;
margin: 30px;
width: 450px;
gap: 30px;
display: flex;
justify-content: space-between;
flex-direction: column;
margin: 30px;
width: 450px;
gap: 30px;
}

.actionButton {
width: 100%;
align-self: center;
}
width: 100%;
align-self: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ async function handleFunctionCall(
if (functionAbi.functionType === 'unconstrained') {
return await viewContractFunction(contractAddress!, contractAbi, functionName, typedArgs, rpcClient, wallet);
} else {
const txnReceipt = await callContractFunction(contractAddress!, contractAbi, functionName, typedArgs, rpcClient, wallet);
const txnReceipt = await callContractFunction(
contractAddress!,
contractAbi,
functionName,
typedArgs,
rpcClient,
wallet,
);
return `Transaction ${txnReceipt.status} on block number ${txnReceipt.blockNumber}`;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.copy {
cursor: pointer;
width: 35px;
height: 25px;
padding: 2px 8px;
}
cursor: pointer;
width: 35px;
height: 25px;
padding: 2px 8px;
}
Loading

0 comments on commit 2ccd3f5

Please sign in to comment.