@aztec/sequencer-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d6f2b3f94
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/sequencer-client.d.ts +12 -12
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +33 -26
- package/dest/config.d.ts +12 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +71 -32
- package/dest/global_variable_builder/global_builder.d.ts +21 -12
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +51 -41
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +7 -4
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +9 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +48 -41
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +600 -129
- package/dest/sequencer/checkpoint_proposal_job.d.ts +102 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1191 -0
- package/dest/sequencer/checkpoint_voter.d.ts +35 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +109 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +23 -3
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +143 -70
- package/dest/sequencer/sequencer.d.ts +109 -131
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +696 -603
- package/dest/sequencer/timetable.d.ts +51 -14
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +145 -59
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +4 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +95 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +220 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +103 -0
- package/package.json +30 -28
- package/src/client/sequencer-client.ts +31 -42
- package/src/config.ts +78 -36
- package/src/global_variable_builder/global_builder.ts +63 -59
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +12 -9
- package/src/publisher/sequencer-publisher-factory.ts +5 -4
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +293 -170
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +877 -0
- package/src/sequencer/checkpoint_voter.ts +130 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +190 -78
- package/src/sequencer/sequencer.ts +438 -805
- package/src/sequencer/timetable.ts +175 -80
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +3 -2
- package/src/test/mock_checkpoint_builder.ts +309 -0
- package/src/test/utils.ts +164 -0
- package/dest/sequencer/block_builder.d.ts +0 -28
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -134
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -222
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -133
package/src/config.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type L1ReaderConfig,
|
|
4
|
-
l1ContractsConfigMappings,
|
|
5
|
-
l1ReaderConfigMappings,
|
|
6
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
2
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
7
3
|
import {
|
|
8
4
|
type ConfigMappingsType,
|
|
9
5
|
booleanConfigHelper,
|
|
@@ -12,11 +8,18 @@ import {
|
|
|
12
8
|
pickConfigMappings,
|
|
13
9
|
} from '@aztec/foundation/config';
|
|
14
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
|
-
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore';
|
|
16
|
-
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p';
|
|
11
|
+
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
|
+
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
17
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
18
|
-
import {
|
|
19
|
-
|
|
14
|
+
import {
|
|
15
|
+
type ChainConfig,
|
|
16
|
+
type SequencerConfig,
|
|
17
|
+
chainConfigMappings,
|
|
18
|
+
sharedSequencerConfigMappings,
|
|
19
|
+
} from '@aztec/stdlib/config';
|
|
20
|
+
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
21
|
+
import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
|
|
22
|
+
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
20
23
|
|
|
21
24
|
import {
|
|
22
25
|
type PublisherConfig,
|
|
@@ -28,7 +31,31 @@ import {
|
|
|
28
31
|
export * from './publisher/config.js';
|
|
29
32
|
export type { SequencerConfig };
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Default values for SequencerConfig.
|
|
36
|
+
* Centralized location for all sequencer configuration defaults.
|
|
37
|
+
*/
|
|
38
|
+
export const DefaultSequencerConfig: ResolvedSequencerConfig = {
|
|
39
|
+
sequencerPollingIntervalMS: 500,
|
|
40
|
+
maxTxsPerBlock: 32,
|
|
41
|
+
minTxsPerBlock: 1,
|
|
42
|
+
buildCheckpointIfEmpty: false,
|
|
43
|
+
publishTxsWithProposals: false,
|
|
44
|
+
maxL2BlockGas: 10e9,
|
|
45
|
+
maxDABlockGas: 10e9,
|
|
46
|
+
maxBlockSizeInBytes: 1024 * 1024,
|
|
47
|
+
enforceTimeTable: true,
|
|
48
|
+
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
49
|
+
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
50
|
+
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
51
|
+
skipCollectingAttestations: false,
|
|
52
|
+
skipInvalidateBlockAsProposer: false,
|
|
53
|
+
broadcastInvalidBlockProposal: false,
|
|
54
|
+
injectFakeAttestation: false,
|
|
55
|
+
fishermanMode: false,
|
|
56
|
+
shuffleAttestationOrdering: false,
|
|
57
|
+
skipPushProposedBlocksToArchiver: false,
|
|
58
|
+
};
|
|
32
59
|
|
|
33
60
|
/**
|
|
34
61
|
* Configuration settings for the SequencerClient.
|
|
@@ -44,35 +71,39 @@ export type SequencerClientConfig = PublisherConfig &
|
|
|
44
71
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
45
72
|
|
|
46
73
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
47
|
-
|
|
48
|
-
env: '
|
|
49
|
-
description: 'The number of ms to wait between polling for
|
|
50
|
-
...numberConfigHelper(
|
|
74
|
+
sequencerPollingIntervalMS: {
|
|
75
|
+
env: 'SEQ_POLLING_INTERVAL_MS',
|
|
76
|
+
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
77
|
+
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
51
78
|
},
|
|
52
79
|
maxTxsPerBlock: {
|
|
53
80
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
54
81
|
description: 'The maximum number of txs to include in a block.',
|
|
55
|
-
...numberConfigHelper(
|
|
82
|
+
...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
|
|
56
83
|
},
|
|
57
84
|
minTxsPerBlock: {
|
|
58
85
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
59
86
|
description: 'The minimum number of txs to include in a block.',
|
|
60
|
-
...numberConfigHelper(
|
|
87
|
+
...numberConfigHelper(DefaultSequencerConfig.minTxsPerBlock),
|
|
88
|
+
},
|
|
89
|
+
minValidTxsPerBlock: {
|
|
90
|
+
description:
|
|
91
|
+
'The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock.',
|
|
61
92
|
},
|
|
62
93
|
publishTxsWithProposals: {
|
|
63
94
|
env: 'SEQ_PUBLISH_TXS_WITH_PROPOSALS',
|
|
64
95
|
description: 'Whether to publish txs with proposals.',
|
|
65
|
-
...booleanConfigHelper(
|
|
96
|
+
...booleanConfigHelper(DefaultSequencerConfig.publishTxsWithProposals),
|
|
66
97
|
},
|
|
67
98
|
maxL2BlockGas: {
|
|
68
99
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
69
100
|
description: 'The maximum L2 block gas.',
|
|
70
|
-
...numberConfigHelper(
|
|
101
|
+
...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
|
|
71
102
|
},
|
|
72
103
|
maxDABlockGas: {
|
|
73
104
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
74
105
|
description: 'The maximum DA block gas.',
|
|
75
|
-
...numberConfigHelper(
|
|
106
|
+
...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
|
|
76
107
|
},
|
|
77
108
|
coinbase: {
|
|
78
109
|
env: 'COINBASE',
|
|
@@ -95,73 +126,84 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
95
126
|
maxBlockSizeInBytes: {
|
|
96
127
|
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
97
128
|
description: 'Max block size',
|
|
98
|
-
...numberConfigHelper(
|
|
129
|
+
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
99
130
|
},
|
|
100
131
|
enforceTimeTable: {
|
|
101
132
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
102
133
|
description: 'Whether to enforce the time table when building blocks',
|
|
103
|
-
...booleanConfigHelper(),
|
|
104
|
-
defaultValue: true,
|
|
134
|
+
...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable),
|
|
105
135
|
},
|
|
106
136
|
governanceProposerPayload: {
|
|
107
137
|
env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
|
|
108
138
|
description: 'The address of the payload for the governanceProposer',
|
|
109
139
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
110
|
-
defaultValue: EthAddress.ZERO,
|
|
111
140
|
},
|
|
112
|
-
|
|
113
|
-
env: '
|
|
114
|
-
description: 'How
|
|
141
|
+
l1PublishingTime: {
|
|
142
|
+
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
143
|
+
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
115
144
|
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
116
145
|
},
|
|
117
146
|
attestationPropagationTime: {
|
|
118
147
|
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
119
148
|
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
|
|
120
|
-
...numberConfigHelper(
|
|
149
|
+
...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
|
|
121
150
|
},
|
|
122
151
|
fakeProcessingDelayPerTxMs: {
|
|
123
152
|
description: 'Used for testing to introduce a fake delay after processing each tx',
|
|
124
153
|
},
|
|
154
|
+
fakeThrowAfterProcessingTxCount: {
|
|
155
|
+
description: 'Used for testing to throw an error after processing N txs',
|
|
156
|
+
},
|
|
125
157
|
secondsBeforeInvalidatingBlockAsCommitteeMember: {
|
|
126
158
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER',
|
|
127
159
|
description:
|
|
128
160
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a committee member (zero to never invalidate).' +
|
|
129
161
|
' The next proposer is expected to invalidate, so the committee acts as a fallback.',
|
|
130
|
-
...numberConfigHelper(
|
|
162
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsCommitteeMember),
|
|
131
163
|
},
|
|
132
164
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: {
|
|
133
165
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER',
|
|
134
166
|
description:
|
|
135
167
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a non-committee member (zero to never invalidate).' +
|
|
136
168
|
' The next proposer is expected to invalidate, then the committee, so other sequencers act as a fallback.',
|
|
137
|
-
...numberConfigHelper(
|
|
169
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsNonCommitteeMember),
|
|
138
170
|
},
|
|
139
171
|
skipCollectingAttestations: {
|
|
140
172
|
description:
|
|
141
173
|
'Whether to skip collecting attestations from validators and only use self-attestations (for testing only)',
|
|
142
|
-
...booleanConfigHelper(
|
|
174
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipCollectingAttestations),
|
|
143
175
|
},
|
|
144
176
|
skipInvalidateBlockAsProposer: {
|
|
145
177
|
description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
|
|
146
|
-
...booleanConfigHelper(
|
|
178
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
|
|
147
179
|
},
|
|
148
180
|
broadcastInvalidBlockProposal: {
|
|
149
181
|
description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
|
|
150
|
-
...booleanConfigHelper(
|
|
182
|
+
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
|
|
151
183
|
},
|
|
152
184
|
injectFakeAttestation: {
|
|
153
185
|
description: 'Inject a fake attestation (for testing only)',
|
|
154
|
-
...booleanConfigHelper(
|
|
186
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
155
187
|
},
|
|
156
188
|
fishermanMode: {
|
|
157
189
|
env: 'FISHERMAN_MODE',
|
|
158
190
|
description:
|
|
159
191
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
160
|
-
...booleanConfigHelper(
|
|
192
|
+
...booleanConfigHelper(DefaultSequencerConfig.fishermanMode),
|
|
161
193
|
},
|
|
162
194
|
shuffleAttestationOrdering: {
|
|
163
195
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
164
|
-
...booleanConfigHelper(
|
|
196
|
+
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
197
|
+
},
|
|
198
|
+
...sharedSequencerConfigMappings,
|
|
199
|
+
buildCheckpointIfEmpty: {
|
|
200
|
+
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
201
|
+
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
202
|
+
...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
|
|
203
|
+
},
|
|
204
|
+
skipPushProposedBlocksToArchiver: {
|
|
205
|
+
description: 'Skip pushing proposed blocks to archiver (default: true)',
|
|
206
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
|
|
165
207
|
},
|
|
166
208
|
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
|
|
167
209
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
createEthereumChain,
|
|
7
|
-
} from '@aztec/ethereum';
|
|
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';
|
|
8
6
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
11
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
13
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
14
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
CheckpointGlobalVariables,
|
|
15
|
+
GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
16
|
+
} from '@aztec/stdlib/tx';
|
|
15
17
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
16
18
|
|
|
17
19
|
import { createPublicClient, fallback, http } from 'viem';
|
|
@@ -21,26 +23,37 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
21
23
|
*/
|
|
22
24
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
23
25
|
private log = createLogger('sequencer:global_variable_builder');
|
|
24
|
-
private
|
|
26
|
+
private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
25
27
|
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
26
28
|
|
|
27
29
|
private readonly rollupContract: RollupContract;
|
|
28
30
|
private readonly publicClient: ViemPublicClient;
|
|
29
31
|
private readonly ethereumSlotDuration: number;
|
|
32
|
+
private readonly aztecSlotDuration: number;
|
|
33
|
+
private readonly l1GenesisTime: bigint;
|
|
30
34
|
|
|
31
|
-
private chainId
|
|
32
|
-
private version
|
|
35
|
+
private chainId: Fr;
|
|
36
|
+
private version: Fr;
|
|
33
37
|
|
|
34
|
-
constructor(
|
|
38
|
+
constructor(
|
|
39
|
+
config: L1ReaderConfig &
|
|
40
|
+
Pick<L1ContractsConfig, 'ethereumSlotDuration'> &
|
|
41
|
+
Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
|
|
42
|
+
) {
|
|
35
43
|
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
36
44
|
|
|
37
45
|
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
38
46
|
|
|
47
|
+
this.version = new Fr(config.rollupVersion);
|
|
48
|
+
this.chainId = new Fr(chainId);
|
|
49
|
+
|
|
39
50
|
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
51
|
+
this.aztecSlotDuration = config.slotDuration;
|
|
52
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
40
53
|
|
|
41
54
|
this.publicClient = createPublicClient({
|
|
42
55
|
chain: chain.chainInfo,
|
|
43
|
-
transport: fallback(chain.rpcUrls.map(url => http(url))),
|
|
56
|
+
transport: fallback(chain.rpcUrls.map(url => http(url, { batch: false }))),
|
|
44
57
|
pollingInterval: config.viemPollingIntervalMS,
|
|
45
58
|
});
|
|
46
59
|
|
|
@@ -48,48 +61,38 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
/**
|
|
51
|
-
* Computes the "current"
|
|
52
|
-
* @returns
|
|
64
|
+
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
65
|
+
* @returns Min fees for the next block
|
|
53
66
|
*/
|
|
54
|
-
private async
|
|
67
|
+
private async computeCurrentMinFees(): Promise<GasFees> {
|
|
55
68
|
// Since this might be called in the middle of a slot where a block might have been published,
|
|
56
69
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
57
70
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
58
71
|
|
|
59
|
-
const
|
|
72
|
+
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
60
73
|
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
61
|
-
SlotNumber.fromBigInt(
|
|
74
|
+
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
62
75
|
);
|
|
63
76
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
64
77
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
65
78
|
|
|
66
|
-
return new GasFees(0, await this.rollupContract.
|
|
79
|
+
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
67
80
|
}
|
|
68
81
|
|
|
69
|
-
public async
|
|
82
|
+
public async getCurrentMinFees(): Promise<GasFees> {
|
|
70
83
|
// Get the current block number
|
|
71
84
|
const blockNumber = await this.publicClient.getBlockNumber();
|
|
72
85
|
|
|
73
|
-
// If the L1 block number has changed then chain a new promise to get the current
|
|
86
|
+
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
74
87
|
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
75
88
|
this.currentL1BlockNumber = blockNumber;
|
|
76
|
-
this.
|
|
77
|
-
}
|
|
78
|
-
return this.currentBaseFees;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public async getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>> {
|
|
82
|
-
if (!this.chainId) {
|
|
83
|
-
this.chainId = new Fr(this.publicClient.chain.id);
|
|
84
|
-
}
|
|
85
|
-
if (!this.version) {
|
|
86
|
-
this.version = new Fr(await this.rollupContract.getVersion());
|
|
89
|
+
this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
|
|
87
90
|
}
|
|
88
|
-
return
|
|
91
|
+
return this.currentMinFees;
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
/**
|
|
92
|
-
* Simple builder of global variables
|
|
95
|
+
* Simple builder of global variables.
|
|
93
96
|
* @param blockNumber - The block number to build global variables for.
|
|
94
97
|
* @param coinbase - The address to receive block reward.
|
|
95
98
|
* @param feeRecipient - The address to receive fees.
|
|
@@ -100,34 +103,35 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
100
103
|
blockNumber: BlockNumber,
|
|
101
104
|
coinbase: EthAddress,
|
|
102
105
|
feeRecipient: AztecAddress,
|
|
103
|
-
|
|
106
|
+
maybeSlot?: SlotNumber,
|
|
104
107
|
): Promise<GlobalVariables> {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
const slot: SlotNumber =
|
|
109
|
+
maybeSlot ??
|
|
110
|
+
(await this.rollupContract.getSlotAt(
|
|
111
|
+
BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)),
|
|
112
|
+
));
|
|
113
|
+
|
|
114
|
+
const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
|
|
115
|
+
return GlobalVariables.from({ blockNumber, ...checkpointGlobalVariables });
|
|
116
|
+
}
|
|
114
117
|
|
|
115
|
-
|
|
118
|
+
/** Builds global variables that are constant throughout a checkpoint. */
|
|
119
|
+
public async buildCheckpointGlobalVariables(
|
|
120
|
+
coinbase: EthAddress,
|
|
121
|
+
feeRecipient: AztecAddress,
|
|
122
|
+
slotNumber: SlotNumber,
|
|
123
|
+
): Promise<CheckpointGlobalVariables & { timestamp: bigint }> {
|
|
124
|
+
const { chainId, version } = this;
|
|
116
125
|
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
const timestamp = getTimestampForSlot(slotNumber, {
|
|
127
|
+
slotDuration: this.aztecSlotDuration,
|
|
128
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
129
|
+
});
|
|
119
130
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
blockNumber,
|
|
124
|
-
slot,
|
|
125
|
-
timestamp,
|
|
126
|
-
coinbase,
|
|
127
|
-
feeRecipient,
|
|
128
|
-
gasFees,
|
|
129
|
-
);
|
|
131
|
+
// We can skip much of the logic in getCurrentMinFees since it we already check that we are not within a slot elsewhere.
|
|
132
|
+
// TODO(palla/mbps): Can we use a cached value here?
|
|
133
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
130
134
|
|
|
131
|
-
return
|
|
135
|
+
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
132
136
|
}
|
|
133
137
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './publisher/index.js';
|
|
4
|
-
export {
|
|
5
|
-
FullNodeBlockBuilder as BlockBuilder,
|
|
6
|
-
Sequencer,
|
|
7
|
-
SequencerState,
|
|
8
|
-
type SequencerEvents,
|
|
9
|
-
} from './sequencer/index.js';
|
|
10
|
-
export * from './tx_validator/tx_validator_factory.js';
|
|
4
|
+
export { Sequencer, SequencerState, type SequencerEvents } from './sequencer/index.js';
|
|
11
5
|
|
|
12
6
|
// Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
|
|
13
7
|
// ISSUE(#9832)
|
package/src/publisher/config.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type L1TxUtilsConfig,
|
|
5
|
-
l1ReaderConfigMappings,
|
|
6
|
-
l1TxUtilsConfigMappings,
|
|
7
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
|
+
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
|
|
8
4
|
import {
|
|
9
5
|
type ConfigMappingsType,
|
|
10
6
|
SecretValue,
|
|
@@ -32,11 +28,13 @@ export type TxSenderConfig = L1ReaderConfig & {
|
|
|
32
28
|
* Configuration of the L1Publisher.
|
|
33
29
|
*/
|
|
34
30
|
export type PublisherConfig = L1TxUtilsConfig &
|
|
35
|
-
|
|
31
|
+
BlobClientConfig & {
|
|
36
32
|
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
37
33
|
publisherAllowInvalidStates?: boolean;
|
|
38
34
|
/** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
|
|
39
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: (
|
|
@@ -76,8 +74,13 @@ export const getPublisherConfigMappings: (
|
|
|
76
74
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
77
75
|
...booleanConfigHelper(false),
|
|
78
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),
|
|
81
|
+
},
|
|
79
82
|
...l1TxUtilsConfigMappings,
|
|
80
|
-
...
|
|
83
|
+
...blobClientConfigMapping,
|
|
81
84
|
});
|
|
82
85
|
|
|
83
86
|
export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
4
4
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
5
|
-
import type { GovernanceProposerContract,
|
|
5
|
+
import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
6
|
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
7
|
+
import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
7
8
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
8
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
9
10
|
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
@@ -32,7 +33,7 @@ export class SequencerPublisherFactory {
|
|
|
32
33
|
private deps: {
|
|
33
34
|
telemetry: TelemetryClient;
|
|
34
35
|
publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
|
|
35
|
-
|
|
36
|
+
blobClient: BlobClientInterface;
|
|
36
37
|
dateProvider: DateProvider;
|
|
37
38
|
epochCache: EpochCache;
|
|
38
39
|
rollupContract: RollupContract;
|
|
@@ -71,7 +72,7 @@ export class SequencerPublisherFactory {
|
|
|
71
72
|
const publisher = new SequencerPublisher(this.sequencerConfig, {
|
|
72
73
|
l1TxUtils: l1Publisher,
|
|
73
74
|
telemetry: this.deps.telemetry,
|
|
74
|
-
|
|
75
|
+
blobClient: this.deps.blobClient,
|
|
75
76
|
rollupContract: this.deps.rollupContract,
|
|
76
77
|
epochCache: this.deps.epochCache,
|
|
77
78
|
governanceProposerContract: this.deps.governanceProposerContract,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
-
import type {
|
|
2
|
+
import type { L1PublishCheckpointStats, L1PublishStats } from '@aztec/stdlib/stats';
|
|
3
3
|
import {
|
|
4
4
|
Attributes,
|
|
5
5
|
type Gauge,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Metrics,
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type UpDownCounter,
|
|
10
|
-
|
|
10
|
+
createUpDownCounterWithDefault,
|
|
11
11
|
} from '@aztec/telemetry-client';
|
|
12
12
|
|
|
13
13
|
import { formatEther } from 'viem/utils';
|
|
@@ -40,88 +40,36 @@ export class SequencerPublisherMetrics {
|
|
|
40
40
|
) {
|
|
41
41
|
const meter = client.getMeter(name);
|
|
42
42
|
|
|
43
|
-
this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE
|
|
44
|
-
description: 'The gas price used for transactions',
|
|
45
|
-
unit: 'gwei',
|
|
46
|
-
valueType: ValueType.DOUBLE,
|
|
47
|
-
});
|
|
43
|
+
this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
48
44
|
|
|
49
|
-
this.txCount = meter
|
|
50
|
-
|
|
45
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
46
|
+
[Attributes.L1_TX_TYPE]: ['process'],
|
|
47
|
+
[Attributes.OK]: [true, false],
|
|
51
48
|
});
|
|
52
49
|
|
|
53
|
-
this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION
|
|
54
|
-
description: 'The duration of transaction processing',
|
|
55
|
-
unit: 'ms',
|
|
56
|
-
valueType: ValueType.INT,
|
|
57
|
-
});
|
|
50
|
+
this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
58
51
|
|
|
59
|
-
this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS
|
|
60
|
-
description: 'The gas consumed by transactions',
|
|
61
|
-
unit: 'gas',
|
|
62
|
-
valueType: ValueType.INT,
|
|
63
|
-
});
|
|
52
|
+
this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
|
|
64
53
|
|
|
65
|
-
this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE
|
|
66
|
-
description: 'The size of the calldata in transactions',
|
|
67
|
-
unit: 'By',
|
|
68
|
-
valueType: ValueType.INT,
|
|
69
|
-
});
|
|
54
|
+
this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
|
|
70
55
|
|
|
71
|
-
this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS
|
|
72
|
-
description: 'The gas consumed by the calldata in transactions',
|
|
73
|
-
unit: 'gas',
|
|
74
|
-
valueType: ValueType.INT,
|
|
75
|
-
});
|
|
56
|
+
this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
|
|
76
57
|
|
|
77
|
-
this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED
|
|
78
|
-
description: 'The amount of blob gas used in transactions',
|
|
79
|
-
unit: 'gas',
|
|
80
|
-
valueType: ValueType.INT,
|
|
81
|
-
});
|
|
58
|
+
this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
|
|
82
59
|
|
|
83
|
-
this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST
|
|
84
|
-
description: 'The gas cost of blobs in transactions',
|
|
85
|
-
unit: 'gwei',
|
|
86
|
-
valueType: ValueType.INT,
|
|
87
|
-
});
|
|
60
|
+
this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
|
|
88
61
|
|
|
89
|
-
this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT
|
|
90
|
-
description: 'Number of blobs in L1 transactions',
|
|
91
|
-
unit: 'blobs',
|
|
92
|
-
valueType: ValueType.INT,
|
|
93
|
-
});
|
|
62
|
+
this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT);
|
|
94
63
|
|
|
95
|
-
this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS
|
|
96
|
-
description: 'Number of L1 blocks between blob tx submission and inclusion',
|
|
97
|
-
unit: 'blocks',
|
|
98
|
-
valueType: ValueType.INT,
|
|
99
|
-
});
|
|
64
|
+
this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS);
|
|
100
65
|
|
|
101
|
-
this.blobTxSuccessCounter = meter
|
|
102
|
-
description: 'Number of successful L1 transactions with blobs',
|
|
103
|
-
});
|
|
66
|
+
this.blobTxSuccessCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS);
|
|
104
67
|
|
|
105
|
-
this.blobTxFailureCounter = meter
|
|
106
|
-
description: 'Number of failed L1 transactions with blobs',
|
|
107
|
-
});
|
|
68
|
+
this.blobTxFailureCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_FAILURE);
|
|
108
69
|
|
|
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
|
-
});
|
|
70
|
+
this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
|
|
119
71
|
|
|
120
|
-
this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE
|
|
121
|
-
unit: 'eth',
|
|
122
|
-
description: 'The balance of the sender address',
|
|
123
|
-
valueType: ValueType.DOUBLE,
|
|
124
|
-
});
|
|
72
|
+
this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
|
|
125
73
|
}
|
|
126
74
|
|
|
127
75
|
recordFailedTx(txType: L1TxType) {
|
|
@@ -135,7 +83,7 @@ export class SequencerPublisherMetrics {
|
|
|
135
83
|
}
|
|
136
84
|
}
|
|
137
85
|
|
|
138
|
-
recordProcessBlockTx(durationMs: number, stats:
|
|
86
|
+
recordProcessBlockTx(durationMs: number, stats: L1PublishCheckpointStats) {
|
|
139
87
|
this.recordTx('process', durationMs, stats);
|
|
140
88
|
|
|
141
89
|
if (stats.blobCount && stats.blobCount > 0) {
|