@aztec/prover-client 0.0.1-commit.b655e406 → 0.0.1-commit.d1f2d6c
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/index.d.ts +1 -1
- package/dest/light/index.d.ts +2 -0
- package/dest/light/index.d.ts.map +1 -0
- package/dest/light/index.js +1 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts +44 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +194 -0
- package/dest/mocks/fixtures.d.ts +1 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +7 -17
- package/dest/mocks/test_context.d.ts +29 -46
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +116 -116
- package/dest/orchestrator/block-building-helpers.d.ts +17 -19
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +87 -112
- package/dest/orchestrator/block-proving-state.d.ts +17 -11
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +81 -20
- package/dest/orchestrator/checkpoint-proving-state.d.ts +22 -9
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +49 -17
- package/dest/orchestrator/epoch-proving-state.d.ts +12 -10
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +38 -4
- package/dest/orchestrator/index.d.ts +1 -1
- package/dest/orchestrator/orchestrator.d.ts +24 -11
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +496 -102
- 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 +7 -16
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +3 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +2 -2
- package/dest/prover-client/server-epoch-prover.d.ts +8 -7
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +2 -2
- package/dest/proving_broker/broker_prover_facade.d.ts +22 -21
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +6 -12
- package/dest/proving_broker/config.d.ts +16 -8
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +14 -2
- package/dest/proving_broker/factory.d.ts +1 -1
- package/dest/proving_broker/fixtures.d.ts +3 -2
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +3 -2
- package/dest/proving_broker/index.d.ts +1 -1
- package/dest/proving_broker/proof_store/factory.d.ts +2 -2
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts +3 -8
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +1 -16
- package/dest/proving_broker/proving_broker.d.ts +2 -2
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +6 -11
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +392 -3
- package/dest/proving_broker/proving_broker_database.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +11 -35
- package/dest/proving_broker/proving_job_controller.d.ts +3 -2
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +2 -3
- package/dest/proving_broker/rpc.d.ts +4 -4
- package/dest/test/mock_proof_store.d.ts +1 -1
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +3 -4
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +4 -4
- package/package.json +20 -18
- package/src/config.ts +1 -1
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +274 -0
- package/src/mocks/fixtures.ts +7 -30
- package/src/mocks/test_context.ts +158 -177
- package/src/orchestrator/block-building-helpers.ts +126 -206
- package/src/orchestrator/block-proving-state.ts +103 -25
- package/src/orchestrator/checkpoint-proving-state.ts +71 -21
- package/src/orchestrator/epoch-proving-state.ts +64 -14
- package/src/orchestrator/orchestrator.ts +97 -89
- package/src/orchestrator/orchestrator_metrics.ts +2 -25
- package/src/orchestrator/tx-proving-state.ts +10 -27
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +11 -12
- package/src/prover-client/server-epoch-prover.ts +6 -7
- package/src/proving_broker/broker_prover_facade.ts +25 -34
- package/src/proving_broker/config.ts +17 -1
- package/src/proving_broker/fixtures.ts +8 -3
- package/src/proving_broker/proving_agent.ts +1 -17
- package/src/proving_broker/proving_broker.ts +6 -9
- package/src/proving_broker/proving_broker_database/memory.ts +2 -1
- package/src/proving_broker/proving_broker_database/persisted.ts +20 -5
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +10 -35
- package/src/proving_broker/proving_job_controller.ts +4 -4
- 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 -94
- 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 -140
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,29 +1,404 @@
|
|
|
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
|
-
import { createBlockEndMarker } from '@aztec/stdlib/block';
|
|
18
384
|
import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
19
385
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
20
386
|
import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
|
|
21
387
|
import { inspect } from 'util';
|
|
22
|
-
import {
|
|
388
|
+
import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifierPrivateInputsFromTx, getRootTreeSiblingPath, getSubtreeSiblingPath, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints, validatePartialState, validateTx } from './block-building-helpers.js';
|
|
23
389
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
24
390
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
25
391
|
import { TxProvingState } from './tx-proving-state.js';
|
|
26
392
|
const logger = createLogger('prover-client:orchestrator');
|
|
393
|
+
_dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
394
|
+
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
395
|
+
})), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
|
|
396
|
+
[Attributes.BLOCK_TXS_COUNT]: txs.length
|
|
397
|
+
})), _dec2 = trackSpan('ProvingOrchestrator.startChonkVerifierCircuits'), _dec3 = trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
|
|
398
|
+
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
399
|
+
})), _dec4 = trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
|
|
400
|
+
[Attributes.TX_HASH]: tx.hash.toString()
|
|
401
|
+
}));
|
|
27
402
|
/**
|
|
28
403
|
* Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
|
|
29
404
|
* 1. Transactions are provided to the scheduler post simulation.
|
|
@@ -39,16 +414,48 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
39
414
|
dbProvider;
|
|
40
415
|
prover;
|
|
41
416
|
proverId;
|
|
417
|
+
cancelJobsOnStop;
|
|
418
|
+
static{
|
|
419
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
420
|
+
[
|
|
421
|
+
_dec,
|
|
422
|
+
2,
|
|
423
|
+
"startNewBlock"
|
|
424
|
+
],
|
|
425
|
+
[
|
|
426
|
+
_dec1,
|
|
427
|
+
2,
|
|
428
|
+
"addTxs"
|
|
429
|
+
],
|
|
430
|
+
[
|
|
431
|
+
_dec2,
|
|
432
|
+
2,
|
|
433
|
+
"startChonkVerifierCircuits"
|
|
434
|
+
],
|
|
435
|
+
[
|
|
436
|
+
_dec3,
|
|
437
|
+
2,
|
|
438
|
+
"setBlockCompleted"
|
|
439
|
+
],
|
|
440
|
+
[
|
|
441
|
+
_dec4,
|
|
442
|
+
2,
|
|
443
|
+
"prepareBaseRollupInputs"
|
|
444
|
+
]
|
|
445
|
+
], []));
|
|
446
|
+
}
|
|
42
447
|
provingState;
|
|
43
448
|
pendingProvingJobs;
|
|
44
449
|
provingPromise;
|
|
45
450
|
metrics;
|
|
451
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
46
452
|
dbs;
|
|
47
|
-
constructor(dbProvider, prover, proverId, telemetryClient = getTelemetryClient()){
|
|
453
|
+
constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, telemetryClient = getTelemetryClient()){
|
|
48
454
|
this.dbProvider = dbProvider;
|
|
49
455
|
this.prover = prover;
|
|
50
456
|
this.proverId = proverId;
|
|
51
|
-
this.
|
|
457
|
+
this.cancelJobsOnStop = cancelJobsOnStop;
|
|
458
|
+
this.provingState = (_initProto(this), undefined);
|
|
52
459
|
this.pendingProvingJobs = [];
|
|
53
460
|
this.provingPromise = undefined;
|
|
54
461
|
this.dbs = new Map();
|
|
@@ -60,6 +467,9 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
60
467
|
getProverId() {
|
|
61
468
|
return this.proverId;
|
|
62
469
|
}
|
|
470
|
+
getNumActiveForks() {
|
|
471
|
+
return this.dbs.size;
|
|
472
|
+
}
|
|
63
473
|
stop() {
|
|
64
474
|
this.cancel();
|
|
65
475
|
return Promise.resolve();
|
|
@@ -77,7 +487,14 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
77
487
|
this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
|
|
78
488
|
this.provingPromise = promise;
|
|
79
489
|
}
|
|
80
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Starts a new checkpoint.
|
|
492
|
+
* @param checkpointIndex - The index of the checkpoint in the epoch.
|
|
493
|
+
* @param constants - The constants for this checkpoint.
|
|
494
|
+
* @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
|
|
495
|
+
* @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
|
|
496
|
+
* @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
|
|
497
|
+
*/ async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
|
|
81
498
|
if (!this.provingState) {
|
|
82
499
|
throw new Error('Empty epoch proving state. Call startNewEpoch before starting a checkpoint.');
|
|
83
500
|
}
|
|
@@ -87,13 +504,16 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
87
504
|
// Fork world state at the end of the immediately previous block.
|
|
88
505
|
const lastBlockNumber = headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber;
|
|
89
506
|
const db = await this.dbProvider.fork(lastBlockNumber);
|
|
90
|
-
const firstBlockNumber = lastBlockNumber + 1;
|
|
91
|
-
this.dbs.set(firstBlockNumber,
|
|
507
|
+
const firstBlockNumber = BlockNumber(lastBlockNumber + 1);
|
|
508
|
+
this.dbs.set(firstBlockNumber, {
|
|
509
|
+
fork: db,
|
|
510
|
+
cleanupPromise: undefined
|
|
511
|
+
});
|
|
92
512
|
// Get archive sibling path before any block in this checkpoint lands.
|
|
93
513
|
const lastArchiveSiblingPath = await getLastSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
94
514
|
// Insert all the l1 to l2 messages into the db. And get the states before and after the insertion.
|
|
95
515
|
const { lastL1ToL2MessageTreeSnapshot, lastL1ToL2MessageSubtreeRootSiblingPath, newL1ToL2MessageTreeSnapshot, newL1ToL2MessageSubtreeRootSiblingPath } = await this.updateL1ToL2MessageTree(l1ToL2Messages, db);
|
|
96
|
-
this.provingState.startNewCheckpoint(checkpointIndex, constants, totalNumBlocks,
|
|
516
|
+
this.provingState.startNewCheckpoint(checkpointIndex, constants, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint, lastArchiveSiblingPath, l1ToL2Messages, lastL1ToL2MessageTreeSnapshot, lastL1ToL2MessageSubtreeRootSiblingPath, newL1ToL2MessageTreeSnapshot, newL1ToL2MessageSubtreeRootSiblingPath);
|
|
97
517
|
}
|
|
98
518
|
/**
|
|
99
519
|
* Starts off a new block
|
|
@@ -113,18 +533,21 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
113
533
|
throw new Error(`Checkpoint not accepting further blocks.`);
|
|
114
534
|
}
|
|
115
535
|
const constants = checkpointProvingState.constants;
|
|
116
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber
|
|
536
|
+
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
117
537
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
118
538
|
if (!this.dbs.has(blockNumber)) {
|
|
119
539
|
// Fork world state at the end of the immediately previous block
|
|
120
|
-
const db = await this.dbProvider.fork(blockNumber - 1);
|
|
121
|
-
this.dbs.set(blockNumber,
|
|
540
|
+
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
541
|
+
this.dbs.set(blockNumber, {
|
|
542
|
+
fork: db,
|
|
543
|
+
cleanupPromise: undefined
|
|
544
|
+
});
|
|
122
545
|
}
|
|
123
|
-
const db = this.dbs.get(blockNumber);
|
|
546
|
+
const db = this.dbs.get(blockNumber).fork;
|
|
124
547
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
125
548
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
126
549
|
const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
127
|
-
const blockProvingState =
|
|
550
|
+
const blockProvingState = checkpointProvingState.startNewBlock(blockNumber, timestamp, totalNumTxs, lastArchiveTreeSnapshot, lastArchiveSiblingPath);
|
|
128
551
|
// Enqueue base parity circuits for the first block in the checkpoint.
|
|
129
552
|
if (blockProvingState.index === 0) {
|
|
130
553
|
for(let i = 0; i < NUM_BASE_PARITY_PER_ROOT_PARITY; i++){
|
|
@@ -134,12 +557,14 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
134
557
|
// Because `addTxs` won't be called for a block without txs, and that's where the sponge blob state is computed.
|
|
135
558
|
// We need to set its end sponge blob here, which will become the start sponge blob for the next block.
|
|
136
559
|
if (totalNumTxs === 0) {
|
|
560
|
+
const endState = await db.getStateReference();
|
|
561
|
+
blockProvingState.setEndState(endState);
|
|
137
562
|
const endSpongeBlob = blockProvingState.getStartSpongeBlob().clone();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
]);
|
|
563
|
+
const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
|
|
564
|
+
await endSpongeBlob.absorb(blockEndBlobFields);
|
|
141
565
|
blockProvingState.setEndSpongeBlob(endSpongeBlob);
|
|
142
|
-
//
|
|
566
|
+
// Try to accumulate the out hashes and blobs as far as we can:
|
|
567
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
143
568
|
await this.provingState.setBlobAccumulators();
|
|
144
569
|
}
|
|
145
570
|
}
|
|
@@ -156,7 +581,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
156
581
|
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
157
582
|
return;
|
|
158
583
|
}
|
|
159
|
-
const blockNumber = txs[0].globalVariables.blockNumber;
|
|
584
|
+
const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
|
|
160
585
|
const provingState = this.provingState.getBlockProvingStateByBlockNumber(blockNumber);
|
|
161
586
|
if (!provingState) {
|
|
162
587
|
throw new Error(`Proving state for block ${blockNumber} not found. Call startNewBlock first.`);
|
|
@@ -168,7 +593,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
168
593
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
169
594
|
}
|
|
170
595
|
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
171
|
-
const db = this.dbs.get(blockNumber);
|
|
596
|
+
const db = this.dbs.get(blockNumber).fork;
|
|
172
597
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
173
598
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
174
599
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -178,7 +603,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
178
603
|
throw new Error(`Invalid proving state when adding a tx`);
|
|
179
604
|
}
|
|
180
605
|
validateTx(tx);
|
|
181
|
-
logger.
|
|
606
|
+
logger.debug(`Received transaction: ${tx.hash}`);
|
|
182
607
|
const startSpongeBlob = spongeBlobState.clone();
|
|
183
608
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
|
|
184
609
|
if (!provingState.verifyState()) {
|
|
@@ -201,11 +626,13 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
201
626
|
});
|
|
202
627
|
}
|
|
203
628
|
}
|
|
204
|
-
await
|
|
205
|
-
|
|
206
|
-
|
|
629
|
+
const endState = await db.getStateReference();
|
|
630
|
+
provingState.setEndState(endState);
|
|
631
|
+
const blockEndBlobFields = provingState.getBlockEndBlobFields();
|
|
632
|
+
await spongeBlobState.absorb(blockEndBlobFields);
|
|
207
633
|
provingState.setEndSpongeBlob(spongeBlobState);
|
|
208
|
-
// Txs have been added to the block. Now try to accumulate the blobs as far as we can:
|
|
634
|
+
// Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
|
|
635
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
209
636
|
await this.provingState.setBlobAccumulators();
|
|
210
637
|
}
|
|
211
638
|
/**
|
|
@@ -248,28 +675,19 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
248
675
|
if (provingState.isAcceptingTxs()) {
|
|
249
676
|
throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
|
|
250
677
|
}
|
|
251
|
-
//
|
|
678
|
+
// Given we've applied every change from this block, now assemble the block header:
|
|
252
679
|
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
253
|
-
const header = await
|
|
254
|
-
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
255
|
-
return header;
|
|
256
|
-
}
|
|
257
|
-
async buildL2BlockHeader(provingState, expectedHeader) {
|
|
258
|
-
// Collect all txs in this block to build the header. The function calling this has made sure that all txs have been added.
|
|
259
|
-
const txs = provingState.getProcessedTxs();
|
|
260
|
-
const startSpongeBlob = provingState.getStartSpongeBlob();
|
|
261
|
-
// Get db for this block
|
|
262
|
-
const db = this.dbs.get(provingState.blockNumber);
|
|
263
|
-
// Given we've applied every change from this block, now assemble the block header
|
|
264
|
-
// and update the archive tree, so we're ready to start processing the next block
|
|
265
|
-
const header = await buildBlockHeaderFromTxs(txs, provingState.getGlobalVariables(), startSpongeBlob, db);
|
|
680
|
+
const header = await provingState.buildBlockHeader();
|
|
266
681
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
267
682
|
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
268
683
|
throw new Error('Block header mismatch');
|
|
269
684
|
}
|
|
685
|
+
// Get db for this block
|
|
686
|
+
const db = this.dbs.get(provingState.blockNumber).fork;
|
|
687
|
+
// Update the archive tree, so we're ready to start processing the next block:
|
|
270
688
|
logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
|
|
271
689
|
await db.updateArchive(header);
|
|
272
|
-
|
|
690
|
+
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
273
691
|
return header;
|
|
274
692
|
}
|
|
275
693
|
// Flagged as protected to disable in certain unit tests
|
|
@@ -292,7 +710,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
292
710
|
}
|
|
293
711
|
// Get db for this block
|
|
294
712
|
const blockNumber = provingState.blockNumber;
|
|
295
|
-
const db = this.dbs.get(blockNumber);
|
|
713
|
+
const db = this.dbs.get(blockNumber).fork;
|
|
296
714
|
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
297
715
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
298
716
|
if (!syncedArchive.equals(newArchive)) {
|
|
@@ -310,14 +728,17 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
310
728
|
// is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
|
|
311
729
|
// but have to make sure it only runs once all operations are completed, otherwise some function here
|
|
312
730
|
// will attempt to access the fork after it was closed.
|
|
313
|
-
|
|
314
|
-
void this.dbs.get(blockNumber)?.close().then(()=>this.dbs.delete(blockNumber)).catch((err)=>logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
731
|
+
void this.cleanupDBFork(blockNumber);
|
|
315
732
|
}
|
|
316
733
|
/**
|
|
317
|
-
* Cancel any further proving
|
|
734
|
+
* Cancel any further proving.
|
|
735
|
+
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
736
|
+
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
318
737
|
*/ cancel() {
|
|
319
|
-
|
|
320
|
-
controller.
|
|
738
|
+
if (this.cancelJobsOnStop) {
|
|
739
|
+
for (const controller of this.pendingProvingJobs){
|
|
740
|
+
controller.abort();
|
|
741
|
+
}
|
|
321
742
|
}
|
|
322
743
|
this.provingState?.cancel();
|
|
323
744
|
}
|
|
@@ -339,6 +760,22 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
339
760
|
});
|
|
340
761
|
return epochProofResult;
|
|
341
762
|
}
|
|
763
|
+
async cleanupDBFork(blockNumber) {
|
|
764
|
+
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
765
|
+
const fork = this.dbs.get(blockNumber);
|
|
766
|
+
if (!fork) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
try {
|
|
770
|
+
if (!fork.cleanupPromise) {
|
|
771
|
+
fork.cleanupPromise = fork.fork.close();
|
|
772
|
+
}
|
|
773
|
+
await fork.cleanupPromise;
|
|
774
|
+
this.dbs.delete(blockNumber);
|
|
775
|
+
} catch (err) {
|
|
776
|
+
logger.error(`Error closing db for block ${blockNumber}`, err);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
342
779
|
/**
|
|
343
780
|
* Enqueue a job to be scheduled
|
|
344
781
|
* @param provingState - The proving state object being operated on
|
|
@@ -547,16 +984,18 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
547
984
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
548
985
|
}
|
|
549
986
|
}), async (result)=>{
|
|
550
|
-
// If the proofs were slower than the block header building, then we need to try validating the block header hashes here.
|
|
551
|
-
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
552
987
|
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
553
988
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
554
989
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
990
|
+
// If the proofs were slower than the block header building, then we need to try validating the block header hashes here.
|
|
991
|
+
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
555
992
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
556
993
|
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
557
994
|
} else {
|
|
558
995
|
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
559
996
|
}
|
|
997
|
+
// We are finished with the block at this point, ensure the fork is cleaned up
|
|
998
|
+
void this.cleanupDBFork(provingState.blockNumber);
|
|
560
999
|
});
|
|
561
1000
|
}
|
|
562
1001
|
// Executes the base parity circuit and stores the intermediate state for the root parity circuit
|
|
@@ -779,37 +1218,15 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
779
1218
|
return;
|
|
780
1219
|
}
|
|
781
1220
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
782
|
-
// This function tries to do AVM proving. If there is a failure, it fakes the proof unless AVM_PROVING_STRICT is defined.
|
|
783
|
-
// Nothing downstream depends on the AVM proof yet. So having this mode lets us incrementally build the AVM circuit.
|
|
784
1221
|
const doAvmProving = wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getAvmProof', {
|
|
785
1222
|
[Attributes.TX_HASH]: txProvingState.processedTx.hash.toString()
|
|
786
1223
|
}, async (signal)=>{
|
|
787
1224
|
const inputs = txProvingState.getAvmInputs();
|
|
788
|
-
|
|
789
|
-
// TODO(#14234)[Unconditional PIs validation]: Remove the whole try-catch logic and
|
|
790
|
-
// just keep the next line but removing the second argument (false).
|
|
791
|
-
return await this.prover.getAvmProof(inputs, false, signal, provingState.epochNumber);
|
|
792
|
-
} catch (err) {
|
|
793
|
-
if (process.env.AVM_PROVING_STRICT) {
|
|
794
|
-
logger.error(`Error thrown when proving AVM circuit with AVM_PROVING_STRICT on`, err);
|
|
795
|
-
throw err;
|
|
796
|
-
} else {
|
|
797
|
-
logger.warn(`Error thrown when proving AVM circuit but AVM_PROVING_STRICT is off. Use snapshotted
|
|
798
|
-
AVM inputs and carrying on. ${inspect(err)}.`);
|
|
799
|
-
try {
|
|
800
|
-
this.metrics.incAvmFallback();
|
|
801
|
-
const snapshotAvmPrivateInputs = readAvmMinimalPublicTxInputsFromFile();
|
|
802
|
-
return await this.prover.getAvmProof(snapshotAvmPrivateInputs, true, signal, provingState.epochNumber);
|
|
803
|
-
} catch (err) {
|
|
804
|
-
logger.error(`Error thrown when proving snapshotted AVM inputs.`, err);
|
|
805
|
-
throw err;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
}
|
|
1225
|
+
return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
|
|
809
1226
|
});
|
|
810
|
-
this.deferredProving(provingState, doAvmProving, (
|
|
1227
|
+
this.deferredProving(provingState, doAvmProving, (proof)=>{
|
|
811
1228
|
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
812
|
-
txProvingState.setAvmProof(
|
|
1229
|
+
txProvingState.setAvmProof(proof);
|
|
813
1230
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
814
1231
|
});
|
|
815
1232
|
}
|
|
@@ -823,26 +1240,3 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
823
1240
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
824
1241
|
}
|
|
825
1242
|
}
|
|
826
|
-
_ts_decorate([
|
|
827
|
-
trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
828
|
-
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
829
|
-
}))
|
|
830
|
-
], ProvingOrchestrator.prototype, "startNewBlock", null);
|
|
831
|
-
_ts_decorate([
|
|
832
|
-
trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
|
|
833
|
-
[Attributes.BLOCK_TXS_COUNT]: txs.length
|
|
834
|
-
}))
|
|
835
|
-
], ProvingOrchestrator.prototype, "addTxs", null);
|
|
836
|
-
_ts_decorate([
|
|
837
|
-
trackSpan('ProvingOrchestrator.startChonkVerifierCircuits')
|
|
838
|
-
], ProvingOrchestrator.prototype, "startChonkVerifierCircuits", null);
|
|
839
|
-
_ts_decorate([
|
|
840
|
-
trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
|
|
841
|
-
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
842
|
-
}))
|
|
843
|
-
], ProvingOrchestrator.prototype, "setBlockCompleted", null);
|
|
844
|
-
_ts_decorate([
|
|
845
|
-
trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
|
|
846
|
-
[Attributes.TX_HASH]: tx.hash.toString()
|
|
847
|
-
}))
|
|
848
|
-
], ProvingOrchestrator.prototype, "prepareBaseRollupInputs", null);
|