@aztec/prover-client 0.55.1 → 0.57.0
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/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +6 -27
- package/dest/mocks/test_context.d.ts +9 -10
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +13 -15
- package/dest/orchestrator/block-building-helpers.d.ts +12 -3
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +34 -32
- package/dest/orchestrator/{proving-state.d.ts → block-proving-state.d.ts} +19 -16
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/block-proving-state.js +147 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +63 -0
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/epoch-proving-state.js +143 -0
- package/dest/orchestrator/orchestrator.d.ts +33 -15
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +315 -172
- package/dest/orchestrator/tx-proving-state.d.ts +3 -2
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +54 -26
- package/dest/prover-agent/memory-proving-queue.d.ts +11 -5
- package/dest/prover-agent/memory-proving-queue.d.ts.map +1 -1
- package/dest/prover-agent/memory-proving-queue.js +16 -6
- package/dest/prover-agent/prover-agent.d.ts.map +1 -1
- package/dest/prover-agent/prover-agent.js +10 -10
- package/dest/prover-agent/rpc.d.ts.map +1 -1
- package/dest/prover-agent/rpc.js +8 -2
- package/dest/test/mock_prover.d.ts +6 -4
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +9 -3
- package/dest/tx-prover/tx-prover.d.ts +3 -3
- package/dest/tx-prover/tx-prover.d.ts.map +1 -1
- package/dest/tx-prover/tx-prover.js +1 -1
- package/package.json +15 -11
- package/src/index.ts +1 -1
- package/src/mocks/fixtures.ts +5 -49
- package/src/mocks/test_context.ts +15 -20
- package/src/orchestrator/block-building-helpers.ts +90 -57
- package/src/orchestrator/{proving-state.ts → block-proving-state.ts} +29 -53
- package/src/orchestrator/epoch-proving-state.ts +221 -0
- package/src/orchestrator/orchestrator.ts +494 -292
- package/src/orchestrator/tx-proving-state.ts +63 -27
- package/src/prover-agent/memory-proving-queue.ts +31 -16
- package/src/prover-agent/prover-agent.ts +11 -9
- package/src/prover-agent/rpc.ts +9 -0
- package/src/test/mock_prover.ts +23 -1
- package/src/tx-prover/tx-prover.ts +4 -4
- package/dest/orchestrator/proving-state.d.ts.map +0 -1
- package/dest/orchestrator/proving-state.js +0 -170
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type L2Block, type MerkleTreeId
|
|
1
|
+
import { type L2Block, type MerkleTreeId } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
|
+
type ARCHIVE_HEIGHT,
|
|
3
4
|
type AppendOnlyTreeSnapshot,
|
|
4
5
|
type BaseOrMergeRollupPublicInputs,
|
|
5
6
|
type BlockRootOrBlockMergePublicInputs,
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
9
10
|
type NESTED_RECURSIVE_PROOF_LENGTH,
|
|
10
11
|
type NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
12
|
+
NUM_BASE_PARITY_PER_ROOT_PARITY,
|
|
11
13
|
type Proof,
|
|
12
14
|
type RECURSIVE_PROOF_LENGTH,
|
|
13
15
|
type RecursiveProof,
|
|
@@ -16,6 +18,7 @@ import {
|
|
|
16
18
|
} from '@aztec/circuits.js';
|
|
17
19
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
18
20
|
|
|
21
|
+
import { type EpochProvingState } from './epoch-proving-state.js';
|
|
19
22
|
import { type TxProvingState } from './tx-proving-state.js';
|
|
20
23
|
|
|
21
24
|
export type MergeRollupInputData = {
|
|
@@ -29,38 +32,38 @@ export type MergeRollupInputData = {
|
|
|
29
32
|
|
|
30
33
|
export type TreeSnapshots = Map<MerkleTreeId, AppendOnlyTreeSnapshot>;
|
|
31
34
|
|
|
32
|
-
enum PROVING_STATE_LIFECYCLE {
|
|
33
|
-
PROVING_STATE_CREATED,
|
|
34
|
-
PROVING_STATE_FULL,
|
|
35
|
-
PROVING_STATE_RESOLVED,
|
|
36
|
-
PROVING_STATE_REJECTED,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
35
|
/**
|
|
40
|
-
* The current state of the proving schedule
|
|
41
|
-
*
|
|
42
|
-
* Captures resolve and reject callbacks to provide a promise base interface to the consumer of our proving.
|
|
36
|
+
* The current state of the proving schedule for a given block. Managed by ProvingState.
|
|
37
|
+
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
|
|
43
38
|
*/
|
|
44
|
-
export class
|
|
45
|
-
private provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
|
|
39
|
+
export class BlockProvingState {
|
|
46
40
|
private mergeRollupInputs: MergeRollupInputData[] = [];
|
|
47
41
|
private rootParityInputs: Array<RootParityInput<typeof RECURSIVE_PROOF_LENGTH> | undefined> = [];
|
|
48
42
|
private finalRootParityInputs: RootParityInput<typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined;
|
|
49
43
|
public blockRootRollupPublicInputs: BlockRootOrBlockMergePublicInputs | undefined;
|
|
44
|
+
public blockRootRollupStarted: boolean = false;
|
|
50
45
|
public finalProof: Proof | undefined;
|
|
51
46
|
public block: L2Block | undefined;
|
|
52
47
|
private txs: TxProvingState[] = [];
|
|
48
|
+
|
|
53
49
|
constructor(
|
|
50
|
+
public readonly index: number,
|
|
54
51
|
public readonly totalNumTxs: number,
|
|
55
|
-
private completionCallback: (result: ProvingResult) => void,
|
|
56
|
-
private rejectionCallback: (reason: string) => void,
|
|
57
52
|
public readonly globalVariables: GlobalVariables,
|
|
58
53
|
public readonly newL1ToL2Messages: Tuple<Fr, typeof NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP>,
|
|
59
|
-
numRootParityInputs: number,
|
|
60
54
|
public readonly messageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
61
55
|
public readonly messageTreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
|
|
56
|
+
public readonly messageTreeSnapshotAfterInsertion: AppendOnlyTreeSnapshot,
|
|
57
|
+
public readonly archiveTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
58
|
+
public readonly archiveTreeRootSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
59
|
+
public readonly previousBlockHash: Fr,
|
|
60
|
+
private readonly parentEpoch: EpochProvingState,
|
|
62
61
|
) {
|
|
63
|
-
this.rootParityInputs = Array.from({ length:
|
|
62
|
+
this.rootParityInputs = Array.from({ length: NUM_BASE_PARITY_PER_ROOT_PARITY }).map(_ => undefined);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public get blockNumber() {
|
|
66
|
+
return this.globalVariables.blockNumber.toNumber();
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
// Returns the number of levels of merge rollups
|
|
@@ -95,12 +98,8 @@ export class ProvingState {
|
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
// Adds a transaction to the proving state, returns it's index
|
|
98
|
-
// Will update the proving life cycle if this is the last transaction
|
|
99
101
|
public addNewTx(tx: TxProvingState) {
|
|
100
102
|
this.txs.push(tx);
|
|
101
|
-
if (this.txs.length === this.totalNumTxs) {
|
|
102
|
-
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL;
|
|
103
|
-
}
|
|
104
103
|
return this.txs.length - 1;
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -124,19 +123,6 @@ export class ProvingState {
|
|
|
124
123
|
return this.rootParityInputs;
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
// Returns true if this proving state is still valid, false otherwise
|
|
128
|
-
public verifyState() {
|
|
129
|
-
return (
|
|
130
|
-
this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED ||
|
|
131
|
-
this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Returns true if we are still able to accept transactions, false otherwise
|
|
136
|
-
public isAcceptingTransactions() {
|
|
137
|
-
return this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
126
|
// Returns the complete set of transaction proving state objects
|
|
141
127
|
public get allTxs() {
|
|
142
128
|
return this.txs;
|
|
@@ -195,6 +181,7 @@ export class ProvingState {
|
|
|
195
181
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
196
182
|
public isReadyForBlockRootRollup() {
|
|
197
183
|
return !(
|
|
184
|
+
this.block === undefined ||
|
|
198
185
|
this.mergeRollupInputs[0] === undefined ||
|
|
199
186
|
this.finalRootParityInput === undefined ||
|
|
200
187
|
this.mergeRollupInputs[0].inputs.findIndex(p => !p) !== -1
|
|
@@ -211,28 +198,17 @@ export class ProvingState {
|
|
|
211
198
|
return this.rootParityInputs.findIndex(p => !p) === -1;
|
|
212
199
|
}
|
|
213
200
|
|
|
214
|
-
//
|
|
215
|
-
public
|
|
216
|
-
this.
|
|
201
|
+
// Returns true if we are still able to accept transactions, false otherwise
|
|
202
|
+
public isAcceptingTransactions() {
|
|
203
|
+
return this.totalNumTxs > this.txs.length;
|
|
217
204
|
}
|
|
218
205
|
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (!this.verifyState()) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_REJECTED;
|
|
226
|
-
this.rejectionCallback(reason);
|
|
206
|
+
// Returns whether the proving state is still valid
|
|
207
|
+
public verifyState() {
|
|
208
|
+
return this.parentEpoch.verifyState();
|
|
227
209
|
}
|
|
228
210
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
public resolve(result: ProvingResult) {
|
|
232
|
-
if (!this.verifyState()) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_RESOLVED;
|
|
236
|
-
this.completionCallback(result);
|
|
211
|
+
public reject(reason: string) {
|
|
212
|
+
this.parentEpoch.reject(reason);
|
|
237
213
|
}
|
|
238
214
|
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { type MerkleTreeId } from '@aztec/circuit-types';
|
|
2
|
+
import {
|
|
3
|
+
type ARCHIVE_HEIGHT,
|
|
4
|
+
type AppendOnlyTreeSnapshot,
|
|
5
|
+
type BlockRootOrBlockMergePublicInputs,
|
|
6
|
+
Fr,
|
|
7
|
+
type GlobalVariables,
|
|
8
|
+
type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
9
|
+
type NESTED_RECURSIVE_PROOF_LENGTH,
|
|
10
|
+
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
11
|
+
type Proof,
|
|
12
|
+
type RecursiveProof,
|
|
13
|
+
type RootRollupPublicInputs,
|
|
14
|
+
type VerificationKeyAsFields,
|
|
15
|
+
} from '@aztec/circuits.js';
|
|
16
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
17
|
+
import { type Tuple } from '@aztec/foundation/serialize';
|
|
18
|
+
|
|
19
|
+
import { BlockProvingState } from './block-proving-state.js';
|
|
20
|
+
|
|
21
|
+
export type TreeSnapshots = Map<MerkleTreeId, AppendOnlyTreeSnapshot>;
|
|
22
|
+
|
|
23
|
+
enum PROVING_STATE_LIFECYCLE {
|
|
24
|
+
PROVING_STATE_CREATED,
|
|
25
|
+
PROVING_STATE_FULL,
|
|
26
|
+
PROVING_STATE_RESOLVED,
|
|
27
|
+
PROVING_STATE_REJECTED,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type BlockMergeRollupInputData = {
|
|
31
|
+
inputs: [BlockRootOrBlockMergePublicInputs | undefined, BlockRootOrBlockMergePublicInputs | undefined];
|
|
32
|
+
proofs: [
|
|
33
|
+
RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined,
|
|
34
|
+
RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined,
|
|
35
|
+
];
|
|
36
|
+
verificationKeys: [VerificationKeyAsFields | undefined, VerificationKeyAsFields | undefined];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type ProvingResult = { status: 'success' } | { status: 'failure'; reason: string };
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The current state of the proving schedule for an epoch.
|
|
43
|
+
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
|
|
44
|
+
* Carries an identifier so we can identify if the proving state is discarded and a new one started.
|
|
45
|
+
* Captures resolve and reject callbacks to provide a promise base interface to the consumer of our proving.
|
|
46
|
+
*/
|
|
47
|
+
export class EpochProvingState {
|
|
48
|
+
private provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
|
|
49
|
+
|
|
50
|
+
private mergeRollupInputs: BlockMergeRollupInputData[] = [];
|
|
51
|
+
public rootRollupPublicInputs: RootRollupPublicInputs | undefined;
|
|
52
|
+
public finalProof: Proof | undefined;
|
|
53
|
+
public blocks: BlockProvingState[] = [];
|
|
54
|
+
|
|
55
|
+
constructor(
|
|
56
|
+
public readonly epochNumber: number,
|
|
57
|
+
public readonly totalNumBlocks: number,
|
|
58
|
+
private completionCallback: (result: ProvingResult) => void,
|
|
59
|
+
private rejectionCallback: (reason: string) => void,
|
|
60
|
+
) {}
|
|
61
|
+
|
|
62
|
+
/** Returns the current block proving state */
|
|
63
|
+
public get currentBlock(): BlockProvingState | undefined {
|
|
64
|
+
return this.blocks.at(-1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Returns the number of levels of merge rollups
|
|
68
|
+
public get numMergeLevels() {
|
|
69
|
+
const totalLeaves = Math.max(2, this.totalNumBlocks);
|
|
70
|
+
return BigInt(Math.ceil(Math.log2(totalLeaves)) - 1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Calculates the index and level of the parent rollup circuit
|
|
74
|
+
// Based on tree implementation in unbalanced_tree.ts -> batchInsert()
|
|
75
|
+
// REFACTOR: This is repeated from the block orchestrator
|
|
76
|
+
public findMergeLevel(currentLevel: bigint, currentIndex: bigint) {
|
|
77
|
+
const totalLeaves = Math.max(2, this.totalNumBlocks);
|
|
78
|
+
const moveUpMergeLevel = (levelSize: number, index: bigint, nodeToShift: boolean) => {
|
|
79
|
+
levelSize /= 2;
|
|
80
|
+
if (levelSize & 1) {
|
|
81
|
+
[levelSize, nodeToShift] = nodeToShift ? [levelSize + 1, false] : [levelSize - 1, true];
|
|
82
|
+
}
|
|
83
|
+
index >>= 1n;
|
|
84
|
+
return { thisLevelSize: levelSize, thisIndex: index, shiftUp: nodeToShift };
|
|
85
|
+
};
|
|
86
|
+
let [thisLevelSize, shiftUp] = totalLeaves & 1 ? [totalLeaves - 1, true] : [totalLeaves, false];
|
|
87
|
+
const maxLevel = this.numMergeLevels + 1n;
|
|
88
|
+
let placeholder = currentIndex;
|
|
89
|
+
for (let i = 0; i < maxLevel - currentLevel; i++) {
|
|
90
|
+
({ thisLevelSize, thisIndex: placeholder, shiftUp } = moveUpMergeLevel(thisLevelSize, placeholder, shiftUp));
|
|
91
|
+
}
|
|
92
|
+
let thisIndex = currentIndex;
|
|
93
|
+
let mergeLevel = currentLevel;
|
|
94
|
+
while (thisIndex >= thisLevelSize && mergeLevel != 0n) {
|
|
95
|
+
mergeLevel -= 1n;
|
|
96
|
+
({ thisLevelSize, thisIndex, shiftUp } = moveUpMergeLevel(thisLevelSize, thisIndex, shiftUp));
|
|
97
|
+
}
|
|
98
|
+
return [mergeLevel - 1n, thisIndex >> 1n, thisIndex & 1n];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Adds a block to the proving state, returns its index
|
|
102
|
+
// Will update the proving life cycle if this is the last block
|
|
103
|
+
public startNewBlock(
|
|
104
|
+
numTxs: number,
|
|
105
|
+
globalVariables: GlobalVariables,
|
|
106
|
+
l1ToL2Messages: Fr[],
|
|
107
|
+
messageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
108
|
+
messageTreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
|
|
109
|
+
messageTreeSnapshotAfterInsertion: AppendOnlyTreeSnapshot,
|
|
110
|
+
archiveTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
111
|
+
archiveTreeRootSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
112
|
+
previousBlockHash: Fr,
|
|
113
|
+
) {
|
|
114
|
+
const block = new BlockProvingState(
|
|
115
|
+
this.blocks.length,
|
|
116
|
+
numTxs,
|
|
117
|
+
globalVariables,
|
|
118
|
+
padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
119
|
+
messageTreeSnapshot,
|
|
120
|
+
messageTreeRootSiblingPath,
|
|
121
|
+
messageTreeSnapshotAfterInsertion,
|
|
122
|
+
archiveTreeSnapshot,
|
|
123
|
+
archiveTreeRootSiblingPath,
|
|
124
|
+
previousBlockHash,
|
|
125
|
+
this,
|
|
126
|
+
);
|
|
127
|
+
this.blocks.push(block);
|
|
128
|
+
if (this.blocks.length === this.totalNumBlocks) {
|
|
129
|
+
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL;
|
|
130
|
+
}
|
|
131
|
+
return this.blocks.length - 1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Returns true if this proving state is still valid, false otherwise
|
|
135
|
+
public verifyState() {
|
|
136
|
+
return (
|
|
137
|
+
this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED ||
|
|
138
|
+
this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Returns true if we are still able to accept blocks, false otherwise
|
|
143
|
+
public isAcceptingBlocks() {
|
|
144
|
+
return this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Stores the inputs to a merge circuit and determines if the circuit is ready to be executed
|
|
149
|
+
* @param mergeInputs - The inputs to store
|
|
150
|
+
* @param indexWithinMerge - The index in the set of inputs to this merge circuit
|
|
151
|
+
* @param indexOfMerge - The global index of this merge circuit
|
|
152
|
+
* @returns True if the merge circuit is ready to be executed, false otherwise
|
|
153
|
+
*/
|
|
154
|
+
public storeMergeInputs(
|
|
155
|
+
mergeInputs: [
|
|
156
|
+
BlockRootOrBlockMergePublicInputs,
|
|
157
|
+
RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>,
|
|
158
|
+
VerificationKeyAsFields,
|
|
159
|
+
],
|
|
160
|
+
indexWithinMerge: number,
|
|
161
|
+
indexOfMerge: number,
|
|
162
|
+
) {
|
|
163
|
+
if (!this.mergeRollupInputs[indexOfMerge]) {
|
|
164
|
+
const mergeInputData: BlockMergeRollupInputData = {
|
|
165
|
+
inputs: [undefined, undefined],
|
|
166
|
+
proofs: [undefined, undefined],
|
|
167
|
+
verificationKeys: [undefined, undefined],
|
|
168
|
+
};
|
|
169
|
+
mergeInputData.inputs[indexWithinMerge] = mergeInputs[0];
|
|
170
|
+
mergeInputData.proofs[indexWithinMerge] = mergeInputs[1];
|
|
171
|
+
mergeInputData.verificationKeys[indexWithinMerge] = mergeInputs[2];
|
|
172
|
+
this.mergeRollupInputs[indexOfMerge] = mergeInputData;
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
const mergeInputData = this.mergeRollupInputs[indexOfMerge];
|
|
176
|
+
mergeInputData.inputs[indexWithinMerge] = mergeInputs[0];
|
|
177
|
+
mergeInputData.proofs[indexWithinMerge] = mergeInputs[1];
|
|
178
|
+
mergeInputData.verificationKeys[indexWithinMerge] = mergeInputs[2];
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Returns a specific transaction proving state
|
|
183
|
+
public getBlockProvingState(index: number) {
|
|
184
|
+
return this.blocks[index];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Returns a set of merge rollup inputs
|
|
188
|
+
public getMergeInputs(indexOfMerge: number) {
|
|
189
|
+
return this.mergeRollupInputs[indexOfMerge];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
193
|
+
public isReadyForRootRollup() {
|
|
194
|
+
return !(this.mergeRollupInputs[0] === undefined || this.mergeRollupInputs[0].inputs.findIndex(p => !p) !== -1);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Attempts to reject the proving state promise with a reason of 'cancelled'
|
|
198
|
+
public cancel() {
|
|
199
|
+
this.reject('Proving cancelled');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Attempts to reject the proving state promise with the given reason
|
|
203
|
+
// Does nothing if not in a valid state
|
|
204
|
+
public reject(reason: string) {
|
|
205
|
+
if (!this.verifyState()) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_REJECTED;
|
|
209
|
+
this.rejectionCallback(reason);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Attempts to resolve the proving state promise with the given result
|
|
213
|
+
// Does nothing if not in a valid state
|
|
214
|
+
public resolve(result: ProvingResult) {
|
|
215
|
+
if (!this.verifyState()) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_RESOLVED;
|
|
219
|
+
this.completionCallback(result);
|
|
220
|
+
}
|
|
221
|
+
}
|