Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion yarn-project/kv-store/src/lmdb/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class AztecLmdbStore implements AztecKVStore {
#rootDb: RootDatabase;
#data: Database<unknown, Key>;
#multiMapData: Database<unknown, Key>;
#log = createDebugLogger('aztec:kv-store:lmdb');

constructor(rootDb: RootDatabase, public readonly isEphemeral: boolean, private path?: string) {
this.#rootDb = rootDb;
Expand Down Expand Up @@ -59,7 +60,7 @@ export class AztecLmdbStore implements AztecKVStore {
ephemeral: boolean = false,
log = createDebugLogger('aztec:kv-store:lmdb'),
): AztecLmdbStore {
log.info(`Opening LMDB database at ${path || 'temporary location'}`);
log.verbose(`Opening LMDB database at ${path || 'temporary location'}`);
const rootDb = open({ path, noSync: ephemeral });
return new AztecLmdbStore(rootDb, ephemeral, path);
}
Expand All @@ -70,9 +71,12 @@ export class AztecLmdbStore implements AztecKVStore {
*/
async fork() {
const baseDir = this.path ? dirname(this.path) : tmpdir();
this.#log.debug(`Forking store with basedir ${baseDir}`);
const forkPath = join(await mkdtemp(join(baseDir, 'aztec-store-fork-')), 'root.mdb');
this.#log.verbose(`Forking store to ${forkPath}`);
await this.#rootDb.backup(forkPath, false);
const forkDb = open(forkPath, { noSync: this.isEphemeral });
this.#log.debug(`Forked store at ${forkPath} opened successfully`);
return new AztecLmdbStore(forkDb, this.isEphemeral, forkPath);
}

Expand Down
50 changes: 29 additions & 21 deletions yarn-project/prover-node/src/prover-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,36 @@ export class ProverNode {
* Checks whether there are new blocks to prove, proves them, and submits them.
*/
protected async work() {
if (this.options.disableAutomaticProving) {
return;
try {
if (this.options.disableAutomaticProving) {
return;
}

const [latestBlockNumber, latestProvenBlockNumber] = await Promise.all([
this.l2BlockSource.getBlockNumber(),
this.l2BlockSource.getProvenBlockNumber(),
]);

// Consider both the latest block we are proving and the last block proven on the chain
const latestBlockBeingProven = this.latestBlockWeAreProving ?? 0;
const latestProven = Math.max(latestBlockBeingProven, latestProvenBlockNumber);
if (latestProven >= latestBlockNumber) {
this.log.debug(`No new blocks to prove`, {
latestBlockNumber,
latestProvenBlockNumber,
latestBlockBeingProven,
});
return;
}

const fromBlock = latestProven + 1;
const toBlock = fromBlock; // We only prove one block at a time for now

await this.startProof(fromBlock, toBlock);
this.latestBlockWeAreProving = toBlock;
} catch (err) {
this.log.error(`Error in prover node work`, err);
}

const [latestBlockNumber, latestProvenBlockNumber] = await Promise.all([
this.l2BlockSource.getBlockNumber(),
this.l2BlockSource.getProvenBlockNumber(),
]);

// Consider both the latest block we are proving and the last block proven on the chain
const latestBlockBeingProven = this.latestBlockWeAreProving ?? 0;
const latestProven = Math.max(latestBlockBeingProven, latestProvenBlockNumber);
if (latestProven >= latestBlockNumber) {
this.log.debug(`No new blocks to prove`, { latestBlockNumber, latestProvenBlockNumber, latestBlockBeingProven });
return;
}

const fromBlock = latestProven + 1;
const toBlock = fromBlock; // We only prove one block at a time for now

await this.startProof(fromBlock, toBlock);
this.latestBlockWeAreProving = toBlock;
}

/**
Expand Down