Skip to content

Commit 1ecba92

Browse files
committed
fix(fast-inbox): dispatch block-root proving on the rollupType discriminant (A-1432)
The same-block input reshape made the private-inputs classes structurally assignable, so the orchestrator's instanceof chain collapsed the union to never (TS2358). Type the block-root selection as a discriminated union and switch on rollupType instead.
1 parent 9372613 commit 1ecba92

2 files changed

Lines changed: 30 additions & 17 deletions

File tree

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ export type ProofState<T, PROOF_LENGTH extends number> = {
3939
isProving?: boolean;
4040
};
4141

42+
/**
43+
* The block-root rollup flavor a block proves with and its private inputs, discriminated by circuit name so callers
44+
* can dispatch to the matching prover entrypoint with the correctly-typed inputs.
45+
*/
46+
export type BlockRootRollupTypeAndInputs =
47+
| { rollupType: 'rollup-block-root-first'; inputs: BlockRootFirstRollupPrivateInputs }
48+
| { rollupType: 'rollup-block-root-first-single-tx'; inputs: BlockRootSingleTxFirstRollupPrivateInputs }
49+
| { rollupType: 'rollup-block-root-first-empty-tx'; inputs: BlockRootEmptyTxFirstRollupPrivateInputs }
50+
| { rollupType: 'rollup-block-root-single-tx'; inputs: BlockRootSingleTxRollupPrivateInputs }
51+
| { rollupType: 'rollup-block-root'; inputs: BlockRootRollupPrivateInputs };
52+
4253
/**
4354
* The current state of the proving schedule for a given block. Managed by ProvingState.
4455
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
@@ -280,7 +291,7 @@ export class BlockProvingState {
280291
return new TxMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
281292
}
282293

283-
public getBlockRootRollupTypeAndInputs() {
294+
public getBlockRootRollupTypeAndInputs(): BlockRootRollupTypeAndInputs {
284295
const provingOutputs = this.#getChildProvingOutputsForBlockRoot();
285296
if (!provingOutputs.every(p => !!p)) {
286297
throw new Error('At least one child is not ready for the block root rollup.');
@@ -324,7 +335,10 @@ export class BlockProvingState {
324335
}
325336
}
326337

327-
#getFirstBlockRootRollupTypeAndInputs([leftRollup, rightRollup]: RollupHonkProofData<TxRollupPublicInputs>[]) {
338+
#getFirstBlockRootRollupTypeAndInputs([
339+
leftRollup,
340+
rightRollup,
341+
]: RollupHonkProofData<TxRollupPublicInputs>[]): BlockRootRollupTypeAndInputs {
328342
const messageBundle = this.#getMessageBundle();
329343
const frontierHint = this.#getFrontierHint();
330344

yarn-project/prover-client/src/orchestrator/checkpoint-sub-tree-orchestrator.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ import type { ParityPublicInputs } from '@aztec/stdlib/parity';
2828
import {
2929
type BaseRollupHints,
3030
type BlockRollupPublicInputs,
31-
BlockRootEmptyTxFirstRollupPrivateInputs,
32-
BlockRootFirstRollupPrivateInputs,
33-
BlockRootSingleTxFirstRollupPrivateInputs,
34-
BlockRootSingleTxRollupPrivateInputs,
3531
CheckpointConstantData,
3632
PrivateTxBaseRollupPrivateInputs,
3733
type PublicChonkVerifierPublicInputs,
@@ -754,7 +750,9 @@ export class CheckpointSubTreeOrchestrator extends ProvingScheduler {
754750
return;
755751
}
756752

757-
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
753+
// Kept whole (not destructured) so the switch on the `rollupType` discriminant narrows `inputs` per case.
754+
const rollup = provingState.getBlockRootRollupTypeAndInputs();
755+
const rollupType = rollup.rollupType;
758756

759757
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
760758

@@ -763,16 +761,17 @@ export class CheckpointSubTreeOrchestrator extends ProvingScheduler {
763761
this.wrapCircuitCall(
764762
'getBlockRootRollupProof',
765763
signal => {
766-
if (inputs instanceof BlockRootFirstRollupPrivateInputs) {
767-
return this.prover.getBlockRootFirstRollupProof(inputs, signal, provingState.epochNumber);
768-
} else if (inputs instanceof BlockRootSingleTxFirstRollupPrivateInputs) {
769-
return this.prover.getBlockRootSingleTxFirstRollupProof(inputs, signal, provingState.epochNumber);
770-
} else if (inputs instanceof BlockRootEmptyTxFirstRollupPrivateInputs) {
771-
return this.prover.getBlockRootEmptyTxFirstRollupProof(inputs, signal, provingState.epochNumber);
772-
} else if (inputs instanceof BlockRootSingleTxRollupPrivateInputs) {
773-
return this.prover.getBlockRootSingleTxRollupProof(inputs, signal, provingState.epochNumber);
774-
} else {
775-
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
764+
switch (rollup.rollupType) {
765+
case 'rollup-block-root-first':
766+
return this.prover.getBlockRootFirstRollupProof(rollup.inputs, signal, provingState.epochNumber);
767+
case 'rollup-block-root-first-single-tx':
768+
return this.prover.getBlockRootSingleTxFirstRollupProof(rollup.inputs, signal, provingState.epochNumber);
769+
case 'rollup-block-root-first-empty-tx':
770+
return this.prover.getBlockRootEmptyTxFirstRollupProof(rollup.inputs, signal, provingState.epochNumber);
771+
case 'rollup-block-root-single-tx':
772+
return this.prover.getBlockRootSingleTxRollupProof(rollup.inputs, signal, provingState.epochNumber);
773+
case 'rollup-block-root':
774+
return this.prover.getBlockRootRollupProof(rollup.inputs, signal, provingState.epochNumber);
776775
}
777776
},
778777
{ [Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType },

0 commit comments

Comments
 (0)