Skip to content

Commit

Permalink
fix: bot waits for pxe synch (#10316)
Browse files Browse the repository at this point in the history
Fix for bot failing to start back up in rough-rhino. Thanks to @Thunkar
for help identifying this.
  • Loading branch information
alexghr authored Dec 1, 2024
1 parent ed0fcc2 commit ebd4165
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion yarn-project/bot/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type DeployOptions,
createDebugLogger,
createPXEClient,
retryUntil,
} from '@aztec/aztec.js';
import { type AztecNode, type FunctionCall, type PXE } from '@aztec/circuit-types';
import { Fr, deriveSigningKey } from '@aztec/circuits.js';
Expand Down Expand Up @@ -65,7 +66,18 @@ export class BotFactory {
const isInit = await this.pxe.isContractInitialized(account.getAddress());
if (isInit) {
this.log.info(`Account at ${account.getAddress().toString()} already initialized`);
return account.register();
const wallet = await account.register();
const blockNumber = await this.pxe.getBlockNumber();
await retryUntil(
async () => {
const status = await this.pxe.getSyncStatus();
return blockNumber <= status.blocks;
},
'pxe synch',
3600,
1,
);
return wallet;
} else {
this.log.info(`Initializing account at ${account.getAddress().toString()}`);
const sentTx = account.deploy();
Expand Down

0 comments on commit ebd4165

Please sign in to comment.