Skip to content

Commit e46bb87

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/spartan
2 parents 39faef3 + d88b17e commit e46bb87

17 files changed

+72
-63
lines changed

yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,11 @@ export class EpochsTestContext {
194194
const proverNode = await withLogNameSuffix(suffix, () =>
195195
createAndSyncProverNode(
196196
proverNodePrivateKey,
197-
{ ...this.context.config, proverId: EthAddress.fromNumber(parseInt(suffix, 10)) },
198-
{ dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')) },
197+
{ ...this.context.config },
198+
{
199+
dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
200+
proverId: EthAddress.fromNumber(parseInt(suffix, 10)),
201+
},
199202
this.context.aztecNode,
200203
undefined,
201204
{ dateProvider: this.context.dateProvider },

yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export class EpochProvingState {
7070

7171
constructor(
7272
public readonly epochNumber: number,
73-
private readonly firstCheckpointNumber: Fr,
7473
public readonly totalNumCheckpoints: number,
7574
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
7675
private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
@@ -84,6 +83,7 @@ export class EpochProvingState {
8483
// Adds a block to the proving state, returns its index
8584
// Will update the proving life cycle if this is the last block
8685
public startNewCheckpoint(
86+
checkpointIndex: number,
8787
constants: CheckpointConstantData,
8888
totalNumBlocks: number,
8989
totalNumBlobFields: number,
@@ -95,22 +95,14 @@ export class EpochProvingState {
9595
newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
9696
newL1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
9797
): CheckpointProvingState {
98-
const slotNumber = constants.slotNumber;
99-
if (slotNumber.lt(this.firstCheckpointNumber)) {
100-
throw new Error(
101-
`Unable to start a new checkpoint - checkpoint too old. Epoch started at ${this.firstCheckpointNumber.toNumber()}. Got ${slotNumber.toNumber()}.`,
102-
);
103-
}
104-
105-
const index = slotNumber.sub(this.firstCheckpointNumber).toNumber();
106-
if (index >= this.totalNumCheckpoints) {
98+
if (checkpointIndex >= this.totalNumCheckpoints) {
10799
throw new Error(
108-
`Unable to start a new checkpoint at index ${index}. Expected at most ${this.totalNumCheckpoints} checkpoints.`,
100+
`Unable to start a new checkpoint at index ${checkpointIndex}. Expected at most ${this.totalNumCheckpoints} checkpoints.`,
109101
);
110102
}
111103

112104
const checkpoint = new CheckpointProvingState(
113-
index,
105+
checkpointIndex,
114106
constants,
115107
totalNumBlocks,
116108
totalNumBlobFields,
@@ -125,7 +117,7 @@ export class EpochProvingState {
125117
this,
126118
this.onCheckpointBlobAccumulatorSet,
127119
);
128-
this.checkpoints[index] = checkpoint;
120+
this.checkpoints[checkpointIndex] = checkpoint;
129121

130122
if (this.checkpoints.filter(c => !!c).length === this.totalNumCheckpoints) {
131123
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL;

yarn-project/prover-client/src/orchestrator/orchestrator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ export class ProvingOrchestrator implements EpochProver {
119119

120120
public startNewEpoch(
121121
epochNumber: number,
122-
firstCheckpointNumber: Fr,
123122
totalNumCheckpoints: number,
124123
finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
125124
) {
@@ -134,7 +133,6 @@ export class ProvingOrchestrator implements EpochProver {
134133
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
135134
this.provingState = new EpochProvingState(
136135
epochNumber,
137-
firstCheckpointNumber,
138136
totalNumCheckpoints,
139137
finalBlobBatchingChallenges,
140138
provingState => this.checkAndEnqueueCheckpointRootRollup(provingState),
@@ -145,6 +143,7 @@ export class ProvingOrchestrator implements EpochProver {
145143
}
146144

147145
public async startNewCheckpoint(
146+
checkpointIndex: number,
148147
constants: CheckpointConstantData,
149148
l1ToL2Messages: Fr[],
150149
totalNumBlocks: number,
@@ -178,6 +177,7 @@ export class ProvingOrchestrator implements EpochProver {
178177
} = await this.updateL1ToL2MessageTree(l1ToL2Messages, db);
179178

180179
this.provingState.startNewCheckpoint(
180+
checkpointIndex,
181181
constants,
182182
totalNumBlocks,
183183
totalNumBlobFields,

yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ describe('prover/orchestrator/errors', () => {
3636
finalBlobChallenges,
3737
} = await buildBlobDataFromTxs([txs]);
3838

39-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1 /* numCheckpoints */, finalBlobChallenges);
39+
orchestrator.startNewEpoch(1, 1 /* numCheckpoints */, finalBlobChallenges);
4040
await orchestrator.startNewCheckpoint(
41+
0, // checkpointIndex
4142
context.getCheckpointConstants(),
4243
[],
4344
1, // numBlocks
@@ -59,8 +60,9 @@ describe('prover/orchestrator/errors', () => {
5960
finalBlobChallenges,
6061
} = await buildBlobDataFromTxs([txs]);
6162

62-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, finalBlobChallenges);
63+
orchestrator.startNewEpoch(1, 1 /* numCheckpoints */, finalBlobChallenges);
6364
await orchestrator.startNewCheckpoint(
65+
0, // checkpointIndex
6466
context.getCheckpointConstants(),
6567
[],
6668
1, // numBlocks
@@ -84,15 +86,16 @@ describe('prover/orchestrator/errors', () => {
8486
});
8587

8688
it('throws if adding a transaction before starting checkpoint', async () => {
87-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, emptyChallenges);
89+
orchestrator.startNewEpoch(1, 1, emptyChallenges);
8890
await expect(async () => await orchestrator.addTxs([await context.makeProcessedTx()])).rejects.toThrow(
8991
/Proving state for block 1 not found/,
9092
);
9193
});
9294

9395
it('throws if adding a transaction before starting block', async () => {
94-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, emptyChallenges);
96+
orchestrator.startNewEpoch(1, 1, emptyChallenges);
9597
await orchestrator.startNewCheckpoint(
98+
0, // checkpointIndex
9699
context.getCheckpointConstants(),
97100
[],
98101
1,
@@ -105,15 +108,16 @@ describe('prover/orchestrator/errors', () => {
105108
});
106109

107110
it('throws if completing a block before start', async () => {
108-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, emptyChallenges);
111+
orchestrator.startNewEpoch(1, 1, emptyChallenges);
109112
await expect(async () => await orchestrator.setBlockCompleted(context.blockNumber)).rejects.toThrow(
110113
/Block proving state for 1 not found/,
111114
);
112115
});
113116

114117
it('throws if adding to a cancelled block', async () => {
115-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, emptyChallenges);
118+
orchestrator.startNewEpoch(1, 1, emptyChallenges);
116119
await orchestrator.startNewCheckpoint(
120+
0, // checkpointIndex
117121
context.getCheckpointConstants(),
118122
[],
119123
1,
@@ -131,10 +135,11 @@ describe('prover/orchestrator/errors', () => {
131135

132136
it('rejects if too many l1 to l2 messages are provided', async () => {
133137
const l1ToL2Messages = new Array(100).fill(new Fr(0n));
134-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, emptyChallenges);
138+
orchestrator.startNewEpoch(1, 1, emptyChallenges);
135139
await expect(
136140
async () =>
137141
await orchestrator.startNewCheckpoint(
142+
0, // checkpointIndex
138143
context.getCheckpointConstants(),
139144
l1ToL2Messages,
140145
1,

yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ describe('prover/orchestrator/failures', () => {
4343
const { blobFieldsLengths, finalBlobChallenges } = await buildBlobDataFromTxs(blocks.map(b => b.txs));
4444

4545
const numCheckpoints = blocks.length;
46-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, numCheckpoints, finalBlobChallenges);
46+
orchestrator.startNewEpoch(1, numCheckpoints, finalBlobChallenges);
4747

4848
for (let i = 0; i < blocks.length; i++) {
4949
const { block, txs, l1ToL2Messages } = blocks[i];
5050
// these operations could fail if the target circuit fails before adding all blocks or txs
5151
try {
5252
await orchestrator.startNewCheckpoint(
53+
i, // checkpointIndex
5354
context.getCheckpointConstants(i),
5455
l1ToL2Messages,
5556
1, // numBlocks

yarn-project/prover-client/src/orchestrator/orchestrator_lifecycle.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ describe('prover/orchestrator/lifecycle', () => {
4242
});
4343
const blobFields = [createBlockEndMarker(0)];
4444
const finalBlobChallenges = await buildFinalBlobChallenges([blobFields]);
45-
orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, finalBlobChallenges);
45+
orchestrator.startNewEpoch(1, 1, finalBlobChallenges);
4646
await orchestrator.startNewCheckpoint(
47+
0, // checkpointIndex
4748
context.getCheckpointConstants(),
4849
[],
4950
1,

yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ describe('prover/orchestrator/mixed-blocks', () => {
1919
finalBlobChallenges,
2020
} = await buildBlobDataFromTxs([txs]);
2121

22-
context.orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, finalBlobChallenges);
22+
context.orchestrator.startNewEpoch(1, 1, finalBlobChallenges);
2323
await context.orchestrator.startNewCheckpoint(
24+
0, // checkpointIndex
2425
context.getCheckpointConstants(),
2526
l1ToL2Messages,
2627
1, // numBlocks

yarn-project/prover-client/src/orchestrator/orchestrator_multi_public_functions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ describe('prover/orchestrator/public-functions', () => {
113113
blobFieldsLengths: [blobFieldsLength],
114114
finalBlobChallenges,
115115
} = await buildBlobDataFromTxs([processed]);
116-
context.orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1, finalBlobChallenges);
116+
context.orchestrator.startNewEpoch(1, 1, finalBlobChallenges);
117117
await context.orchestrator.startNewCheckpoint(
118+
0, // checkpointIndex
118119
context.getCheckpointConstants(),
119120
[],
120121
1,

yarn-project/prover-client/src/orchestrator/orchestrator_multiple_blocks.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ describe('prover/orchestrator/multi-block', () => {
3535
const { blobFieldsLengths, finalBlobChallenges } = await buildBlobDataFromTxs(blocks.map(b => b.txs));
3636

3737
logger.info(`Starting new epoch with ${numBlocks}`);
38-
context.orchestrator.startNewEpoch(1, context.firstCheckpointNumber, numCheckpoints, finalBlobChallenges);
38+
context.orchestrator.startNewEpoch(1, numCheckpoints, finalBlobChallenges);
3939

4040
for (let i = 0; i < blocks.length; i++) {
4141
const { block, txs } = blocks[i];
4242
await context.orchestrator.startNewCheckpoint(
43+
i, // checkpointIndex
4344
context.getCheckpointConstants(i),
4445
[],
4546
1 /* numBlocks */,
@@ -78,15 +79,11 @@ describe('prover/orchestrator/multi-block', () => {
7879
logger.info(`Starting epoch ${epochNumber} with ${numBlocks} checkpoints/blocks`);
7980
const blocksInEpoch = blocks.slice(epochIndex * numBlocks, (epochIndex + 1) * numBlocks);
8081
const { blobFieldsLengths, finalBlobChallenges } = await buildBlobDataFromTxs(blocksInEpoch.map(b => b.txs));
81-
context.orchestrator.startNewEpoch(
82-
epochNumber,
83-
context.firstCheckpointNumber,
84-
numCheckpoints,
85-
finalBlobChallenges,
86-
);
82+
context.orchestrator.startNewEpoch(epochNumber, numCheckpoints, finalBlobChallenges);
8783
for (let i = 0; i < blocksInEpoch.length; i++) {
8884
const { block, txs } = blocksInEpoch[i];
8985
await context.orchestrator.startNewCheckpoint(
86+
i, // checkpointIndex
9087
context.getCheckpointConstants(i),
9188
[],
9289
1 /* numBlocks */,

yarn-project/prover-client/src/orchestrator/orchestrator_public_functions.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ describe('prover/orchestrator/public-functions', () => {
4646
} = await buildBlobDataFromTxs([processed]);
4747

4848
// This will need to be a 2 tx block
49-
context.orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1 /* numCheckpoints */, finalBlobChallenges);
49+
context.orchestrator.startNewEpoch(1, 1 /* numCheckpoints */, finalBlobChallenges);
5050
await context.orchestrator.startNewCheckpoint(
51+
0, // checkpointIndex
5152
context.getCheckpointConstants(),
5253
[],
5354
1, // numBlocks
@@ -84,8 +85,9 @@ describe('prover/orchestrator/public-functions', () => {
8485
blobFieldsLengths: [blobFieldsLength],
8586
finalBlobChallenges,
8687
} = await buildBlobDataFromTxs([processed]);
87-
context.orchestrator.startNewEpoch(1, context.firstCheckpointNumber, 1 /* numCheckpoints */, finalBlobChallenges);
88+
context.orchestrator.startNewEpoch(1, 1 /* numCheckpoints */, finalBlobChallenges);
8889
await context.orchestrator.startNewCheckpoint(
90+
0, // checkpointIndex
8991
context.getCheckpointConstants(),
9092
[],
9193
1, // numBlocks

0 commit comments

Comments
 (0)