@aztec/sequencer-client 0.81.0 → 0.82.0
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/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +10 -29
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +10 -0
- package/dest/sequencer/sequencer.d.ts +1 -0
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +7 -1
- package/package.json +25 -25
- package/src/global_variable_builder/global_builder.ts +11 -15
- package/src/sequencer/metrics.ts +10 -0
- package/src/sequencer/sequencer.ts +14 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/global_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/global_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAIpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,IAAI,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD;;GAEG;AACH,qBAAa,qBAAsB,YAAW,8BAA8B;IAC1E,OAAO,CAAC,GAAG,CAAqD;IAEhE,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,oBAAoB,CAAS;gBAEzB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IAgBpF;;;OAGG;IACU,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAanD;;;;;;;OAOG;IACU,oBAAoB,CAC/B,WAAW,EAAE,EAAE,EACf,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC;CA8B5B"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { createEthereumChain } from '@aztec/ethereum';
|
|
1
|
+
import { RollupContract, createEthereumChain } from '@aztec/ethereum';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
5
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
5
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
7
|
-
import { createPublicClient, fallback,
|
|
6
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
8
7
|
/**
|
|
9
8
|
* Simple global variables builder.
|
|
10
9
|
*/ export class GlobalVariableBuilder {
|
|
@@ -21,11 +20,7 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
21
20
|
transport: fallback(chain.rpcUrls.map((url)=>http(url))),
|
|
22
21
|
pollingInterval: config.viemPollingIntervalMS
|
|
23
22
|
});
|
|
24
|
-
this.rollupContract =
|
|
25
|
-
address: getAddress(l1Contracts.rollupAddress.toString()),
|
|
26
|
-
abi: RollupAbi,
|
|
27
|
-
client: this.publicClient
|
|
28
|
-
});
|
|
23
|
+
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
29
24
|
}
|
|
30
25
|
/**
|
|
31
26
|
* Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
|
|
@@ -34,18 +29,11 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
34
29
|
// Since this might be called in the middle of a slot where a block might have been published,
|
|
35
30
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
36
31
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
37
|
-
const lastBlock = await this.rollupContract.
|
|
38
|
-
|
|
39
|
-
]);
|
|
40
|
-
const earliestTimestamp = await this.rollupContract.read.getTimestampForSlot([
|
|
41
|
-
lastBlock.slotNumber + 1n
|
|
42
|
-
]);
|
|
32
|
+
const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
|
|
33
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
|
|
43
34
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
44
35
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
45
|
-
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
46
|
-
timestamp,
|
|
47
|
-
true
|
|
48
|
-
])));
|
|
36
|
+
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
49
37
|
}
|
|
50
38
|
/**
|
|
51
39
|
* Simple builder of global variables that use the minimum time possible.
|
|
@@ -55,24 +43,17 @@ import { createPublicClient, fallback, getAddress, getContract, http } from 'vie
|
|
|
55
43
|
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
56
44
|
* @returns The global variables for the given block number.
|
|
57
45
|
*/ async buildGlobalVariables(blockNumber, coinbase, feeRecipient, slotNumber) {
|
|
58
|
-
const version = new Fr(await this.rollupContract.
|
|
46
|
+
const version = new Fr(await this.rollupContract.getVersion());
|
|
59
47
|
const chainId = new Fr(this.publicClient.chain.id);
|
|
60
48
|
if (slotNumber === undefined) {
|
|
61
49
|
const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
62
|
-
slotNumber = await this.rollupContract.
|
|
63
|
-
ts
|
|
64
|
-
]);
|
|
50
|
+
slotNumber = await this.rollupContract.getSlotAt(ts);
|
|
65
51
|
}
|
|
66
|
-
const timestamp = await this.rollupContract.
|
|
67
|
-
slotNumber
|
|
68
|
-
]);
|
|
52
|
+
const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
|
|
69
53
|
const slotFr = new Fr(slotNumber);
|
|
70
54
|
const timestampFr = new Fr(timestamp);
|
|
71
55
|
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
72
|
-
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
73
|
-
timestamp,
|
|
74
|
-
true
|
|
75
|
-
])));
|
|
56
|
+
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
76
57
|
const globalVariables = new GlobalVariables(chainId, version, blockNumber, slotFr, timestampFr, coinbase, feeRecipient, gasFees);
|
|
77
58
|
return globalVariables;
|
|
78
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/sequencer/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAA0B,MAAM,YAAY,CAAC;AAEtG,qBAAa,gBAAgB;IAC3B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,uBAAuB,CAAQ;IACvC,OAAO,CAAC,6BAA6B,CAAY;IACjD,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,gBAAgB,C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ValueType.INT
|
|
54
54
|
});
|
|
55
|
+
// Init gauges and counters
|
|
55
56
|
this.setCurrentBlock(0, 0);
|
|
57
|
+
this.blockCounter.add(0, {
|
|
58
|
+
[Attributes.STATUS]: 'cancelled'
|
|
59
|
+
});
|
|
60
|
+
this.blockCounter.add(0, {
|
|
61
|
+
[Attributes.STATUS]: 'failed'
|
|
62
|
+
});
|
|
63
|
+
this.blockCounter.add(0, {
|
|
64
|
+
[Attributes.STATUS]: 'built'
|
|
65
|
+
});
|
|
56
66
|
}
|
|
57
67
|
startCollectingAttestationsTimer() {
|
|
58
68
|
const startTime = Date.now();
|
|
@@ -63,6 +63,7 @@ export declare class Sequencer {
|
|
|
63
63
|
private maxBlockSizeInBytes;
|
|
64
64
|
private maxBlockGas;
|
|
65
65
|
private metrics;
|
|
66
|
+
private l1Metrics;
|
|
66
67
|
private isFlushing;
|
|
67
68
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */
|
|
68
69
|
protected timetable: SequencerTimetable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAW,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,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;KAAE,GAAG,SAAS,CAAC;IAsDxF,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kBAAkB;IAK1B,IAAI,iBAAiB,WAEpB;IAED,IAAI,QAAQ,IAAI,UAAU,CAEzB;IAED,IAAI,YAAY,IAAI,YAAY,CAE/B;CACF"}
|
|
@@ -17,7 +17,7 @@ import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
|
|
|
17
17
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
18
18
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
19
19
|
import { BlockHeader, ContentCommitment, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
20
|
-
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
20
|
+
import { Attributes, L1Metrics, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
21
21
|
import { VoteType } from '../publisher/sequencer-publisher.js';
|
|
22
22
|
import { createValidatorsForBlockBuilding } from '../tx_validator/tx_validator_factory.js';
|
|
23
23
|
import { getDefaultAllowedSetupFunctions } from './allowed.js';
|
|
@@ -62,6 +62,7 @@ export { SequencerState };
|
|
|
62
62
|
maxBlockSizeInBytes;
|
|
63
63
|
maxBlockGas;
|
|
64
64
|
metrics;
|
|
65
|
+
l1Metrics;
|
|
65
66
|
isFlushing;
|
|
66
67
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */ timetable;
|
|
67
68
|
enforceTimeTable;
|
|
@@ -94,6 +95,9 @@ export { SequencerState };
|
|
|
94
95
|
this.isFlushing = false;
|
|
95
96
|
this.enforceTimeTable = false;
|
|
96
97
|
this.metrics = new SequencerMetrics(telemetry, ()=>this.state, 'Sequencer');
|
|
98
|
+
this.l1Metrics = new L1Metrics(telemetry.getMeter('SequencerL1Metrics'), publisher.l1TxUtils.publicClient, [
|
|
99
|
+
publisher.getSenderAddress()
|
|
100
|
+
]);
|
|
97
101
|
// Register the block builder with the validator client for re-execution
|
|
98
102
|
this.validatorClient?.registerBlockBuilder(this.buildBlock.bind(this));
|
|
99
103
|
// Register the slasher on the publisher to fetch slashing payloads
|
|
@@ -165,6 +169,7 @@ export { SequencerState };
|
|
|
165
169
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
166
170
|
this.setState(SequencerState.IDLE, 0n, true);
|
|
167
171
|
this.runningPromise.start();
|
|
172
|
+
this.l1Metrics.start();
|
|
168
173
|
this.log.info(`Sequencer started with address ${this.publisher.getSenderAddress().toString()}`);
|
|
169
174
|
}
|
|
170
175
|
/**
|
|
@@ -176,6 +181,7 @@ export { SequencerState };
|
|
|
176
181
|
this.slasherClient.stop();
|
|
177
182
|
this.publisher.interrupt();
|
|
178
183
|
this.setState(SequencerState.STOPPED, 0n, true);
|
|
184
|
+
this.l1Metrics.stop();
|
|
179
185
|
this.log.info('Stopped sequencer');
|
|
180
186
|
}
|
|
181
187
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.0",
|
|
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.
|
|
32
|
-
"@aztec/bb-prover": "0.
|
|
33
|
-
"@aztec/blob-lib": "0.
|
|
34
|
-
"@aztec/blob-sink": "0.
|
|
35
|
-
"@aztec/constants": "0.
|
|
36
|
-
"@aztec/epoch-cache": "0.
|
|
37
|
-
"@aztec/ethereum": "0.
|
|
38
|
-
"@aztec/foundation": "0.
|
|
39
|
-
"@aztec/l1-artifacts": "0.
|
|
40
|
-
"@aztec/merkle-tree": "0.
|
|
41
|
-
"@aztec/noir-acvm_js": "0.
|
|
42
|
-
"@aztec/noir-contracts.js": "0.
|
|
43
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
44
|
-
"@aztec/noir-types": "0.
|
|
45
|
-
"@aztec/p2p": "0.
|
|
46
|
-
"@aztec/protocol-contracts": "0.
|
|
47
|
-
"@aztec/prover-client": "0.
|
|
48
|
-
"@aztec/simulator": "0.
|
|
49
|
-
"@aztec/stdlib": "0.
|
|
50
|
-
"@aztec/telemetry-client": "0.
|
|
51
|
-
"@aztec/validator-client": "0.
|
|
52
|
-
"@aztec/world-state": "0.
|
|
31
|
+
"@aztec/aztec.js": "0.82.0",
|
|
32
|
+
"@aztec/bb-prover": "0.82.0",
|
|
33
|
+
"@aztec/blob-lib": "0.82.0",
|
|
34
|
+
"@aztec/blob-sink": "0.82.0",
|
|
35
|
+
"@aztec/constants": "0.82.0",
|
|
36
|
+
"@aztec/epoch-cache": "0.82.0",
|
|
37
|
+
"@aztec/ethereum": "0.82.0",
|
|
38
|
+
"@aztec/foundation": "0.82.0",
|
|
39
|
+
"@aztec/l1-artifacts": "0.82.0",
|
|
40
|
+
"@aztec/merkle-tree": "0.82.0",
|
|
41
|
+
"@aztec/noir-acvm_js": "0.82.0",
|
|
42
|
+
"@aztec/noir-contracts.js": "0.82.0",
|
|
43
|
+
"@aztec/noir-protocol-circuits-types": "0.82.0",
|
|
44
|
+
"@aztec/noir-types": "0.82.0",
|
|
45
|
+
"@aztec/p2p": "0.82.0",
|
|
46
|
+
"@aztec/protocol-contracts": "0.82.0",
|
|
47
|
+
"@aztec/prover-client": "0.82.0",
|
|
48
|
+
"@aztec/simulator": "0.82.0",
|
|
49
|
+
"@aztec/stdlib": "0.82.0",
|
|
50
|
+
"@aztec/telemetry-client": "0.82.0",
|
|
51
|
+
"@aztec/validator-client": "0.82.0",
|
|
52
|
+
"@aztec/world-state": "0.82.0",
|
|
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.
|
|
60
|
-
"@aztec/kv-store": "0.
|
|
59
|
+
"@aztec/archiver": "0.82.0",
|
|
60
|
+
"@aztec/kv-store": "0.82.0",
|
|
61
61
|
"@jest/globals": "^29.5.0",
|
|
62
62
|
"@types/jest": "^29.5.0",
|
|
63
63
|
"@types/levelup": "^5.1.2",
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type L1ContractsConfig,
|
|
3
3
|
type L1ReaderConfig,
|
|
4
|
+
RollupContract,
|
|
4
5
|
type ViemPublicClient,
|
|
5
6
|
createEthereumChain,
|
|
6
7
|
} from '@aztec/ethereum';
|
|
7
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
9
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
10
|
-
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
11
11
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
13
13
|
import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
|
|
14
14
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Simple global variables builder.
|
|
@@ -21,7 +21,7 @@ import { type GetContractReturnType, createPublicClient, fallback, getAddress, g
|
|
|
21
21
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
22
22
|
private log = createLogger('sequencer:global_variable_builder');
|
|
23
23
|
|
|
24
|
-
private rollupContract:
|
|
24
|
+
private rollupContract: RollupContract;
|
|
25
25
|
private publicClient: ViemPublicClient;
|
|
26
26
|
private ethereumSlotDuration: number;
|
|
27
27
|
|
|
@@ -38,11 +38,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
38
38
|
pollingInterval: config.viemPollingIntervalMS,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
this.rollupContract =
|
|
42
|
-
address: getAddress(l1Contracts.rollupAddress.toString()),
|
|
43
|
-
abi: RollupAbi,
|
|
44
|
-
client: this.publicClient,
|
|
45
|
-
});
|
|
41
|
+
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
/**
|
|
@@ -54,12 +50,12 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
54
50
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
55
51
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
56
52
|
|
|
57
|
-
const lastBlock = await this.rollupContract.
|
|
58
|
-
const earliestTimestamp = await this.rollupContract.
|
|
53
|
+
const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
|
|
54
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
|
|
59
55
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
60
56
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
61
57
|
|
|
62
|
-
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
58
|
+
return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
/**
|
|
@@ -76,21 +72,21 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
76
72
|
feeRecipient: AztecAddress,
|
|
77
73
|
slotNumber?: bigint,
|
|
78
74
|
): Promise<GlobalVariables> {
|
|
79
|
-
const version = new Fr(await this.rollupContract.
|
|
75
|
+
const version = new Fr(await this.rollupContract.getVersion());
|
|
80
76
|
const chainId = new Fr(this.publicClient.chain.id);
|
|
81
77
|
|
|
82
78
|
if (slotNumber === undefined) {
|
|
83
79
|
const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
84
|
-
slotNumber = await this.rollupContract.
|
|
80
|
+
slotNumber = await this.rollupContract.getSlotAt(ts);
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
const timestamp = await this.rollupContract.
|
|
83
|
+
const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
|
|
88
84
|
|
|
89
85
|
const slotFr = new Fr(slotNumber);
|
|
90
86
|
const timestampFr = new Fr(timestamp);
|
|
91
87
|
|
|
92
88
|
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
93
|
-
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.
|
|
89
|
+
const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.getManaBaseFeeAt(timestamp, true)));
|
|
94
90
|
|
|
95
91
|
const globalVariables = new GlobalVariables(
|
|
96
92
|
chainId,
|
package/src/sequencer/metrics.ts
CHANGED
|
@@ -78,7 +78,17 @@ export class SequencerMetrics {
|
|
|
78
78
|
valueType: ValueType.INT,
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
// Init gauges and counters
|
|
81
82
|
this.setCurrentBlock(0, 0);
|
|
83
|
+
this.blockCounter.add(0, {
|
|
84
|
+
[Attributes.STATUS]: 'cancelled',
|
|
85
|
+
});
|
|
86
|
+
this.blockCounter.add(0, {
|
|
87
|
+
[Attributes.STATUS]: 'failed',
|
|
88
|
+
});
|
|
89
|
+
this.blockCounter.add(0, {
|
|
90
|
+
[Attributes.STATUS]: 'built',
|
|
91
|
+
});
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
startCollectingAttestationsTimer(): () => void {
|
|
@@ -33,7 +33,14 @@ import {
|
|
|
33
33
|
Tx,
|
|
34
34
|
type TxHash,
|
|
35
35
|
} from '@aztec/stdlib/tx';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
Attributes,
|
|
38
|
+
L1Metrics,
|
|
39
|
+
type TelemetryClient,
|
|
40
|
+
type Tracer,
|
|
41
|
+
getTelemetryClient,
|
|
42
|
+
trackSpan,
|
|
43
|
+
} from '@aztec/telemetry-client';
|
|
37
44
|
import type { ValidatorClient } from '@aztec/validator-client';
|
|
38
45
|
|
|
39
46
|
import type { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
@@ -73,6 +80,7 @@ export class Sequencer {
|
|
|
73
80
|
private maxBlockSizeInBytes: number = 1024 * 1024;
|
|
74
81
|
private maxBlockGas: Gas = new Gas(100e9, 100e9);
|
|
75
82
|
private metrics: SequencerMetrics;
|
|
83
|
+
private l1Metrics: L1Metrics;
|
|
76
84
|
private isFlushing: boolean = false;
|
|
77
85
|
|
|
78
86
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */
|
|
@@ -99,6 +107,9 @@ export class Sequencer {
|
|
|
99
107
|
protected log = createLogger('sequencer'),
|
|
100
108
|
) {
|
|
101
109
|
this.metrics = new SequencerMetrics(telemetry, () => this.state, 'Sequencer');
|
|
110
|
+
this.l1Metrics = new L1Metrics(telemetry.getMeter('SequencerL1Metrics'), publisher.l1TxUtils.publicClient, [
|
|
111
|
+
publisher.getSenderAddress(),
|
|
112
|
+
]);
|
|
102
113
|
|
|
103
114
|
// Register the block builder with the validator client for re-execution
|
|
104
115
|
this.validatorClient?.registerBlockBuilder(this.buildBlock.bind(this));
|
|
@@ -187,6 +198,7 @@ export class Sequencer {
|
|
|
187
198
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
188
199
|
this.setState(SequencerState.IDLE, 0n, true /** force */);
|
|
189
200
|
this.runningPromise.start();
|
|
201
|
+
this.l1Metrics.start();
|
|
190
202
|
this.log.info(`Sequencer started with address ${this.publisher.getSenderAddress().toString()}`);
|
|
191
203
|
}
|
|
192
204
|
|
|
@@ -200,6 +212,7 @@ export class Sequencer {
|
|
|
200
212
|
this.slasherClient.stop();
|
|
201
213
|
this.publisher.interrupt();
|
|
202
214
|
this.setState(SequencerState.STOPPED, 0n, true /** force */);
|
|
215
|
+
this.l1Metrics.stop();
|
|
203
216
|
this.log.info('Stopped sequencer');
|
|
204
217
|
}
|
|
205
218
|
|