@aztec/node-lib 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05
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 +7 -8
- 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 +61 -17
- 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 +34 -24
- package/src/actions/build-snapshot-metadata.ts +2 -2
- package/src/actions/snapshot-sync.ts +17 -12
- package/src/actions/upload-snapshot.ts +1 -1
- package/src/config/index.ts +29 -15
- package/src/factories/l1_tx_utils.ts +71 -37
- package/src/metrics/l1_tx_metrics.ts +27 -56
- package/src/stores/l1_tx_store.ts +21 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IL1TxMetrics, L1TxState } from '@aztec/ethereum';
|
|
2
|
-
import { TxUtilsState } from '@aztec/ethereum';
|
|
1
|
+
import type { IL1TxMetrics, L1TxState } from '@aztec/ethereum/l1-tx-utils';
|
|
2
|
+
import { TxUtilsState } from '@aztec/ethereum/l1-tx-utils';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import {
|
|
5
5
|
Attributes,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type Meter,
|
|
8
8
|
Metrics,
|
|
9
9
|
type UpDownCounter,
|
|
10
|
-
|
|
10
|
+
createUpDownCounterWithDefault,
|
|
11
11
|
} from '@aztec/telemetry-client';
|
|
12
12
|
|
|
13
13
|
export type L1TxScope = 'sequencer' | 'prover' | 'other';
|
|
@@ -38,55 +38,24 @@ export class L1TxMetrics implements IL1TxMetrics {
|
|
|
38
38
|
private scope: L1TxScope = 'other',
|
|
39
39
|
private logger = createLogger('l1-tx-utils:metrics'),
|
|
40
40
|
) {
|
|
41
|
-
this.txMinedDuration = this.meter.createHistogram(Metrics.L1_TX_MINED_DURATION
|
|
42
|
-
description: 'Time from initial tx send until mined',
|
|
43
|
-
unit: 's',
|
|
44
|
-
valueType: ValueType.INT,
|
|
45
|
-
});
|
|
41
|
+
this.txMinedDuration = this.meter.createHistogram(Metrics.L1_TX_MINED_DURATION);
|
|
46
42
|
|
|
47
|
-
this.txAttemptsUntilMined = this.meter.createHistogram(Metrics.L1_TX_ATTEMPTS_UNTIL_MINED
|
|
48
|
-
description: 'Number of tx attempts (including speed-ups) until mined',
|
|
49
|
-
unit: 'attempts',
|
|
50
|
-
valueType: ValueType.INT,
|
|
51
|
-
});
|
|
43
|
+
this.txAttemptsUntilMined = this.meter.createHistogram(Metrics.L1_TX_ATTEMPTS_UNTIL_MINED);
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
valueType: ValueType.INT,
|
|
56
|
-
});
|
|
45
|
+
const scopeAttributes = [{ [Attributes.L1_TX_SCOPE]: this.scope }];
|
|
46
|
+
this.txMinedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_MINED_COUNT, scopeAttributes);
|
|
57
47
|
|
|
58
|
-
this.txRevertedCount = this.meter
|
|
59
|
-
description: 'Count of transactions that reverted',
|
|
60
|
-
valueType: ValueType.INT,
|
|
61
|
-
});
|
|
48
|
+
this.txRevertedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_REVERTED_COUNT, scopeAttributes);
|
|
62
49
|
|
|
63
|
-
this.txCancelledCount = this.meter
|
|
64
|
-
description: 'Count of transactions cancelled',
|
|
65
|
-
valueType: ValueType.INT,
|
|
66
|
-
});
|
|
50
|
+
this.txCancelledCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_CANCELLED_COUNT, scopeAttributes);
|
|
67
51
|
|
|
68
|
-
this.txNotMinedCount = this.meter
|
|
69
|
-
description: 'Count of transactions not mined (timed out)',
|
|
70
|
-
valueType: ValueType.INT,
|
|
71
|
-
});
|
|
52
|
+
this.txNotMinedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_NOT_MINED_COUNT, scopeAttributes);
|
|
72
53
|
|
|
73
|
-
this.maxPriorityFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_PRIORITY_FEE
|
|
74
|
-
description: 'Max priority fee per gas at tx end state (in wei)',
|
|
75
|
-
unit: 'wei',
|
|
76
|
-
valueType: ValueType.INT,
|
|
77
|
-
});
|
|
54
|
+
this.maxPriorityFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_PRIORITY_FEE);
|
|
78
55
|
|
|
79
|
-
this.maxFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_FEE
|
|
80
|
-
description: 'Max fee per gas at tx end state (in wei)',
|
|
81
|
-
unit: 'wei',
|
|
82
|
-
valueType: ValueType.INT,
|
|
83
|
-
});
|
|
56
|
+
this.maxFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_FEE);
|
|
84
57
|
|
|
85
|
-
this.blobFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_BLOB_FEE
|
|
86
|
-
description: 'Max fee per blob gas at tx end state (in wei)',
|
|
87
|
-
unit: 'wei',
|
|
88
|
-
valueType: ValueType.INT,
|
|
89
|
-
});
|
|
58
|
+
this.blobFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_BLOB_FEE);
|
|
90
59
|
}
|
|
91
60
|
|
|
92
61
|
/**
|
|
@@ -123,17 +92,19 @@ export class L1TxMetrics implements IL1TxMetrics {
|
|
|
123
92
|
const attempts = isCancelTx ? state.cancelTxHashes.length : state.txHashes.length;
|
|
124
93
|
this.txAttemptsUntilMined.record(attempts, attributes);
|
|
125
94
|
|
|
126
|
-
// Record gas prices at end state
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
const
|
|
95
|
+
// Record gas prices at end state, converted from wei to gwei to match metric unit definitions
|
|
96
|
+
const weiToGwei = 1e9;
|
|
97
|
+
const maxPriorityFeeGwei = Number(state.gasPrice.maxPriorityFeePerGas) / weiToGwei;
|
|
98
|
+
const maxFeeGwei = Number(state.gasPrice.maxFeePerGas) / weiToGwei;
|
|
99
|
+
const blobFeeGwei = state.gasPrice.maxFeePerBlobGas
|
|
100
|
+
? Number(state.gasPrice.maxFeePerBlobGas) / weiToGwei
|
|
101
|
+
: undefined;
|
|
130
102
|
|
|
131
|
-
this.maxPriorityFeeHistogram.record(
|
|
132
|
-
this.maxFeeHistogram.record(
|
|
103
|
+
this.maxPriorityFeeHistogram.record(maxPriorityFeeGwei, attributes);
|
|
104
|
+
this.maxFeeHistogram.record(maxFeeGwei, attributes);
|
|
133
105
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.blobFeeHistogram.record(blobFeeWei, attributes);
|
|
106
|
+
if (blobFeeGwei !== undefined) {
|
|
107
|
+
this.blobFeeHistogram.record(blobFeeGwei, attributes);
|
|
137
108
|
}
|
|
138
109
|
|
|
139
110
|
this.logger.debug(`Recorded tx end state metrics`, {
|
|
@@ -142,9 +113,9 @@ export class L1TxMetrics implements IL1TxMetrics {
|
|
|
142
113
|
isCancelTx,
|
|
143
114
|
isReverted,
|
|
144
115
|
scope: this.scope,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
116
|
+
maxPriorityFeeGwei,
|
|
117
|
+
maxFeeGwei,
|
|
118
|
+
blobFeeGwei,
|
|
148
119
|
});
|
|
149
120
|
}
|
|
150
121
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IL1TxStore, L1BlobInputs, L1TxConfig, L1TxState } from '@aztec/ethereum';
|
|
1
|
+
import type { IL1TxStore, L1BlobInputs, L1TxConfig, L1TxState } from '@aztec/ethereum/l1-tx-utils';
|
|
2
2
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -231,11 +231,18 @@ export class L1TxStore implements IL1TxStore {
|
|
|
231
231
|
* @param account - The sender account address
|
|
232
232
|
* @param stateId - The state ID to delete
|
|
233
233
|
*/
|
|
234
|
-
public async deleteState(account: string,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
public async deleteState(account: string, ...stateIds: number[]): Promise<void> {
|
|
235
|
+
if (stateIds.length === 0) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
await this.store.transactionAsync(async () => {
|
|
240
|
+
for (const stateId of stateIds) {
|
|
241
|
+
const key = this.makeKey(account, stateId);
|
|
242
|
+
await this.states.delete(key);
|
|
243
|
+
await this.blobs.delete(key);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
239
246
|
}
|
|
240
247
|
|
|
241
248
|
/**
|
|
@@ -243,14 +250,16 @@ export class L1TxStore implements IL1TxStore {
|
|
|
243
250
|
* @param account - The sender account address
|
|
244
251
|
*/
|
|
245
252
|
public async clearStates(account: string): Promise<void> {
|
|
246
|
-
|
|
253
|
+
await this.store.transactionAsync(async () => {
|
|
254
|
+
const states = await this.loadStates(account);
|
|
247
255
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
256
|
+
for (const state of states) {
|
|
257
|
+
await this.deleteState(account, state.id);
|
|
258
|
+
}
|
|
251
259
|
|
|
252
|
-
|
|
253
|
-
|
|
260
|
+
await this.stateIdCounter.delete(account);
|
|
261
|
+
this.log.info(`Cleared all tx states for account ${account}`);
|
|
262
|
+
});
|
|
254
263
|
}
|
|
255
264
|
|
|
256
265
|
/**
|