@aztec/node-lib 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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/actions/build-snapshot-metadata.js +2 -2
- package/dest/actions/snapshot-sync.d.ts +7 -5
- package/dest/actions/snapshot-sync.d.ts.map +1 -1
- package/dest/actions/snapshot-sync.js +18 -16
- package/dest/actions/upload-snapshot.d.ts +2 -2
- package/dest/actions/upload-snapshot.d.ts.map +1 -1
- package/dest/config/index.d.ts +7 -5
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +16 -9
- package/dest/factories/l1_tx_utils.d.ts +34 -21
- package/dest/factories/l1_tx_utils.d.ts.map +1 -1
- package/dest/factories/l1_tx_utils.js +62 -18
- package/dest/metrics/l1_tx_metrics.d.ts +2 -2
- package/dest/metrics/l1_tx_metrics.d.ts.map +1 -1
- package/dest/metrics/l1_tx_metrics.js +28 -55
- package/dest/stores/l1_tx_store.d.ts +4 -4
- package/dest/stores/l1_tx_store.d.ts.map +1 -1
- package/dest/stores/l1_tx_store.js +19 -11
- package/package.json +32 -22
- package/src/actions/build-snapshot-metadata.ts +2 -2
- package/src/actions/snapshot-sync.ts +35 -21
- package/src/actions/upload-snapshot.ts +1 -1
- package/src/config/index.ts +30 -15
- package/src/factories/l1_tx_utils.ts +72 -38
- package/src/metrics/l1_tx_metrics.ts +27 -56
- package/src/stores/l1_tx_store.ts +21 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TxUtilsState } from '@aztec/ethereum';
|
|
1
|
+
import { TxUtilsState } from '@aztec/ethereum/l1-tx-utils';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { Attributes, Metrics,
|
|
3
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
4
4
|
/**
|
|
5
5
|
* Metrics for L1 transaction utils tracking tx lifecycle and gas costs.
|
|
6
6
|
*/ export class L1TxMetrics {
|
|
@@ -24,47 +24,20 @@ import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
|
24
24
|
this.meter = meter;
|
|
25
25
|
this.scope = scope;
|
|
26
26
|
this.logger = logger;
|
|
27
|
-
this.txMinedDuration = this.meter.createHistogram(Metrics.L1_TX_MINED_DURATION
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.txRevertedCount = this.meter.createUpDownCounter(Metrics.L1_TX_REVERTED_COUNT, {
|
|
42
|
-
description: 'Count of transactions that reverted',
|
|
43
|
-
valueType: ValueType.INT
|
|
44
|
-
});
|
|
45
|
-
this.txCancelledCount = this.meter.createUpDownCounter(Metrics.L1_TX_CANCELLED_COUNT, {
|
|
46
|
-
description: 'Count of transactions cancelled',
|
|
47
|
-
valueType: ValueType.INT
|
|
48
|
-
});
|
|
49
|
-
this.txNotMinedCount = this.meter.createUpDownCounter(Metrics.L1_TX_NOT_MINED_COUNT, {
|
|
50
|
-
description: 'Count of transactions not mined (timed out)',
|
|
51
|
-
valueType: ValueType.INT
|
|
52
|
-
});
|
|
53
|
-
this.maxPriorityFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_PRIORITY_FEE, {
|
|
54
|
-
description: 'Max priority fee per gas at tx end state (in wei)',
|
|
55
|
-
unit: 'wei',
|
|
56
|
-
valueType: ValueType.INT
|
|
57
|
-
});
|
|
58
|
-
this.maxFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_FEE, {
|
|
59
|
-
description: 'Max fee per gas at tx end state (in wei)',
|
|
60
|
-
unit: 'wei',
|
|
61
|
-
valueType: ValueType.INT
|
|
62
|
-
});
|
|
63
|
-
this.blobFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_BLOB_FEE, {
|
|
64
|
-
description: 'Max fee per blob gas at tx end state (in wei)',
|
|
65
|
-
unit: 'wei',
|
|
66
|
-
valueType: ValueType.INT
|
|
67
|
-
});
|
|
27
|
+
this.txMinedDuration = this.meter.createHistogram(Metrics.L1_TX_MINED_DURATION);
|
|
28
|
+
this.txAttemptsUntilMined = this.meter.createHistogram(Metrics.L1_TX_ATTEMPTS_UNTIL_MINED);
|
|
29
|
+
const scopeAttributes = [
|
|
30
|
+
{
|
|
31
|
+
[Attributes.L1_TX_SCOPE]: this.scope
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
this.txMinedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_MINED_COUNT, scopeAttributes);
|
|
35
|
+
this.txRevertedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_REVERTED_COUNT, scopeAttributes);
|
|
36
|
+
this.txCancelledCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_CANCELLED_COUNT, scopeAttributes);
|
|
37
|
+
this.txNotMinedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_NOT_MINED_COUNT, scopeAttributes);
|
|
38
|
+
this.maxPriorityFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_PRIORITY_FEE);
|
|
39
|
+
this.maxFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_FEE);
|
|
40
|
+
this.blobFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_BLOB_FEE);
|
|
68
41
|
}
|
|
69
42
|
/**
|
|
70
43
|
* Records metrics when a transaction is mined.
|
|
@@ -96,15 +69,15 @@ import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
|
96
69
|
// Record number of attempts until mined
|
|
97
70
|
const attempts = isCancelTx ? state.cancelTxHashes.length : state.txHashes.length;
|
|
98
71
|
this.txAttemptsUntilMined.record(attempts, attributes);
|
|
99
|
-
// Record gas prices at end state
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
this.blobFeeHistogram.record(
|
|
72
|
+
// Record gas prices at end state, converted from wei to gwei to match metric unit definitions
|
|
73
|
+
const weiToGwei = 1e9;
|
|
74
|
+
const maxPriorityFeeGwei = Number(state.gasPrice.maxPriorityFeePerGas) / weiToGwei;
|
|
75
|
+
const maxFeeGwei = Number(state.gasPrice.maxFeePerGas) / weiToGwei;
|
|
76
|
+
const blobFeeGwei = state.gasPrice.maxFeePerBlobGas ? Number(state.gasPrice.maxFeePerBlobGas) / weiToGwei : undefined;
|
|
77
|
+
this.maxPriorityFeeHistogram.record(maxPriorityFeeGwei, attributes);
|
|
78
|
+
this.maxFeeHistogram.record(maxFeeGwei, attributes);
|
|
79
|
+
if (blobFeeGwei !== undefined) {
|
|
80
|
+
this.blobFeeHistogram.record(blobFeeGwei, attributes);
|
|
108
81
|
}
|
|
109
82
|
this.logger.debug(`Recorded tx end state metrics`, {
|
|
110
83
|
status: TxUtilsState[state.status],
|
|
@@ -112,9 +85,9 @@ import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
|
112
85
|
isCancelTx,
|
|
113
86
|
isReverted,
|
|
114
87
|
scope: this.scope,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
88
|
+
maxPriorityFeeGwei,
|
|
89
|
+
maxFeeGwei,
|
|
90
|
+
blobFeeGwei
|
|
118
91
|
});
|
|
119
92
|
}
|
|
120
93
|
recordDroppedTx(state) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IL1TxStore, L1BlobInputs, L1TxState } from '@aztec/ethereum';
|
|
1
|
+
import type { IL1TxStore, L1BlobInputs, L1TxState } from '@aztec/ethereum/l1-tx-utils';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
|
9
9
|
export declare class L1TxStore implements IL1TxStore {
|
|
10
10
|
private readonly store;
|
|
11
11
|
private readonly log;
|
|
12
|
-
static readonly SCHEMA_VERSION
|
|
12
|
+
static readonly SCHEMA_VERSION = 2;
|
|
13
13
|
private readonly states;
|
|
14
14
|
private readonly blobs;
|
|
15
15
|
private readonly stateIdCounter;
|
|
@@ -54,7 +54,7 @@ export declare class L1TxStore implements IL1TxStore {
|
|
|
54
54
|
* @param account - The sender account address
|
|
55
55
|
* @param stateId - The state ID to delete
|
|
56
56
|
*/
|
|
57
|
-
deleteState(account: string,
|
|
57
|
+
deleteState(account: string, ...stateIds: number[]): Promise<void>;
|
|
58
58
|
/**
|
|
59
59
|
* Clears all transaction states for a specific account.
|
|
60
60
|
* @param account - The sender account address
|
|
@@ -86,4 +86,4 @@ export declare class L1TxStore implements IL1TxStore {
|
|
|
86
86
|
*/
|
|
87
87
|
private deserializeBlobInputs;
|
|
88
88
|
}
|
|
89
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
89
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDFfdHhfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZXMvbDFfdHhfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLFlBQVksRUFBYyxTQUFTLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVuRyxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUVwRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQTJFeEU7Ozs7R0FJRztBQUNILHFCQUFhLFNBQVUsWUFBVyxVQUFVO0lBUXhDLE9BQU8sQ0FBQyxR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BQU8sRUFBRSxNQUFNLEVBQUUsR0FBRyxRQUFRLEVBQUUsTUFBTSxFQUFFLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQVk5RTtJQUVEOzs7T0FHRztJQUNVLFdBQVcsQ0FBQyxPQUFPLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FXdkQ7SUFFRDs7O09BR0c7SUFDVSxjQUFjLElBQUksT0FBTyxDQUFDLE1BQU0sRUFBRSxDQUFDLENBUy9DO0lBRUQ7O09BRUc7SUFDVSxLQUFLLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUdsQztJQUVEOztPQUVHO0lBQ0gsT0FBTyxDQUFDLGNBQWM7SUFrQ3RCOztPQUVHO0lBQ0gsT0FBTyxDQUFDLGdCQUFnQjtJQTJDeEI7O09BRUc7SUFDSCxPQUFPLENBQUMsbUJBQW1CO0lBTzNCOztPQUVHO0lBQ0gsT0FBTyxDQUFDLHFCQUFxQjtDQVk5QiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l1_tx_store.d.ts","sourceRoot":"","sources":["../../src/stores/l1_tx_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAc,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"l1_tx_store.d.ts","sourceRoot":"","sources":["../../src/stores/l1_tx_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAc,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAEnG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AA2ExE;;;;GAIG;AACH,qBAAa,SAAU,YAAW,UAAU;IAQxC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAR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,gBAAgB;IA2CxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAY9B"}
|
|
@@ -134,22 +134,30 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
134
134
|
* Deletes a specific state and its associated blobs.
|
|
135
135
|
* @param account - The sender account address
|
|
136
136
|
* @param stateId - The state ID to delete
|
|
137
|
-
*/ async deleteState(account,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.
|
|
137
|
+
*/ async deleteState(account, ...stateIds) {
|
|
138
|
+
if (stateIds.length === 0) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await this.store.transactionAsync(async ()=>{
|
|
142
|
+
for (const stateId of stateIds){
|
|
143
|
+
const key = this.makeKey(account, stateId);
|
|
144
|
+
await this.states.delete(key);
|
|
145
|
+
await this.blobs.delete(key);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
142
148
|
}
|
|
143
149
|
/**
|
|
144
150
|
* Clears all transaction states for a specific account.
|
|
145
151
|
* @param account - The sender account address
|
|
146
152
|
*/ async clearStates(account) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
await this.store.transactionAsync(async ()=>{
|
|
154
|
+
const states = await this.loadStates(account);
|
|
155
|
+
for (const state of states){
|
|
156
|
+
await this.deleteState(account, state.id);
|
|
157
|
+
}
|
|
158
|
+
await this.stateIdCounter.delete(account);
|
|
159
|
+
this.log.info(`Cleared all tx states for account ${account}`);
|
|
160
|
+
});
|
|
153
161
|
}
|
|
154
162
|
/**
|
|
155
163
|
* Gets all accounts that have stored states.
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/node-lib",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.d58ff9d0",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"typedocOptions": {
|
|
6
|
+
"entryPoints": [
|
|
7
|
+
"./src/actions/index.ts",
|
|
8
|
+
"./src/config/index.ts",
|
|
9
|
+
"./src/factories/index.ts"
|
|
10
|
+
],
|
|
11
|
+
"name": "Node Library",
|
|
12
|
+
"tsconfig": "./tsconfig.json"
|
|
13
|
+
},
|
|
5
14
|
"exports": {
|
|
6
15
|
"./actions": "./dest/actions/index.js",
|
|
7
16
|
"./config": "./dest/config/index.js",
|
|
@@ -57,36 +66,37 @@
|
|
|
57
66
|
]
|
|
58
67
|
},
|
|
59
68
|
"dependencies": {
|
|
60
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
61
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
62
|
-
"@aztec/blob-
|
|
63
|
-
"@aztec/constants": "0.0.1-commit.
|
|
64
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
65
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
66
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
67
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
68
|
-
"@aztec/
|
|
69
|
-
"@aztec/
|
|
70
|
-
"@aztec/
|
|
71
|
-
"@aztec/
|
|
72
|
-
"@aztec/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.d3ec352c",
|
|
69
|
+
"@aztec/archiver": "0.0.1-commit.d58ff9d0",
|
|
70
|
+
"@aztec/bb-prover": "0.0.1-commit.d58ff9d0",
|
|
71
|
+
"@aztec/blob-client": "0.0.1-commit.d58ff9d0",
|
|
72
|
+
"@aztec/constants": "0.0.1-commit.d58ff9d0",
|
|
73
|
+
"@aztec/epoch-cache": "0.0.1-commit.d58ff9d0",
|
|
74
|
+
"@aztec/ethereum": "0.0.1-commit.d58ff9d0",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.d58ff9d0",
|
|
76
|
+
"@aztec/kv-store": "0.0.1-commit.d58ff9d0",
|
|
77
|
+
"@aztec/p2p": "0.0.1-commit.d58ff9d0",
|
|
78
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d58ff9d0",
|
|
79
|
+
"@aztec/prover-client": "0.0.1-commit.d58ff9d0",
|
|
80
|
+
"@aztec/sequencer-client": "0.0.1-commit.d58ff9d0",
|
|
81
|
+
"@aztec/simulator": "0.0.1-commit.d58ff9d0",
|
|
82
|
+
"@aztec/stdlib": "0.0.1-commit.d58ff9d0",
|
|
83
|
+
"@aztec/telemetry-client": "0.0.1-commit.d58ff9d0",
|
|
84
|
+
"@aztec/validator-client": "0.0.1-commit.d58ff9d0",
|
|
85
|
+
"@aztec/world-state": "0.0.1-commit.d58ff9d0",
|
|
78
86
|
"tslib": "^2.4.0"
|
|
79
87
|
},
|
|
80
88
|
"devDependencies": {
|
|
81
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
89
|
+
"@aztec/blob-lib": "0.0.1-commit.d58ff9d0",
|
|
90
|
+
"@aztec/node-keystore": "0.0.1-commit.d58ff9d0",
|
|
82
91
|
"@jest/globals": "^30.0.0",
|
|
83
92
|
"@types/jest": "^30.0.0",
|
|
84
93
|
"@types/node": "^22.15.17",
|
|
85
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
94
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
86
95
|
"jest": "^30.0.0",
|
|
87
96
|
"jest-mock-extended": "^4.0.0",
|
|
88
97
|
"ts-node": "^10.9.1",
|
|
89
|
-
"typescript": "^5.3.3"
|
|
98
|
+
"typescript": "^5.3.3",
|
|
99
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
90
100
|
},
|
|
91
101
|
"files": [
|
|
92
102
|
"dest",
|
|
@@ -7,13 +7,13 @@ export async function buildSnapshotMetadata(
|
|
|
7
7
|
archiver: Archiver,
|
|
8
8
|
config: UploadSnapshotConfig,
|
|
9
9
|
): Promise<UploadSnapshotMetadata> {
|
|
10
|
-
const [rollupAddress, l1BlockNumber,
|
|
10
|
+
const [rollupAddress, l1BlockNumber, tips] = await Promise.all([
|
|
11
11
|
archiver.getRollupAddress(),
|
|
12
12
|
archiver.getL1BlockNumber(),
|
|
13
13
|
archiver.getL2Tips(),
|
|
14
14
|
] as const);
|
|
15
15
|
|
|
16
|
-
const { number: l2BlockNumber, hash: l2BlockHash } =
|
|
16
|
+
const { number: l2BlockNumber, hash: l2BlockHash } = tips.proposed;
|
|
17
17
|
if (!l2BlockHash) {
|
|
18
18
|
throw new Error(`Failed to get L2 block hash from archiver.`);
|
|
19
19
|
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ARCHIVER_DB_VERSION,
|
|
3
|
+
ARCHIVER_STORE_NAME,
|
|
4
|
+
type ArchiverConfig,
|
|
5
|
+
createArchiverStore,
|
|
6
|
+
getArchiverSynchPoint,
|
|
7
|
+
} from '@aztec/archiver';
|
|
2
8
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
|
-
import { type EthereumClientConfig, getPublicClient } from '@aztec/ethereum';
|
|
9
|
+
import { type EthereumClientConfig, getPublicClient } from '@aztec/ethereum/client';
|
|
10
|
+
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
4
11
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
12
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
6
13
|
import type { Logger } from '@aztec/foundation/log';
|
|
7
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
8
14
|
import { P2P_STORE_NAME } from '@aztec/p2p';
|
|
15
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/stdlib/block';
|
|
9
16
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
10
|
-
import { DatabaseVersionManager } from '@aztec/stdlib/database-version';
|
|
17
|
+
import { DatabaseVersionManager } from '@aztec/stdlib/database-version/manager';
|
|
11
18
|
import { type ReadOnlyFileStore, createReadOnlyFileStore } from '@aztec/stdlib/file-store';
|
|
19
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
12
20
|
import {
|
|
13
21
|
type SnapshotMetadata,
|
|
14
22
|
type SnapshotsIndexMetadata,
|
|
@@ -28,8 +36,10 @@ const MIN_L1_BLOCKS_TO_TRIGGER_REPLACE = 86400 / 2 / 12;
|
|
|
28
36
|
|
|
29
37
|
type SnapshotSyncConfig = Pick<SharedNodeConfig, 'syncMode'> &
|
|
30
38
|
Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> &
|
|
31
|
-
Pick<
|
|
32
|
-
|
|
39
|
+
Pick<L1ContractsConfig, 'aztecEpochDuration'> &
|
|
40
|
+
Pick<ArchiverConfig, 'archiverStoreMapSizeKb'> &
|
|
41
|
+
DataStoreConfig &
|
|
42
|
+
Required<Pick<DataStoreConfig, 'rollupAddress'>> &
|
|
33
43
|
EthereumClientConfig & {
|
|
34
44
|
snapshotsUrls?: string[];
|
|
35
45
|
minL1BlocksToTriggerReplace?: number;
|
|
@@ -40,7 +50,7 @@ type SnapshotSyncConfig = Pick<SharedNodeConfig, 'syncMode'> &
|
|
|
40
50
|
* Behaviour depends on syncing mode.
|
|
41
51
|
*/
|
|
42
52
|
export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
|
|
43
|
-
const { syncMode, snapshotsUrls, dataDirectory, l1ChainId, rollupVersion,
|
|
53
|
+
const { syncMode, snapshotsUrls, dataDirectory, l1ChainId, rollupVersion, rollupAddress } = config;
|
|
44
54
|
if (syncMode === 'full') {
|
|
45
55
|
log.debug('Snapshot sync is disabled. Running full sync.', { syncMode: syncMode });
|
|
46
56
|
return false;
|
|
@@ -56,19 +66,21 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
|
|
|
56
66
|
return false;
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
// Create an archiver store to check the current state (do this only once)
|
|
69
|
+
// Create an archiver store to check the current state (do this only once). This temporary store is only
|
|
70
|
+
// read for its sync point and never serves tagged-log queries, so the genesis block hash it carries is
|
|
71
|
+
// immaterial — pass the protocol constant.
|
|
60
72
|
log.verbose(`Creating temporary archiver data store`);
|
|
61
|
-
const archiverStore = await createArchiverStore(config);
|
|
73
|
+
const archiverStore = await createArchiverStore(config, GENESIS_BLOCK_HEADER_HASH);
|
|
62
74
|
let archiverL1BlockNumber: bigint | undefined;
|
|
63
75
|
let archiverL2BlockNumber: number | undefined;
|
|
64
76
|
try {
|
|
65
77
|
[archiverL1BlockNumber, archiverL2BlockNumber] = await Promise.all([
|
|
66
|
-
archiverStore
|
|
67
|
-
archiverStore.
|
|
78
|
+
getArchiverSynchPoint(archiverStore).then(s => s.blocksSynchedTo),
|
|
79
|
+
archiverStore.blocks.getLatestL2BlockNumber(),
|
|
68
80
|
] as const);
|
|
69
81
|
} finally {
|
|
70
82
|
log.verbose(`Closing temporary archiver data store`, { archiverL1BlockNumber, archiverL2BlockNumber });
|
|
71
|
-
await archiverStore.close();
|
|
83
|
+
await archiverStore.db.close();
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
const minL1BlocksToTriggerReplace = config.minL1BlocksToTriggerReplace ?? MIN_L1_BLOCKS_TO_TRIGGER_REPLACE;
|
|
@@ -80,7 +92,11 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
|
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
const currentL1BlockNumber = await getPublicClient(config).getBlockNumber();
|
|
83
|
-
if (
|
|
95
|
+
if (
|
|
96
|
+
archiverL1BlockNumber &&
|
|
97
|
+
currentL1BlockNumber >= archiverL1BlockNumber &&
|
|
98
|
+
currentL1BlockNumber - archiverL1BlockNumber < minL1BlocksToTriggerReplace
|
|
99
|
+
) {
|
|
84
100
|
log.verbose(
|
|
85
101
|
`Skipping snapshot sync as archiver is less than ${
|
|
86
102
|
currentL1BlockNumber - archiverL1BlockNumber
|
|
@@ -93,7 +109,7 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
|
|
|
93
109
|
const indexMetadata: SnapshotsIndexMetadata = {
|
|
94
110
|
l1ChainId,
|
|
95
111
|
rollupVersion,
|
|
96
|
-
rollupAddress
|
|
112
|
+
rollupAddress,
|
|
97
113
|
};
|
|
98
114
|
|
|
99
115
|
// Fetch latest snapshot from each URL
|
|
@@ -171,7 +187,7 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
|
|
|
171
187
|
snapshotCandidates.sort((a, b) => b.snapshot.l1BlockNumber - a.snapshot.l1BlockNumber);
|
|
172
188
|
|
|
173
189
|
// Try each candidate in order until one succeeds
|
|
174
|
-
for (const { snapshot, url } of snapshotCandidates) {
|
|
190
|
+
for (const { snapshot, url, fileStore } of snapshotCandidates) {
|
|
175
191
|
const { l1BlockNumber, l2BlockNumber } = snapshot;
|
|
176
192
|
log.info(`Attempting to sync from snapshot at L1 block ${l1BlockNumber} L2 block ${l2BlockNumber}`, {
|
|
177
193
|
snapshot,
|
|
@@ -181,8 +197,8 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
|
|
|
181
197
|
try {
|
|
182
198
|
await snapshotSync(snapshot, log, {
|
|
183
199
|
dataDirectory: config.dataDirectory!,
|
|
184
|
-
rollupAddress: config.
|
|
185
|
-
|
|
200
|
+
rollupAddress: config.rollupAddress,
|
|
201
|
+
fileStore,
|
|
186
202
|
});
|
|
187
203
|
log.info(`Snapshot synced to L1 block ${l1BlockNumber} L2 block ${l2BlockNumber}`, {
|
|
188
204
|
snapshot,
|
|
@@ -208,15 +224,13 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
|
|
|
208
224
|
export async function snapshotSync(
|
|
209
225
|
snapshot: Pick<SnapshotMetadata, 'dataUrls'>,
|
|
210
226
|
log: Logger,
|
|
211
|
-
config: { dataDirectory: string; rollupAddress: EthAddress;
|
|
227
|
+
config: { dataDirectory: string; rollupAddress: EthAddress; fileStore: ReadOnlyFileStore },
|
|
212
228
|
) {
|
|
213
|
-
const { dataDirectory, rollupAddress } = config;
|
|
229
|
+
const { dataDirectory, rollupAddress, fileStore } = config;
|
|
214
230
|
if (!dataDirectory) {
|
|
215
231
|
throw new Error(`No local data directory defined. Cannot sync snapshot.`);
|
|
216
232
|
}
|
|
217
233
|
|
|
218
|
-
const fileStore = await createReadOnlyFileStore(config.snapshotsUrl, log);
|
|
219
|
-
|
|
220
234
|
let downloadDir: string | undefined;
|
|
221
235
|
|
|
222
236
|
try {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ARCHIVER_DB_VERSION, type Archiver } from '@aztec/archiver';
|
|
2
2
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
3
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
5
4
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
6
5
|
import { createFileStore } from '@aztec/stdlib/file-store';
|
|
7
6
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
8
8
|
import { uploadSnapshotToIndex } from '@aztec/stdlib/snapshots';
|
|
9
9
|
import { WORLD_STATE_DB_VERSION } from '@aztec/world-state';
|
|
10
10
|
|
package/src/config/index.ts
CHANGED
|
@@ -5,20 +5,22 @@ export type SharedNodeConfig = {
|
|
|
5
5
|
testAccounts: boolean;
|
|
6
6
|
/** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
|
|
7
7
|
sponsoredFPC: boolean;
|
|
8
|
+
/** Additional addresses to prefund with fee juice at genesis */
|
|
9
|
+
prefundAddresses: string[];
|
|
8
10
|
/** Sync mode: full to always sync via L1, snapshot to download a snapshot if there is no local data, force-snapshot to download even if there is local data. */
|
|
9
11
|
syncMode: 'full' | 'snapshot' | 'force-snapshot';
|
|
10
12
|
/** Base URLs for snapshots index. Index file will be searched at `SNAPSHOTS_BASE_URL/aztec-L1_CHAIN_ID-VERSION-ROLLUP_ADDRESS/index.json` */
|
|
11
13
|
snapshotsUrls?: string[];
|
|
12
|
-
|
|
13
|
-
/** Auto update mode: disabled - to completely ignore remote signals to update the node. enabled - to respect the signals (potentially shutting this node down). log - check for updates but log a warning instead of applying them*/
|
|
14
|
-
autoUpdate?: 'disabled' | 'notify' | 'config' | 'config-and-version';
|
|
15
|
-
/** The base URL against which to check for updates */
|
|
16
|
-
autoUpdateUrl?: string;
|
|
17
|
-
|
|
18
14
|
/** URL of the Web3Signer instance */
|
|
19
15
|
web3SignerUrl?: string;
|
|
20
16
|
/** Whether to run in fisherman mode */
|
|
21
17
|
fishermanMode?: boolean;
|
|
18
|
+
|
|
19
|
+
/** Force verification of tx Chonk proofs. Only used for testnet */
|
|
20
|
+
debugForceTxProofVerification: boolean;
|
|
21
|
+
|
|
22
|
+
/** Soft-shutdown the node when the canonical rollup is no longer compatible, keeping the health server up for K8s probes */
|
|
23
|
+
enableAutoShutdown: boolean;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export const sharedNodeConfigMappings: ConfigMappingsType<SharedNodeConfig> = {
|
|
@@ -32,6 +34,16 @@ export const sharedNodeConfigMappings: ConfigMappingsType<SharedNodeConfig> = {
|
|
|
32
34
|
description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
|
|
33
35
|
...booleanConfigHelper(false),
|
|
34
36
|
},
|
|
37
|
+
prefundAddresses: {
|
|
38
|
+
env: 'PREFUND_ADDRESSES',
|
|
39
|
+
description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis (local network only).',
|
|
40
|
+
parseEnv: (val: string) =>
|
|
41
|
+
val
|
|
42
|
+
.split(',')
|
|
43
|
+
.map(a => a.trim())
|
|
44
|
+
.filter(a => a.length > 0),
|
|
45
|
+
defaultValue: [],
|
|
46
|
+
},
|
|
35
47
|
syncMode: {
|
|
36
48
|
env: 'SYNC_MODE',
|
|
37
49
|
description:
|
|
@@ -49,15 +61,6 @@ export const sharedNodeConfigMappings: ConfigMappingsType<SharedNodeConfig> = {
|
|
|
49
61
|
fallback: ['SYNC_SNAPSHOTS_URL'],
|
|
50
62
|
defaultValue: [],
|
|
51
63
|
},
|
|
52
|
-
autoUpdate: {
|
|
53
|
-
env: 'AUTO_UPDATE',
|
|
54
|
-
description: 'The auto update mode for this node',
|
|
55
|
-
defaultValue: 'disabled',
|
|
56
|
-
},
|
|
57
|
-
autoUpdateUrl: {
|
|
58
|
-
env: 'AUTO_UPDATE_URL',
|
|
59
|
-
description: 'Base URL to check for updates',
|
|
60
|
-
},
|
|
61
64
|
web3SignerUrl: {
|
|
62
65
|
env: 'WEB3_SIGNER_URL',
|
|
63
66
|
description: 'URL of the Web3Signer instance',
|
|
@@ -68,4 +71,16 @@ export const sharedNodeConfigMappings: ConfigMappingsType<SharedNodeConfig> = {
|
|
|
68
71
|
description: 'Whether to run in fisherman mode.',
|
|
69
72
|
...booleanConfigHelper(false),
|
|
70
73
|
},
|
|
74
|
+
debugForceTxProofVerification: {
|
|
75
|
+
env: 'DEBUG_FORCE_TX_PROOF_VERIFICATION',
|
|
76
|
+
description: 'Whether to force tx proof verification. Only has an effect if real proving is turned off',
|
|
77
|
+
...booleanConfigHelper(false),
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
enableAutoShutdown: {
|
|
81
|
+
env: 'ENABLE_AUTO_SHUTDOWN',
|
|
82
|
+
description:
|
|
83
|
+
'Soft-shutdown the node when the canonical rollup is no longer compatible (protocol constants diverge), keeping the health server up so K8s probes keep passing. Only applies to nodes following the canonical rollup.',
|
|
84
|
+
...booleanConfigHelper(false),
|
|
85
|
+
},
|
|
71
86
|
};
|