Skip to content

Commit

Permalink
Merge branch 'master' into 02-24-refactor_using_native_u128_type
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan authored Feb 26, 2025
2 parents fa32da8 + 5b4332e commit cc9de73
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
33 changes: 18 additions & 15 deletions yarn-project/end-to-end/src/shared/submit-transactions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { Fr, GrumpkinScalar, type Logger, type SentTx, TxStatus, type Wallet } from '@aztec/aztec.js';
import { times } from '@aztec/foundation/collection';
import type { PXEService } from '@aztec/pxe';

// submits a set of transactions to the provided Private eXecution Environment (PXE)
Expand All @@ -10,21 +11,23 @@ export const submitTxsTo = async (
logger: Logger,
): Promise<SentTx[]> => {
const txs: SentTx[] = [];
for (let i = 0; i < numTxs; i++) {
const accountManager = await getSchnorrAccount(pxe, Fr.random(), GrumpkinScalar.random(), Fr.random());
const tx = accountManager.deploy({ deployWallet: wallet });
const txHash = await tx.getTxHash();
await Promise.all(
times(numTxs, async () => {
const accountManager = await getSchnorrAccount(pxe, Fr.random(), GrumpkinScalar.random(), Fr.random());
const tx = accountManager.deploy({ deployWallet: wallet });
const txHash = await tx.getTxHash();

logger.info(`Tx sent with hash ${txHash}`);
const receipt = await tx.getReceipt();
expect(receipt).toEqual(
expect.objectContaining({
status: TxStatus.PENDING,
error: '',
}),
);
logger.info(`Receipt received for ${txHash}`);
txs.push(tx);
}
logger.info(`Tx sent with hash ${txHash}`);
const receipt = await tx.getReceipt();
expect(receipt).toEqual(
expect.objectContaining({
status: TxStatus.PENDING,
error: '',
}),
);
logger.info(`Receipt received for ${txHash}`);
txs.push(tx);
}),
);
return txs;
};
18 changes: 18 additions & 0 deletions yarn-project/pxe/src/synchronizer/synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { PxeDatabase } from '../database/index.js';
export class Synchronizer implements L2BlockStreamEventHandler {
private initialSyncBlockNumber = INITIAL_L2_BLOCK_NUM - 1;
private log: Logger;
private isSyncing: Promise<void> | undefined;
protected readonly blockStream: L2BlockStream;

constructor(
Expand Down Expand Up @@ -78,6 +79,23 @@ export class Synchronizer implements L2BlockStreamEventHandler {
* recent data (e.g. notes), and handling any reorgs that might have occurred.
*/
public async sync() {
if (this.isSyncing !== undefined) {
this.log.debug(`Waiting for the ongoing sync to finish`);
await this.isSyncing;
return;
}

this.log.debug(`Syncing PXE with the node`);
const isSyncing = this.doSync();
this.isSyncing = isSyncing;
try {
await isSyncing;
} finally {
this.isSyncing = undefined;
}
}

private async doSync() {
let currentHeader;

try {
Expand Down

0 comments on commit cc9de73

Please sign in to comment.