@aztec/prover-client 0.0.1-commit.9b94fc1 → 0.0.1-commit.9badcec54
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 +13 -3
- 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 +38 -14
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +148 -32
- 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 +40 -18
- 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 +25 -8
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +568 -158
- 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 +6 -6
- 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 +18 -31
- package/dest/proving_broker/config.d.ts +15 -3
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +22 -5
- 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 +60 -18
- 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 +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 +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 +6 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +24 -15
- 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 +22 -22
- package/src/config.ts +14 -3
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +215 -45
- package/src/mocks/fixtures.ts +6 -5
- package/src/mocks/test_context.ts +36 -19
- 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 +173 -147
- 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 +33 -24
- package/src/prover-client/server-epoch-prover.ts +4 -4
- package/src/proving_broker/broker_prover_facade.ts +26 -36
- package/src/proving_broker/config.ts +25 -3
- 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 +59 -13
- package/src/proving_broker/proving_broker_database/persisted.ts +15 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
- package/src/proving_broker/proving_job_controller.ts +11 -6
- package/src/proving_broker/rpc.ts +26 -3
- 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,388 @@
|
|
|
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';
|
|
381
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
13
382
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
383
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
14
384
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
15
385
|
import { elapsed } from '@aztec/foundation/timer';
|
|
16
|
-
import { readAvmMinimalPublicTxInputsFromFile } from '@aztec/simulator/public/fixtures';
|
|
17
386
|
import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
18
387
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
19
388
|
import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
|
|
@@ -22,7 +391,15 @@ import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifi
|
|
|
22
391
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
23
392
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
24
393
|
import { TxProvingState } from './tx-proving-state.js';
|
|
25
|
-
|
|
394
|
+
_dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
395
|
+
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
396
|
+
})), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
|
|
397
|
+
[Attributes.BLOCK_TXS_COUNT]: txs.length
|
|
398
|
+
})), _dec2 = trackSpan('ProvingOrchestrator.startChonkVerifierCircuits'), _dec3 = trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
|
|
399
|
+
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
400
|
+
})), _dec4 = trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
|
|
401
|
+
[Attributes.TX_HASH]: tx.hash.toString()
|
|
402
|
+
}));
|
|
26
403
|
/**
|
|
27
404
|
* Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
|
|
28
405
|
* 1. Transactions are provided to the scheduler post simulation.
|
|
@@ -38,20 +415,59 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
38
415
|
dbProvider;
|
|
39
416
|
prover;
|
|
40
417
|
proverId;
|
|
418
|
+
cancelJobsOnStop;
|
|
419
|
+
enqueueConcurrency;
|
|
420
|
+
static{
|
|
421
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
422
|
+
[
|
|
423
|
+
_dec,
|
|
424
|
+
2,
|
|
425
|
+
"startNewBlock"
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
_dec1,
|
|
429
|
+
2,
|
|
430
|
+
"addTxs"
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
_dec2,
|
|
434
|
+
2,
|
|
435
|
+
"startChonkVerifierCircuits"
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
_dec3,
|
|
439
|
+
2,
|
|
440
|
+
"setBlockCompleted"
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
_dec4,
|
|
444
|
+
2,
|
|
445
|
+
"prepareBaseRollupInputs"
|
|
446
|
+
]
|
|
447
|
+
], []));
|
|
448
|
+
}
|
|
41
449
|
provingState;
|
|
42
450
|
pendingProvingJobs;
|
|
43
451
|
provingPromise;
|
|
44
452
|
metrics;
|
|
453
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
45
454
|
dbs;
|
|
46
|
-
|
|
455
|
+
logger;
|
|
456
|
+
deferredJobQueue;
|
|
457
|
+
constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, enqueueConcurrency, telemetryClient = getTelemetryClient(), bindings){
|
|
47
458
|
this.dbProvider = dbProvider;
|
|
48
459
|
this.prover = prover;
|
|
49
460
|
this.proverId = proverId;
|
|
50
|
-
this.
|
|
461
|
+
this.cancelJobsOnStop = cancelJobsOnStop;
|
|
462
|
+
this.enqueueConcurrency = enqueueConcurrency;
|
|
463
|
+
this.provingState = (_initProto(this), undefined);
|
|
51
464
|
this.pendingProvingJobs = [];
|
|
52
465
|
this.provingPromise = undefined;
|
|
53
466
|
this.dbs = new Map();
|
|
467
|
+
this.deferredJobQueue = new SerialQueue();
|
|
468
|
+
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
54
469
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
470
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
55
471
|
}
|
|
56
472
|
get tracer() {
|
|
57
473
|
return this.metrics.tracer;
|
|
@@ -59,9 +475,14 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
59
475
|
getProverId() {
|
|
60
476
|
return this.proverId;
|
|
61
477
|
}
|
|
62
|
-
|
|
478
|
+
getNumActiveForks() {
|
|
479
|
+
return this.dbs.size;
|
|
480
|
+
}
|
|
481
|
+
async stop() {
|
|
482
|
+
// Grab the old queue before cancel() replaces it, so we can await its draining.
|
|
483
|
+
const oldQueue = this.deferredJobQueue;
|
|
63
484
|
this.cancel();
|
|
64
|
-
|
|
485
|
+
await oldQueue.cancel();
|
|
65
486
|
}
|
|
66
487
|
startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
|
|
67
488
|
if (this.provingState?.verifyState()) {
|
|
@@ -72,11 +493,18 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
72
493
|
status: 'failure',
|
|
73
494
|
reason
|
|
74
495
|
}));
|
|
75
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
496
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
76
497
|
this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
|
|
77
498
|
this.provingPromise = promise;
|
|
78
499
|
}
|
|
79
|
-
|
|
500
|
+
/**
|
|
501
|
+
* Starts a new checkpoint.
|
|
502
|
+
* @param checkpointIndex - The index of the checkpoint in the epoch.
|
|
503
|
+
* @param constants - The constants for this checkpoint.
|
|
504
|
+
* @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
|
|
505
|
+
* @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
|
|
506
|
+
* @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
|
|
507
|
+
*/ async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
|
|
80
508
|
if (!this.provingState) {
|
|
81
509
|
throw new Error('Empty epoch proving state. Call startNewEpoch before starting a checkpoint.');
|
|
82
510
|
}
|
|
@@ -86,7 +514,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
86
514
|
// Fork world state at the end of the immediately previous block.
|
|
87
515
|
const lastBlockNumber = headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber;
|
|
88
516
|
const db = await this.dbProvider.fork(lastBlockNumber);
|
|
89
|
-
const firstBlockNumber = lastBlockNumber + 1;
|
|
517
|
+
const firstBlockNumber = BlockNumber(lastBlockNumber + 1);
|
|
90
518
|
this.dbs.set(firstBlockNumber, db);
|
|
91
519
|
// Get archive sibling path before any block in this checkpoint lands.
|
|
92
520
|
const lastArchiveSiblingPath = await getLastSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
@@ -112,14 +540,14 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
112
540
|
throw new Error(`Checkpoint not accepting further blocks.`);
|
|
113
541
|
}
|
|
114
542
|
const constants = checkpointProvingState.constants;
|
|
115
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
543
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
116
544
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
117
545
|
if (!this.dbs.has(blockNumber)) {
|
|
118
546
|
// Fork world state at the end of the immediately previous block
|
|
119
|
-
const db = await this.dbProvider.fork(blockNumber - 1);
|
|
547
|
+
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
120
548
|
this.dbs.set(blockNumber, db);
|
|
121
549
|
}
|
|
122
|
-
const db = this.
|
|
550
|
+
const db = this.getDbForBlock(blockNumber);
|
|
123
551
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
124
552
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
125
553
|
const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
@@ -139,7 +567,8 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
139
567
|
const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
|
|
140
568
|
await endSpongeBlob.absorb(blockEndBlobFields);
|
|
141
569
|
blockProvingState.setEndSpongeBlob(endSpongeBlob);
|
|
142
|
-
//
|
|
570
|
+
// Try to accumulate the out hashes and blobs as far as we can:
|
|
571
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
143
572
|
await this.provingState.setBlobAccumulators();
|
|
144
573
|
}
|
|
145
574
|
}
|
|
@@ -153,10 +582,10 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
153
582
|
if (!txs.length) {
|
|
154
583
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
155
584
|
// 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.`);
|
|
585
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
157
586
|
return;
|
|
158
587
|
}
|
|
159
|
-
const blockNumber = txs[0].globalVariables.blockNumber;
|
|
588
|
+
const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
|
|
160
589
|
const provingState = this.provingState.getBlockProvingStateByBlockNumber(blockNumber);
|
|
161
590
|
if (!provingState) {
|
|
162
591
|
throw new Error(`Proving state for block ${blockNumber} not found. Call startNewBlock first.`);
|
|
@@ -167,8 +596,8 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
167
596
|
if (!provingState.isAcceptingTxs()) {
|
|
168
597
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
169
598
|
}
|
|
170
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
171
|
-
const db = this.
|
|
599
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
600
|
+
const db = this.getDbForBlock(blockNumber);
|
|
172
601
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
173
602
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
174
603
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -178,7 +607,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
178
607
|
throw new Error(`Invalid proving state when adding a tx`);
|
|
179
608
|
}
|
|
180
609
|
validateTx(tx);
|
|
181
|
-
logger.
|
|
610
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
182
611
|
const startSpongeBlob = spongeBlobState.clone();
|
|
183
612
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
|
|
184
613
|
if (!provingState.verifyState()) {
|
|
@@ -189,10 +618,10 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
189
618
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
190
619
|
if (txProvingState.requireAvmProof) {
|
|
191
620
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
192
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
621
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
193
622
|
this.enqueueVM(provingState, txIndex);
|
|
194
623
|
} else {
|
|
195
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
624
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
196
625
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
197
626
|
}
|
|
198
627
|
} catch (err) {
|
|
@@ -206,7 +635,8 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
206
635
|
const blockEndBlobFields = provingState.getBlockEndBlobFields();
|
|
207
636
|
await spongeBlobState.absorb(blockEndBlobFields);
|
|
208
637
|
provingState.setEndSpongeBlob(spongeBlobState);
|
|
209
|
-
// Txs have been added to the block. Now try to accumulate the blobs as far as we can:
|
|
638
|
+
// Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
|
|
639
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
210
640
|
await this.provingState.setBlobAccumulators();
|
|
211
641
|
}
|
|
212
642
|
/**
|
|
@@ -221,7 +651,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
221
651
|
const txHash = tx.getTxHash().toString();
|
|
222
652
|
const privateInputs = getPublicChonkVerifierPrivateInputsFromTx(tx, this.proverId.toField());
|
|
223
653
|
const tubeProof = promiseWithResolvers();
|
|
224
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
654
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
225
655
|
this.doEnqueueChonkVerifier(txHash, privateInputs, (proof)=>{
|
|
226
656
|
tubeProof.resolve(proof);
|
|
227
657
|
});
|
|
@@ -250,17 +680,23 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
250
680
|
throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
|
|
251
681
|
}
|
|
252
682
|
// Given we've applied every change from this block, now assemble the block header:
|
|
253
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
683
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
254
684
|
const header = await provingState.buildBlockHeader();
|
|
255
685
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
256
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
686
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
257
687
|
throw new Error('Block header mismatch');
|
|
258
688
|
}
|
|
259
|
-
// Get db for this block
|
|
260
|
-
const db = this.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
689
|
+
// Get db for this block and remove from map — no other code should use it after this point.
|
|
690
|
+
const db = this.getDbForBlock(provingState.blockNumber);
|
|
691
|
+
this.dbs.delete(provingState.blockNumber);
|
|
692
|
+
// Update the archive tree, capture the snapshot, and close the fork deterministically.
|
|
693
|
+
try {
|
|
694
|
+
this.logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
|
|
695
|
+
await db.updateArchive(header);
|
|
696
|
+
provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
|
|
697
|
+
} finally{
|
|
698
|
+
await db.close();
|
|
699
|
+
}
|
|
264
700
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
265
701
|
return header;
|
|
266
702
|
}
|
|
@@ -268,50 +704,65 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
268
704
|
async verifyBuiltBlockAgainstSyncedState(provingState) {
|
|
269
705
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
270
706
|
if (!builtBlockHeader) {
|
|
271
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
707
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
272
708
|
return;
|
|
273
709
|
}
|
|
274
710
|
const output = provingState.getBlockRootRollupOutput();
|
|
275
711
|
if (!output) {
|
|
276
|
-
logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
712
|
+
this.logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
const newArchive = provingState.getBuiltArchive();
|
|
716
|
+
if (!newArchive) {
|
|
717
|
+
this.logger.debug('Archive snapshot not yet captured, skipping header check.');
|
|
277
718
|
return;
|
|
278
719
|
}
|
|
279
720
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
280
721
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
281
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
722
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
282
723
|
provingState.reject(`Block header hash mismatch.`);
|
|
283
724
|
return;
|
|
284
725
|
}
|
|
285
|
-
// Get db for this block
|
|
286
726
|
const blockNumber = provingState.blockNumber;
|
|
287
|
-
const db = this.dbs.get(blockNumber);
|
|
288
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
289
727
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
290
728
|
if (!syncedArchive.equals(newArchive)) {
|
|
291
|
-
logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
729
|
+
this.logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
292
730
|
provingState.reject(`Archive tree mismatch.`);
|
|
293
731
|
return;
|
|
294
732
|
}
|
|
295
733
|
const circuitArchive = output.newArchive;
|
|
296
734
|
if (!newArchive.equals(circuitArchive)) {
|
|
297
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
735
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
298
736
|
provingState.reject(`New archive mismatch.`);
|
|
299
737
|
return;
|
|
300
738
|
}
|
|
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
739
|
}
|
|
308
740
|
/**
|
|
309
|
-
* Cancel any further proving
|
|
741
|
+
* Cancel any further proving.
|
|
742
|
+
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
743
|
+
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
310
744
|
*/ cancel() {
|
|
311
|
-
|
|
312
|
-
|
|
745
|
+
void this.deferredJobQueue.cancel();
|
|
746
|
+
// Recreate the queue so it can accept jobs for subsequent epochs.
|
|
747
|
+
this.deferredJobQueue = new SerialQueue();
|
|
748
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
749
|
+
if (this.cancelJobsOnStop) {
|
|
750
|
+
for (const controller of this.pendingProvingJobs){
|
|
751
|
+
controller.abort();
|
|
752
|
+
}
|
|
313
753
|
}
|
|
314
754
|
this.provingState?.cancel();
|
|
755
|
+
for (const [blockNumber, db] of this.dbs.entries()){
|
|
756
|
+
void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
757
|
+
}
|
|
758
|
+
this.dbs.clear();
|
|
759
|
+
}
|
|
760
|
+
getDbForBlock(blockNumber) {
|
|
761
|
+
const db = this.dbs.get(blockNumber);
|
|
762
|
+
if (!db) {
|
|
763
|
+
throw new Error(`World state fork for block ${blockNumber} not found.`);
|
|
764
|
+
}
|
|
765
|
+
return db;
|
|
315
766
|
}
|
|
316
767
|
/**
|
|
317
768
|
* Returns the proof for the current epoch.
|
|
@@ -338,7 +789,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
338
789
|
* @param job - The actual job, returns a promise notifying of the job's completion
|
|
339
790
|
*/ deferredProving(provingState, request, callback) {
|
|
340
791
|
if (!provingState.verifyState()) {
|
|
341
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
792
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
342
793
|
return;
|
|
343
794
|
}
|
|
344
795
|
const controller = new AbortController();
|
|
@@ -353,7 +804,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
353
804
|
}
|
|
354
805
|
const result = await request(controller.signal);
|
|
355
806
|
if (!provingState.verifyState()) {
|
|
356
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
807
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
357
808
|
return;
|
|
358
809
|
}
|
|
359
810
|
// we could have been cancelled whilst waiting for the result
|
|
@@ -368,7 +819,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
368
819
|
// drop this result
|
|
369
820
|
return;
|
|
370
821
|
}
|
|
371
|
-
logger.error(`Error thrown when proving job`, err);
|
|
822
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
372
823
|
provingState.reject(`${err}`);
|
|
373
824
|
} finally{
|
|
374
825
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -377,8 +828,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
377
828
|
}
|
|
378
829
|
}
|
|
379
830
|
};
|
|
380
|
-
|
|
381
|
-
|
|
831
|
+
void this.deferredJobQueue.put(async ()=>{
|
|
832
|
+
void safeJob();
|
|
833
|
+
// we yield here to the macro task queue such to give Nodejs a chance to run other operatoins in between enqueues
|
|
834
|
+
await sleep(0);
|
|
835
|
+
});
|
|
382
836
|
}
|
|
383
837
|
async updateL1ToL2MessageTree(l1ToL2Messages, db) {
|
|
384
838
|
const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
|
|
@@ -424,17 +878,17 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
424
878
|
// Executes the next level of merge if all inputs are available
|
|
425
879
|
enqueueBaseRollup(provingState, txIndex) {
|
|
426
880
|
if (!provingState.verifyState()) {
|
|
427
|
-
logger.debug('Not running base rollup, state invalid');
|
|
881
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
428
882
|
return;
|
|
429
883
|
}
|
|
430
884
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
431
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
885
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
432
886
|
return;
|
|
433
887
|
}
|
|
434
888
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
435
889
|
const { processedTx } = txProvingState;
|
|
436
890
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
437
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
891
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
438
892
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${inputs instanceof PrivateTxBaseRollupPrivateInputs ? 'getPrivateTxBaseRollupProof' : 'getPublicTxBaseRollupProof'}`, {
|
|
439
893
|
[Attributes.TX_HASH]: processedTx.hash.toString(),
|
|
440
894
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
@@ -445,7 +899,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
445
899
|
return this.prover.getPublicTxBaseRollupProof(inputs, signal, provingState.epochNumber);
|
|
446
900
|
}
|
|
447
901
|
}), (result)=>{
|
|
448
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
902
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
449
903
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
450
904
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
451
905
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -459,14 +913,14 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
459
913
|
// Once completed, will enqueue the the public tx base rollup.
|
|
460
914
|
getOrEnqueueChonkVerifier(provingState, txIndex) {
|
|
461
915
|
if (!provingState.verifyState()) {
|
|
462
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
916
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
463
917
|
return;
|
|
464
918
|
}
|
|
465
919
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
466
920
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
467
921
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
|
|
468
922
|
const handleResult = (result)=>{
|
|
469
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
923
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
470
924
|
txHash
|
|
471
925
|
});
|
|
472
926
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
@@ -474,18 +928,18 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
474
928
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
475
929
|
};
|
|
476
930
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
477
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
931
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
478
932
|
txHash
|
|
479
933
|
});
|
|
480
934
|
void this.provingState.cachedChonkVerifierProofs.get(txHash).then(handleResult);
|
|
481
935
|
return;
|
|
482
936
|
}
|
|
483
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
937
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
484
938
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
485
939
|
}
|
|
486
940
|
doEnqueueChonkVerifier(txHash, inputs, handler, provingState = this.provingState) {
|
|
487
941
|
if (!provingState.verifyState()) {
|
|
488
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
942
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
489
943
|
return;
|
|
490
944
|
}
|
|
491
945
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getPublicChonkVerifierProof', {
|
|
@@ -497,11 +951,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
497
951
|
// Enqueues the next level of merge if all inputs are available
|
|
498
952
|
enqueueMergeRollup(provingState, location) {
|
|
499
953
|
if (!provingState.verifyState()) {
|
|
500
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
954
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
501
955
|
return;
|
|
502
956
|
}
|
|
503
957
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
504
|
-
logger.debug('Merge rollup already started.');
|
|
958
|
+
this.logger.debug('Merge rollup already started.');
|
|
505
959
|
return;
|
|
506
960
|
}
|
|
507
961
|
const inputs = provingState.getMergeRollupInputs(location);
|
|
@@ -515,15 +969,15 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
515
969
|
// Executes the block root rollup circuit
|
|
516
970
|
enqueueBlockRootRollup(provingState) {
|
|
517
971
|
if (!provingState.verifyState()) {
|
|
518
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
972
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
519
973
|
return;
|
|
520
974
|
}
|
|
521
975
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
522
|
-
logger.debug('Block root rollup already started.');
|
|
976
|
+
this.logger.debug('Block root rollup already started.');
|
|
523
977
|
return;
|
|
524
978
|
}
|
|
525
979
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
526
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
980
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
527
981
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockRootRollupProof', {
|
|
528
982
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
529
983
|
}, (signal)=>{
|
|
@@ -539,15 +993,16 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
539
993
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
540
994
|
}
|
|
541
995
|
}), async (result)=>{
|
|
542
|
-
|
|
543
|
-
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
544
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
996
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
545
997
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
546
998
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
999
|
+
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
1000
|
+
// will be the first to see all three pieces (header, proof output, archive) and run the checks.
|
|
1001
|
+
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
547
1002
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
548
|
-
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
1003
|
+
await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
549
1004
|
} else {
|
|
550
|
-
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
1005
|
+
await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
551
1006
|
}
|
|
552
1007
|
});
|
|
553
1008
|
}
|
|
@@ -555,11 +1010,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
555
1010
|
// Enqueues the root parity circuit if all inputs are available
|
|
556
1011
|
enqueueBaseParityCircuit(checkpointProvingState, provingState, baseParityIndex) {
|
|
557
1012
|
if (!provingState.verifyState()) {
|
|
558
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
1013
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
559
1014
|
return;
|
|
560
1015
|
}
|
|
561
1016
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
562
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
1017
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
563
1018
|
return;
|
|
564
1019
|
}
|
|
565
1020
|
const inputs = checkpointProvingState.getBaseParityInputs(baseParityIndex);
|
|
@@ -580,11 +1035,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
580
1035
|
// Enqueues the root rollup proof if all inputs are available
|
|
581
1036
|
enqueueRootParityCircuit(provingState) {
|
|
582
1037
|
if (!provingState.verifyState()) {
|
|
583
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
1038
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
584
1039
|
return;
|
|
585
1040
|
}
|
|
586
1041
|
if (!provingState.tryStartProvingRootParity()) {
|
|
587
|
-
logger.debug('Root parity already started.');
|
|
1042
|
+
this.logger.debug('Root parity already started.');
|
|
588
1043
|
return;
|
|
589
1044
|
}
|
|
590
1045
|
const inputs = provingState.getParityRootInputs();
|
|
@@ -599,33 +1054,33 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
599
1054
|
// Enqueues the next level of merge if all inputs are available
|
|
600
1055
|
enqueueBlockMergeRollup(provingState, location) {
|
|
601
1056
|
if (!provingState.verifyState()) {
|
|
602
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1057
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
603
1058
|
return;
|
|
604
1059
|
}
|
|
605
1060
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
606
|
-
logger.debug('Block merge rollup already started.');
|
|
1061
|
+
this.logger.debug('Block merge rollup already started.');
|
|
607
1062
|
return;
|
|
608
1063
|
}
|
|
609
1064
|
const inputs = provingState.getBlockMergeRollupInputs(location);
|
|
610
1065
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
|
|
611
1066
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
|
|
612
|
-
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1067
|
+
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
|
|
613
1068
|
provingState.setBlockMergeRollupProof(location, result);
|
|
614
|
-
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1069
|
+
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
615
1070
|
});
|
|
616
1071
|
}
|
|
617
|
-
enqueueCheckpointRootRollup(provingState) {
|
|
1072
|
+
async enqueueCheckpointRootRollup(provingState) {
|
|
618
1073
|
if (!provingState.verifyState()) {
|
|
619
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1074
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
620
1075
|
return;
|
|
621
1076
|
}
|
|
622
1077
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
623
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1078
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
624
1079
|
return;
|
|
625
1080
|
}
|
|
626
1081
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
627
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
628
|
-
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1082
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1083
|
+
const inputs = await provingState.getCheckpointRootRollupInputs();
|
|
629
1084
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointRootRollupProof', {
|
|
630
1085
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
631
1086
|
}, (signal)=>{
|
|
@@ -638,11 +1093,11 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
638
1093
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator().toBlobAccumulator();
|
|
639
1094
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
640
1095
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
641
|
-
logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
1096
|
+
this.logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
642
1097
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
643
1098
|
return;
|
|
644
1099
|
}
|
|
645
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1100
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
646
1101
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
647
1102
|
const epochProvingState = provingState.parentEpoch;
|
|
648
1103
|
if (epochProvingState.totalNumCheckpoints === 1) {
|
|
@@ -654,37 +1109,37 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
654
1109
|
}
|
|
655
1110
|
enqueueCheckpointMergeRollup(provingState, location) {
|
|
656
1111
|
if (!provingState.verifyState()) {
|
|
657
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1112
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
658
1113
|
return;
|
|
659
1114
|
}
|
|
660
1115
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
661
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1116
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
662
1117
|
return;
|
|
663
1118
|
}
|
|
664
1119
|
const inputs = provingState.getCheckpointMergeRollupInputs(location);
|
|
665
1120
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
|
|
666
1121
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
|
|
667
1122
|
}, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
668
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1123
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
669
1124
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
670
1125
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
671
1126
|
});
|
|
672
1127
|
}
|
|
673
1128
|
enqueueEpochPadding(provingState) {
|
|
674
1129
|
if (!provingState.verifyState()) {
|
|
675
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1130
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
676
1131
|
return;
|
|
677
1132
|
}
|
|
678
1133
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
679
|
-
logger.debug('Padding checkpoint already started.');
|
|
1134
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
680
1135
|
return;
|
|
681
1136
|
}
|
|
682
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1137
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
683
1138
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
684
1139
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
|
|
685
1140
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
|
|
686
1141
|
}, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
687
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1142
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
688
1143
|
provingState.setCheckpointPaddingProof(result);
|
|
689
1144
|
this.checkAndEnqueueRootRollup(provingState);
|
|
690
1145
|
});
|
|
@@ -692,15 +1147,15 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
692
1147
|
// Executes the root rollup circuit
|
|
693
1148
|
enqueueRootRollup(provingState) {
|
|
694
1149
|
if (!provingState.verifyState()) {
|
|
695
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1150
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
696
1151
|
return;
|
|
697
1152
|
}
|
|
698
|
-
logger.debug(`Preparing root rollup`);
|
|
1153
|
+
this.logger.debug(`Preparing root rollup`);
|
|
699
1154
|
const inputs = provingState.getRootRollupInputs();
|
|
700
1155
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
|
|
701
1156
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
|
|
702
1157
|
}, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
703
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1158
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
704
1159
|
provingState.setRootRollupProof(result);
|
|
705
1160
|
provingState.resolve({
|
|
706
1161
|
status: 'success'
|
|
@@ -720,27 +1175,27 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
720
1175
|
}
|
|
721
1176
|
checkAndEnqueueBlockRootRollup(provingState) {
|
|
722
1177
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
723
|
-
logger.debug('Not ready for block root rollup');
|
|
1178
|
+
this.logger.debug('Not ready for block root rollup');
|
|
724
1179
|
return;
|
|
725
1180
|
}
|
|
726
1181
|
this.enqueueBlockRootRollup(provingState);
|
|
727
1182
|
}
|
|
728
|
-
checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1183
|
+
async checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
729
1184
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
730
1185
|
return;
|
|
731
1186
|
}
|
|
732
1187
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
733
1188
|
if (parentLocation.level === 0) {
|
|
734
|
-
this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1189
|
+
await this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
735
1190
|
} else {
|
|
736
1191
|
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
737
1192
|
}
|
|
738
1193
|
}
|
|
739
|
-
checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1194
|
+
async checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
740
1195
|
if (!provingState.isReadyForCheckpointRoot()) {
|
|
741
1196
|
return;
|
|
742
1197
|
}
|
|
743
|
-
this.enqueueCheckpointRootRollup(provingState);
|
|
1198
|
+
await this.enqueueCheckpointRootRollup(provingState);
|
|
744
1199
|
}
|
|
745
1200
|
checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
|
|
746
1201
|
if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
|
|
@@ -755,7 +1210,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
755
1210
|
}
|
|
756
1211
|
checkAndEnqueueRootRollup(provingState) {
|
|
757
1212
|
if (!provingState.isReadyForRootRollup()) {
|
|
758
|
-
logger.debug('Not ready for root rollup');
|
|
1213
|
+
this.logger.debug('Not ready for root rollup');
|
|
759
1214
|
return;
|
|
760
1215
|
}
|
|
761
1216
|
this.enqueueRootRollup(provingState);
|
|
@@ -767,41 +1222,19 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
767
1222
|
* @param txIndex - The index of the transaction being proven
|
|
768
1223
|
*/ enqueueVM(provingState, txIndex) {
|
|
769
1224
|
if (!provingState.verifyState()) {
|
|
770
|
-
logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1225
|
+
this.logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
771
1226
|
return;
|
|
772
1227
|
}
|
|
773
1228
|
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
1229
|
const doAvmProving = wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getAvmProof', {
|
|
777
1230
|
[Attributes.TX_HASH]: txProvingState.processedTx.hash.toString()
|
|
778
1231
|
}, async (signal)=>{
|
|
779
1232
|
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
|
-
}
|
|
1233
|
+
return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
|
|
801
1234
|
});
|
|
802
|
-
this.deferredProving(provingState, doAvmProving, (
|
|
803
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
804
|
-
txProvingState.setAvmProof(
|
|
1235
|
+
this.deferredProving(provingState, doAvmProving, (proof)=>{
|
|
1236
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1237
|
+
txProvingState.setAvmProof(proof);
|
|
805
1238
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
806
1239
|
});
|
|
807
1240
|
}
|
|
@@ -811,30 +1244,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
811
1244
|
return;
|
|
812
1245
|
}
|
|
813
1246
|
// 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`);
|
|
1247
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
815
1248
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
816
1249
|
}
|
|
817
1250
|
}
|
|
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);
|