@aztec/archiver 0.85.0 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +13 -4
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +6 -2
- package/dest/archiver/data_retrieval.js +1 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +13 -6
- package/package.json +12 -14
- package/src/archiver/archiver.ts +16 -4
- package/src/archiver/config.ts +5 -0
- package/src/archiver/data_retrieval.ts +1 -1
- package/src/archiver/kv_archiver_store/block_store.ts +19 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAkB,KAAK,gBAAgB,EAAuB,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAkB,KAAK,gBAAgB,EAAuB,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAelE,OAAO,KAAK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AG,OAAO,CAAC,EAAE,EAAE,CAAC;IAIrD;;;;OAIG;IACH,qBAAqB,CAAC,aAAa,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIrE,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IAIpC,kCAAkC,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9F,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI9F,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;CAuCnC"}
|
|
@@ -8,6 +8,7 @@ import { RollupContract, createEthereumChain } from '@aztec/ethereum';
|
|
|
8
8
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
10
10
|
import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
|
|
11
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
11
12
|
import { count } from '@aztec/foundation/string';
|
|
12
13
|
import { elapsed } from '@aztec/foundation/timer';
|
|
13
14
|
import { InboxAbi } from '@aztec/l1-artifacts';
|
|
@@ -106,8 +107,12 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
106
107
|
if (this.runningPromise) {
|
|
107
108
|
throw new Error('Archiver is already running');
|
|
108
109
|
}
|
|
110
|
+
await this.blobSinkClient.testSources();
|
|
109
111
|
if (blockUntilSynced) {
|
|
110
|
-
await this.syncSafe(
|
|
112
|
+
while(!await this.syncSafe(true)){
|
|
113
|
+
this.log.info(`Retrying initial archiver sync in ${this.config.pollingIntervalMs}ms`);
|
|
114
|
+
await sleep(this.config.pollingIntervalMs);
|
|
115
|
+
}
|
|
111
116
|
}
|
|
112
117
|
this.runningPromise = new RunningPromise(()=>this.sync(false), this.log, this.config.pollingIntervalMs, makeLoggingErrorHandler(this.log, // Ignored errors will not log to the console
|
|
113
118
|
// We ignore NoBlobBodiesFound as the message may not have been passed to the blob sink yet
|
|
@@ -123,10 +128,14 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
123
128
|
async syncSafe(initialRun) {
|
|
124
129
|
try {
|
|
125
130
|
await this.sync(initialRun);
|
|
131
|
+
return true;
|
|
126
132
|
} catch (error) {
|
|
127
|
-
|
|
128
|
-
error
|
|
129
|
-
}
|
|
133
|
+
if (error instanceof NoBlobBodiesFoundError) {
|
|
134
|
+
this.log.error(`Error syncing archiver: ${error.message}`);
|
|
135
|
+
} else {
|
|
136
|
+
this.log.error('Error during archiver sync', error);
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
130
139
|
}
|
|
131
140
|
}
|
|
132
141
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/archiver/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/archiver/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAIpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,kBAAkB,EAA6C,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAE7E;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,4GAA4G;IAC5G,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B,kFAAkF;IAClF,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,yCAAyC;IACzC,WAAW,EAAE,mBAAmB,CAAC;IAEjC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,qGAAqG;IACrG,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,GAAG,cAAc,GAChB,iBAAiB,GACjB,cAAc,GACd,WAAW,CAAC;AAEd,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CA4CrE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
|
package/dest/archiver/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { blobSinkConfigMapping } from '@aztec/blob-sink/client';
|
|
2
|
-
import { l1ContractsConfigMappings, l1ReaderConfigMappings } from '@aztec/ethereum';
|
|
2
|
+
import { l1ContractAddressesMapping, l1ContractsConfigMappings, l1ReaderConfigMappings } from '@aztec/ethereum';
|
|
3
3
|
import { getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
4
4
|
import { chainConfigMappings } from '@aztec/stdlib/config';
|
|
5
5
|
export const archiverConfigMappings = {
|
|
@@ -40,7 +40,11 @@ export const archiverConfigMappings = {
|
|
|
40
40
|
description: 'The polling interval viem uses in ms',
|
|
41
41
|
...numberConfigHelper(1000)
|
|
42
42
|
},
|
|
43
|
-
...l1ContractsConfigMappings
|
|
43
|
+
...l1ContractsConfigMappings,
|
|
44
|
+
l1Contracts: {
|
|
45
|
+
description: 'The deployed L1 contract addresses',
|
|
46
|
+
nested: l1ContractAddressesMapping
|
|
47
|
+
}
|
|
44
48
|
};
|
|
45
49
|
/**
|
|
46
50
|
* Returns the archiver configuration from the environment variables.
|
|
@@ -159,7 +159,7 @@ export async function getL1BlockTime(publicClient, blockNumber) {
|
|
|
159
159
|
}
|
|
160
160
|
let blockFields;
|
|
161
161
|
try {
|
|
162
|
-
blockFields = Blob.toEncodedFields(blobBodies);
|
|
162
|
+
blockFields = Blob.toEncodedFields(blobBodies.map((b)=>b.blob));
|
|
163
163
|
} catch (err) {
|
|
164
164
|
if (err instanceof BlobDeserializationError) {
|
|
165
165
|
logger.fatal(err.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/block_store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAA6C,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAExF,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAWzE;;GAEG;AACH,qBAAa,UAAU;;IAwBT,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,iBAAiB;IAUzC;;;;OAIG;IACG,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IA2B7D;;;;;;OAMG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IA0BvD;;;;;OAKG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAAC,gBAAgB,CAAC;IASvF;;;;OAIG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;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Ae,GAAG,SAAS,CAAC;IAmBvE;;;;OAIG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAuBzE;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAI1F;;;;OAIG;IACH,mBAAmB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAI7G;;;OAGG;IACG,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKhD;;;OAGG;IACH,uBAAuB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAItD,uBAAuB,CAAC,aAAa,EAAE,MAAM;IAIvC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/C,sBAAsB,CAAC,WAAW,EAAE,MAAM;CAe3C"}
|
|
@@ -92,8 +92,8 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
92
92
|
* @param limit - The number of blocks to return.
|
|
93
93
|
* @returns The requested L2 blocks
|
|
94
94
|
*/ async *getBlocks(start, limit) {
|
|
95
|
-
for await (const blockStorage of this.#blocks.
|
|
96
|
-
const block = await this.getBlockFromBlockStorage(blockStorage);
|
|
95
|
+
for await (const [blockNumber, blockStorage] of this.#blocks.entriesAsync(this.#computeBlockRange(start, limit))){
|
|
96
|
+
const block = await this.getBlockFromBlockStorage(blockNumber, blockStorage);
|
|
97
97
|
if (block) {
|
|
98
98
|
yield block;
|
|
99
99
|
}
|
|
@@ -108,7 +108,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
108
108
|
if (!blockStorage || !blockStorage.header) {
|
|
109
109
|
return Promise.resolve(undefined);
|
|
110
110
|
}
|
|
111
|
-
return this.getBlockFromBlockStorage(blockStorage);
|
|
111
|
+
return this.getBlockFromBlockStorage(blockNumber, blockStorage);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* Gets the headers for a sequence of L2 blocks.
|
|
@@ -116,11 +116,15 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
116
116
|
* @param limit - The number of blocks to return.
|
|
117
117
|
* @returns The requested L2 block headers
|
|
118
118
|
*/ async *getBlockHeaders(start, limit) {
|
|
119
|
-
for await (const blockStorage of this.#blocks.
|
|
120
|
-
|
|
119
|
+
for await (const [blockNumber, blockStorage] of this.#blocks.entriesAsync(this.#computeBlockRange(start, limit))){
|
|
120
|
+
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
121
|
+
if (header.getBlockNumber() !== blockNumber) {
|
|
122
|
+
throw new Error(`Block number mismatch when retrieving block header from archive (expected ${blockNumber} but got ${header.getBlockNumber()})`);
|
|
123
|
+
}
|
|
124
|
+
yield header;
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
|
-
async getBlockFromBlockStorage(blockStorage) {
|
|
127
|
+
async getBlockFromBlockStorage(blockNumber, blockStorage) {
|
|
124
128
|
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
125
129
|
const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
|
|
126
130
|
const blockHash = (await header.hash()).toString();
|
|
@@ -131,6 +135,9 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
131
135
|
}
|
|
132
136
|
const body = Body.fromBuffer(blockBodyBuffer);
|
|
133
137
|
const block = new L2Block(archive, header, body);
|
|
138
|
+
if (block.number !== blockNumber) {
|
|
139
|
+
throw new Error(`Block number mismatch when retrieving block from archive (expected ${blockNumber} but got ${block.number} with hash ${await block.hash()})`);
|
|
140
|
+
}
|
|
134
141
|
const signatures = blockStorage.signatures.map(Signature.fromBuffer);
|
|
135
142
|
return {
|
|
136
143
|
block,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -20,8 +20,6 @@
|
|
|
20
20
|
"build": "yarn clean && tsc -b",
|
|
21
21
|
"build:dev": "tsc -b --watch",
|
|
22
22
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
23
|
-
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
24
|
-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
25
23
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
26
24
|
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
|
|
27
25
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
@@ -64,17 +62,17 @@
|
|
|
64
62
|
]
|
|
65
63
|
},
|
|
66
64
|
"dependencies": {
|
|
67
|
-
"@aztec/blob-lib": "0.
|
|
68
|
-
"@aztec/blob-sink": "0.
|
|
69
|
-
"@aztec/constants": "0.
|
|
70
|
-
"@aztec/ethereum": "0.
|
|
71
|
-
"@aztec/foundation": "0.
|
|
72
|
-
"@aztec/kv-store": "0.
|
|
73
|
-
"@aztec/l1-artifacts": "0.
|
|
74
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
75
|
-
"@aztec/protocol-contracts": "0.
|
|
76
|
-
"@aztec/stdlib": "0.
|
|
77
|
-
"@aztec/telemetry-client": "0.
|
|
65
|
+
"@aztec/blob-lib": "0.86.0",
|
|
66
|
+
"@aztec/blob-sink": "0.86.0",
|
|
67
|
+
"@aztec/constants": "0.86.0",
|
|
68
|
+
"@aztec/ethereum": "0.86.0",
|
|
69
|
+
"@aztec/foundation": "0.86.0",
|
|
70
|
+
"@aztec/kv-store": "0.86.0",
|
|
71
|
+
"@aztec/l1-artifacts": "0.86.0",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.86.0",
|
|
73
|
+
"@aztec/protocol-contracts": "0.86.0",
|
|
74
|
+
"@aztec/stdlib": "0.86.0",
|
|
75
|
+
"@aztec/telemetry-client": "0.86.0",
|
|
78
76
|
"debug": "^4.3.4",
|
|
79
77
|
"lodash.groupby": "^4.6.0",
|
|
80
78
|
"lodash.omit": "^4.5.0",
|
package/src/archiver/archiver.ts
CHANGED
|
@@ -4,9 +4,10 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
|
|
7
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
7
8
|
import { count } from '@aztec/foundation/string';
|
|
8
9
|
import { elapsed } from '@aztec/foundation/timer';
|
|
9
|
-
import { InboxAbi } from '@aztec/l1-artifacts';
|
|
10
|
+
import { InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
10
11
|
import {
|
|
11
12
|
ContractClassRegisteredEvent,
|
|
12
13
|
PrivateFunctionBroadcastedEvent,
|
|
@@ -182,8 +183,13 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
|
|
|
182
183
|
throw new Error('Archiver is already running');
|
|
183
184
|
}
|
|
184
185
|
|
|
186
|
+
await this.blobSinkClient.testSources();
|
|
187
|
+
|
|
185
188
|
if (blockUntilSynced) {
|
|
186
|
-
await this.syncSafe(
|
|
189
|
+
while (!(await this.syncSafe(true))) {
|
|
190
|
+
this.log.info(`Retrying initial archiver sync in ${this.config.pollingIntervalMs}ms`);
|
|
191
|
+
await sleep(this.config.pollingIntervalMs);
|
|
192
|
+
}
|
|
187
193
|
}
|
|
188
194
|
|
|
189
195
|
this.runningPromise = new RunningPromise(
|
|
@@ -211,8 +217,14 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
|
|
|
211
217
|
private async syncSafe(initialRun: boolean) {
|
|
212
218
|
try {
|
|
213
219
|
await this.sync(initialRun);
|
|
220
|
+
return true;
|
|
214
221
|
} catch (error) {
|
|
215
|
-
|
|
222
|
+
if (error instanceof NoBlobBodiesFoundError) {
|
|
223
|
+
this.log.error(`Error syncing archiver: ${error.message}`);
|
|
224
|
+
} else {
|
|
225
|
+
this.log.error('Error during archiver sync', error);
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
230
|
|
|
@@ -519,7 +531,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
|
|
|
519
531
|
|
|
520
532
|
// TODO(md): Retrieve from blob sink then from consensus client, then from peers
|
|
521
533
|
const retrievedBlocks = await retrieveBlocksFromRollup(
|
|
522
|
-
this.rollup.getContract(),
|
|
534
|
+
this.rollup.getContract() as GetContractReturnType<typeof RollupAbi, ViemPublicClient>,
|
|
523
535
|
this.publicClient,
|
|
524
536
|
this.blobSinkClient,
|
|
525
537
|
searchStartBlock, // TODO(palla/reorg): If the L2 reorg was due to an L1 reorg, we need to start search earlier
|
package/src/archiver/config.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type L1ContractAddresses,
|
|
4
4
|
type L1ContractsConfig,
|
|
5
5
|
type L1ReaderConfig,
|
|
6
|
+
l1ContractAddressesMapping,
|
|
6
7
|
l1ContractsConfigMappings,
|
|
7
8
|
l1ReaderConfigMappings,
|
|
8
9
|
} from '@aztec/ethereum';
|
|
@@ -88,6 +89,10 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
88
89
|
...numberConfigHelper(1000),
|
|
89
90
|
},
|
|
90
91
|
...l1ContractsConfigMappings,
|
|
92
|
+
l1Contracts: {
|
|
93
|
+
description: 'The deployed L1 contract addresses',
|
|
94
|
+
nested: l1ContractAddressesMapping,
|
|
95
|
+
},
|
|
91
96
|
};
|
|
92
97
|
|
|
93
98
|
/**
|
|
@@ -248,7 +248,7 @@ async function getBlockFromRollupTx(
|
|
|
248
248
|
|
|
249
249
|
let blockFields: Fr[];
|
|
250
250
|
try {
|
|
251
|
-
blockFields = Blob.toEncodedFields(blobBodies);
|
|
251
|
+
blockFields = Blob.toEncodedFields(blobBodies.map(b => b.blob));
|
|
252
252
|
} catch (err: any) {
|
|
253
253
|
if (err instanceof BlobDeserializationError) {
|
|
254
254
|
logger.fatal(err.message);
|
|
@@ -130,8 +130,8 @@ export class BlockStore {
|
|
|
130
130
|
* @returns The requested L2 blocks
|
|
131
131
|
*/
|
|
132
132
|
async *getBlocks(start: number, limit: number): AsyncIterableIterator<PublishedL2Block> {
|
|
133
|
-
for await (const blockStorage of this.#blocks.
|
|
134
|
-
const block = await this.getBlockFromBlockStorage(blockStorage);
|
|
133
|
+
for await (const [blockNumber, blockStorage] of this.#blocks.entriesAsync(this.#computeBlockRange(start, limit))) {
|
|
134
|
+
const block = await this.getBlockFromBlockStorage(blockNumber, blockStorage);
|
|
135
135
|
if (block) {
|
|
136
136
|
yield block;
|
|
137
137
|
}
|
|
@@ -148,7 +148,7 @@ export class BlockStore {
|
|
|
148
148
|
if (!blockStorage || !blockStorage.header) {
|
|
149
149
|
return Promise.resolve(undefined);
|
|
150
150
|
}
|
|
151
|
-
return this.getBlockFromBlockStorage(blockStorage);
|
|
151
|
+
return this.getBlockFromBlockStorage(blockNumber, blockStorage);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
@@ -158,12 +158,18 @@ export class BlockStore {
|
|
|
158
158
|
* @returns The requested L2 block headers
|
|
159
159
|
*/
|
|
160
160
|
async *getBlockHeaders(start: number, limit: number): AsyncIterableIterator<BlockHeader> {
|
|
161
|
-
for await (const blockStorage of this.#blocks.
|
|
162
|
-
|
|
161
|
+
for await (const [blockNumber, blockStorage] of this.#blocks.entriesAsync(this.#computeBlockRange(start, limit))) {
|
|
162
|
+
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
163
|
+
if (header.getBlockNumber() !== blockNumber) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Block number mismatch when retrieving block header from archive (expected ${blockNumber} but got ${header.getBlockNumber()})`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
yield header;
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
private async getBlockFromBlockStorage(blockStorage: BlockStorage) {
|
|
172
|
+
private async getBlockFromBlockStorage(blockNumber: number, blockStorage: BlockStorage) {
|
|
167
173
|
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
168
174
|
const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
|
|
169
175
|
const blockHash = (await header.hash()).toString();
|
|
@@ -174,6 +180,13 @@ export class BlockStore {
|
|
|
174
180
|
}
|
|
175
181
|
const body = Body.fromBuffer(blockBodyBuffer);
|
|
176
182
|
const block = new L2Block(archive, header, body);
|
|
183
|
+
if (block.number !== blockNumber) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Block number mismatch when retrieving block from archive (expected ${blockNumber} but got ${
|
|
186
|
+
block.number
|
|
187
|
+
} with hash ${await block.hash()})`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
177
190
|
const signatures = blockStorage.signatures.map(Signature.fromBuffer);
|
|
178
191
|
return { block, l1: blockStorage.l1, signatures };
|
|
179
192
|
}
|