Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to wait for two blocks for the claim to be claimable?

Copy link
Contributor Author

@spalladino spalladino Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be. I just mindlessly replaced the calls for this PR :-P

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}`);
}
}
}
}