Skip to content

Commit 60e73f9

Browse files
authored
chore: Fetch rollup address using version as index (#13620)
If fetching the rollup address given a version identifier fails, it tries again using it as an index instead.
1 parent 822e8d9 commit 60e73f9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

yarn-project/ethereum/src/contracts/registry.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ describe('Registry', () => {
8181
const address = await registry.getRollupAddress(deployedVersion);
8282
expect(address).toEqual(rollupAddress);
8383
}
84+
{
85+
const address = await registry.getRollupAddress(0);
86+
expect(address).toEqual(rollupAddress);
87+
}
8488
});
8589

8690
it('handles non-existent versions', async () => {

yarn-project/ethereum/src/contracts/registry.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EthAddress } from '@aztec/foundation/eth-address';
2+
import { createLogger } from '@aztec/foundation/log';
23
import { RegistryAbi } from '@aztec/l1-artifacts/RegistryAbi';
34
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
45

@@ -18,6 +19,8 @@ import { RollupContract } from './rollup.js';
1819

1920
export class RegistryContract {
2021
public address: EthAddress;
22+
23+
private readonly log = createLogger('ethereum:contracts:registry');
2124
private readonly registry: GetContractReturnType<typeof RegistryAbi, PublicClient<HttpTransport, Chain>>;
2225

2326
constructor(public readonly client: L1Clients['publicClient'], address: Hex | EthAddress) {
@@ -44,6 +47,14 @@ export class RegistryContract {
4447

4548
try {
4649
return EthAddress.fromString(await this.registry.read.getRollup([version]));
50+
} catch (e) {
51+
this.log.warn(`Failed fetching rollup address for version ${version}. Retrying as index.`);
52+
}
53+
54+
try {
55+
const actualVersion = await this.registry.read.getVersion([version]);
56+
const rollupAddress = await this.registry.read.getRollup([actualVersion]);
57+
return EthAddress.fromString(rollupAddress);
4758
} catch (e) {
4859
throw new Error('Rollup address is undefined');
4960
}

0 commit comments

Comments
 (0)