@aztec/sequencer-client 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
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/client/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +7 -6
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +23 -14
- package/dest/config.d.ts +5 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +21 -1
- package/dest/global_variable_builder/global_builder.d.ts +5 -7
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +12 -8
- package/dest/global_variable_builder/index.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/publisher/config.d.ts +9 -10
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +19 -17
- package/dest/publisher/index.d.ts +2 -2
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +9 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +8 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +2 -2
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +1 -1
- package/dest/publisher/sequencer-publisher.d.ts +53 -50
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +187 -132
- package/dest/sequencer/block_builder.d.ts +6 -8
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +18 -9
- package/dest/sequencer/config.d.ts +2 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +11 -0
- package/dest/sequencer/errors.d.ts.map +1 -0
- package/dest/sequencer/errors.js +15 -0
- package/dest/sequencer/index.d.ts +1 -1
- package/dest/sequencer/metrics.d.ts +17 -20
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +59 -87
- package/dest/sequencer/sequencer.d.ts +54 -32
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +458 -184
- package/dest/sequencer/timetable.d.ts +4 -8
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +3 -10
- package/dest/sequencer/utils.d.ts +11 -25
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +9 -24
- package/dest/test/index.d.ts +2 -2
- package/dest/test/index.d.ts.map +1 -1
- package/dest/tx_validator/nullifier_cache.d.ts +1 -1
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +12 -9
- package/package.json +32 -31
- package/src/client/sequencer-client.ts +24 -18
- package/src/config.ts +23 -6
- package/src/global_variable_builder/global_builder.ts +19 -17
- package/src/publisher/config.ts +29 -27
- package/src/publisher/index.ts +1 -1
- package/src/publisher/sequencer-publisher-factory.ts +16 -3
- package/src/publisher/sequencer-publisher-metrics.ts +1 -1
- package/src/publisher/sequencer-publisher.ts +257 -183
- package/src/sequencer/block_builder.ts +23 -28
- package/src/sequencer/config.ts +1 -1
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/metrics.ts +71 -98
- package/src/sequencer/sequencer.ts +546 -237
- package/src/sequencer/timetable.ts +10 -14
- package/src/sequencer/utils.ts +10 -24
- package/src/test/index.ts +1 -1
- package/src/tx_validator/tx_validator_factory.ts +13 -7
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@aztec/
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
+
import type { L1ReaderConfig } from '@aztec/ethereum/l1-reader';
|
|
5
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
6
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
10
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
11
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
11
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
@@ -55,8 +54,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
55
54
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
56
55
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
57
56
|
|
|
58
|
-
const lastBlock = await this.rollupContract.
|
|
59
|
-
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
57
|
+
const lastBlock = await this.rollupContract.getCheckpoint(await this.rollupContract.getCheckpointNumber());
|
|
58
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
59
|
+
SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
|
|
60
|
+
);
|
|
60
61
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
61
62
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
62
63
|
|
|
@@ -94,21 +95,22 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
94
95
|
* @returns The global variables for the given block number.
|
|
95
96
|
*/
|
|
96
97
|
public async buildGlobalVariables(
|
|
97
|
-
blockNumber:
|
|
98
|
+
blockNumber: BlockNumber,
|
|
98
99
|
coinbase: EthAddress,
|
|
99
100
|
feeRecipient: AztecAddress,
|
|
100
|
-
slotNumber?:
|
|
101
|
+
slotNumber?: SlotNumber,
|
|
101
102
|
): Promise<GlobalVariables> {
|
|
102
103
|
const { chainId, version } = await this.getGlobalConstantVariables();
|
|
103
104
|
|
|
105
|
+
let slot: SlotNumber;
|
|
104
106
|
if (slotNumber === undefined) {
|
|
105
107
|
const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
106
|
-
|
|
108
|
+
slot = await this.rollupContract.getSlotAt(ts);
|
|
109
|
+
} else {
|
|
110
|
+
slot = slotNumber;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
const timestamp = await this.rollupContract.getTimestampForSlot(
|
|
110
|
-
|
|
111
|
-
const slotFr = new Fr(slotNumber);
|
|
113
|
+
const timestamp = await this.rollupContract.getTimestampForSlot(slot);
|
|
112
114
|
|
|
113
115
|
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
114
116
|
const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
|
|
@@ -117,7 +119,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
117
119
|
chainId,
|
|
118
120
|
version,
|
|
119
121
|
blockNumber,
|
|
120
|
-
|
|
122
|
+
slot,
|
|
121
123
|
timestamp,
|
|
122
124
|
coinbase,
|
|
123
125
|
feeRecipient,
|
package/src/publisher/config.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
|
|
2
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
|
+
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils';
|
|
2
4
|
import {
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@aztec/
|
|
8
|
-
import { type ConfigMappingsType, SecretValue, getConfigFromMappings } from '@aztec/foundation/config';
|
|
5
|
+
type ConfigMappingsType,
|
|
6
|
+
SecretValue,
|
|
7
|
+
booleanConfigHelper,
|
|
8
|
+
getConfigFromMappings,
|
|
9
|
+
} from '@aztec/foundation/config';
|
|
9
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -21,11 +22,6 @@ export type TxSenderConfig = L1ReaderConfig & {
|
|
|
21
22
|
* Publisher addresses to be used with a remote signer
|
|
22
23
|
*/
|
|
23
24
|
publisherAddresses?: EthAddress[];
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The address of the custom forwarder contract.
|
|
27
|
-
*/
|
|
28
|
-
customForwarderContractAddress: EthAddress;
|
|
29
25
|
};
|
|
30
26
|
|
|
31
27
|
/**
|
|
@@ -33,28 +29,24 @@ export type TxSenderConfig = L1ReaderConfig & {
|
|
|
33
29
|
*/
|
|
34
30
|
export type PublisherConfig = L1TxUtilsConfig &
|
|
35
31
|
BlobSinkConfig & {
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
33
|
+
publisherAllowInvalidStates?: boolean;
|
|
34
|
+
/** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
|
|
35
|
+
fishermanMode?: boolean;
|
|
36
|
+
/** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
|
|
37
|
+
publisherForwarderAddress?: EthAddress;
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
export const getTxSenderConfigMappings: (
|
|
43
41
|
scope: 'PROVER' | 'SEQ',
|
|
44
42
|
) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
|
|
45
43
|
...l1ReaderConfigMappings,
|
|
46
|
-
customForwarderContractAddress: {
|
|
47
|
-
env: `CUSTOM_FORWARDER_CONTRACT_ADDRESS`,
|
|
48
|
-
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
49
|
-
description: 'The address of the custom forwarder contract.',
|
|
50
|
-
defaultValue: EthAddress.ZERO,
|
|
51
|
-
},
|
|
52
44
|
publisherPrivateKeys: {
|
|
53
45
|
env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEYS` : `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
54
46
|
description: 'The private keys to be used by the publisher.',
|
|
55
47
|
parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
56
48
|
defaultValue: [],
|
|
57
|
-
fallback: scope === 'PROVER' ?
|
|
49
|
+
fallback: [scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
58
50
|
},
|
|
59
51
|
publisherAddresses: {
|
|
60
52
|
env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
|
|
@@ -71,11 +63,21 @@ export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSender
|
|
|
71
63
|
export const getPublisherConfigMappings: (
|
|
72
64
|
scope: 'PROVER' | 'SEQ',
|
|
73
65
|
) => ConfigMappingsType<PublisherConfig & L1TxUtilsConfig> = scope => ({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
publisherAllowInvalidStates: {
|
|
67
|
+
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
68
|
+
env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
69
|
+
...booleanConfigHelper(true),
|
|
70
|
+
},
|
|
71
|
+
fishermanMode: {
|
|
72
|
+
env: 'FISHERMAN_MODE',
|
|
73
|
+
description:
|
|
74
|
+
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
75
|
+
...booleanConfigHelper(false),
|
|
76
|
+
},
|
|
77
|
+
publisherForwarderAddress: {
|
|
78
|
+
env: scope === `PROVER` ? `PROVER_PUBLISHER_FORWARDER_ADDRESS` : `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
79
|
+
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
80
|
+
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
79
81
|
},
|
|
80
82
|
...l1TxUtilsConfigMappings,
|
|
81
83
|
...blobSinkConfigMapping,
|
package/src/publisher/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { EthAddress } from '@aztec/aztec.js';
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
2
3
|
import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
|
|
3
4
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
-
import type { GovernanceProposerContract,
|
|
5
|
+
import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
6
|
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
7
|
+
import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
8
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
6
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
7
10
|
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
8
11
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -10,7 +13,7 @@ import { NodeKeystoreAdapter } from '@aztec/validator-client';
|
|
|
10
13
|
|
|
11
14
|
import type { SequencerClientConfig } from '../config.js';
|
|
12
15
|
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
13
|
-
import { SequencerPublisher } from './sequencer-publisher.js';
|
|
16
|
+
import { type Action, SequencerPublisher } from './sequencer-publisher.js';
|
|
14
17
|
|
|
15
18
|
export type AttestorPublisherPair = {
|
|
16
19
|
attestorAddress: EthAddress;
|
|
@@ -19,6 +22,12 @@ export type AttestorPublisherPair = {
|
|
|
19
22
|
|
|
20
23
|
export class SequencerPublisherFactory {
|
|
21
24
|
private publisherMetrics: SequencerPublisherMetrics;
|
|
25
|
+
|
|
26
|
+
/** Stores the last slot in which every action was carried out by a publisher */
|
|
27
|
+
private lastActions: Partial<Record<Action, SlotNumber>> = {};
|
|
28
|
+
|
|
29
|
+
private logger: Logger;
|
|
30
|
+
|
|
22
31
|
constructor(
|
|
23
32
|
private sequencerConfig: SequencerClientConfig,
|
|
24
33
|
private deps: {
|
|
@@ -31,9 +40,11 @@ export class SequencerPublisherFactory {
|
|
|
31
40
|
governanceProposerContract: GovernanceProposerContract;
|
|
32
41
|
slashFactoryContract: SlashFactoryContract;
|
|
33
42
|
nodeKeyStore: NodeKeystoreAdapter;
|
|
43
|
+
logger?: Logger;
|
|
34
44
|
},
|
|
35
45
|
) {
|
|
36
46
|
this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
|
|
47
|
+
this.logger = deps.logger ?? createLogger('sequencer');
|
|
37
48
|
}
|
|
38
49
|
/**
|
|
39
50
|
* Creates a new SequencerPublisher instance.
|
|
@@ -69,6 +80,8 @@ export class SequencerPublisherFactory {
|
|
|
69
80
|
slashFactoryContract: this.deps.slashFactoryContract,
|
|
70
81
|
dateProvider: this.deps.dateProvider,
|
|
71
82
|
metrics: this.publisherMetrics,
|
|
83
|
+
lastActions: this.lastActions,
|
|
84
|
+
log: this.logger.createChild('publisher'),
|
|
72
85
|
});
|
|
73
86
|
|
|
74
87
|
return {
|