@aztec/sequencer-client 0.82.2-alpha-testnet.4 → 0.82.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.
@@ -11,6 +11,7 @@ export declare class SequencerPublisherMetrics {
11
11
  private txCalldataGas;
12
12
  private txBlobDataGasUsed;
13
13
  private txBlobDataGasCost;
14
+ private txTotalFee;
14
15
  private readonly blobCountHistogram;
15
16
  private readonly blobInclusionBlocksHistogram;
16
17
  private readonly blobTxSuccessCounter;
@@ -1 +1 @@
1
- {"version":3,"file":"sequencer-publisher-metrics.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher-metrics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC;AAEjC,qBAAa,yBAAyB;IAqBlC,OAAO,CAAC,MAAM;IApBhB,OAAO,CAAC,QAAQ,CAAY;IAE5B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,iBAAiB,CAAY;IAErC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAY;IAC/C,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAY;IACzD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAgB;IACrD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAgB;IAErD,OAAO,CAAC,aAAa,CAAQ;gBAG3B,MAAM,EAAE,eAAe,EACvB,IAAI,SAAuB,EACnB,MAAM,mCAA8C;IA6E9D,cAAc,CAAC,MAAM,EAAE,QAAQ;IAW/B,o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CAuCjB"}
@@ -11,6 +11,7 @@ export class SequencerPublisherMetrics {
11
11
  txCalldataGas;
12
12
  txBlobDataGasUsed;
13
13
  txBlobDataGasCost;
14
+ txTotalFee;
14
15
  blobCountHistogram;
15
16
  blobInclusionBlocksHistogram;
16
17
  blobTxSuccessCounter;
@@ -73,6 +74,32 @@ export class SequencerPublisherMetrics {
73
74
  this.blobTxFailureCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_FAILURE, {
74
75
  description: 'Number of failed L1 transactions with blobs'
75
76
  });
77
+ this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, {
78
+ description: 'How much L1 tx costs',
79
+ unit: 'eth',
80
+ valueType: ValueType.DOUBLE,
81
+ advice: {
82
+ explicitBucketBoundaries: [
83
+ 0.001,
84
+ 0.002,
85
+ 0.004,
86
+ 0.008,
87
+ 0.01,
88
+ 0.02,
89
+ 0.04,
90
+ 0.08,
91
+ 0.1,
92
+ 0.2,
93
+ 0.4,
94
+ 0.8,
95
+ 1,
96
+ 1.2,
97
+ 1.4,
98
+ 1.8,
99
+ 2
100
+ ]
101
+ }
102
+ });
76
103
  this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
77
104
  unit: 'eth',
78
105
  description: 'The balance of the sender address',
@@ -125,5 +152,13 @@ export class SequencerPublisherMetrics {
125
152
  } catch (e) {
126
153
  // ignore
127
154
  }
155
+ const executionFee = stats.gasUsed * stats.gasPrice;
156
+ const blobFee = stats.blobGasUsed * stats.blobDataGas;
157
+ const totalFee = executionFee + blobFee;
158
+ try {
159
+ this.txTotalFee.record(parseFloat(formatEther(totalFee)));
160
+ } catch (e) {
161
+ // ignore
162
+ }
128
163
  }
129
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,cAAM,cAAe,SAAQ,SAAS;IACpB,sBAAsB,EAAG,sBAAsB,CAAC;IAChD,SAAS,EAAG,kBAAkB,CAAC;IAC/B,SAAS,EAAG,kBAAkB,CAAC;CAChD;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAE3C,cAAM,oBAAqB,SAAQ,eAAe;IAChC,SAAS,EAAG,aAAa,CAAC;CAC3C;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,cAAM,cAAe,SAAQ,SAAS;IACrB,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,SAAS,EAAE,kBAAkB,CAAC;IAC9B,SAAS,EAAE,kBAAkB,CAAC;CAC9C;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAE3C,cAAM,oBAAqB,SAAQ,eAAe;IACjC,SAAS,EAAE,aAAa,CAAC;CACzC;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC"}
@@ -1,10 +1,6 @@
1
1
  import { SequencerClient } from '../client/sequencer-client.js';
2
2
  import { Sequencer } from '../sequencer/sequencer.js';
3
3
  class TestSequencer_ extends Sequencer {
4
- publicProcessorFactory;
5
- timetable;
6
- publisher;
7
4
  }
8
5
  class TestSequencerClient_ extends SequencerClient {
9
- sequencer;
10
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,EACE,WAAW,EACX,SAAS,EACT,cAAc,EACd,OAAO,EACP,kBAAkB,GACnB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,GACA,WAAW,CAAC,EAAE,CAAC,CAkBjB;AAED,wBAAgB,gCAAgC,CAC9C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAE,GAC/B;IACD,mBAAmB,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IACrC,oBAAoB,EAAE,WAAW,CAA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import { MerkleTreeId } from '@aztec/aztec.js';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
3
  import { AggregateTxValidator, BlockHeaderTxValidator, DataTxValidator, DoubleSpendTxValidator, MetadataTxValidator, TxProofValidator } from '@aztec/p2p';
3
4
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
- import { readPublicState } from '@aztec/simulator/server';
5
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
5
6
  import { ArchiveCache } from './archive_cache.js';
6
7
  import { GasTxValidator } from './gas_validator.js';
7
8
  import { NullifierCache } from './nullifier_cache.js';
@@ -37,8 +38,14 @@ class DatabasePublicStateSource {
37
38
  constructor(db){
38
39
  this.db = db;
39
40
  }
40
- storageRead(contractAddress, slot) {
41
- return readPublicState(this.db, contractAddress, slot);
41
+ async storageRead(contractAddress, slot) {
42
+ const leafSlot = (await computePublicDataTreeLeafSlot(contractAddress, slot)).toBigInt();
43
+ const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
44
+ if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
45
+ return Fr.ZERO;
46
+ }
47
+ const preimage = await this.db.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
48
+ return preimage.value;
42
49
  }
43
50
  }
44
51
  function preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.82.2-alpha-testnet.4",
3
+ "version": "0.82.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -28,36 +28,36 @@
28
28
  "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
29
29
  },
30
30
  "dependencies": {
31
- "@aztec/aztec.js": "0.82.2-alpha-testnet.4",
32
- "@aztec/bb-prover": "0.82.2-alpha-testnet.4",
33
- "@aztec/blob-lib": "0.82.2-alpha-testnet.4",
34
- "@aztec/blob-sink": "0.82.2-alpha-testnet.4",
35
- "@aztec/constants": "0.82.2-alpha-testnet.4",
36
- "@aztec/epoch-cache": "0.82.2-alpha-testnet.4",
37
- "@aztec/ethereum": "0.82.2-alpha-testnet.4",
38
- "@aztec/foundation": "0.82.2-alpha-testnet.4",
39
- "@aztec/l1-artifacts": "0.82.2-alpha-testnet.4",
40
- "@aztec/merkle-tree": "0.82.2-alpha-testnet.4",
41
- "@aztec/noir-acvm_js": "0.82.2-alpha-testnet.4",
42
- "@aztec/noir-contracts.js": "0.82.2-alpha-testnet.4",
43
- "@aztec/noir-protocol-circuits-types": "0.82.2-alpha-testnet.4",
44
- "@aztec/noir-types": "0.82.2-alpha-testnet.4",
45
- "@aztec/p2p": "0.82.2-alpha-testnet.4",
46
- "@aztec/protocol-contracts": "0.82.2-alpha-testnet.4",
47
- "@aztec/prover-client": "0.82.2-alpha-testnet.4",
48
- "@aztec/simulator": "0.82.2-alpha-testnet.4",
49
- "@aztec/stdlib": "0.82.2-alpha-testnet.4",
50
- "@aztec/telemetry-client": "0.82.2-alpha-testnet.4",
51
- "@aztec/validator-client": "0.82.2-alpha-testnet.4",
52
- "@aztec/world-state": "0.82.2-alpha-testnet.4",
31
+ "@aztec/aztec.js": "0.82.3",
32
+ "@aztec/bb-prover": "0.82.3",
33
+ "@aztec/blob-lib": "0.82.3",
34
+ "@aztec/blob-sink": "0.82.3",
35
+ "@aztec/constants": "0.82.3",
36
+ "@aztec/epoch-cache": "0.82.3",
37
+ "@aztec/ethereum": "0.82.3",
38
+ "@aztec/foundation": "0.82.3",
39
+ "@aztec/l1-artifacts": "0.82.3",
40
+ "@aztec/merkle-tree": "0.82.3",
41
+ "@aztec/noir-acvm_js": "0.82.3",
42
+ "@aztec/noir-contracts.js": "0.82.3",
43
+ "@aztec/noir-protocol-circuits-types": "0.82.3",
44
+ "@aztec/noir-types": "0.82.3",
45
+ "@aztec/p2p": "0.82.3",
46
+ "@aztec/protocol-contracts": "0.82.3",
47
+ "@aztec/prover-client": "0.82.3",
48
+ "@aztec/simulator": "0.82.3",
49
+ "@aztec/stdlib": "0.82.3",
50
+ "@aztec/telemetry-client": "0.82.3",
51
+ "@aztec/validator-client": "0.82.3",
52
+ "@aztec/world-state": "0.82.3",
53
53
  "lodash.chunk": "^4.2.0",
54
54
  "lodash.pick": "^4.4.0",
55
55
  "tslib": "^2.4.0",
56
56
  "viem": "2.23.7"
57
57
  },
58
58
  "devDependencies": {
59
- "@aztec/archiver": "0.82.2-alpha-testnet.4",
60
- "@aztec/kv-store": "0.82.2-alpha-testnet.4",
59
+ "@aztec/archiver": "0.82.3",
60
+ "@aztec/kv-store": "0.82.3",
61
61
  "@jest/globals": "^29.5.0",
62
62
  "@types/jest": "^29.5.0",
63
63
  "@types/levelup": "^5.1.2",
@@ -24,6 +24,7 @@ export class SequencerPublisherMetrics {
24
24
  private txCalldataGas: Histogram;
25
25
  private txBlobDataGasUsed: Histogram;
26
26
  private txBlobDataGasCost: Histogram;
27
+ private txTotalFee: Histogram;
27
28
 
28
29
  private readonly blobCountHistogram: Histogram;
29
30
  private readonly blobInclusionBlocksHistogram: Histogram;
@@ -105,6 +106,17 @@ export class SequencerPublisherMetrics {
105
106
  description: 'Number of failed L1 transactions with blobs',
106
107
  });
107
108
 
109
+ this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, {
110
+ description: 'How much L1 tx costs',
111
+ unit: 'eth',
112
+ valueType: ValueType.DOUBLE,
113
+ advice: {
114
+ explicitBucketBoundaries: [
115
+ 0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2,
116
+ ],
117
+ },
118
+ });
119
+
108
120
  this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
109
121
  unit: 'eth',
110
122
  description: 'The balance of the sender address',
@@ -172,5 +184,15 @@ export class SequencerPublisherMetrics {
172
184
  } catch (e) {
173
185
  // ignore
174
186
  }
187
+
188
+ const executionFee = stats.gasUsed * stats.gasPrice;
189
+ const blobFee = stats.blobGasUsed * stats.blobDataGas;
190
+ const totalFee = executionFee + blobFee;
191
+
192
+ try {
193
+ this.txTotalFee.record(parseFloat(formatEther(totalFee)));
194
+ } catch (e) {
195
+ // ignore
196
+ }
175
197
  }
176
198
  }
package/src/test/index.ts CHANGED
@@ -6,15 +6,15 @@ import { Sequencer } from '../sequencer/sequencer.js';
6
6
  import type { SequencerTimetable } from '../sequencer/timetable.js';
7
7
 
8
8
  class TestSequencer_ extends Sequencer {
9
- public override publicProcessorFactory!: PublicProcessorFactory;
10
- public override timetable!: SequencerTimetable;
11
- public override publisher!: SequencerPublisher;
9
+ public declare publicProcessorFactory: PublicProcessorFactory;
10
+ public declare timetable: SequencerTimetable;
11
+ public declare publisher: SequencerPublisher;
12
12
  }
13
13
 
14
14
  export type TestSequencer = TestSequencer_;
15
15
 
16
16
  class TestSequencerClient_ extends SequencerClient {
17
- public override sequencer!: TestSequencer;
17
+ public declare sequencer: TestSequencer;
18
18
  }
19
19
 
20
20
  export type TestSequencerClient = TestSequencerClient_;
@@ -1,3 +1,4 @@
1
+ import { MerkleTreeId } from '@aztec/aztec.js';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
3
  import {
3
4
  AggregateTxValidator,
@@ -8,15 +9,16 @@ import {
8
9
  TxProofValidator,
9
10
  } from '@aztec/p2p';
10
11
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
11
- import { readPublicState } from '@aztec/simulator/server';
12
12
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
13
13
  import type { ContractDataSource } from '@aztec/stdlib/contract';
14
14
  import type { GasFees } from '@aztec/stdlib/gas';
15
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
15
16
  import type {
16
17
  AllowedElement,
17
18
  ClientProtocolCircuitVerifier,
18
19
  MerkleTreeReadOperations,
19
20
  } from '@aztec/stdlib/interfaces/server';
21
+ import type { PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
20
22
  import { GlobalVariables, type ProcessedTx, type Tx, type TxValidator } from '@aztec/stdlib/tx';
21
23
 
22
24
  import { ArchiveCache } from './archive_cache.js';
@@ -92,8 +94,20 @@ export function createValidatorsForBlockBuilding(
92
94
  class DatabasePublicStateSource implements PublicStateSource {
93
95
  constructor(private db: MerkleTreeReadOperations) {}
94
96
 
95
- storageRead(contractAddress: AztecAddress, slot: Fr): Promise<Fr> {
96
- return readPublicState(this.db, contractAddress, slot);
97
+ async storageRead(contractAddress: AztecAddress, slot: Fr): Promise<Fr> {
98
+ const leafSlot = (await computePublicDataTreeLeafSlot(contractAddress, slot)).toBigInt();
99
+
100
+ const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
101
+ if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
102
+ return Fr.ZERO;
103
+ }
104
+
105
+ const preimage = (await this.db.getLeafPreimage(
106
+ MerkleTreeId.PUBLIC_DATA_TREE,
107
+ lowLeafResult.index,
108
+ )) as PublicDataTreeLeafPreimage;
109
+
110
+ return preimage.value;
97
111
  }
98
112
  }
99
113