Skip to content

Commit

Permalink
fix: Do not try flushing txs in bot setup if not set (#12144)
Browse files Browse the repository at this point in the history
Adds a missing guard to flush txs that caused the bot to fail setup in
public networks, accidentally introduced in #11480.
  • Loading branch information
spalladino authored Feb 20, 2025
1 parent b0cdf20 commit bb5473c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions yarn-project/bot/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ export class BotFactory {
const sentTx = account.deploy({ fee: { paymentMethod } });
const txHash = await sentTx.getTxHash();
this.log.info(`Sent tx with hash ${txHash.toString()}`);
if (this.config.flushSetupTransactions) {
this.log.verbose('Flushing transactions');
await this.node!.flushTxs();
}
await this.tryFlushTxs();
this.log.verbose('Waiting for account deployment to settle');
await sentTx.wait({ timeout: this.config.txMinedWaitSeconds });
this.log.info(`Account deployed at ${address}`);
Expand Down Expand Up @@ -159,10 +156,7 @@ export class BotFactory {
const sentTx = deploy.send(deployOpts);
const txHash = await sentTx.getTxHash();
this.log.info(`Sent tx with hash ${txHash.toString()}`);
if (this.config.flushSetupTransactions) {
this.log.verbose('Flushing transactions');
await this.node!.flushTxs();
}
await this.tryFlushTxs();
this.log.verbose('Waiting for token setup to settle');
return sentTx.deployed({ timeout: this.config.txMinedWaitSeconds });
}
Expand Down Expand Up @@ -206,10 +200,7 @@ export class BotFactory {
const sentTx = new BatchCall(token.wallet, calls).send();
const txHash = await sentTx.getTxHash();
this.log.info(`Sent tx with hash ${txHash.toString()}`);
if (this.config.flushSetupTransactions) {
this.log.verbose('Flushing transactions');
await this.node!.flushTxs();
}
await this.tryFlushTxs();
this.log.verbose('Waiting for token mint to settle');
await sentTx.wait({ timeout: this.config.txMinedWaitSeconds });
}
Expand Down Expand Up @@ -243,7 +234,18 @@ export class BotFactory {

private async advanceL2Block() {
const initialBlockNumber = await this.node!.getBlockNumber();
await this.node!.flushTxs();
await this.tryFlushTxs();
await retryUntil(async () => (await this.node!.getBlockNumber()) >= initialBlockNumber + 1);
}

private async tryFlushTxs() {
if (this.config.flushSetupTransactions) {
this.log.verbose('Flushing transactions');
try {
await this.node!.flushTxs();
} catch (err) {
this.log.error(`Failed to flush transactions: ${err}`);
}
}
}
}

0 comments on commit bb5473c

Please sign in to comment.