@aztec/prover-client 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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 +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +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 +34 -14
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +122 -27
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +6 -5
- package/dest/mocks/test_context.d.ts +5 -3
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +28 -11
- package/dest/orchestrator/block-building-helpers.d.ts +6 -6
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +7 -6
- package/dest/orchestrator/block-proving-state.d.ts +8 -4
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +8 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts +22 -8
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +43 -8
- package/dest/orchestrator/epoch-proving-state.d.ts +10 -9
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +38 -2
- package/dest/orchestrator/orchestrator.d.ts +23 -8
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +548 -154
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -15
- package/dest/orchestrator/tx-proving-state.d.ts +6 -5
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +8 -8
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/prover-client.d.ts +5 -5
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +15 -10
- package/dest/prover-client/server-epoch-prover.d.ts +5 -5
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.d.ts +7 -5
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +6 -13
- package/dest/proving_broker/config.d.ts +14 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +20 -3
- package/dest/proving_broker/fixtures.js +1 -1
- 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 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_agent.d.ts +5 -9
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -19
- package/dest/proving_broker/proving_broker.d.ts +7 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +33 -11
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +389 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +15 -35
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +8 -6
- package/dest/proving_broker/rpc.d.ts +4 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +8 -0
- package/dest/test/mock_proof_store.d.ts +3 -3
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +5 -5
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +4 -4
- package/package.json +20 -19
- package/src/config.ts +1 -1
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +186 -34
- package/src/mocks/fixtures.ts +6 -5
- package/src/mocks/test_context.ts +26 -11
- package/src/orchestrator/block-building-helpers.ts +7 -6
- package/src/orchestrator/block-proving-state.ts +12 -2
- package/src/orchestrator/checkpoint-proving-state.ts +60 -12
- package/src/orchestrator/epoch-proving-state.ts +66 -13
- package/src/orchestrator/orchestrator.ts +154 -143
- package/src/orchestrator/orchestrator_metrics.ts +2 -25
- package/src/orchestrator/tx-proving-state.ts +10 -14
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +31 -23
- package/src/prover-client/server-epoch-prover.ts +4 -4
- package/src/proving_broker/broker_prover_facade.ts +10 -17
- package/src/proving_broker/config.ts +23 -1
- package/src/proving_broker/fixtures.ts +1 -1
- 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 -1
- package/src/proving_broker/proving_agent.ts +6 -19
- package/src/proving_broker/proving_broker.ts +34 -9
- package/src/proving_broker/proving_broker_database/persisted.ts +15 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +14 -35
- package/src/proving_broker/proving_job_controller.ts +11 -6
- package/src/proving_broker/rpc.ts +14 -0
- package/src/test/mock_prover.ts +2 -14
- package/dest/block-factory/index.d.ts +0 -2
- package/dest/block-factory/index.d.ts.map +0 -1
- package/dest/block-factory/index.js +0 -1
- package/dest/block-factory/light.d.ts +0 -38
- package/dest/block-factory/light.d.ts.map +0 -1
- package/dest/block-factory/light.js +0 -108
- 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 -52
- 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/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -137
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,19 +1,386 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
6
372
|
}
|
|
373
|
+
var _dec, _dec1, _dec2, _dec3, _dec4, _initProto;
|
|
7
374
|
import { L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUM_BASE_PARITY_PER_ROOT_PARITY } from '@aztec/constants';
|
|
375
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
8
376
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
377
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
378
|
import { AbortError } from '@aztec/foundation/error';
|
|
10
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
11
379
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
380
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
13
381
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
14
382
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
15
383
|
import { elapsed } from '@aztec/foundation/timer';
|
|
16
|
-
import { readAvmMinimalPublicTxInputsFromFile } from '@aztec/simulator/public/fixtures';
|
|
17
384
|
import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
18
385
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
19
386
|
import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
|
|
@@ -22,7 +389,15 @@ import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifi
|
|
|
22
389
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
23
390
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
24
391
|
import { TxProvingState } from './tx-proving-state.js';
|
|
25
|
-
|
|
392
|
+
_dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
393
|
+
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
394
|
+
})), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
|
|
395
|
+
[Attributes.BLOCK_TXS_COUNT]: txs.length
|
|
396
|
+
})), _dec2 = trackSpan('ProvingOrchestrator.startChonkVerifierCircuits'), _dec3 = trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
|
|
397
|
+
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
398
|
+
})), _dec4 = trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
|
|
399
|
+
[Attributes.TX_HASH]: tx.hash.toString()
|
|
400
|
+
}));
|
|
26
401
|
/**
|
|
27
402
|
* Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
|
|
28
403
|
* 1. Transactions are provided to the scheduler post simulation.
|
|
@@ -38,19 +413,53 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
38
413
|
dbProvider;
|
|
39
414
|
prover;
|
|
40
415
|
proverId;
|
|
416
|
+
cancelJobsOnStop;
|
|
417
|
+
static{
|
|
418
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
419
|
+
[
|
|
420
|
+
_dec,
|
|
421
|
+
2,
|
|
422
|
+
"startNewBlock"
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
_dec1,
|
|
426
|
+
2,
|
|
427
|
+
"addTxs"
|
|
428
|
+
],
|
|
429
|
+
[
|
|
430
|
+
_dec2,
|
|
431
|
+
2,
|
|
432
|
+
"startChonkVerifierCircuits"
|
|
433
|
+
],
|
|
434
|
+
[
|
|
435
|
+
_dec3,
|
|
436
|
+
2,
|
|
437
|
+
"setBlockCompleted"
|
|
438
|
+
],
|
|
439
|
+
[
|
|
440
|
+
_dec4,
|
|
441
|
+
2,
|
|
442
|
+
"prepareBaseRollupInputs"
|
|
443
|
+
]
|
|
444
|
+
], []));
|
|
445
|
+
}
|
|
41
446
|
provingState;
|
|
42
447
|
pendingProvingJobs;
|
|
43
448
|
provingPromise;
|
|
44
449
|
metrics;
|
|
450
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
45
451
|
dbs;
|
|
46
|
-
|
|
452
|
+
logger;
|
|
453
|
+
constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, telemetryClient = getTelemetryClient(), bindings){
|
|
47
454
|
this.dbProvider = dbProvider;
|
|
48
455
|
this.prover = prover;
|
|
49
456
|
this.proverId = proverId;
|
|
50
|
-
this.
|
|
457
|
+
this.cancelJobsOnStop = cancelJobsOnStop;
|
|
458
|
+
this.provingState = (_initProto(this), undefined);
|
|
51
459
|
this.pendingProvingJobs = [];
|
|
52
460
|
this.provingPromise = undefined;
|
|
53
461
|
this.dbs = new Map();
|
|
462
|
+
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
54
463
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
55
464
|
}
|
|
56
465
|
get tracer() {
|
|
@@ -59,6 +468,9 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
59
468
|
getProverId() {
|
|
60
469
|
return this.proverId;
|
|
61
470
|
}
|
|
471
|
+
getNumActiveForks() {
|
|
472
|
+
return this.dbs.size;
|
|
473
|
+
}
|
|
62
474
|
stop() {
|
|
63
475
|
this.cancel();
|
|
64
476
|
return Promise.resolve();
|
|
@@ -72,11 +484,18 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
72
484
|
status: 'failure',
|
|
73
485
|
reason
|
|
74
486
|
}));
|
|
75
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
487
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
76
488
|
this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
|
|
77
489
|
this.provingPromise = promise;
|
|
78
490
|
}
|
|
79
|
-
|
|
491
|
+
/**
|
|
492
|
+
* Starts a new checkpoint.
|
|
493
|
+
* @param checkpointIndex - The index of the checkpoint in the epoch.
|
|
494
|
+
* @param constants - The constants for this checkpoint.
|
|
495
|
+
* @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
|
|
496
|
+
* @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
|
|
497
|
+
* @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
|
|
498
|
+
*/ async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
|
|
80
499
|
if (!this.provingState) {
|
|
81
500
|
throw new Error('Empty epoch proving state. Call startNewEpoch before starting a checkpoint.');
|
|
82
501
|
}
|
|
@@ -86,7 +505,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
86
505
|
// Fork world state at the end of the immediately previous block.
|
|
87
506
|
const lastBlockNumber = headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber;
|
|
88
507
|
const db = await this.dbProvider.fork(lastBlockNumber);
|
|
89
|
-
const firstBlockNumber = lastBlockNumber + 1;
|
|
508
|
+
const firstBlockNumber = BlockNumber(lastBlockNumber + 1);
|
|
90
509
|
this.dbs.set(firstBlockNumber, db);
|
|
91
510
|
// Get archive sibling path before any block in this checkpoint lands.
|
|
92
511
|
const lastArchiveSiblingPath = await getLastSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
@@ -112,14 +531,14 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
112
531
|
throw new Error(`Checkpoint not accepting further blocks.`);
|
|
113
532
|
}
|
|
114
533
|
const constants = checkpointProvingState.constants;
|
|
115
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
534
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
116
535
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
117
536
|
if (!this.dbs.has(blockNumber)) {
|
|
118
537
|
// Fork world state at the end of the immediately previous block
|
|
119
|
-
const db = await this.dbProvider.fork(blockNumber - 1);
|
|
538
|
+
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
120
539
|
this.dbs.set(blockNumber, db);
|
|
121
540
|
}
|
|
122
|
-
const db = this.
|
|
541
|
+
const db = this.getDbForBlock(blockNumber);
|
|
123
542
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
124
543
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
125
544
|
const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
@@ -139,7 +558,8 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
139
558
|
const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
|
|
140
559
|
await endSpongeBlob.absorb(blockEndBlobFields);
|
|
141
560
|
blockProvingState.setEndSpongeBlob(endSpongeBlob);
|
|
142
|
-
//
|
|
561
|
+
// Try to accumulate the out hashes and blobs as far as we can:
|
|
562
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
143
563
|
await this.provingState.setBlobAccumulators();
|
|
144
564
|
}
|
|
145
565
|
}
|
|
@@ -153,10 +573,10 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
153
573
|
if (!txs.length) {
|
|
154
574
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
155
575
|
// on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
|
|
156
|
-
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
576
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
157
577
|
return;
|
|
158
578
|
}
|
|
159
|
-
const blockNumber = txs[0].globalVariables.blockNumber;
|
|
579
|
+
const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
|
|
160
580
|
const provingState = this.provingState.getBlockProvingStateByBlockNumber(blockNumber);
|
|
161
581
|
if (!provingState) {
|
|
162
582
|
throw new Error(`Proving state for block ${blockNumber} not found. Call startNewBlock first.`);
|
|
@@ -167,8 +587,8 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
167
587
|
if (!provingState.isAcceptingTxs()) {
|
|
168
588
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
169
589
|
}
|
|
170
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
171
|
-
const db = this.
|
|
590
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
591
|
+
const db = this.getDbForBlock(blockNumber);
|
|
172
592
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
173
593
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
174
594
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -178,7 +598,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
178
598
|
throw new Error(`Invalid proving state when adding a tx`);
|
|
179
599
|
}
|
|
180
600
|
validateTx(tx);
|
|
181
|
-
logger.
|
|
601
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
182
602
|
const startSpongeBlob = spongeBlobState.clone();
|
|
183
603
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
|
|
184
604
|
if (!provingState.verifyState()) {
|
|
@@ -189,10 +609,10 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
189
609
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
190
610
|
if (txProvingState.requireAvmProof) {
|
|
191
611
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
192
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
612
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
193
613
|
this.enqueueVM(provingState, txIndex);
|
|
194
614
|
} else {
|
|
195
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
615
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
196
616
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
197
617
|
}
|
|
198
618
|
} catch (err) {
|
|
@@ -206,7 +626,8 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
206
626
|
const blockEndBlobFields = provingState.getBlockEndBlobFields();
|
|
207
627
|
await spongeBlobState.absorb(blockEndBlobFields);
|
|
208
628
|
provingState.setEndSpongeBlob(spongeBlobState);
|
|
209
|
-
// Txs have been added to the block. Now try to accumulate the blobs as far as we can:
|
|
629
|
+
// Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
|
|
630
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
210
631
|
await this.provingState.setBlobAccumulators();
|
|
211
632
|
}
|
|
212
633
|
/**
|
|
@@ -221,7 +642,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
221
642
|
const txHash = tx.getTxHash().toString();
|
|
222
643
|
const privateInputs = getPublicChonkVerifierPrivateInputsFromTx(tx, this.proverId.toField());
|
|
223
644
|
const tubeProof = promiseWithResolvers();
|
|
224
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
645
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
225
646
|
this.doEnqueueChonkVerifier(txHash, privateInputs, (proof)=>{
|
|
226
647
|
tubeProof.resolve(proof);
|
|
227
648
|
});
|
|
@@ -250,17 +671,23 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
250
671
|
throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
|
|
251
672
|
}
|
|
252
673
|
// Given we've applied every change from this block, now assemble the block header:
|
|
253
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
674
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
254
675
|
const header = await provingState.buildBlockHeader();
|
|
255
676
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
256
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
677
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
257
678
|
throw new Error('Block header mismatch');
|
|
258
679
|
}
|
|
259
|
-
// Get db for this block
|
|
260
|
-
const db = this.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
680
|
+
// Get db for this block and remove from map — no other code should use it after this point.
|
|
681
|
+
const db = this.getDbForBlock(provingState.blockNumber);
|
|
682
|
+
this.dbs.delete(provingState.blockNumber);
|
|
683
|
+
// Update the archive tree, capture the snapshot, and close the fork deterministically.
|
|
684
|
+
try {
|
|
685
|
+
this.logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
|
|
686
|
+
await db.updateArchive(header);
|
|
687
|
+
provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
|
|
688
|
+
} finally{
|
|
689
|
+
await db.close();
|
|
690
|
+
}
|
|
264
691
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
265
692
|
return header;
|
|
266
693
|
}
|
|
@@ -268,50 +695,61 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
268
695
|
async verifyBuiltBlockAgainstSyncedState(provingState) {
|
|
269
696
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
270
697
|
if (!builtBlockHeader) {
|
|
271
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
698
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
272
699
|
return;
|
|
273
700
|
}
|
|
274
701
|
const output = provingState.getBlockRootRollupOutput();
|
|
275
702
|
if (!output) {
|
|
276
|
-
logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
703
|
+
this.logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
const newArchive = provingState.getBuiltArchive();
|
|
707
|
+
if (!newArchive) {
|
|
708
|
+
this.logger.debug('Archive snapshot not yet captured, skipping header check.');
|
|
277
709
|
return;
|
|
278
710
|
}
|
|
279
711
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
280
712
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
281
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
713
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
282
714
|
provingState.reject(`Block header hash mismatch.`);
|
|
283
715
|
return;
|
|
284
716
|
}
|
|
285
|
-
// Get db for this block
|
|
286
717
|
const blockNumber = provingState.blockNumber;
|
|
287
|
-
const db = this.dbs.get(blockNumber);
|
|
288
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
289
718
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
290
719
|
if (!syncedArchive.equals(newArchive)) {
|
|
291
|
-
logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
720
|
+
this.logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
292
721
|
provingState.reject(`Archive tree mismatch.`);
|
|
293
722
|
return;
|
|
294
723
|
}
|
|
295
724
|
const circuitArchive = output.newArchive;
|
|
296
725
|
if (!newArchive.equals(circuitArchive)) {
|
|
297
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
726
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
298
727
|
provingState.reject(`New archive mismatch.`);
|
|
299
728
|
return;
|
|
300
729
|
}
|
|
301
|
-
// TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
|
|
302
|
-
// is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
|
|
303
|
-
// but have to make sure it only runs once all operations are completed, otherwise some function here
|
|
304
|
-
// will attempt to access the fork after it was closed.
|
|
305
|
-
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
306
|
-
void this.dbs.get(blockNumber)?.close().then(()=>this.dbs.delete(blockNumber)).catch((err)=>logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
307
730
|
}
|
|
308
731
|
/**
|
|
309
|
-
* Cancel any further proving
|
|
732
|
+
* Cancel any further proving.
|
|
733
|
+
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
734
|
+
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
310
735
|
*/ cancel() {
|
|
311
|
-
|
|
312
|
-
controller.
|
|
736
|
+
if (this.cancelJobsOnStop) {
|
|
737
|
+
for (const controller of this.pendingProvingJobs){
|
|
738
|
+
controller.abort();
|
|
739
|
+
}
|
|
313
740
|
}
|
|
314
741
|
this.provingState?.cancel();
|
|
742
|
+
for (const [blockNumber, db] of this.dbs.entries()){
|
|
743
|
+
void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
744
|
+
}
|
|
745
|
+
this.dbs.clear();
|
|
746
|
+
}
|
|
747
|
+
getDbForBlock(blockNumber) {
|
|
748
|
+
const db = this.dbs.get(blockNumber);
|
|
749
|
+
if (!db) {
|
|
750
|
+
throw new Error(`World state fork for block ${blockNumber} not found.`);
|
|
751
|
+
}
|
|
752
|
+
return db;
|
|
315
753
|
}
|
|
316
754
|
/**
|
|
317
755
|
* Returns the proof for the current epoch.
|
|
@@ -338,7 +776,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
338
776
|
* @param job - The actual job, returns a promise notifying of the job's completion
|
|
339
777
|
*/ deferredProving(provingState, request, callback) {
|
|
340
778
|
if (!provingState.verifyState()) {
|
|
341
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
779
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
342
780
|
return;
|
|
343
781
|
}
|
|
344
782
|
const controller = new AbortController();
|
|
@@ -353,7 +791,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
353
791
|
}
|
|
354
792
|
const result = await request(controller.signal);
|
|
355
793
|
if (!provingState.verifyState()) {
|
|
356
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
794
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
357
795
|
return;
|
|
358
796
|
}
|
|
359
797
|
// we could have been cancelled whilst waiting for the result
|
|
@@ -368,7 +806,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
368
806
|
// drop this result
|
|
369
807
|
return;
|
|
370
808
|
}
|
|
371
|
-
logger.error(`Error thrown when proving job`, err);
|
|
809
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
372
810
|
provingState.reject(`${err}`);
|
|
373
811
|
} finally{
|
|
374
812
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -424,17 +862,17 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
424
862
|
// Executes the next level of merge if all inputs are available
|
|
425
863
|
enqueueBaseRollup(provingState, txIndex) {
|
|
426
864
|
if (!provingState.verifyState()) {
|
|
427
|
-
logger.debug('Not running base rollup, state invalid');
|
|
865
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
428
866
|
return;
|
|
429
867
|
}
|
|
430
868
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
431
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
869
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
432
870
|
return;
|
|
433
871
|
}
|
|
434
872
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
435
873
|
const { processedTx } = txProvingState;
|
|
436
874
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
437
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
875
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
438
876
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${inputs instanceof PrivateTxBaseRollupPrivateInputs ? 'getPrivateTxBaseRollupProof' : 'getPublicTxBaseRollupProof'}`, {
|
|
439
877
|
[Attributes.TX_HASH]: processedTx.hash.toString(),
|
|
440
878
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
@@ -445,7 +883,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
445
883
|
return this.prover.getPublicTxBaseRollupProof(inputs, signal, provingState.epochNumber);
|
|
446
884
|
}
|
|
447
885
|
}), (result)=>{
|
|
448
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
886
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
449
887
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
450
888
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
451
889
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -459,14 +897,14 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
459
897
|
// Once completed, will enqueue the the public tx base rollup.
|
|
460
898
|
getOrEnqueueChonkVerifier(provingState, txIndex) {
|
|
461
899
|
if (!provingState.verifyState()) {
|
|
462
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
900
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
463
901
|
return;
|
|
464
902
|
}
|
|
465
903
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
466
904
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
467
905
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
|
|
468
906
|
const handleResult = (result)=>{
|
|
469
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
907
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
470
908
|
txHash
|
|
471
909
|
});
|
|
472
910
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
@@ -474,18 +912,18 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
474
912
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
475
913
|
};
|
|
476
914
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
477
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
915
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
478
916
|
txHash
|
|
479
917
|
});
|
|
480
918
|
void this.provingState.cachedChonkVerifierProofs.get(txHash).then(handleResult);
|
|
481
919
|
return;
|
|
482
920
|
}
|
|
483
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
921
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
484
922
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
485
923
|
}
|
|
486
924
|
doEnqueueChonkVerifier(txHash, inputs, handler, provingState = this.provingState) {
|
|
487
925
|
if (!provingState.verifyState()) {
|
|
488
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
926
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
489
927
|
return;
|
|
490
928
|
}
|
|
491
929
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getPublicChonkVerifierProof', {
|
|
@@ -497,11 +935,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
497
935
|
// Enqueues the next level of merge if all inputs are available
|
|
498
936
|
enqueueMergeRollup(provingState, location) {
|
|
499
937
|
if (!provingState.verifyState()) {
|
|
500
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
938
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
501
939
|
return;
|
|
502
940
|
}
|
|
503
941
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
504
|
-
logger.debug('Merge rollup already started.');
|
|
942
|
+
this.logger.debug('Merge rollup already started.');
|
|
505
943
|
return;
|
|
506
944
|
}
|
|
507
945
|
const inputs = provingState.getMergeRollupInputs(location);
|
|
@@ -515,15 +953,15 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
515
953
|
// Executes the block root rollup circuit
|
|
516
954
|
enqueueBlockRootRollup(provingState) {
|
|
517
955
|
if (!provingState.verifyState()) {
|
|
518
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
956
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
519
957
|
return;
|
|
520
958
|
}
|
|
521
959
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
522
|
-
logger.debug('Block root rollup already started.');
|
|
960
|
+
this.logger.debug('Block root rollup already started.');
|
|
523
961
|
return;
|
|
524
962
|
}
|
|
525
963
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
526
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
964
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
527
965
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockRootRollupProof', {
|
|
528
966
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
529
967
|
}, (signal)=>{
|
|
@@ -539,15 +977,16 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
539
977
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
540
978
|
}
|
|
541
979
|
}), async (result)=>{
|
|
542
|
-
|
|
543
|
-
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
544
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
980
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
545
981
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
546
982
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
983
|
+
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
984
|
+
// will be the first to see all three pieces (header, proof output, archive) and run the checks.
|
|
985
|
+
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
547
986
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
548
|
-
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
987
|
+
await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
549
988
|
} else {
|
|
550
|
-
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
989
|
+
await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
551
990
|
}
|
|
552
991
|
});
|
|
553
992
|
}
|
|
@@ -555,11 +994,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
555
994
|
// Enqueues the root parity circuit if all inputs are available
|
|
556
995
|
enqueueBaseParityCircuit(checkpointProvingState, provingState, baseParityIndex) {
|
|
557
996
|
if (!provingState.verifyState()) {
|
|
558
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
997
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
559
998
|
return;
|
|
560
999
|
}
|
|
561
1000
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
562
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
1001
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
563
1002
|
return;
|
|
564
1003
|
}
|
|
565
1004
|
const inputs = checkpointProvingState.getBaseParityInputs(baseParityIndex);
|
|
@@ -580,11 +1019,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
580
1019
|
// Enqueues the root rollup proof if all inputs are available
|
|
581
1020
|
enqueueRootParityCircuit(provingState) {
|
|
582
1021
|
if (!provingState.verifyState()) {
|
|
583
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
1022
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
584
1023
|
return;
|
|
585
1024
|
}
|
|
586
1025
|
if (!provingState.tryStartProvingRootParity()) {
|
|
587
|
-
logger.debug('Root parity already started.');
|
|
1026
|
+
this.logger.debug('Root parity already started.');
|
|
588
1027
|
return;
|
|
589
1028
|
}
|
|
590
1029
|
const inputs = provingState.getParityRootInputs();
|
|
@@ -599,33 +1038,33 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
599
1038
|
// Enqueues the next level of merge if all inputs are available
|
|
600
1039
|
enqueueBlockMergeRollup(provingState, location) {
|
|
601
1040
|
if (!provingState.verifyState()) {
|
|
602
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1041
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
603
1042
|
return;
|
|
604
1043
|
}
|
|
605
1044
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
606
|
-
logger.debug('Block merge rollup already started.');
|
|
1045
|
+
this.logger.debug('Block merge rollup already started.');
|
|
607
1046
|
return;
|
|
608
1047
|
}
|
|
609
1048
|
const inputs = provingState.getBlockMergeRollupInputs(location);
|
|
610
1049
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
|
|
611
1050
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
|
|
612
|
-
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1051
|
+
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
|
|
613
1052
|
provingState.setBlockMergeRollupProof(location, result);
|
|
614
|
-
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1053
|
+
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
615
1054
|
});
|
|
616
1055
|
}
|
|
617
|
-
enqueueCheckpointRootRollup(provingState) {
|
|
1056
|
+
async enqueueCheckpointRootRollup(provingState) {
|
|
618
1057
|
if (!provingState.verifyState()) {
|
|
619
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1058
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
620
1059
|
return;
|
|
621
1060
|
}
|
|
622
1061
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
623
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1062
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
624
1063
|
return;
|
|
625
1064
|
}
|
|
626
1065
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
627
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
628
|
-
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1066
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1067
|
+
const inputs = await provingState.getCheckpointRootRollupInputs();
|
|
629
1068
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointRootRollupProof', {
|
|
630
1069
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
631
1070
|
}, (signal)=>{
|
|
@@ -638,11 +1077,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
638
1077
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator().toBlobAccumulator();
|
|
639
1078
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
640
1079
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
641
|
-
logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
1080
|
+
this.logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
642
1081
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
643
1082
|
return;
|
|
644
1083
|
}
|
|
645
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1084
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
646
1085
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
647
1086
|
const epochProvingState = provingState.parentEpoch;
|
|
648
1087
|
if (epochProvingState.totalNumCheckpoints === 1) {
|
|
@@ -654,37 +1093,37 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
654
1093
|
}
|
|
655
1094
|
enqueueCheckpointMergeRollup(provingState, location) {
|
|
656
1095
|
if (!provingState.verifyState()) {
|
|
657
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1096
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
658
1097
|
return;
|
|
659
1098
|
}
|
|
660
1099
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
661
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1100
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
662
1101
|
return;
|
|
663
1102
|
}
|
|
664
1103
|
const inputs = provingState.getCheckpointMergeRollupInputs(location);
|
|
665
1104
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
|
|
666
1105
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
|
|
667
1106
|
}, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
668
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1107
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
669
1108
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
670
1109
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
671
1110
|
});
|
|
672
1111
|
}
|
|
673
1112
|
enqueueEpochPadding(provingState) {
|
|
674
1113
|
if (!provingState.verifyState()) {
|
|
675
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1114
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
676
1115
|
return;
|
|
677
1116
|
}
|
|
678
1117
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
679
|
-
logger.debug('Padding checkpoint already started.');
|
|
1118
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
680
1119
|
return;
|
|
681
1120
|
}
|
|
682
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1121
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
683
1122
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
684
1123
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
|
|
685
1124
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
|
|
686
1125
|
}, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
687
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1126
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
688
1127
|
provingState.setCheckpointPaddingProof(result);
|
|
689
1128
|
this.checkAndEnqueueRootRollup(provingState);
|
|
690
1129
|
});
|
|
@@ -692,15 +1131,15 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
692
1131
|
// Executes the root rollup circuit
|
|
693
1132
|
enqueueRootRollup(provingState) {
|
|
694
1133
|
if (!provingState.verifyState()) {
|
|
695
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1134
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
696
1135
|
return;
|
|
697
1136
|
}
|
|
698
|
-
logger.debug(`Preparing root rollup`);
|
|
1137
|
+
this.logger.debug(`Preparing root rollup`);
|
|
699
1138
|
const inputs = provingState.getRootRollupInputs();
|
|
700
1139
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
|
|
701
1140
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
|
|
702
1141
|
}, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
703
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1142
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
704
1143
|
provingState.setRootRollupProof(result);
|
|
705
1144
|
provingState.resolve({
|
|
706
1145
|
status: 'success'
|
|
@@ -720,27 +1159,27 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
720
1159
|
}
|
|
721
1160
|
checkAndEnqueueBlockRootRollup(provingState) {
|
|
722
1161
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
723
|
-
logger.debug('Not ready for block root rollup');
|
|
1162
|
+
this.logger.debug('Not ready for block root rollup');
|
|
724
1163
|
return;
|
|
725
1164
|
}
|
|
726
1165
|
this.enqueueBlockRootRollup(provingState);
|
|
727
1166
|
}
|
|
728
|
-
checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1167
|
+
async checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
729
1168
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
730
1169
|
return;
|
|
731
1170
|
}
|
|
732
1171
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
733
1172
|
if (parentLocation.level === 0) {
|
|
734
|
-
this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1173
|
+
await this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
735
1174
|
} else {
|
|
736
1175
|
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
737
1176
|
}
|
|
738
1177
|
}
|
|
739
|
-
checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1178
|
+
async checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
740
1179
|
if (!provingState.isReadyForCheckpointRoot()) {
|
|
741
1180
|
return;
|
|
742
1181
|
}
|
|
743
|
-
this.enqueueCheckpointRootRollup(provingState);
|
|
1182
|
+
await this.enqueueCheckpointRootRollup(provingState);
|
|
744
1183
|
}
|
|
745
1184
|
checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
|
|
746
1185
|
if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
|
|
@@ -755,7 +1194,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
755
1194
|
}
|
|
756
1195
|
checkAndEnqueueRootRollup(provingState) {
|
|
757
1196
|
if (!provingState.isReadyForRootRollup()) {
|
|
758
|
-
logger.debug('Not ready for root rollup');
|
|
1197
|
+
this.logger.debug('Not ready for root rollup');
|
|
759
1198
|
return;
|
|
760
1199
|
}
|
|
761
1200
|
this.enqueueRootRollup(provingState);
|
|
@@ -767,41 +1206,19 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
767
1206
|
* @param txIndex - The index of the transaction being proven
|
|
768
1207
|
*/ enqueueVM(provingState, txIndex) {
|
|
769
1208
|
if (!provingState.verifyState()) {
|
|
770
|
-
logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1209
|
+
this.logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
771
1210
|
return;
|
|
772
1211
|
}
|
|
773
1212
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
774
|
-
// This function tries to do AVM proving. If there is a failure, it fakes the proof unless AVM_PROVING_STRICT is defined.
|
|
775
|
-
// Nothing downstream depends on the AVM proof yet. So having this mode lets us incrementally build the AVM circuit.
|
|
776
1213
|
const doAvmProving = wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getAvmProof', {
|
|
777
1214
|
[Attributes.TX_HASH]: txProvingState.processedTx.hash.toString()
|
|
778
1215
|
}, async (signal)=>{
|
|
779
1216
|
const inputs = txProvingState.getAvmInputs();
|
|
780
|
-
|
|
781
|
-
// TODO(#14234)[Unconditional PIs validation]: Remove the whole try-catch logic and
|
|
782
|
-
// just keep the next line but removing the second argument (false).
|
|
783
|
-
return await this.prover.getAvmProof(inputs, false, signal, provingState.epochNumber);
|
|
784
|
-
} catch (err) {
|
|
785
|
-
if (process.env.AVM_PROVING_STRICT) {
|
|
786
|
-
logger.error(`Error thrown when proving AVM circuit with AVM_PROVING_STRICT on`, err);
|
|
787
|
-
throw err;
|
|
788
|
-
} else {
|
|
789
|
-
logger.warn(`Error thrown when proving AVM circuit but AVM_PROVING_STRICT is off. Use snapshotted
|
|
790
|
-
AVM inputs and carrying on. ${inspect(err)}.`);
|
|
791
|
-
try {
|
|
792
|
-
this.metrics.incAvmFallback();
|
|
793
|
-
const snapshotAvmPrivateInputs = readAvmMinimalPublicTxInputsFromFile();
|
|
794
|
-
return await this.prover.getAvmProof(snapshotAvmPrivateInputs, true, signal, provingState.epochNumber);
|
|
795
|
-
} catch (err) {
|
|
796
|
-
logger.error(`Error thrown when proving snapshotted AVM inputs.`, err);
|
|
797
|
-
throw err;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
}
|
|
1217
|
+
return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
|
|
801
1218
|
});
|
|
802
|
-
this.deferredProving(provingState, doAvmProving, (
|
|
803
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
804
|
-
txProvingState.setAvmProof(
|
|
1219
|
+
this.deferredProving(provingState, doAvmProving, (proof)=>{
|
|
1220
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1221
|
+
txProvingState.setAvmProof(proof);
|
|
805
1222
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
806
1223
|
});
|
|
807
1224
|
}
|
|
@@ -811,30 +1228,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
811
1228
|
return;
|
|
812
1229
|
}
|
|
813
1230
|
// We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
814
|
-
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1231
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
815
1232
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
816
1233
|
}
|
|
817
1234
|
}
|
|
818
|
-
_ts_decorate([
|
|
819
|
-
trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
820
|
-
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
821
|
-
}))
|
|
822
|
-
], ProvingOrchestrator.prototype, "startNewBlock", null);
|
|
823
|
-
_ts_decorate([
|
|
824
|
-
trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
|
|
825
|
-
[Attributes.BLOCK_TXS_COUNT]: txs.length
|
|
826
|
-
}))
|
|
827
|
-
], ProvingOrchestrator.prototype, "addTxs", null);
|
|
828
|
-
_ts_decorate([
|
|
829
|
-
trackSpan('ProvingOrchestrator.startChonkVerifierCircuits')
|
|
830
|
-
], ProvingOrchestrator.prototype, "startChonkVerifierCircuits", null);
|
|
831
|
-
_ts_decorate([
|
|
832
|
-
trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
|
|
833
|
-
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
834
|
-
}))
|
|
835
|
-
], ProvingOrchestrator.prototype, "setBlockCompleted", null);
|
|
836
|
-
_ts_decorate([
|
|
837
|
-
trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
|
|
838
|
-
[Attributes.TX_HASH]: tx.hash.toString()
|
|
839
|
-
}))
|
|
840
|
-
], ProvingOrchestrator.prototype, "prepareBaseRollupInputs", null);
|