Skip to content

Commit 42f5f71

Browse files
committed
Renamed rootAccumulator to witnessedRootsHash
1 parent d44805e commit 42f5f71

File tree

10 files changed

+58
-51
lines changed

10 files changed

+58
-51
lines changed

packages/protocol/src/prover/block/BlockProvable.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class BlockProverStateCommitments extends Struct({
7272
stateRoot: Field,
7373
// Commitment to the list of unprocessed (pending) batches of STs that need to be proven
7474
pendingSTBatchesHash: Field,
75-
rootAccumulator: Field,
75+
witnessedRootsHash: Field,
7676
networkStateHash: Field,
7777
blockHashRoot: Field,
7878
eternalTransactionsHash: Field,
@@ -91,7 +91,7 @@ export class BlockProverStateCommitments extends Struct({
9191
transactionsHash: state.transactionList.commitment,
9292
eternalTransactionsHash: state.eternalTransactionsList.commitment,
9393
incomingMessagesHash: state.incomingMessages.commitment,
94-
rootAccumulator: state.witnessedRoots.commitment,
94+
witnessedRootsHash: state.witnessedRoots.commitment,
9595
};
9696
}
9797

@@ -118,7 +118,7 @@ export class BlockProverStateCommitments extends Struct({
118118
pendingSTBatches: new AppliedBatchHashList(
119119
publicInput.pendingSTBatchesHash
120120
),
121-
witnessedRoots: new WitnessedRootHashList(publicInput.rootAccumulator),
121+
witnessedRoots: new WitnessedRootHashList(publicInput.witnessedRootsHash),
122122
blockNumber: publicInput.blockNumber,
123123
};
124124
}
@@ -130,7 +130,7 @@ export class BlockProverPublicOutput extends Struct({
130130
transactionsHash: Field,
131131
stateRoot: Field,
132132
pendingSTBatchesHash: Field,
133-
rootAccumulator: Field,
133+
witnessedRootsHash: Field,
134134
networkStateHash: Field,
135135
blockHashRoot: Field,
136136
eternalTransactionsHash: Field,

packages/protocol/src/prover/block/BlockProver.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,11 @@ export class BlockProverProgrammable extends ZkProgrammable<
477477
apply: Bool,
478478
stateRoot: Field,
479479
pendingSTBatchesHash: Field,
480-
rootAccumulator: Field
480+
witnessedRootsHash: Field
481481
): {
482482
stateRoot: Field;
483483
pendingSTBatchesHash: Field;
484-
rootAccumulator: Field;
484+
witnessedRootsHash: Field;
485485
} {
486486
assertEqualsIf(
487487
stateTransitionProof.publicInput.currentBatchStateHash,
@@ -521,14 +521,14 @@ export class BlockProverProgrammable extends ZkProgrammable<
521521
// Assert root Accumulator
522522
assertEqualsIf(
523523
Field(0),
524-
stateTransitionProof.publicInput.rootAccumulator,
524+
stateTransitionProof.publicInput.witnessedRootsHash,
525525
apply,
526526
errors.propertyNotMatching("from state root")
527527
);
528-
// Assert the rootAccumulator created is the same
528+
// Assert the witnessedRootsHash created is the same
529529
assertEqualsIf(
530-
rootAccumulator,
531-
stateTransitionProof.publicOutput.rootAccumulator,
530+
witnessedRootsHash,
531+
stateTransitionProof.publicOutput.witnessedRootsHash,
532532
apply,
533533
"Root accumulator Commitment is not the same that have been executed by the ST proof"
534534
);
@@ -541,11 +541,15 @@ export class BlockProverProgrammable extends ZkProgrammable<
541541
);
542542
// Reset only if we didn't defer
543543
const newBatchesHash = Provable.if(apply, Field(0), pendingSTBatchesHash);
544-
const newRootAccumulator = Provable.if(apply, Field(0), rootAccumulator);
544+
const newWitnessedRootsHash = Provable.if(
545+
apply,
546+
Field(0),
547+
witnessedRootsHash
548+
);
545549
return {
546550
stateRoot: newRoot,
547551
pendingSTBatchesHash: newBatchesHash,
548-
rootAccumulator: newRootAccumulator,
552+
witnessedRootsHash: newWitnessedRootsHash,
549553
};
550554
}
551555

@@ -723,7 +727,7 @@ export class BlockProverProgrammable extends ZkProgrammable<
723727
);
724728
state.stateRoot = stateProofResult.stateRoot;
725729
state.pendingSTBatches.commitment = stateProofResult.pendingSTBatchesHash;
726-
state.witnessedRoots.commitment = stateProofResult.rootAccumulator;
730+
state.witnessedRoots.commitment = stateProofResult.witnessedRootsHash;
727731

728732
state.blockNumber = blockIndex.add(1);
729733

@@ -823,13 +827,13 @@ export class BlockProverProgrammable extends ZkProgrammable<
823827
errors.transactionsHashNotMatching("proof1.to -> proof2.from")
824828
);
825829

826-
// Check rootAccumulator
827-
publicInput.rootAccumulator.assertEquals(
828-
proof1.publicInput.rootAccumulator,
830+
// Check witnessedRootsHash
831+
publicInput.witnessedRootsHash.assertEquals(
832+
proof1.publicInput.witnessedRootsHash,
829833
errors.transactionsHashNotMatching("publicInput.from -> proof1.from")
830834
);
831-
proof1.publicOutput.rootAccumulator.assertEquals(
832-
proof2.publicInput.rootAccumulator,
835+
proof1.publicOutput.witnessedRootsHash.assertEquals(
836+
proof2.publicInput.witnessedRootsHash,
833837
errors.transactionsHashNotMatching("proof1.to -> proof2.from")
834838
);
835839

@@ -889,7 +893,7 @@ export class BlockProverProgrammable extends ZkProgrammable<
889893
closed: isValidClosedMerge,
890894
blockNumber: proof2.publicOutput.blockNumber,
891895
pendingSTBatchesHash: proof2.publicOutput.pendingSTBatchesHash,
892-
rootAccumulator: proof2.publicOutput.rootAccumulator,
896+
witnessedRootsHash: proof2.publicOutput.witnessedRootsHash,
893897
});
894898
}
895899

packages/protocol/src/prover/statetransition/StateTransitionProvable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export class StateTransitionProverPublicInput extends Struct({
1111
batchesHash: Field,
1212
currentBatchStateHash: Field,
1313
root: Field,
14-
rootAccumulator: Field,
14+
witnessedRootsHash: Field,
1515
}) {}
1616

1717
export class StateTransitionProverPublicOutput extends Struct({
1818
batchesHash: Field,
1919
currentBatchStateHash: Field,
2020
root: Field,
21-
rootAccumulator: Field,
21+
witnessedRootsHash: Field,
2222
}) {}
2323

2424
export type StateTransitionProof = Proof<

packages/protocol/src/prover/statetransition/StateTransitionProver.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface StateTransitionProverExecutionState {
4444
currentBatch: AppliedStateTransitionBatchState;
4545
batchList: AppliedBatchHashList;
4646
finalizedRoot: Field;
47-
rootAccumulator: WitnessedRootHashList;
47+
witnessedRoots: WitnessedRootHashList;
4848
}
4949

5050
const StateTransitionSelfProofClass = SelfProof<
@@ -201,7 +201,7 @@ export class StateTransitionProverProgrammable extends ZkProgrammable<
201201
witnessRoot
202202
.implies(closing)
203203
.assertTrue("Can only witness roots at closing batches");
204-
state.rootAccumulator.pushIf(
204+
state.witnessedRoots.pushIf(
205205
{
206206
root: state.finalizedRoot,
207207
appliedBatchListState: state.batchList.commitment,
@@ -321,7 +321,7 @@ export class StateTransitionProverProgrammable extends ZkProgrammable<
321321
batchList: new AppliedBatchHashList(publicInput.batchesHash),
322322
currentBatch: currentAppliedBatch,
323323
finalizedRoot: publicInput.root,
324-
rootAccumulator: new WitnessedRootHashList(publicInput.rootAccumulator),
324+
witnessedRoots: new WitnessedRootHashList(publicInput.witnessedRootsHash),
325325
};
326326

327327
const result = this.applyTransitions(state, batch, witnesses);
@@ -330,7 +330,7 @@ export class StateTransitionProverProgrammable extends ZkProgrammable<
330330
batchesHash: result.batchList.commitment,
331331
currentBatchStateHash: result.currentBatch.hashOrZero(),
332332
root: result.finalizedRoot,
333-
rootAccumulator: result.rootAccumulator.commitment,
333+
witnessedRootsHash: result.witnessedRoots.commitment,
334334
});
335335
}
336336

@@ -383,23 +383,26 @@ export class StateTransitionProverProgrammable extends ZkProgrammable<
383383
);
384384

385385
// Check root accumulator
386-
publicInput.rootAccumulator.assertEquals(
387-
proof1.publicInput.rootAccumulator,
386+
publicInput.witnessedRootsHash.assertEquals(
387+
proof1.publicInput.witnessedRootsHash,
388388
errors.propertyNotMatching(
389-
"rootAccumulator",
389+
"witnessedRootsHash",
390390
"publicInput.from -> proof1.from"
391391
)
392392
);
393-
proof1.publicOutput.rootAccumulator.assertEquals(
394-
proof2.publicInput.rootAccumulator,
395-
errors.propertyNotMatching("rootAccumulator", "proof1.to -> proof2.from")
393+
proof1.publicOutput.witnessedRootsHash.assertEquals(
394+
proof2.publicInput.witnessedRootsHash,
395+
errors.propertyNotMatching(
396+
"witnessedRootsHash",
397+
"proof1.to -> proof2.from"
398+
)
396399
);
397400

398401
return new StateTransitionProverPublicInput({
399402
currentBatchStateHash: proof2.publicOutput.currentBatchStateHash,
400403
batchesHash: proof2.publicOutput.batchesHash,
401404
root: proof2.publicOutput.root,
402-
rootAccumulator: proof2.publicOutput.rootAccumulator,
405+
witnessedRootsHash: proof2.publicOutput.witnessedRootsHash,
403406
});
404407
}
405408
}

packages/protocol/test/prover/statetransition/StateTransitionProver.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe("StateTransitionProver", () => {
8080
const result = await prover.proveBatch(
8181
{
8282
root: tree.getRoot(),
83-
rootAccumulator: Field(0),
83+
witnessedRootsHash: Field(0),
8484
batchesHash: Field(0),
8585
currentBatchStateHash: Field(0),
8686
},
@@ -117,7 +117,7 @@ describe("StateTransitionProver", () => {
117117
await prover.proveBatch(
118118
{
119119
root: Field(RollupMerkleTree.EMPTY_ROOT),
120-
rootAccumulator: Field(0),
120+
witnessedRootsHash: Field(0),
121121
batchesHash: Field(0),
122122
currentBatchStateHash: Field(0),
123123
},
@@ -163,7 +163,7 @@ describe("StateTransitionProver", () => {
163163
await prover.proveBatch(
164164
{
165165
root: inputRoot,
166-
rootAccumulator: Field(0),
166+
witnessedRootsHash: Field(0),
167167
batchesHash: Field(0),
168168
currentBatchStateHash: Field(0),
169169
},
@@ -219,7 +219,7 @@ describe("StateTransitionProver", () => {
219219
const result = await prover.proveBatch(
220220
{
221221
root: Field(RollupMerkleTree.EMPTY_ROOT),
222-
rootAccumulator: Field(0),
222+
witnessedRootsHash: Field(0),
223223
batchesHash: Field(0),
224224
currentBatchStateHash: Field(0),
225225
},

packages/sequencer/src/protocol/production/flow/StateTransitionFlow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class StateTransitionFlow {
3434
root: Field(0),
3535
currentBatchStateHash: Field(0),
3636
batchesHash: Field(0),
37-
rootAccumulator: Field(0),
37+
witnessedRootsHash: Field(0),
3838
};
3939

4040
return await this.protocol.stateTransitionProver.zkProgrammable.zkProgram[0].Proof.dummy(
@@ -56,8 +56,8 @@ export class StateTransitionFlow {
5656
a.publicOutput.root
5757
.equals(b.publicInput.root)
5858
.and(
59-
a.publicOutput.rootAccumulator.equals(
60-
b.publicInput.rootAccumulator
59+
a.publicOutput.witnessedRootsHash.equals(
60+
b.publicInput.witnessedRootsHash
6161
)
6262
)
6363
.and(

packages/sequencer/src/protocol/production/tracing/BlockTracingService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class BlockTracingService {
5858
incomingMessagesHash: block.block.fromMessagesHash,
5959
transactionsHash: Field(0),
6060
networkStateHash: block.block.networkState.before.hash(),
61-
rootAccumulator: state.witnessedRoots.commitment,
61+
witnessedRootsHash: state.witnessedRoots.commitment,
6262
pendingSTBatchesHash: state.pendingSTBatches.commitment,
6363
});
6464

packages/sequencer/src/protocol/production/tracing/StateTransitionTracingService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class StateTransitionTracingService {
103103

104104
const batchList = new AppliedBatchHashList(Field(0));
105105
let currentSTList = new DefaultProvableHashList(ProvableStateTransition);
106-
const rootAccumulator = new DefaultProvableHashList<WitnessedRoot>(
106+
const witnessedRootsList = new DefaultProvableHashList<WitnessedRoot>(
107107
WitnessedRoot
108108
);
109109

@@ -122,7 +122,7 @@ export class StateTransitionTracingService {
122122
batchesHash: batchList.commitment,
123123
currentBatchStateHash: batchState.hashOrZero(),
124124
root: finalizedStateRoot,
125-
rootAccumulator: rootAccumulator.commitment,
125+
witnessedRootsHash: witnessedRootsList.commitment,
126126
};
127127

128128
const witnesses = await mapSequential(
@@ -180,7 +180,7 @@ export class StateTransitionTracingService {
180180
});
181181

182182
if (witnessRoot.toBoolean()) {
183-
rootAccumulator.push({
183+
witnessedRootsList.push({
184184
root: finalizedStateRoot,
185185
appliedBatchListState: batchList.commitment,
186186
});

packages/sequencer/src/protocol/production/tracing/TransactionTracingService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class TransactionTracingService {
9393
eternalTransactionsHash: previousState.eternalTransactionsList.commitment,
9494
incomingMessagesHash: previousState.incomingMessages.commitment,
9595
networkStateHash: previousState.networkState.hash(),
96-
rootAccumulator: previousState.witnessedRoots.commitment,
96+
witnessedRootsHash: previousState.witnessedRoots.commitment,
9797
pendingSTBatchesHash: previousState.pendingSTBatches.commitment,
9898
blockHashRoot: Field(0),
9999
blockNumber: MAX_FIELD,

packages/sequencer/test/production/tracing/StateTransitionTracingService.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,23 @@ describe("StateTransitionTracingService", () => {
211211
batchList.commitment.toString()
212212
);
213213

214-
const rootAccumulator = new WitnessedRootHashList();
214+
const witnessedRootsList = new WitnessedRootHashList();
215215
const tempTree = await applyBatchesToTree(
216216
batch.slice(0, 2),
217217
new CachedMerkleTreeStore(store)
218218
);
219219

220-
rootAccumulator.push({
220+
witnessedRootsList.push({
221221
root: tempTree.getRoot(),
222222
appliedBatchListState: tempBatchListHash,
223223
});
224-
rootAccumulator.push({
224+
witnessedRootsList.push({
225225
root: tree.getRoot(),
226226
appliedBatchListState: batchList.commitment,
227227
});
228228

229-
expect(trace[1].publicInput.rootAccumulator.toString()).toStrictEqual(
230-
rootAccumulator.commitment.toString()
229+
expect(trace[1].publicInput.witnessedRootsHash.toString()).toStrictEqual(
230+
witnessedRootsList.commitment.toString()
231231
);
232232
});
233233
});
@@ -272,8 +272,8 @@ describe("StateTransitionTracingService", () => {
272272
});
273273

274274
it("check rootAccumulator is zero", () => {
275-
expect(trace1[0].publicInput.rootAccumulator.toString()).toBe("0");
276-
expect(trace2[0].publicInput.rootAccumulator.toString()).toBe("0");
275+
expect(trace1[0].publicInput.witnessedRootsHash.toString()).toBe("0");
276+
expect(trace2[0].publicInput.witnessedRootsHash.toString()).toBe("0");
277277
});
278278

279279
it("check currentBatchHash is zero", () => {

0 commit comments

Comments
 (0)