Skip to content

Commit ebd4165

Browse files
authored
fix: bot waits for pxe synch (#10316)
Fix for bot failing to start back up in rough-rhino. Thanks to @Thunkar for help identifying this.
1 parent ed0fcc2 commit ebd4165

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

yarn-project/bot/src/factory.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
type DeployOptions,
77
createDebugLogger,
88
createPXEClient,
9+
retryUntil,
910
} from '@aztec/aztec.js';
1011
import { type AztecNode, type FunctionCall, type PXE } from '@aztec/circuit-types';
1112
import { Fr, deriveSigningKey } from '@aztec/circuits.js';
@@ -65,7 +66,18 @@ export class BotFactory {
6566
const isInit = await this.pxe.isContractInitialized(account.getAddress());
6667
if (isInit) {
6768
this.log.info(`Account at ${account.getAddress().toString()} already initialized`);
68-
return account.register();
69+
const wallet = await account.register();
70+
const blockNumber = await this.pxe.getBlockNumber();
71+
await retryUntil(
72+
async () => {
73+
const status = await this.pxe.getSyncStatus();
74+
return blockNumber <= status.blocks;
75+
},
76+
'pxe synch',
77+
3600,
78+
1,
79+
);
80+
return wallet;
6981
} else {
7082
this.log.info(`Initializing account at ${account.getAddress().toString()}`);
7183
const sentTx = account.deploy();

0 commit comments

Comments
 (0)