@aztec/archiver 1.0.0-nightly.20250708 → 1.0.0-nightly.20250710
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.
|
@@ -13,8 +13,8 @@ import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/runni
|
|
|
13
13
|
import { sleep } from '@aztec/foundation/sleep';
|
|
14
14
|
import { count } from '@aztec/foundation/string';
|
|
15
15
|
import { Timer, elapsed } from '@aztec/foundation/timer';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { ContractClassPublishedEvent, PrivateFunctionBroadcastedEvent, UtilityFunctionBroadcastedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
17
|
+
import { ContractInstancePublishedEvent, ContractInstanceUpdatedEvent } from '@aztec/protocol-contracts/instance-registry';
|
|
18
18
|
import { L2BlockSourceEvents } from '@aztec/stdlib/block';
|
|
19
19
|
import { computePublicBytecodeCommitment, isValidPrivateFunctionMembershipProof, isValidUtilityFunctionMembershipProof } from '@aztec/stdlib/contract';
|
|
20
20
|
import { getEpochAtSlot, getEpochNumberAtTimestamp, getSlotAtTimestamp, getSlotRangeForEpoch, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
@@ -976,11 +976,11 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
976
976
|
this.#log = createLogger('archiver:block-helper');
|
|
977
977
|
}
|
|
978
978
|
/**
|
|
979
|
-
* Extracts and stores contract classes out of
|
|
979
|
+
* Extracts and stores contract classes out of ContractClassPublished events emitted by the class registry contract.
|
|
980
980
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
981
|
-
*/ async #
|
|
982
|
-
const
|
|
983
|
-
const contractClasses = await Promise.all(
|
|
981
|
+
*/ async #updatePublishedContractClasses(allLogs, blockNum, operation) {
|
|
982
|
+
const contractClassPublishedEvents = allLogs.filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log));
|
|
983
|
+
const contractClasses = await Promise.all(contractClassPublishedEvents.map((e)=>e.toContractClassPublic()));
|
|
984
984
|
if (contractClasses.length > 0) {
|
|
985
985
|
contractClasses.forEach((c)=>this.#log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
986
986
|
if (operation == 0) {
|
|
@@ -994,10 +994,10 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
994
994
|
return true;
|
|
995
995
|
}
|
|
996
996
|
/**
|
|
997
|
-
* Extracts and stores contract instances out of
|
|
997
|
+
* Extracts and stores contract instances out of ContractInstancePublished events emitted by the canonical deployer contract.
|
|
998
998
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
999
999
|
*/ async #updateDeployedContractInstances(allLogs, blockNum, operation) {
|
|
1000
|
-
const contractInstances = allLogs.filter((log)=>
|
|
1000
|
+
const contractInstances = allLogs.filter((log)=>ContractInstancePublishedEvent.isContractInstancePublishedEvent(log)).map((log)=>ContractInstancePublishedEvent.fromLog(log)).map((e)=>e.toContractInstance());
|
|
1001
1001
|
if (contractInstances.length > 0) {
|
|
1002
1002
|
contractInstances.forEach((c)=>this.#log.verbose(`${Operation[operation]} contract instance at ${c.address.toString()}`));
|
|
1003
1003
|
if (operation == 0) {
|
|
@@ -1009,7 +1009,7 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
1009
1009
|
return true;
|
|
1010
1010
|
}
|
|
1011
1011
|
/**
|
|
1012
|
-
* Extracts and stores contract instances out of
|
|
1012
|
+
* Extracts and stores contract instances out of ContractInstancePublished events emitted by the canonical deployer contract.
|
|
1013
1013
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
1014
1014
|
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
1015
1015
|
* @param operation - The operation to perform on the contract instance updates (Store or Delete).
|
|
@@ -1085,11 +1085,11 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
1085
1085
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
1086
1086
|
...blocks.map(async (block)=>{
|
|
1087
1087
|
const contractClassLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.contractClassLogs);
|
|
1088
|
-
//
|
|
1088
|
+
// ContractInstancePublished event logs are broadcast in privateLogs.
|
|
1089
1089
|
const privateLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.privateLogs);
|
|
1090
1090
|
const publicLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.publicLogs);
|
|
1091
1091
|
return (await Promise.all([
|
|
1092
|
-
this.#
|
|
1092
|
+
this.#updatePublishedContractClasses(contractClassLogs, block.block.number, 0),
|
|
1093
1093
|
this.#updateDeployedContractInstances(privateLogs, block.block.number, 0),
|
|
1094
1094
|
this.#updateUpdatedContractInstances(publicLogs, block.block.header.globalVariables.timestamp, 0),
|
|
1095
1095
|
this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.block.number)
|
|
@@ -1113,11 +1113,11 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
1113
1113
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
1114
1114
|
...blocks.map(async (block)=>{
|
|
1115
1115
|
const contractClassLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.contractClassLogs);
|
|
1116
|
-
//
|
|
1116
|
+
// ContractInstancePublished event logs are broadcast in privateLogs.
|
|
1117
1117
|
const privateLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.privateLogs);
|
|
1118
1118
|
const publicLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.publicLogs);
|
|
1119
1119
|
return (await Promise.all([
|
|
1120
|
-
this.#
|
|
1120
|
+
this.#updatePublishedContractClasses(contractClassLogs, block.block.number, 1),
|
|
1121
1121
|
this.#updateDeployedContractInstances(privateLogs, block.block.number, 1),
|
|
1122
1122
|
this.#updateUpdatedContractInstances(publicLogs, block.block.header.globalVariables.timestamp, 1)
|
|
1123
1123
|
])).every(Boolean);
|
|
@@ -4,24 +4,24 @@ import { SerializableContractInstance, SerializableContractInstanceUpdate } from
|
|
|
4
4
|
*/ export class ContractInstanceStore {
|
|
5
5
|
db;
|
|
6
6
|
#contractInstances;
|
|
7
|
-
#
|
|
7
|
+
#contractInstancePublishedAt;
|
|
8
8
|
#contractInstanceUpdates;
|
|
9
9
|
constructor(db){
|
|
10
10
|
this.db = db;
|
|
11
11
|
this.#contractInstances = db.openMap('archiver_contract_instances');
|
|
12
|
-
this.#
|
|
12
|
+
this.#contractInstancePublishedAt = db.openMap('archiver_contract_instances_publication_block_number');
|
|
13
13
|
this.#contractInstanceUpdates = db.openMap('archiver_contract_instance_updates');
|
|
14
14
|
}
|
|
15
15
|
addContractInstance(contractInstance, blockNumber) {
|
|
16
16
|
return this.db.transactionAsync(async ()=>{
|
|
17
17
|
await this.#contractInstances.set(contractInstance.address.toString(), new SerializableContractInstance(contractInstance).toBuffer());
|
|
18
|
-
await this.#
|
|
18
|
+
await this.#contractInstancePublishedAt.set(contractInstance.address.toString(), blockNumber);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
deleteContractInstance(contractInstance) {
|
|
22
22
|
return this.db.transactionAsync(async ()=>{
|
|
23
23
|
await this.#contractInstances.delete(contractInstance.address.toString());
|
|
24
|
-
await this.#
|
|
24
|
+
await this.#contractInstancePublishedAt.delete(contractInstance.address.toString());
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
getUpdateKey(contractAddress, timestamp, logIndex) {
|
|
@@ -72,6 +72,6 @@ import { SerializableContractInstance, SerializableContractInstanceUpdate } from
|
|
|
72
72
|
return instance;
|
|
73
73
|
}
|
|
74
74
|
getContractInstanceDeploymentBlockNumber(address) {
|
|
75
|
-
return this.#
|
|
75
|
+
return this.#contractInstancePublishedAt.getAsync(address.toString());
|
|
76
76
|
}
|
|
77
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "1.0.0-nightly.
|
|
3
|
+
"version": "1.0.0-nightly.20250710",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -66,17 +66,17 @@
|
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@aztec/blob-lib": "1.0.0-nightly.
|
|
70
|
-
"@aztec/blob-sink": "1.0.0-nightly.
|
|
71
|
-
"@aztec/constants": "1.0.0-nightly.
|
|
72
|
-
"@aztec/ethereum": "1.0.0-nightly.
|
|
73
|
-
"@aztec/foundation": "1.0.0-nightly.
|
|
74
|
-
"@aztec/kv-store": "1.0.0-nightly.
|
|
75
|
-
"@aztec/l1-artifacts": "1.0.0-nightly.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "1.0.0-nightly.
|
|
77
|
-
"@aztec/protocol-contracts": "1.0.0-nightly.
|
|
78
|
-
"@aztec/stdlib": "1.0.0-nightly.
|
|
79
|
-
"@aztec/telemetry-client": "1.0.0-nightly.
|
|
69
|
+
"@aztec/blob-lib": "1.0.0-nightly.20250710",
|
|
70
|
+
"@aztec/blob-sink": "1.0.0-nightly.20250710",
|
|
71
|
+
"@aztec/constants": "1.0.0-nightly.20250710",
|
|
72
|
+
"@aztec/ethereum": "1.0.0-nightly.20250710",
|
|
73
|
+
"@aztec/foundation": "1.0.0-nightly.20250710",
|
|
74
|
+
"@aztec/kv-store": "1.0.0-nightly.20250710",
|
|
75
|
+
"@aztec/l1-artifacts": "1.0.0-nightly.20250710",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "1.0.0-nightly.20250710",
|
|
77
|
+
"@aztec/protocol-contracts": "1.0.0-nightly.20250710",
|
|
78
|
+
"@aztec/stdlib": "1.0.0-nightly.20250710",
|
|
79
|
+
"@aztec/telemetry-client": "1.0.0-nightly.20250710",
|
|
80
80
|
"lodash.groupby": "^4.6.0",
|
|
81
81
|
"lodash.omit": "^4.5.0",
|
|
82
82
|
"tsc-watch": "^6.0.0",
|
package/src/archiver/archiver.ts
CHANGED
|
@@ -19,14 +19,14 @@ import { Timer, elapsed } from '@aztec/foundation/timer';
|
|
|
19
19
|
import type { CustomRange } from '@aztec/kv-store';
|
|
20
20
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
21
21
|
import {
|
|
22
|
-
|
|
22
|
+
ContractClassPublishedEvent,
|
|
23
23
|
PrivateFunctionBroadcastedEvent,
|
|
24
24
|
UtilityFunctionBroadcastedEvent,
|
|
25
|
-
} from '@aztec/protocol-contracts/class-
|
|
25
|
+
} from '@aztec/protocol-contracts/class-registry';
|
|
26
26
|
import {
|
|
27
|
-
|
|
27
|
+
ContractInstancePublishedEvent,
|
|
28
28
|
ContractInstanceUpdatedEvent,
|
|
29
|
-
} from '@aztec/protocol-contracts/instance-
|
|
29
|
+
} from '@aztec/protocol-contracts/instance-registry';
|
|
30
30
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
31
31
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
32
32
|
import {
|
|
@@ -1282,15 +1282,15 @@ export class ArchiverStoreHelper
|
|
|
1282
1282
|
constructor(protected readonly store: ArchiverDataStore) {}
|
|
1283
1283
|
|
|
1284
1284
|
/**
|
|
1285
|
-
* Extracts and stores contract classes out of
|
|
1285
|
+
* Extracts and stores contract classes out of ContractClassPublished events emitted by the class registry contract.
|
|
1286
1286
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
1287
1287
|
*/
|
|
1288
|
-
async #
|
|
1289
|
-
const
|
|
1290
|
-
.filter(log =>
|
|
1291
|
-
.map(log =>
|
|
1288
|
+
async #updatePublishedContractClasses(allLogs: ContractClassLog[], blockNum: number, operation: Operation) {
|
|
1289
|
+
const contractClassPublishedEvents = allLogs
|
|
1290
|
+
.filter(log => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
|
|
1291
|
+
.map(log => ContractClassPublishedEvent.fromLog(log));
|
|
1292
1292
|
|
|
1293
|
-
const contractClasses = await Promise.all(
|
|
1293
|
+
const contractClasses = await Promise.all(contractClassPublishedEvents.map(e => e.toContractClassPublic()));
|
|
1294
1294
|
if (contractClasses.length > 0) {
|
|
1295
1295
|
contractClasses.forEach(c => this.#log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
1296
1296
|
if (operation == Operation.Store) {
|
|
@@ -1307,13 +1307,13 @@ export class ArchiverStoreHelper
|
|
|
1307
1307
|
}
|
|
1308
1308
|
|
|
1309
1309
|
/**
|
|
1310
|
-
* Extracts and stores contract instances out of
|
|
1310
|
+
* Extracts and stores contract instances out of ContractInstancePublished events emitted by the canonical deployer contract.
|
|
1311
1311
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
1312
1312
|
*/
|
|
1313
1313
|
async #updateDeployedContractInstances(allLogs: PrivateLog[], blockNum: number, operation: Operation) {
|
|
1314
1314
|
const contractInstances = allLogs
|
|
1315
|
-
.filter(log =>
|
|
1316
|
-
.map(log =>
|
|
1315
|
+
.filter(log => ContractInstancePublishedEvent.isContractInstancePublishedEvent(log))
|
|
1316
|
+
.map(log => ContractInstancePublishedEvent.fromLog(log))
|
|
1317
1317
|
.map(e => e.toContractInstance());
|
|
1318
1318
|
if (contractInstances.length > 0) {
|
|
1319
1319
|
contractInstances.forEach(c =>
|
|
@@ -1329,7 +1329,7 @@ export class ArchiverStoreHelper
|
|
|
1329
1329
|
}
|
|
1330
1330
|
|
|
1331
1331
|
/**
|
|
1332
|
-
* Extracts and stores contract instances out of
|
|
1332
|
+
* Extracts and stores contract instances out of ContractInstancePublished events emitted by the canonical deployer contract.
|
|
1333
1333
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
1334
1334
|
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
1335
1335
|
* @param operation - The operation to perform on the contract instance updates (Store or Delete).
|
|
@@ -1428,12 +1428,12 @@ export class ArchiverStoreHelper
|
|
|
1428
1428
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
1429
1429
|
...blocks.map(async block => {
|
|
1430
1430
|
const contractClassLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
|
|
1431
|
-
//
|
|
1431
|
+
// ContractInstancePublished event logs are broadcast in privateLogs.
|
|
1432
1432
|
const privateLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
|
|
1433
1433
|
const publicLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
|
|
1434
1434
|
return (
|
|
1435
1435
|
await Promise.all([
|
|
1436
|
-
this.#
|
|
1436
|
+
this.#updatePublishedContractClasses(contractClassLogs, block.block.number, Operation.Store),
|
|
1437
1437
|
this.#updateDeployedContractInstances(privateLogs, block.block.number, Operation.Store),
|
|
1438
1438
|
this.#updateUpdatedContractInstances(
|
|
1439
1439
|
publicLogs,
|
|
@@ -1466,13 +1466,13 @@ export class ArchiverStoreHelper
|
|
|
1466
1466
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
1467
1467
|
...blocks.map(async block => {
|
|
1468
1468
|
const contractClassLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
|
|
1469
|
-
//
|
|
1469
|
+
// ContractInstancePublished event logs are broadcast in privateLogs.
|
|
1470
1470
|
const privateLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
|
|
1471
1471
|
const publicLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
|
|
1472
1472
|
|
|
1473
1473
|
return (
|
|
1474
1474
|
await Promise.all([
|
|
1475
|
-
this.#
|
|
1475
|
+
this.#updatePublishedContractClasses(contractClassLogs, block.block.number, Operation.Delete),
|
|
1476
1476
|
this.#updateDeployedContractInstances(privateLogs, block.block.number, Operation.Delete),
|
|
1477
1477
|
this.#updateUpdatedContractInstances(
|
|
1478
1478
|
publicLogs,
|
|
@@ -16,12 +16,12 @@ type ContractInstanceUpdateKey = [string, string] | [string, string, number];
|
|
|
16
16
|
*/
|
|
17
17
|
export class ContractInstanceStore {
|
|
18
18
|
#contractInstances: AztecAsyncMap<string, Buffer>;
|
|
19
|
-
#
|
|
19
|
+
#contractInstancePublishedAt: AztecAsyncMap<string, number>;
|
|
20
20
|
#contractInstanceUpdates: AztecAsyncMap<ContractInstanceUpdateKey, Buffer>;
|
|
21
21
|
|
|
22
22
|
constructor(private db: AztecAsyncKVStore) {
|
|
23
23
|
this.#contractInstances = db.openMap('archiver_contract_instances');
|
|
24
|
-
this.#
|
|
24
|
+
this.#contractInstancePublishedAt = db.openMap('archiver_contract_instances_publication_block_number');
|
|
25
25
|
this.#contractInstanceUpdates = db.openMap('archiver_contract_instance_updates');
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -31,14 +31,14 @@ export class ContractInstanceStore {
|
|
|
31
31
|
contractInstance.address.toString(),
|
|
32
32
|
new SerializableContractInstance(contractInstance).toBuffer(),
|
|
33
33
|
);
|
|
34
|
-
await this.#
|
|
34
|
+
await this.#contractInstancePublishedAt.set(contractInstance.address.toString(), blockNumber);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
deleteContractInstance(contractInstance: ContractInstanceWithAddress): Promise<void> {
|
|
39
39
|
return this.db.transactionAsync(async () => {
|
|
40
40
|
await this.#contractInstances.delete(contractInstance.address.toString());
|
|
41
|
-
await this.#
|
|
41
|
+
await this.#contractInstancePublishedAt.delete(contractInstance.address.toString());
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -110,6 +110,6 @@ export class ContractInstanceStore {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
getContractInstanceDeploymentBlockNumber(address: AztecAddress): Promise<number | undefined> {
|
|
113
|
-
return this.#
|
|
113
|
+
return this.#contractInstancePublishedAt.getAsync(address.toString());
|
|
114
114
|
}
|
|
115
115
|
}
|