@aztec/node-lib 3.0.0-canary.a9708bd → 3.0.0-devnet.3
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/snapshot-sync.d.ts +2 -1
- package/dest/actions/snapshot-sync.d.ts.map +1 -1
- package/dest/actions/snapshot-sync.js +89 -54
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +8 -3
- package/dest/factories/index.d.ts +2 -0
- package/dest/factories/index.d.ts.map +1 -0
- package/dest/factories/index.js +1 -0
- package/dest/factories/l1_tx_utils.d.ts +53 -0
- package/dest/factories/l1_tx_utils.d.ts.map +1 -0
- package/dest/factories/l1_tx_utils.js +50 -0
- package/dest/metrics/index.d.ts +2 -0
- package/dest/metrics/index.d.ts.map +1 -0
- package/dest/metrics/index.js +1 -0
- package/dest/metrics/l1_tx_metrics.d.ts +29 -0
- package/dest/metrics/l1_tx_metrics.d.ts.map +1 -0
- package/dest/metrics/l1_tx_metrics.js +138 -0
- package/dest/stores/index.d.ts +2 -0
- package/dest/stores/index.d.ts.map +1 -0
- package/dest/stores/index.js +1 -0
- package/dest/stores/l1_tx_store.d.ts +89 -0
- package/dest/stores/l1_tx_store.d.ts.map +1 -0
- package/dest/stores/l1_tx_store.js +264 -0
- package/package.json +24 -20
- package/src/actions/snapshot-sync.ts +101 -62
- package/src/config/index.ts +12 -5
- package/src/factories/index.ts +1 -0
- package/src/factories/l1_tx_utils.ts +122 -0
- package/src/metrics/index.ts +1 -0
- package/src/metrics/l1_tx_metrics.ts +169 -0
- package/src/stores/index.ts +1 -0
- package/src/stores/l1_tx_store.ts +387 -0
|
@@ -6,7 +6,8 @@ import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
|
6
6
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
7
7
|
import { type SnapshotMetadata } from '@aztec/stdlib/snapshots';
|
|
8
8
|
import type { SharedNodeConfig } from '../config/index.js';
|
|
9
|
-
type SnapshotSyncConfig = Pick<SharedNodeConfig, 'syncMode'
|
|
9
|
+
type SnapshotSyncConfig = Pick<SharedNodeConfig, 'syncMode'> & Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> & Pick<ArchiverConfig, 'archiverStoreMapSizeKb' | 'maxLogs'> & Required<DataStoreConfig> & EthereumClientConfig & {
|
|
10
|
+
snapshotsUrls?: string[];
|
|
10
11
|
minL1BlocksToTriggerReplace?: number;
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-sync.d.ts","sourceRoot":"","sources":["../../src/actions/snapshot-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AAErH,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EACL,KAAK,gBAAgB,EAKtB,MAAM,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D,KAAK,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"snapshot-sync.d.ts","sourceRoot":"","sources":["../../src/actions/snapshot-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AAErH,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EACL,KAAK,gBAAgB,EAKtB,MAAM,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D,KAAK,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAC1D,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,CAAC,GAChD,IAAI,CAAC,cAAc,EAAE,wBAAwB,GAAG,SAAS,CAAC,GAC1D,QAAQ,CAAC,eAAe,CAAC,GACzB,oBAAoB,GAAG;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,oBAiK5E;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC5C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,iBAqDnF"}
|
|
@@ -15,29 +15,22 @@ const MIN_L1_BLOCKS_TO_TRIGGER_REPLACE = 86400 / 2 / 12;
|
|
|
15
15
|
* Connects to a remote snapshot index and downloads the latest snapshot if the local archiver is behind.
|
|
16
16
|
* Behaviour depends on syncing mode.
|
|
17
17
|
*/ export async function trySnapshotSync(config, log) {
|
|
18
|
-
const { syncMode,
|
|
18
|
+
const { syncMode, snapshotsUrls, dataDirectory, l1ChainId, rollupVersion, l1Contracts } = config;
|
|
19
19
|
if (syncMode === 'full') {
|
|
20
20
|
log.debug('Snapshot sync is disabled. Running full sync.', {
|
|
21
21
|
syncMode: syncMode
|
|
22
22
|
});
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
|
-
if (!
|
|
26
|
-
log.verbose('Snapshot sync is disabled. No snapshots
|
|
25
|
+
if (!snapshotsUrls || snapshotsUrls.length === 0) {
|
|
26
|
+
log.verbose('Snapshot sync is disabled. No snapshots URLs provided.');
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
if (!dataDirectory) {
|
|
30
30
|
log.verbose('Snapshot sync is disabled. No local data directory defined.');
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
fileStore = await createReadOnlyFileStore(snapshotsUrl, log);
|
|
36
|
-
} catch (err) {
|
|
37
|
-
log.error(`Invalid config for downloading snapshots`, err);
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
// Create an archiver store to check the current state
|
|
33
|
+
// Create an archiver store to check the current state (do this only once)
|
|
41
34
|
log.verbose(`Creating temporary archiver data store`);
|
|
42
35
|
const archiverStore = await createArchiverStore(config);
|
|
43
36
|
let archiverL1BlockNumber;
|
|
@@ -73,59 +66,101 @@ const MIN_L1_BLOCKS_TO_TRIGGER_REPLACE = 86400 / 2 / 12;
|
|
|
73
66
|
rollupVersion,
|
|
74
67
|
rollupAddress: l1Contracts.rollupAddress
|
|
75
68
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
snapshotsUrl
|
|
69
|
+
const snapshotCandidates = [];
|
|
70
|
+
for (const snapshotsUrl of snapshotsUrls){
|
|
71
|
+
let fileStore;
|
|
72
|
+
try {
|
|
73
|
+
fileStore = await createReadOnlyFileStore(snapshotsUrl, log);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
log.error(`Invalid config for downloading snapshots from ${snapshotsUrl}`, err);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
let snapshot;
|
|
79
|
+
try {
|
|
80
|
+
snapshot = await getLatestSnapshotMetadata(indexMetadata, fileStore);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
log.error(`Failed to get latest snapshot metadata from ${snapshotsUrl}. Skipping this URL.`, err, {
|
|
83
|
+
...indexMetadata,
|
|
84
|
+
snapshotsUrl
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!snapshot) {
|
|
89
|
+
log.verbose(`No snapshot found at ${snapshotsUrl}. Skipping this URL.`, {
|
|
90
|
+
...indexMetadata,
|
|
91
|
+
snapshotsUrl
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (snapshot.schemaVersions.archiver !== ARCHIVER_DB_VERSION) {
|
|
96
|
+
log.warn(`Skipping snapshot from ${snapshotsUrl} as it has schema version ${snapshot.schemaVersions.archiver} but expected ${ARCHIVER_DB_VERSION}.`, snapshot);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (snapshot.schemaVersions.worldState !== WORLD_STATE_DB_VERSION) {
|
|
100
|
+
log.warn(`Skipping snapshot from ${snapshotsUrl} as it has world state schema version ${snapshot.schemaVersions.worldState} but we expected ${WORLD_STATE_DB_VERSION}.`, snapshot);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (archiverL1BlockNumber && snapshot.l1BlockNumber < archiverL1BlockNumber) {
|
|
104
|
+
log.verbose(`Skipping snapshot from ${snapshotsUrl} since local archiver is at L1 block ${archiverL1BlockNumber} which is further than snapshot at ${snapshot.l1BlockNumber}`, {
|
|
105
|
+
snapshot,
|
|
106
|
+
archiverL1BlockNumber,
|
|
107
|
+
snapshotsUrl
|
|
108
|
+
});
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (archiverL1BlockNumber && snapshot.l1BlockNumber - Number(archiverL1BlockNumber) < minL1BlocksToTriggerReplace) {
|
|
112
|
+
log.verbose(`Skipping snapshot from ${snapshotsUrl} as archiver is less than ${snapshot.l1BlockNumber - Number(archiverL1BlockNumber)} L1 blocks behind this snapshot.`, {
|
|
113
|
+
snapshot,
|
|
114
|
+
archiverL1BlockNumber,
|
|
115
|
+
snapshotsUrl
|
|
116
|
+
});
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
snapshotCandidates.push({
|
|
120
|
+
snapshot,
|
|
121
|
+
url: snapshotsUrl,
|
|
122
|
+
fileStore
|
|
83
123
|
});
|
|
84
|
-
return false;
|
|
85
124
|
}
|
|
86
|
-
if (
|
|
87
|
-
log.verbose(`No
|
|
125
|
+
if (snapshotCandidates.length === 0) {
|
|
126
|
+
log.verbose(`No valid snapshots found from any URL. Skipping snapshot sync.`, {
|
|
88
127
|
...indexMetadata,
|
|
89
|
-
|
|
90
|
-
});
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
if (snapshot.schemaVersions.archiver !== ARCHIVER_DB_VERSION) {
|
|
94
|
-
log.warn(`Skipping snapshot sync as last snapshot has schema version ${snapshot.schemaVersions.archiver} but expected ${ARCHIVER_DB_VERSION}.`, snapshot);
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
if (snapshot.schemaVersions.worldState !== WORLD_STATE_DB_VERSION) {
|
|
98
|
-
log.warn(`Skipping snapshot sync as last snapshot has world state schema version ${snapshot.schemaVersions.worldState} but we expected ${WORLD_STATE_DB_VERSION}.`, snapshot);
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
if (archiverL1BlockNumber && snapshot.l1BlockNumber < archiverL1BlockNumber) {
|
|
102
|
-
log.verbose(`Skipping snapshot sync since local archiver is at L1 block ${archiverL1BlockNumber} which is further than last snapshot at ${snapshot.l1BlockNumber}`, {
|
|
103
|
-
snapshot,
|
|
104
|
-
archiverL1BlockNumber
|
|
128
|
+
snapshotsUrls
|
|
105
129
|
});
|
|
106
130
|
return false;
|
|
107
131
|
}
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
// Sort candidates by L1 block number (highest first)
|
|
133
|
+
snapshotCandidates.sort((a, b)=>b.snapshot.l1BlockNumber - a.snapshot.l1BlockNumber);
|
|
134
|
+
// Try each candidate in order until one succeeds
|
|
135
|
+
for (const { snapshot, url } of snapshotCandidates){
|
|
136
|
+
const { l1BlockNumber, l2BlockNumber } = snapshot;
|
|
137
|
+
log.info(`Attempting to sync from snapshot at L1 block ${l1BlockNumber} L2 block ${l2BlockNumber}`, {
|
|
110
138
|
snapshot,
|
|
111
|
-
|
|
139
|
+
snapshotsUrl: url
|
|
112
140
|
});
|
|
113
|
-
|
|
141
|
+
try {
|
|
142
|
+
await snapshotSync(snapshot, log, {
|
|
143
|
+
dataDirectory: config.dataDirectory,
|
|
144
|
+
rollupAddress: config.l1Contracts.rollupAddress,
|
|
145
|
+
snapshotsUrl: url
|
|
146
|
+
});
|
|
147
|
+
log.info(`Snapshot synced to L1 block ${l1BlockNumber} L2 block ${l2BlockNumber}`, {
|
|
148
|
+
snapshot,
|
|
149
|
+
snapshotsUrl: url
|
|
150
|
+
});
|
|
151
|
+
return true;
|
|
152
|
+
} catch (err) {
|
|
153
|
+
log.error(`Failed to download snapshot from ${url}. Trying next candidate.`, err, {
|
|
154
|
+
snapshot,
|
|
155
|
+
snapshotsUrl: url
|
|
156
|
+
});
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
114
159
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
snapshot,
|
|
118
|
-
snapshotsUrl
|
|
119
|
-
});
|
|
120
|
-
await snapshotSync(snapshot, log, {
|
|
121
|
-
dataDirectory: config.dataDirectory,
|
|
122
|
-
rollupAddress: config.l1Contracts.rollupAddress,
|
|
123
|
-
snapshotsUrl
|
|
124
|
-
});
|
|
125
|
-
log.info(`Snapshot synced to L1 block ${l1BlockNumber} L2 block ${l2BlockNumber}`, {
|
|
126
|
-
snapshot
|
|
160
|
+
log.error(`Failed to download snapshot from all URLs.`, {
|
|
161
|
+
snapshotsUrls
|
|
127
162
|
});
|
|
128
|
-
return
|
|
163
|
+
return false;
|
|
129
164
|
}
|
|
130
165
|
/**
|
|
131
166
|
* Downloads the given snapshot replacing any local data stores.
|
package/dest/config/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export type SharedNodeConfig = {
|
|
|
6
6
|
sponsoredFPC: boolean;
|
|
7
7
|
/** 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. */
|
|
8
8
|
syncMode: 'full' | 'snapshot' | 'force-snapshot';
|
|
9
|
-
/** Base
|
|
10
|
-
|
|
9
|
+
/** Base URLs for snapshots index. Index file will be searched at `SNAPSHOTS_BASE_URL/aztec-L1_CHAIN_ID-VERSION-ROLLUP_ADDRESS/index.json` */
|
|
10
|
+
snapshotsUrls?: string[];
|
|
11
11
|
/** 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*/
|
|
12
12
|
autoUpdate?: 'disabled' | 'notify' | 'config' | 'config-and-version';
|
|
13
13
|
/** The base URL against which to check for updates */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,0BAA0B,CAAC;AAExF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yFAAyF;IACzF,YAAY,EAAE,OAAO,CAAC;IACtB,yFAAyF;IACzF,YAAY,EAAE,OAAO,CAAC;IACtB,gKAAgK;IAChK,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,CAAC;IACjD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,0BAA0B,CAAC;AAExF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yFAAyF;IACzF,YAAY,EAAE,OAAO,CAAC;IACtB,yFAAyF;IACzF,YAAY,EAAE,OAAO,CAAC;IACtB,gKAAgK;IAChK,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,CAAC;IACjD,6IAA6I;IAC7I,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB,qOAAqO;IACrO,UAAU,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,oBAAoB,CAAC;IACrE,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,kBAAkB,CAAC,gBAAgB,CA0CzE,CAAC"}
|
package/dest/config/index.js
CHANGED
|
@@ -15,9 +15,14 @@ export const sharedNodeConfigMappings = {
|
|
|
15
15
|
description: 'Set sync mode to `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.',
|
|
16
16
|
defaultValue: 'snapshot'
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
env: '
|
|
20
|
-
description: 'Base
|
|
18
|
+
snapshotsUrls: {
|
|
19
|
+
env: 'SYNC_SNAPSHOTS_URLS',
|
|
20
|
+
description: 'Base URLs for snapshots index, comma-separated.',
|
|
21
|
+
parseEnv: (val)=>val.split(',').map((url)=>url.trim()).filter((url)=>url.length > 0),
|
|
22
|
+
fallback: [
|
|
23
|
+
'SYNC_SNAPSHOTS_URL'
|
|
24
|
+
],
|
|
25
|
+
defaultValue: []
|
|
21
26
|
},
|
|
22
27
|
autoUpdate: {
|
|
23
28
|
env: 'AUTO_UPDATE',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './l1_tx_utils.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EthSigner, ExtendedViemWalletClient, L1TxUtilsConfig, ViemClient } from '@aztec/ethereum';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
+
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
5
|
+
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
6
|
+
import type { L1TxScope } from '../metrics/l1_tx_metrics.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates L1TxUtils with blobs from multiple Viem wallets, sharing store and metrics.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createL1TxUtilsWithBlobsFromViemWallet(clients: ExtendedViemWalletClient[], config: DataStoreConfig & Partial<L1TxUtilsConfig> & {
|
|
11
|
+
debugMaxGasLimit?: boolean;
|
|
12
|
+
scope?: L1TxScope;
|
|
13
|
+
}, deps: {
|
|
14
|
+
telemetry: TelemetryClient;
|
|
15
|
+
logger?: ReturnType<typeof createLogger>;
|
|
16
|
+
dateProvider?: DateProvider;
|
|
17
|
+
}): Promise<import("@aztec/ethereum/l1-tx-utils-with-blobs").L1TxUtilsWithBlobs[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates L1TxUtils with blobs from multiple EthSigners, sharing store and metrics.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createL1TxUtilsWithBlobsFromEthSigner(client: ViemClient, signers: EthSigner[], config: DataStoreConfig & Partial<L1TxUtilsConfig> & {
|
|
22
|
+
debugMaxGasLimit?: boolean;
|
|
23
|
+
scope?: L1TxScope;
|
|
24
|
+
}, deps: {
|
|
25
|
+
telemetry: TelemetryClient;
|
|
26
|
+
logger?: ReturnType<typeof createLogger>;
|
|
27
|
+
dateProvider?: DateProvider;
|
|
28
|
+
}): Promise<import("@aztec/ethereum/l1-tx-utils-with-blobs").L1TxUtilsWithBlobs[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates L1TxUtils (without blobs) from multiple Viem wallets, sharing store and metrics.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createL1TxUtilsFromViemWalletWithStore(clients: ExtendedViemWalletClient[], config: DataStoreConfig & Partial<L1TxUtilsConfig> & {
|
|
33
|
+
debugMaxGasLimit?: boolean;
|
|
34
|
+
scope?: L1TxScope;
|
|
35
|
+
}, deps: {
|
|
36
|
+
telemetry: TelemetryClient;
|
|
37
|
+
logger?: ReturnType<typeof createLogger>;
|
|
38
|
+
dateProvider?: DateProvider;
|
|
39
|
+
scope?: L1TxScope;
|
|
40
|
+
}): Promise<import("@aztec/ethereum").L1TxUtils[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Creates L1TxUtils (without blobs) from multiple EthSigners, sharing store and metrics.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createL1TxUtilsFromEthSignerWithStore(client: ViemClient, signers: EthSigner[], config: DataStoreConfig & Partial<L1TxUtilsConfig> & {
|
|
45
|
+
debugMaxGasLimit?: boolean;
|
|
46
|
+
scope?: L1TxScope;
|
|
47
|
+
}, deps: {
|
|
48
|
+
telemetry: TelemetryClient;
|
|
49
|
+
logger?: ReturnType<typeof createLogger>;
|
|
50
|
+
dateProvider?: DateProvider;
|
|
51
|
+
scope?: L1TxScope;
|
|
52
|
+
}): Promise<import("@aztec/ethereum").L1TxUtils[]>;
|
|
53
|
+
//# sourceMappingURL=l1_tx_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l1_tx_utils.d.ts","sourceRoot":"","sources":["../../src/factories/l1_tx_utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,wBAAwB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMxG,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AA+B7D;;GAEG;AACH,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,wBAAwB,EAAE,EACnC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,EACtG,IAAI,EAAE;IACJ,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,kFAOF;AAED;;GAEG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,SAAS,EAAE,EACpB,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,EACtG,IAAI,EAAE;IACJ,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,kFAOF;AAED;;GAEG;AACH,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,wBAAwB,EAAE,EACnC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,EACtG,IAAI,EAAE;IACJ,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,kDAKF;AAED;;GAEG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,SAAS,EAAE,EACpB,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,EACtG,IAAI,EAAE;IACJ,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,kDAKF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createL1TxUtilsFromEthSigner as createL1TxUtilsFromEthSignerBase, createL1TxUtilsFromViemWallet as createL1TxUtilsFromViemWalletBase } from '@aztec/ethereum';
|
|
2
|
+
import { createL1TxUtilsWithBlobsFromEthSigner as createL1TxUtilsWithBlobsFromEthSignerBase, createL1TxUtilsWithBlobsFromViemWallet as createL1TxUtilsWithBlobsFromViemWalletBase } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
3
|
+
import { omit } from '@aztec/foundation/collection';
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
+
import { L1TxMetrics } from '../metrics/l1_tx_metrics.js';
|
|
7
|
+
import { L1TxStore } from '../stores/l1_tx_store.js';
|
|
8
|
+
const L1_TX_STORE_NAME = 'l1-tx-utils';
|
|
9
|
+
/**
|
|
10
|
+
* Creates shared dependencies (logger, store, metrics) for L1TxUtils instances.
|
|
11
|
+
*/ async function createSharedDeps(config, deps) {
|
|
12
|
+
const logger = deps.logger ?? createLogger('l1-tx-utils');
|
|
13
|
+
// Note that we do NOT bind them to the rollup address, since we still need to
|
|
14
|
+
// monitor and cancel txs for previous rollups to free up our nonces.
|
|
15
|
+
const noRollupConfig = omit(config, 'l1Contracts');
|
|
16
|
+
const kvStore = await createStore(L1_TX_STORE_NAME, L1TxStore.SCHEMA_VERSION, noRollupConfig, logger);
|
|
17
|
+
const store = new L1TxStore(kvStore, logger);
|
|
18
|
+
const meter = deps.telemetry.getMeter('L1TxUtils');
|
|
19
|
+
const metrics = new L1TxMetrics(meter, config.scope ?? 'other', logger);
|
|
20
|
+
return {
|
|
21
|
+
logger,
|
|
22
|
+
store,
|
|
23
|
+
metrics,
|
|
24
|
+
dateProvider: deps.dateProvider
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates L1TxUtils with blobs from multiple Viem wallets, sharing store and metrics.
|
|
29
|
+
*/ export async function createL1TxUtilsWithBlobsFromViemWallet(clients, config, deps) {
|
|
30
|
+
const sharedDeps = await createSharedDeps(config, deps);
|
|
31
|
+
return clients.map((client)=>createL1TxUtilsWithBlobsFromViemWalletBase(client, sharedDeps, config, config.debugMaxGasLimit));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates L1TxUtils with blobs from multiple EthSigners, sharing store and metrics.
|
|
35
|
+
*/ export async function createL1TxUtilsWithBlobsFromEthSigner(client, signers, config, deps) {
|
|
36
|
+
const sharedDeps = await createSharedDeps(config, deps);
|
|
37
|
+
return signers.map((signer)=>createL1TxUtilsWithBlobsFromEthSignerBase(client, signer, sharedDeps, config, config.debugMaxGasLimit));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates L1TxUtils (without blobs) from multiple Viem wallets, sharing store and metrics.
|
|
41
|
+
*/ export async function createL1TxUtilsFromViemWalletWithStore(clients, config, deps) {
|
|
42
|
+
const sharedDeps = await createSharedDeps(config, deps);
|
|
43
|
+
return clients.map((client)=>createL1TxUtilsFromViemWalletBase(client, sharedDeps, config));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates L1TxUtils (without blobs) from multiple EthSigners, sharing store and metrics.
|
|
47
|
+
*/ export async function createL1TxUtilsFromEthSignerWithStore(client, signers, config, deps) {
|
|
48
|
+
const sharedDeps = await createSharedDeps(config, deps);
|
|
49
|
+
return signers.map((signer)=>createL1TxUtilsFromEthSignerBase(client, signer, sharedDeps, config));
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './l1_tx_metrics.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IL1TxMetrics, L1TxState } from '@aztec/ethereum';
|
|
2
|
+
import { type Meter } from '@aztec/telemetry-client';
|
|
3
|
+
export type L1TxScope = 'sequencer' | 'prover' | 'other';
|
|
4
|
+
/**
|
|
5
|
+
* Metrics for L1 transaction utils tracking tx lifecycle and gas costs.
|
|
6
|
+
*/
|
|
7
|
+
export declare class L1TxMetrics implements IL1TxMetrics {
|
|
8
|
+
private meter;
|
|
9
|
+
private scope;
|
|
10
|
+
private logger;
|
|
11
|
+
private txMinedDuration;
|
|
12
|
+
private txAttemptsUntilMined;
|
|
13
|
+
private txMinedCount;
|
|
14
|
+
private txRevertedCount;
|
|
15
|
+
private txCancelledCount;
|
|
16
|
+
private txNotMinedCount;
|
|
17
|
+
private maxPriorityFeeHistogram;
|
|
18
|
+
private maxFeeHistogram;
|
|
19
|
+
private blobFeeHistogram;
|
|
20
|
+
constructor(meter: Meter, scope?: L1TxScope, logger?: import("@aztec/foundation/log").Logger);
|
|
21
|
+
/**
|
|
22
|
+
* Records metrics when a transaction is mined.
|
|
23
|
+
* @param state - The L1 transaction state
|
|
24
|
+
* @param l1Timestamp - The current L1 timestamp
|
|
25
|
+
*/
|
|
26
|
+
recordMinedTx(state: L1TxState, l1Timestamp: Date): void;
|
|
27
|
+
recordDroppedTx(state: L1TxState): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=l1_tx_metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l1_tx_metrics.d.ts","sourceRoot":"","sources":["../../src/metrics/l1_tx_metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAGL,KAAK,KAAK,EAIX,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzD;;GAEG;AACH,qBAAa,WAAY,YAAW,YAAY;IAmB5C,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IAnBhB,OAAO,CAAC,eAAe,CAAY;IAGnC,OAAO,CAAC,oBAAoB,CAAY;IAGxC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,eAAe,CAAgB;IAGvC,OAAO,CAAC,uBAAuB,CAAY;IAC3C,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,gBAAgB,CAAY;gBAG1B,KAAK,EAAE,KAAK,EACZ,KAAK,GAAE,SAAmB,EAC1B,MAAM,yCAAsC;IAqDtD;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,GAAG,IAAI;IAsDxD,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;CAkB/C"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { TxUtilsState } from '@aztec/ethereum';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
4
|
+
/**
|
|
5
|
+
* Metrics for L1 transaction utils tracking tx lifecycle and gas costs.
|
|
6
|
+
*/ export class L1TxMetrics {
|
|
7
|
+
meter;
|
|
8
|
+
scope;
|
|
9
|
+
logger;
|
|
10
|
+
// Time until tx is mined
|
|
11
|
+
txMinedDuration;
|
|
12
|
+
// Number of attempts until mined
|
|
13
|
+
txAttemptsUntilMined;
|
|
14
|
+
// Counters for end states
|
|
15
|
+
txMinedCount;
|
|
16
|
+
txRevertedCount;
|
|
17
|
+
txCancelledCount;
|
|
18
|
+
txNotMinedCount;
|
|
19
|
+
// Gas price histograms (at end state, in wei)
|
|
20
|
+
maxPriorityFeeHistogram;
|
|
21
|
+
maxFeeHistogram;
|
|
22
|
+
blobFeeHistogram;
|
|
23
|
+
constructor(meter, scope = 'other', logger = createLogger('l1-tx-utils:metrics')){
|
|
24
|
+
this.meter = meter;
|
|
25
|
+
this.scope = scope;
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
this.txMinedDuration = this.meter.createHistogram(Metrics.L1_TX_MINED_DURATION, {
|
|
28
|
+
description: 'Time from initial tx send until mined',
|
|
29
|
+
unit: 's',
|
|
30
|
+
valueType: ValueType.INT
|
|
31
|
+
});
|
|
32
|
+
this.txAttemptsUntilMined = this.meter.createHistogram(Metrics.L1_TX_ATTEMPTS_UNTIL_MINED, {
|
|
33
|
+
description: 'Number of tx attempts (including speed-ups) until mined',
|
|
34
|
+
unit: 'attempts',
|
|
35
|
+
valueType: ValueType.INT
|
|
36
|
+
});
|
|
37
|
+
this.txMinedCount = this.meter.createUpDownCounter(Metrics.L1_TX_MINED_COUNT, {
|
|
38
|
+
description: 'Count of transactions successfully mined',
|
|
39
|
+
valueType: ValueType.INT
|
|
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
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Records metrics when a transaction is mined.
|
|
71
|
+
* @param state - The L1 transaction state
|
|
72
|
+
* @param l1Timestamp - The current L1 timestamp
|
|
73
|
+
*/ recordMinedTx(state, l1Timestamp) {
|
|
74
|
+
if (state.status !== TxUtilsState.MINED) {
|
|
75
|
+
this.logger.warn(`Attempted to record mined tx metrics for a tx not in MINED state (state: ${TxUtilsState[state.status]})`, {
|
|
76
|
+
scope: this.scope,
|
|
77
|
+
nonce: state.nonce
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const attributes = {
|
|
82
|
+
[Attributes.L1_TX_SCOPE]: this.scope
|
|
83
|
+
};
|
|
84
|
+
const isCancelTx = state.cancelTxHashes.length > 0;
|
|
85
|
+
const isReverted = state.receipt?.status === 'reverted';
|
|
86
|
+
if (isCancelTx) {
|
|
87
|
+
this.txCancelledCount.add(1, attributes);
|
|
88
|
+
} else if (isReverted) {
|
|
89
|
+
this.txRevertedCount.add(1, attributes);
|
|
90
|
+
} else {
|
|
91
|
+
this.txMinedCount.add(1, attributes);
|
|
92
|
+
}
|
|
93
|
+
// Record time to mine using provided L1 timestamp
|
|
94
|
+
const duration = Math.floor((l1Timestamp.getTime() - state.sentAtL1Ts.getTime()) / 1000);
|
|
95
|
+
this.txMinedDuration.record(duration, attributes);
|
|
96
|
+
// Record number of attempts until mined
|
|
97
|
+
const attempts = isCancelTx ? state.cancelTxHashes.length : state.txHashes.length;
|
|
98
|
+
this.txAttemptsUntilMined.record(attempts, attributes);
|
|
99
|
+
// Record gas prices at end state (in wei as integers)
|
|
100
|
+
const maxPriorityFeeWei = Number(state.gasPrice.maxPriorityFeePerGas);
|
|
101
|
+
const maxFeeWei = Number(state.gasPrice.maxFeePerGas);
|
|
102
|
+
const blobFeeWei = state.gasPrice.maxFeePerBlobGas ? Number(state.gasPrice.maxFeePerBlobGas) : undefined;
|
|
103
|
+
this.maxPriorityFeeHistogram.record(maxPriorityFeeWei, attributes);
|
|
104
|
+
this.maxFeeHistogram.record(maxFeeWei, attributes);
|
|
105
|
+
// Record blob fee if present (in wei as integer)
|
|
106
|
+
if (blobFeeWei !== undefined) {
|
|
107
|
+
this.blobFeeHistogram.record(blobFeeWei, attributes);
|
|
108
|
+
}
|
|
109
|
+
this.logger.debug(`Recorded tx end state metrics`, {
|
|
110
|
+
status: TxUtilsState[state.status],
|
|
111
|
+
nonce: state.nonce,
|
|
112
|
+
isCancelTx,
|
|
113
|
+
isReverted,
|
|
114
|
+
scope: this.scope,
|
|
115
|
+
maxPriorityFeeWei,
|
|
116
|
+
maxFeeWei,
|
|
117
|
+
blobFeeWei
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
recordDroppedTx(state) {
|
|
121
|
+
if (state.status !== TxUtilsState.NOT_MINED) {
|
|
122
|
+
this.logger.warn(`Attempted to record dropped tx metrics for a tx not in NOT_MINED state (state: ${TxUtilsState[state.status]})`, {
|
|
123
|
+
scope: this.scope,
|
|
124
|
+
nonce: state.nonce
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const attributes = {
|
|
129
|
+
[Attributes.L1_TX_SCOPE]: this.scope
|
|
130
|
+
};
|
|
131
|
+
this.txNotMinedCount.add(1, attributes);
|
|
132
|
+
this.logger.debug(`Recorded tx dropped metrics`, {
|
|
133
|
+
status: TxUtilsState[state.status],
|
|
134
|
+
nonce: state.nonce,
|
|
135
|
+
scope: this.scope
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './l1_tx_store.js';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { IL1TxStore, L1BlobInputs, L1TxState } from '@aztec/ethereum';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
+
/**
|
|
5
|
+
* Store for persisting L1 transaction states across all L1TxUtils instances.
|
|
6
|
+
* Each state is stored individually with a unique ID, and blobs are stored separately.
|
|
7
|
+
* @remarks This class lives in this package instead of `ethereum` because it depends on `kv-store`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class L1TxStore implements IL1TxStore {
|
|
10
|
+
private readonly store;
|
|
11
|
+
private readonly log;
|
|
12
|
+
static readonly SCHEMA_VERSION = 2;
|
|
13
|
+
private readonly states;
|
|
14
|
+
private readonly blobs;
|
|
15
|
+
private readonly stateIdCounter;
|
|
16
|
+
constructor(store: AztecAsyncKVStore, log?: Logger);
|
|
17
|
+
/**
|
|
18
|
+
* Gets the next available state ID for an account.
|
|
19
|
+
*/
|
|
20
|
+
consumeNextStateId(account: string): Promise<number>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a storage key for state/blob data.
|
|
23
|
+
*/
|
|
24
|
+
private makeKey;
|
|
25
|
+
/**
|
|
26
|
+
* Saves a single transaction state for a specific account.
|
|
27
|
+
* Blobs are not stored here, use saveBlobs instead.
|
|
28
|
+
* @param account - The sender account address
|
|
29
|
+
* @param state - Transaction state to save
|
|
30
|
+
*/
|
|
31
|
+
saveState(account: string, state: L1TxState): Promise<L1TxState>;
|
|
32
|
+
/**
|
|
33
|
+
* Saves blobs for a given state.
|
|
34
|
+
* @param account - The sender account address
|
|
35
|
+
* @param stateId - The state ID
|
|
36
|
+
* @param blobInputs - Blob inputs to save
|
|
37
|
+
*/
|
|
38
|
+
saveBlobs(account: string, stateId: number, blobInputs: L1BlobInputs | undefined): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Loads all transaction states for a specific account.
|
|
41
|
+
* @param account - The sender account address
|
|
42
|
+
* @returns Array of transaction states with their IDs
|
|
43
|
+
*/
|
|
44
|
+
loadStates(account: string): Promise<L1TxState[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Loads a single state by ID.
|
|
47
|
+
* @param account - The sender account address
|
|
48
|
+
* @param stateId - The state ID
|
|
49
|
+
* @returns The transaction state or undefined if not found
|
|
50
|
+
*/
|
|
51
|
+
loadState(account: string, stateId: number): Promise<L1TxState | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Deletes a specific state and its associated blobs.
|
|
54
|
+
* @param account - The sender account address
|
|
55
|
+
* @param stateId - The state ID to delete
|
|
56
|
+
*/
|
|
57
|
+
deleteState(account: string, stateId: number): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Clears all transaction states for a specific account.
|
|
60
|
+
* @param account - The sender account address
|
|
61
|
+
*/
|
|
62
|
+
clearStates(account: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Gets all accounts that have stored states.
|
|
65
|
+
* @returns Array of account addresses
|
|
66
|
+
*/
|
|
67
|
+
getAllAccounts(): Promise<string[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Closes the store.
|
|
70
|
+
*/
|
|
71
|
+
close(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Serializes an L1TxState for storage.
|
|
74
|
+
*/
|
|
75
|
+
private serializeState;
|
|
76
|
+
/**
|
|
77
|
+
* Deserializes a stored state back to L1TxState.
|
|
78
|
+
*/
|
|
79
|
+
private deserializeState;
|
|
80
|
+
/**
|
|
81
|
+
* Serializes blob inputs for separate storage.
|
|
82
|
+
*/
|
|
83
|
+
private serializeBlobInputs;
|
|
84
|
+
/**
|
|
85
|
+
* Deserializes blob inputs from storage, combining blob data with metadata.
|
|
86
|
+
*/
|
|
87
|
+
private deserializeBlobInputs;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=l1_tx_store.d.ts.map
|
|
@@ -0,0 +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,iBAAiB,CAAC;AAEvF,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;IARtB,gBAAuB,cAAc,KAAK;IAE1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;IACtD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgC;gBAG5C,KAAK,EAAE,iBAAiB,EACxB,GAAG,GAAE,MAA0C;IAOlE;;OAEG;IACI,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAS3D;;OAEG;IACH,OAAO,CAAC,OAAO;IAIf;;;;;OAKG;IACU,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAU7E;;;;;OAKG;IACU,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7G;;;;OAIG;IACU,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAsC9D;;;;;OAKG;IACU,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IA4BxF;;;;OAIG;IACU,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzE;;;OAGG;IACU,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxD;;;OAGG;IACU,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAWhD;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnC;;OAEG;IACH,OAAO,CAAC,cAAc;IAkCtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2CxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAY9B"}
|