@aztec/prover-client 0.0.0-test.1 → 0.0.1-commit.017a351
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config.d.ts +8 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +26 -2
- package/dest/index.d.ts +1 -1
- package/dest/light/index.d.ts +2 -0
- package/dest/light/index.d.ts.map +1 -0
- package/dest/light/index.js +1 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts +52 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +231 -0
- package/dest/mocks/fixtures.d.ts +8 -8
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +36 -17
- package/dest/mocks/test_context.d.ts +45 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +162 -90
- package/dest/orchestrator/block-building-helpers.d.ts +36 -29
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +170 -189
- package/dest/orchestrator/block-proving-state.d.ts +73 -48
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +289 -177
- package/dest/orchestrator/checkpoint-proving-state.d.ts +83 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +252 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +107 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +151 -0
- package/dest/orchestrator/epoch-proving-context.d.ts +51 -0
- package/dest/orchestrator/epoch-proving-context.d.ts.map +1 -0
- package/dest/orchestrator/epoch-proving-context.js +81 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +43 -28
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +179 -73
- package/dest/orchestrator/index.d.ts +4 -1
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -0
- package/dest/orchestrator/orchestrator.d.ts +59 -51
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +808 -385
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -6
- package/dest/orchestrator/proving-scheduler.d.ts +72 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +117 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +83 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +182 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts +62 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-scheduler.js +73 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-state.js +185 -0
- package/dest/orchestrator/tx-proving-state.d.ts +15 -12
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +27 -44
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +68 -9
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +68 -14
- package/dest/prover-client/server-epoch-prover.d.ts +16 -12
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +11 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +28 -19
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +74 -61
- package/dest/proving_broker/config.d.ts +18 -61
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +43 -9
- package/dest/proving_broker/factory.d.ts +2 -2
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +5 -1
- package/dest/proving_broker/fixtures.d.ts +3 -2
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +3 -2
- package/dest/proving_broker/index.d.ts +2 -1
- package/dest/proving_broker/index.d.ts.map +1 -1
- package/dest/proving_broker/index.js +1 -0
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -1
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -0
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts +8 -12
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +86 -65
- package/dest/proving_broker/proving_broker.d.ts +18 -6
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +108 -44
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +401 -11
- package/dest/proving_broker/proving_broker_database.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +22 -35
- package/dest/proving_broker/proving_job_controller.d.ts +11 -10
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +92 -62
- package/dest/proving_broker/rpc.d.ts +9 -7
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +88 -27
- package/dest/test/mock_proof_store.d.ts +9 -0
- package/dest/test/mock_proof_store.d.ts.map +1 -0
- package/dest/test/mock_proof_store.js +10 -0
- package/dest/test/mock_prover.d.ts +23 -17
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +38 -20
- package/package.json +34 -33
- package/src/config.ts +41 -9
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +320 -0
- package/src/mocks/fixtures.ts +46 -40
- package/src/mocks/test_context.ts +231 -120
- package/src/orchestrator/block-building-helpers.ts +258 -334
- package/src/orchestrator/block-proving-state.ts +334 -231
- package/src/orchestrator/checkpoint-proving-state.ts +362 -0
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +271 -0
- package/src/orchestrator/epoch-proving-context.ts +101 -0
- package/src/orchestrator/epoch-proving-state.ts +239 -111
- package/src/orchestrator/index.ts +8 -0
- package/src/orchestrator/orchestrator.ts +591 -451
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- package/src/orchestrator/proving-scheduler.ts +156 -0
- package/src/orchestrator/top-tree-orchestrator.ts +314 -0
- package/src/orchestrator/top-tree-proving-scheduler.ts +154 -0
- package/src/orchestrator/top-tree-proving-state.ts +220 -0
- package/src/orchestrator/tx-proving-state.ts +48 -66
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +173 -38
- package/src/prover-client/server-epoch-prover.ts +40 -22
- package/src/proving_broker/broker_prover_facade.ts +227 -149
- package/src/proving_broker/config.ts +49 -8
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +8 -3
- package/src/proving_broker/index.ts +1 -0
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -0
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +95 -66
- package/src/proving_broker/proving_broker.ts +121 -49
- package/src/proving_broker/proving_broker_database/memory.ts +3 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +31 -15
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
- package/src/proving_broker/proving_job_controller.ts +100 -83
- package/src/proving_broker/rpc.ts +46 -25
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +156 -64
- package/dest/bin/get-proof-inputs.d.ts +0 -2
- package/dest/bin/get-proof-inputs.d.ts.map +0 -1
- package/dest/bin/get-proof-inputs.js +0 -51
- package/dest/block_builder/index.d.ts +0 -6
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/index.js +0 -1
- package/dest/block_builder/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -51
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
- package/src/bin/get-proof-inputs.ts +0 -59
- package/src/block_builder/index.ts +0 -6
- package/src/block_builder/light.ts +0 -101
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -72
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,126 +1,160 @@
|
|
|
1
|
-
import { SpongeBlob } from '@aztec/blob-lib';
|
|
1
|
+
import { type BlockBlobData, type BlockEndBlobData, type SpongeBlob, encodeBlockEndBlobData } from '@aztec/blob-lib';
|
|
2
2
|
import {
|
|
3
3
|
type ARCHIVE_HEIGHT,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
4
|
+
type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
5
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
7
6
|
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
8
7
|
NUM_BASE_PARITY_PER_ROOT_PARITY,
|
|
9
|
-
type RECURSIVE_PROOF_LENGTH,
|
|
10
|
-
VK_TREE_HEIGHT,
|
|
11
8
|
} from '@aztec/constants';
|
|
12
|
-
import {
|
|
13
|
-
import { Fr } from '@aztec/foundation/
|
|
14
|
-
import type
|
|
15
|
-
import type
|
|
16
|
-
import { MembershipWitness, type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
17
|
-
import { getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
18
|
-
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
19
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
9
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
|
+
import { type Tuple, assertLength } from '@aztec/foundation/serialize';
|
|
12
|
+
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
20
13
|
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
21
|
-
import { type ParityPublicInputs,
|
|
14
|
+
import { type ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
15
|
+
import type { RollupHonkProofData } from '@aztec/stdlib/proofs';
|
|
22
16
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
SingleTxBlockRootRollupInputs,
|
|
17
|
+
BlockRollupPublicInputs,
|
|
18
|
+
BlockRootEmptyTxFirstRollupPrivateInputs,
|
|
19
|
+
BlockRootFirstRollupPrivateInputs,
|
|
20
|
+
BlockRootRollupPrivateInputs,
|
|
21
|
+
BlockRootSingleTxFirstRollupPrivateInputs,
|
|
22
|
+
BlockRootSingleTxRollupPrivateInputs,
|
|
23
|
+
CheckpointConstantData,
|
|
24
|
+
TxMergeRollupPrivateInputs,
|
|
25
|
+
type TxRollupPublicInputs,
|
|
33
26
|
} from '@aztec/stdlib/rollup';
|
|
34
27
|
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
35
|
-
import
|
|
36
|
-
import {
|
|
28
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
29
|
+
import { BlockHeader, GlobalVariables, StateReference } from '@aztec/stdlib/tx';
|
|
30
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
37
31
|
|
|
38
|
-
import {
|
|
39
|
-
import type {
|
|
32
|
+
import { buildHeaderFromCircuitOutputs, toProofData } from './block-building-helpers.js';
|
|
33
|
+
import type { CheckpointProvingState } from './checkpoint-proving-state.js';
|
|
40
34
|
import type { TxProvingState } from './tx-proving-state.js';
|
|
41
35
|
|
|
42
|
-
export type
|
|
36
|
+
export type ProofState<T, PROOF_LENGTH extends number> = {
|
|
37
|
+
provingOutput?: PublicInputsAndRecursiveProof<T, PROOF_LENGTH>;
|
|
38
|
+
isProving?: boolean;
|
|
39
|
+
};
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* The current state of the proving schedule for a given block. Managed by ProvingState.
|
|
46
43
|
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
|
|
47
44
|
*/
|
|
48
45
|
export class BlockProvingState {
|
|
49
|
-
private
|
|
50
|
-
|
|
46
|
+
private baseOrMergeProofs: UnbalancedTreeStore<
|
|
47
|
+
ProofState<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
51
48
|
> = new UnbalancedTreeStore(0);
|
|
52
|
-
private
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
private baseParityProofs: (ProofState<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined)[] =
|
|
50
|
+
Array.from({
|
|
51
|
+
length: NUM_BASE_PARITY_PER_ROOT_PARITY,
|
|
52
|
+
}).map(_ => undefined);
|
|
53
|
+
private rootParityProof: ProofState<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined;
|
|
54
|
+
private blockRootProof:
|
|
55
|
+
| ProofState<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
56
56
|
| undefined;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
private builtBlockHeader: BlockHeader | undefined;
|
|
58
|
+
private builtArchive: AppendOnlyTreeSnapshot | undefined;
|
|
59
|
+
private endState: StateReference | undefined;
|
|
60
|
+
private endSpongeBlob: SpongeBlob | undefined;
|
|
61
61
|
private txs: TxProvingState[] = [];
|
|
62
|
-
|
|
62
|
+
private isFirstBlock: boolean;
|
|
63
|
+
private error: string | undefined;
|
|
63
64
|
|
|
64
65
|
constructor(
|
|
65
66
|
public readonly index: number,
|
|
66
|
-
public readonly
|
|
67
|
-
public readonly
|
|
68
|
-
private readonly
|
|
69
|
-
private readonly
|
|
70
|
-
|
|
71
|
-
private readonly
|
|
72
|
-
private readonly
|
|
73
|
-
private readonly
|
|
67
|
+
public readonly blockNumber: BlockNumber,
|
|
68
|
+
public readonly totalNumTxs: number,
|
|
69
|
+
private readonly constants: CheckpointConstantData,
|
|
70
|
+
private readonly timestamp: UInt64,
|
|
71
|
+
public readonly lastArchiveTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
72
|
+
private readonly lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
73
|
+
private readonly lastL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
74
|
+
private readonly lastL1ToL2MessageSubtreeRootSiblingPath: Tuple<
|
|
75
|
+
Fr,
|
|
76
|
+
typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH
|
|
77
|
+
>,
|
|
78
|
+
public readonly newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
79
|
+
private readonly headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
80
|
+
private readonly startSpongeBlob: SpongeBlob,
|
|
81
|
+
public parentCheckpoint: CheckpointProvingState,
|
|
74
82
|
) {
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
77
|
-
|
|
83
|
+
this.isFirstBlock = index === 0;
|
|
84
|
+
if (!totalNumTxs && !this.isFirstBlock) {
|
|
85
|
+
throw new Error(`Cannot create a block with 0 txs, unless it's the first block.`);
|
|
86
|
+
}
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
return this.globalVariables.blockNumber.toNumber();
|
|
88
|
+
this.baseOrMergeProofs = new UnbalancedTreeStore(totalNumTxs);
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
public
|
|
84
|
-
|
|
85
|
-
throw new Error(`Block ${this.blockNumber} already initalised.`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.baseOrMergeProvingOutputs = new UnbalancedTreeStore(numTxs);
|
|
89
|
-
// Initialise the sponge which will eventually absorb all tx effects to be added to the blob.
|
|
90
|
-
// Like l1 to l2 messages, we need to know beforehand how many effects will be absorbed.
|
|
91
|
-
this.spongeBlobState = SpongeBlob.init(numBlobFields);
|
|
92
|
-
this.totalNumTxs = numTxs;
|
|
91
|
+
public get epochNumber(): number {
|
|
92
|
+
return this.parentCheckpoint.epochNumber;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// Adds a transaction to the proving state, returns it's index
|
|
96
96
|
public addNewTx(tx: TxProvingState) {
|
|
97
|
-
if (!this.
|
|
98
|
-
throw new Error(`
|
|
97
|
+
if (!this.isAcceptingTxs()) {
|
|
98
|
+
throw new Error(`Cannot add more txs to block ${this.blockNumber}.`);
|
|
99
99
|
}
|
|
100
|
-
|
|
101
100
|
const txIndex = this.txs.length;
|
|
102
101
|
this.txs[txIndex] = tx;
|
|
103
102
|
return txIndex;
|
|
104
103
|
}
|
|
105
104
|
|
|
105
|
+
public isAcceptingTxs() {
|
|
106
|
+
return this.txs.length < this.totalNumTxs;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public getProcessedTxs() {
|
|
110
|
+
return this.txs.map(t => t.processedTx);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public tryStartProvingBase(txIndex: number) {
|
|
114
|
+
if (this.baseOrMergeProofs.getLeaf(txIndex)?.isProving) {
|
|
115
|
+
return false;
|
|
116
|
+
} else {
|
|
117
|
+
this.baseOrMergeProofs.setLeaf(txIndex, { isProving: true });
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
106
122
|
public setBaseRollupProof(
|
|
107
123
|
txIndex: number,
|
|
108
124
|
provingOutput: PublicInputsAndRecursiveProof<
|
|
109
|
-
|
|
125
|
+
TxRollupPublicInputs,
|
|
110
126
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
111
127
|
>,
|
|
112
128
|
): TreeNodeLocation {
|
|
113
|
-
return this.
|
|
129
|
+
return this.baseOrMergeProofs.setLeaf(txIndex, { provingOutput });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public tryStartProvingMerge(location: TreeNodeLocation) {
|
|
133
|
+
if (this.baseOrMergeProofs.getNode(location)?.isProving) {
|
|
134
|
+
return false;
|
|
135
|
+
} else {
|
|
136
|
+
this.baseOrMergeProofs.setNode(location, { isProving: true });
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
114
139
|
}
|
|
115
140
|
|
|
116
141
|
public setMergeRollupProof(
|
|
117
142
|
location: TreeNodeLocation,
|
|
118
143
|
provingOutput: PublicInputsAndRecursiveProof<
|
|
119
|
-
|
|
144
|
+
TxRollupPublicInputs,
|
|
120
145
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
121
146
|
>,
|
|
122
147
|
) {
|
|
123
|
-
this.
|
|
148
|
+
this.baseOrMergeProofs.setNode(location, { provingOutput });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public tryStartProvingBaseParity(index: number) {
|
|
152
|
+
if (this.baseParityProofs[index]?.isProving) {
|
|
153
|
+
return false;
|
|
154
|
+
} else {
|
|
155
|
+
this.baseParityProofs[index] = { isProving: true };
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
124
158
|
}
|
|
125
159
|
|
|
126
160
|
// Stores a set of root parity inputs at the given index
|
|
@@ -130,136 +164,236 @@ export class BlockProvingState {
|
|
|
130
164
|
`Unable to set a base parity proofs at index ${index}. Expected at most ${NUM_BASE_PARITY_PER_ROOT_PARITY} proofs.`,
|
|
131
165
|
);
|
|
132
166
|
}
|
|
133
|
-
this.
|
|
167
|
+
this.baseParityProofs[index] = { provingOutput };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public tryStartProvingRootParity() {
|
|
171
|
+
if (this.rootParityProof?.isProving) {
|
|
172
|
+
return false;
|
|
173
|
+
} else {
|
|
174
|
+
this.rootParityProof = { isProving: true };
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
134
177
|
}
|
|
135
178
|
|
|
136
179
|
public setRootParityProof(provingOutput: PublicInputsAndRecursiveProof<ParityPublicInputs>) {
|
|
137
|
-
this.
|
|
180
|
+
this.rootParityProof = { provingOutput };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public tryStartProvingBlockRoot() {
|
|
184
|
+
if (this.blockRootProof?.isProving) {
|
|
185
|
+
return false;
|
|
186
|
+
} else {
|
|
187
|
+
this.blockRootProof = { isProving: true };
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
138
190
|
}
|
|
139
191
|
|
|
140
192
|
public setBlockRootRollupProof(
|
|
141
193
|
provingOutput: PublicInputsAndRecursiveProof<
|
|
142
|
-
|
|
194
|
+
BlockRollupPublicInputs,
|
|
143
195
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
144
196
|
>,
|
|
145
|
-
) {
|
|
146
|
-
this.
|
|
197
|
+
): TreeNodeLocation {
|
|
198
|
+
this.blockRootProof = { provingOutput };
|
|
199
|
+
return this.parentCheckpoint.setBlockRootRollupProof(this.index, provingOutput);
|
|
147
200
|
}
|
|
148
201
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this.txs;
|
|
202
|
+
public getBlockRootRollupOutput() {
|
|
203
|
+
return this.blockRootProof?.provingOutput?.inputs;
|
|
152
204
|
}
|
|
153
205
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
206
|
+
public async buildBlockHeader() {
|
|
207
|
+
if (this.isAcceptingTxs()) {
|
|
208
|
+
throw new Error('All txs must be added to the block before building the header.');
|
|
209
|
+
}
|
|
210
|
+
if (!this.endState) {
|
|
211
|
+
throw new Error('Call `setEndState` first.');
|
|
212
|
+
}
|
|
213
|
+
if (!this.endSpongeBlob) {
|
|
214
|
+
throw new Error('Call `setEndSpongeBlob` first.');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const endSpongeBlob = this.endSpongeBlob.clone();
|
|
218
|
+
const endSpongeBlobHash = await endSpongeBlob.squeeze();
|
|
219
|
+
|
|
220
|
+
this.builtBlockHeader = new BlockHeader(
|
|
221
|
+
this.lastArchiveTreeSnapshot,
|
|
222
|
+
this.endState,
|
|
223
|
+
endSpongeBlobHash,
|
|
224
|
+
this.#getGlobalVariables(),
|
|
225
|
+
this.#getTotalFees(),
|
|
226
|
+
new Fr(this.#getTotalManaUsed()),
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
return this.builtBlockHeader;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public getBuiltBlockHeader() {
|
|
233
|
+
return this.builtBlockHeader;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public setBuiltArchive(archive: AppendOnlyTreeSnapshot) {
|
|
237
|
+
this.builtArchive = archive;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public getBuiltArchive() {
|
|
241
|
+
return this.builtArchive;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public getStartSpongeBlob() {
|
|
245
|
+
return this.startSpongeBlob;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public setEndSpongeBlob(endSpongeBlob: SpongeBlob) {
|
|
249
|
+
this.endSpongeBlob = endSpongeBlob;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public getEndSpongeBlob() {
|
|
253
|
+
return this.endSpongeBlob;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public setEndState(endState: StateReference) {
|
|
257
|
+
this.endState = endState;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public hasEndState() {
|
|
261
|
+
return !!this.endState;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public getBlockEndBlobFields(): Fr[] {
|
|
265
|
+
return encodeBlockEndBlobData(this.getBlockEndBlobData());
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
getBlockEndBlobData(): BlockEndBlobData {
|
|
269
|
+
if (!this.endState) {
|
|
270
|
+
throw new Error('Call `setEndState` first.');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const partial = this.endState.partial;
|
|
274
|
+
return {
|
|
275
|
+
blockEndMarker: {
|
|
276
|
+
numTxs: this.totalNumTxs,
|
|
277
|
+
timestamp: this.timestamp,
|
|
278
|
+
blockNumber: this.blockNumber,
|
|
279
|
+
},
|
|
280
|
+
blockEndStateField: {
|
|
281
|
+
l1ToL2MessageNextAvailableLeafIndex: this.newL1ToL2MessageTreeSnapshot.nextAvailableLeafIndex,
|
|
282
|
+
noteHashNextAvailableLeafIndex: partial.noteHashTree.nextAvailableLeafIndex,
|
|
283
|
+
nullifierNextAvailableLeafIndex: partial.nullifierTree.nextAvailableLeafIndex,
|
|
284
|
+
publicDataNextAvailableLeafIndex: partial.publicDataTree.nextAvailableLeafIndex,
|
|
285
|
+
totalManaUsed: this.#getTotalManaUsed(),
|
|
286
|
+
},
|
|
287
|
+
lastArchiveRoot: this.lastArchiveTreeSnapshot.root,
|
|
288
|
+
noteHashRoot: partial.noteHashTree.root,
|
|
289
|
+
nullifierRoot: partial.nullifierTree.root,
|
|
290
|
+
publicDataRoot: partial.publicDataTree.root,
|
|
291
|
+
l1ToL2MessageRoot: this.isFirstBlock ? this.newL1ToL2MessageTreeSnapshot.root : undefined,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
public getBlockBlobData(): BlockBlobData {
|
|
296
|
+
return {
|
|
297
|
+
...this.getBlockEndBlobData(),
|
|
298
|
+
txs: this.getTxEffects().map(t => t.toTxBlobData()),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public getTxEffects() {
|
|
303
|
+
return this.txs.map(t => t.processedTx.txEffect);
|
|
157
304
|
}
|
|
158
305
|
|
|
159
306
|
public getParentLocation(location: TreeNodeLocation) {
|
|
160
|
-
return this.
|
|
307
|
+
return this.baseOrMergeProofs.getParentLocation(location);
|
|
161
308
|
}
|
|
162
309
|
|
|
163
310
|
public getMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
164
|
-
const [left, right] = this.
|
|
311
|
+
const [left, right] = this.baseOrMergeProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
|
|
165
312
|
if (!left || !right) {
|
|
166
|
-
throw new Error('At
|
|
313
|
+
throw new Error('At least one child is not ready for the merge rollup.');
|
|
167
314
|
}
|
|
168
315
|
|
|
169
|
-
return new
|
|
316
|
+
return new TxMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
170
317
|
}
|
|
171
318
|
|
|
172
|
-
public
|
|
173
|
-
|
|
174
|
-
|
|
319
|
+
public getBlockRootRollupTypeAndInputs() {
|
|
320
|
+
const provingOutputs = this.#getChildProvingOutputsForBlockRoot();
|
|
321
|
+
if (!provingOutputs.every(p => !!p)) {
|
|
322
|
+
throw new Error('At least one child is not ready for the block root rollup.');
|
|
175
323
|
}
|
|
176
324
|
|
|
177
|
-
const
|
|
178
|
-
const nonEmptyProofs = proofs.filter(p => !!p);
|
|
179
|
-
if (proofs.length !== nonEmptyProofs.length) {
|
|
180
|
-
throw new Error('At lease one child is not ready for the block root.');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const data = this.#getBlockRootRollupData(proverId);
|
|
184
|
-
|
|
185
|
-
if (this.totalNumTxs === 0) {
|
|
186
|
-
const constants = ConstantRollupData.from({
|
|
187
|
-
lastArchive: this.lastArchiveSnapshot,
|
|
188
|
-
globalVariables: this.globalVariables,
|
|
189
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
190
|
-
protocolContractTreeRoot,
|
|
191
|
-
});
|
|
325
|
+
const previousRollups = provingOutputs.map(p => toProofData(p));
|
|
192
326
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
inputs: EmptyBlockRootRollupInputs.from({
|
|
196
|
-
data,
|
|
197
|
-
constants,
|
|
198
|
-
isPadding: false,
|
|
199
|
-
}),
|
|
200
|
-
};
|
|
327
|
+
if (this.isFirstBlock) {
|
|
328
|
+
return this.#getFirstBlockRootRollupTypeAndInputs(previousRollups);
|
|
201
329
|
}
|
|
202
330
|
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (previousRollupData.length === 1) {
|
|
331
|
+
const [leftRollup, rightRollup] = previousRollups;
|
|
332
|
+
if (!rightRollup) {
|
|
207
333
|
return {
|
|
208
|
-
rollupType: '
|
|
209
|
-
inputs: new
|
|
334
|
+
rollupType: 'rollup-block-root-single-tx' satisfies CircuitName,
|
|
335
|
+
inputs: new BlockRootSingleTxRollupPrivateInputs(leftRollup, this.lastArchiveSiblingPath),
|
|
210
336
|
};
|
|
211
337
|
} else {
|
|
212
338
|
return {
|
|
213
|
-
rollupType: 'block-root
|
|
214
|
-
inputs: new
|
|
215
|
-
previousRollupData as [PreviousRollupData, PreviousRollupData],
|
|
216
|
-
data,
|
|
217
|
-
blobData,
|
|
218
|
-
),
|
|
339
|
+
rollupType: 'rollup-block-root' satisfies CircuitName,
|
|
340
|
+
inputs: new BlockRootRollupPrivateInputs([leftRollup, rightRollup], this.lastArchiveSiblingPath),
|
|
219
341
|
};
|
|
220
342
|
}
|
|
221
343
|
}
|
|
222
344
|
|
|
223
|
-
|
|
224
|
-
if (!this.
|
|
345
|
+
#getFirstBlockRootRollupTypeAndInputs([leftRollup, rightRollup]: RollupHonkProofData<TxRollupPublicInputs>[]) {
|
|
346
|
+
if (!this.rootParityProof?.provingOutput) {
|
|
225
347
|
throw new Error('Root parity is not ready.');
|
|
226
348
|
}
|
|
349
|
+
const l1ToL2Roots = toProofData(this.rootParityProof.provingOutput);
|
|
227
350
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
351
|
+
if (!leftRollup) {
|
|
352
|
+
return {
|
|
353
|
+
rollupType: 'rollup-block-root-first-empty-tx' satisfies CircuitName,
|
|
354
|
+
inputs: new BlockRootEmptyTxFirstRollupPrivateInputs(
|
|
355
|
+
l1ToL2Roots,
|
|
356
|
+
this.lastArchiveTreeSnapshot,
|
|
357
|
+
this.headerOfLastBlockInPreviousCheckpoint.state,
|
|
358
|
+
this.constants,
|
|
359
|
+
this.timestamp,
|
|
360
|
+
this.lastL1ToL2MessageSubtreeRootSiblingPath,
|
|
361
|
+
this.lastArchiveSiblingPath,
|
|
362
|
+
),
|
|
363
|
+
};
|
|
364
|
+
} else if (!rightRollup) {
|
|
365
|
+
return {
|
|
366
|
+
rollupType: 'rollup-block-root-first-single-tx' satisfies CircuitName,
|
|
367
|
+
inputs: new BlockRootSingleTxFirstRollupPrivateInputs(
|
|
368
|
+
l1ToL2Roots,
|
|
369
|
+
leftRollup,
|
|
370
|
+
this.lastL1ToL2MessageTreeSnapshot,
|
|
371
|
+
this.lastL1ToL2MessageSubtreeRootSiblingPath,
|
|
372
|
+
this.lastArchiveSiblingPath,
|
|
373
|
+
),
|
|
374
|
+
};
|
|
375
|
+
} else {
|
|
376
|
+
return {
|
|
377
|
+
rollupType: 'rollup-block-root-first' satisfies CircuitName,
|
|
378
|
+
inputs: new BlockRootFirstRollupPrivateInputs(
|
|
379
|
+
l1ToL2Roots,
|
|
380
|
+
[leftRollup, rightRollup],
|
|
381
|
+
this.lastL1ToL2MessageTreeSnapshot,
|
|
382
|
+
this.lastL1ToL2MessageSubtreeRootSiblingPath,
|
|
383
|
+
this.lastArchiveSiblingPath,
|
|
384
|
+
),
|
|
385
|
+
};
|
|
386
|
+
}
|
|
252
387
|
}
|
|
253
388
|
|
|
254
|
-
public
|
|
255
|
-
|
|
389
|
+
public getParityRootInputs() {
|
|
390
|
+
const baseParityProvingOutputs = this.baseParityProofs.filter(p => !!p?.provingOutput).map(p => p!.provingOutput!);
|
|
391
|
+
if (baseParityProvingOutputs.length !== this.baseParityProofs.length) {
|
|
256
392
|
throw new Error('At lease one base parity is not ready.');
|
|
257
393
|
}
|
|
258
394
|
|
|
259
|
-
const children =
|
|
260
|
-
return new
|
|
261
|
-
children as Tuple<RootParityInput<typeof RECURSIVE_PROOF_LENGTH>, typeof NUM_BASE_PARITY_PER_ROOT_PARITY>,
|
|
262
|
-
);
|
|
395
|
+
const children = baseParityProvingOutputs.map(p => toProofData(p));
|
|
396
|
+
return new ParityRootPrivateInputs(assertLength(children, NUM_BASE_PARITY_PER_ROOT_PARITY));
|
|
263
397
|
}
|
|
264
398
|
|
|
265
399
|
// Returns a specific transaction proving state
|
|
@@ -267,82 +401,47 @@ export class BlockProvingState {
|
|
|
267
401
|
return this.txs[txIndex];
|
|
268
402
|
}
|
|
269
403
|
|
|
270
|
-
public async buildHeaderFromProvingOutputs(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
? []
|
|
274
|
-
: await Promise.all(this.#getChildProofsForBlockRoot().map(p => this.#getPreviousRollupData(p!)));
|
|
275
|
-
|
|
276
|
-
let endPartialState = this.previousBlockHeader.state.partial;
|
|
277
|
-
if (this.totalNumTxs !== 0) {
|
|
278
|
-
const previousRollupData = this.#getChildProofsForBlockRoot();
|
|
279
|
-
const lastRollup = previousRollupData[previousRollupData.length - 1];
|
|
280
|
-
if (!lastRollup) {
|
|
281
|
-
throw new Error('End state of the block is not available. Last rollup is not ready yet.');
|
|
282
|
-
}
|
|
283
|
-
endPartialState = lastRollup.inputs.end;
|
|
404
|
+
public async buildHeaderFromProvingOutputs() {
|
|
405
|
+
if (!this.blockRootProof?.provingOutput) {
|
|
406
|
+
throw new Error('Block root rollup is not ready.');
|
|
284
407
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return buildHeaderFromCircuitOutputs(
|
|
288
|
-
previousRollupData.map(d => d.baseOrMergeRollupPublicInputs),
|
|
289
|
-
this.rootParityProvingOutput!.inputs,
|
|
290
|
-
this.blockRootProvingOutput!.inputs,
|
|
291
|
-
endState,
|
|
292
|
-
logger,
|
|
293
|
-
);
|
|
408
|
+
|
|
409
|
+
return await buildHeaderFromCircuitOutputs(this.blockRootProof.provingOutput.inputs);
|
|
294
410
|
}
|
|
295
411
|
|
|
296
412
|
public isReadyForMergeRollup(location: TreeNodeLocation) {
|
|
297
|
-
return this.
|
|
413
|
+
return !!this.baseOrMergeProofs.getSibling(location)?.provingOutput;
|
|
298
414
|
}
|
|
299
415
|
|
|
300
416
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
301
417
|
public isReadyForBlockRootRollup() {
|
|
302
|
-
const childProofs = this.#
|
|
303
|
-
return this.
|
|
418
|
+
const childProofs = this.#getChildProvingOutputsForBlockRoot();
|
|
419
|
+
return (!this.isFirstBlock || !!this.rootParityProof?.provingOutput) && childProofs.every(p => !!p);
|
|
304
420
|
}
|
|
305
421
|
|
|
306
422
|
// Returns true if we have sufficient root parity inputs to execute the root parity circuit
|
|
307
423
|
public isReadyForRootParity() {
|
|
308
|
-
return this.
|
|
424
|
+
return this.baseParityProofs.every(p => !!p?.provingOutput);
|
|
309
425
|
}
|
|
310
426
|
|
|
311
427
|
public isComplete() {
|
|
312
|
-
return !!this.
|
|
428
|
+
return !!this.blockRootProof;
|
|
313
429
|
}
|
|
314
430
|
|
|
315
|
-
// Returns whether the proving state is still valid
|
|
316
431
|
public verifyState() {
|
|
317
|
-
return this.
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
public reject(reason: string) {
|
|
321
|
-
this.error = reason;
|
|
322
|
-
this.parentEpoch.reject(reason);
|
|
432
|
+
return this.parentCheckpoint.verifyState();
|
|
323
433
|
}
|
|
324
434
|
|
|
325
|
-
|
|
326
|
-
return
|
|
327
|
-
l1ToL2Roots: this.#getRootParityData(this.rootParityProvingOutput!),
|
|
328
|
-
l1ToL2MessageSubtreeSiblingPath: this.l1ToL2MessageSubtreeSiblingPath,
|
|
329
|
-
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
330
|
-
previousBlockHeader: this.previousBlockHeader,
|
|
331
|
-
proverId,
|
|
332
|
-
});
|
|
435
|
+
public getError() {
|
|
436
|
+
return this.error;
|
|
333
437
|
}
|
|
334
438
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return BlockRootRollupBlobData.from({
|
|
339
|
-
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_BLOCK),
|
|
340
|
-
blobCommitments: padArrayEnd(blobCommitments, [Fr.ZERO, Fr.ZERO], BLOBS_PER_BLOCK),
|
|
341
|
-
blobsHash,
|
|
342
|
-
});
|
|
439
|
+
public reject(reason: string) {
|
|
440
|
+
this.error = reason;
|
|
441
|
+
this.parentCheckpoint.reject(reason);
|
|
343
442
|
}
|
|
344
443
|
|
|
345
|
-
#
|
|
444
|
+
#getChildProvingOutputsForBlockRoot() {
|
|
346
445
|
if (this.totalNumTxs === 0) {
|
|
347
446
|
return [];
|
|
348
447
|
}
|
|
@@ -350,30 +449,34 @@ export class BlockProvingState {
|
|
|
350
449
|
const rootLocation = { level: 0, index: 0 };
|
|
351
450
|
// If there's only 1 tx, its base rollup proof will be stored at the root.
|
|
352
451
|
return this.totalNumTxs === 1
|
|
353
|
-
? [this.
|
|
354
|
-
: this.
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
#getPreviousRollupData({
|
|
358
|
-
inputs,
|
|
359
|
-
proof,
|
|
360
|
-
verificationKey,
|
|
361
|
-
}: PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>) {
|
|
362
|
-
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
363
|
-
return new PreviousRollupData(
|
|
364
|
-
inputs,
|
|
365
|
-
proof,
|
|
366
|
-
verificationKey.keyAsFields,
|
|
367
|
-
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
368
|
-
);
|
|
452
|
+
? [this.baseOrMergeProofs.getNode(rootLocation)?.provingOutput]
|
|
453
|
+
: this.baseOrMergeProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
369
454
|
}
|
|
370
455
|
|
|
371
|
-
#
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
456
|
+
#getGlobalVariables() {
|
|
457
|
+
if (this.txs.length) {
|
|
458
|
+
return this.txs[0].processedTx.globalVariables;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const constants = this.constants;
|
|
462
|
+
|
|
463
|
+
return GlobalVariables.from({
|
|
464
|
+
chainId: constants.chainId,
|
|
465
|
+
version: constants.version,
|
|
466
|
+
blockNumber: this.blockNumber,
|
|
467
|
+
slotNumber: constants.slotNumber,
|
|
468
|
+
timestamp: this.timestamp,
|
|
469
|
+
coinbase: constants.coinbase,
|
|
470
|
+
feeRecipient: constants.feeRecipient,
|
|
471
|
+
gasFees: constants.gasFees,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
#getTotalFees() {
|
|
476
|
+
return this.txs.reduce((acc, tx) => acc.add(tx.processedTx.txEffect.transactionFee), Fr.ZERO);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
#getTotalManaUsed() {
|
|
480
|
+
return this.txs.reduce((acc, tx) => acc + BigInt(tx.processedTx.gasUsed.billedGas.l2Gas), 0n);
|
|
378
481
|
}
|
|
379
482
|
}
|