@aztec/sequencer-client 3.0.3-rc.3 → 4.0.0-devnet.1-patch.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/client/sequencer-client.d.ts +11 -11
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +29 -25
- package/dest/config.d.ts +7 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +66 -28
- package/dest/global_variable_builder/global_builder.d.ts +19 -11
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +48 -39
- 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 +3 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +2 -2
- package/dest/publisher/sequencer-publisher-factory.d.ts +3 -3
- 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 +43 -39
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +599 -130
- 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/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 +22 -2
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +143 -70
- package/dest/sequencer/sequencer.d.ts +107 -129
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +677 -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 +3 -2
- 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 +27 -35
- package/src/config.ts +73 -27
- package/src/global_variable_builder/global_builder.ts +57 -51
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +3 -3
- package/src/publisher/sequencer-publisher-factory.ts +3 -3
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +284 -161
- 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/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +189 -77
- package/src/sequencer/sequencer.ts +416 -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 +2 -1
- 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 -127
- 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 -214
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -133
package/src/config.ts
CHANGED
|
@@ -11,7 +11,14 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
11
11
|
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
12
|
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
13
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
-
import {
|
|
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';
|
|
15
22
|
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
16
23
|
|
|
17
24
|
import {
|
|
@@ -24,7 +31,31 @@ import {
|
|
|
24
31
|
export * from './publisher/config.js';
|
|
25
32
|
export type { SequencerConfig };
|
|
26
33
|
|
|
27
|
-
|
|
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
|
+
};
|
|
28
59
|
|
|
29
60
|
/**
|
|
30
61
|
* Configuration settings for the SequencerClient.
|
|
@@ -40,35 +71,39 @@ export type SequencerClientConfig = PublisherConfig &
|
|
|
40
71
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
41
72
|
|
|
42
73
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
43
|
-
|
|
44
|
-
env: '
|
|
45
|
-
description: 'The number of ms to wait between polling for
|
|
46
|
-
...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),
|
|
47
78
|
},
|
|
48
79
|
maxTxsPerBlock: {
|
|
49
80
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
50
81
|
description: 'The maximum number of txs to include in a block.',
|
|
51
|
-
...numberConfigHelper(
|
|
82
|
+
...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
|
|
52
83
|
},
|
|
53
84
|
minTxsPerBlock: {
|
|
54
85
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
55
86
|
description: 'The minimum number of txs to include in a block.',
|
|
56
|
-
...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.',
|
|
57
92
|
},
|
|
58
93
|
publishTxsWithProposals: {
|
|
59
94
|
env: 'SEQ_PUBLISH_TXS_WITH_PROPOSALS',
|
|
60
95
|
description: 'Whether to publish txs with proposals.',
|
|
61
|
-
...booleanConfigHelper(
|
|
96
|
+
...booleanConfigHelper(DefaultSequencerConfig.publishTxsWithProposals),
|
|
62
97
|
},
|
|
63
98
|
maxL2BlockGas: {
|
|
64
99
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
65
100
|
description: 'The maximum L2 block gas.',
|
|
66
|
-
...numberConfigHelper(
|
|
101
|
+
...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
|
|
67
102
|
},
|
|
68
103
|
maxDABlockGas: {
|
|
69
104
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
70
105
|
description: 'The maximum DA block gas.',
|
|
71
|
-
...numberConfigHelper(
|
|
106
|
+
...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
|
|
72
107
|
},
|
|
73
108
|
coinbase: {
|
|
74
109
|
env: 'COINBASE',
|
|
@@ -91,73 +126,84 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
91
126
|
maxBlockSizeInBytes: {
|
|
92
127
|
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
93
128
|
description: 'Max block size',
|
|
94
|
-
...numberConfigHelper(
|
|
129
|
+
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
95
130
|
},
|
|
96
131
|
enforceTimeTable: {
|
|
97
132
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
98
133
|
description: 'Whether to enforce the time table when building blocks',
|
|
99
|
-
...booleanConfigHelper(),
|
|
100
|
-
defaultValue: true,
|
|
134
|
+
...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable),
|
|
101
135
|
},
|
|
102
136
|
governanceProposerPayload: {
|
|
103
137
|
env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
|
|
104
138
|
description: 'The address of the payload for the governanceProposer',
|
|
105
139
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
106
|
-
defaultValue: EthAddress.ZERO,
|
|
107
140
|
},
|
|
108
|
-
|
|
109
|
-
env: '
|
|
110
|
-
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).',
|
|
111
144
|
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
112
145
|
},
|
|
113
146
|
attestationPropagationTime: {
|
|
114
147
|
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
115
148
|
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
|
|
116
|
-
...numberConfigHelper(
|
|
149
|
+
...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
|
|
117
150
|
},
|
|
118
151
|
fakeProcessingDelayPerTxMs: {
|
|
119
152
|
description: 'Used for testing to introduce a fake delay after processing each tx',
|
|
120
153
|
},
|
|
154
|
+
fakeThrowAfterProcessingTxCount: {
|
|
155
|
+
description: 'Used for testing to throw an error after processing N txs',
|
|
156
|
+
},
|
|
121
157
|
secondsBeforeInvalidatingBlockAsCommitteeMember: {
|
|
122
158
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER',
|
|
123
159
|
description:
|
|
124
160
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a committee member (zero to never invalidate).' +
|
|
125
161
|
' The next proposer is expected to invalidate, so the committee acts as a fallback.',
|
|
126
|
-
...numberConfigHelper(
|
|
162
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsCommitteeMember),
|
|
127
163
|
},
|
|
128
164
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: {
|
|
129
165
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER',
|
|
130
166
|
description:
|
|
131
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).' +
|
|
132
168
|
' The next proposer is expected to invalidate, then the committee, so other sequencers act as a fallback.',
|
|
133
|
-
...numberConfigHelper(
|
|
169
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsNonCommitteeMember),
|
|
134
170
|
},
|
|
135
171
|
skipCollectingAttestations: {
|
|
136
172
|
description:
|
|
137
173
|
'Whether to skip collecting attestations from validators and only use self-attestations (for testing only)',
|
|
138
|
-
...booleanConfigHelper(
|
|
174
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipCollectingAttestations),
|
|
139
175
|
},
|
|
140
176
|
skipInvalidateBlockAsProposer: {
|
|
141
177
|
description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
|
|
142
|
-
...booleanConfigHelper(
|
|
178
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
|
|
143
179
|
},
|
|
144
180
|
broadcastInvalidBlockProposal: {
|
|
145
181
|
description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
|
|
146
|
-
...booleanConfigHelper(
|
|
182
|
+
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
|
|
147
183
|
},
|
|
148
184
|
injectFakeAttestation: {
|
|
149
185
|
description: 'Inject a fake attestation (for testing only)',
|
|
150
|
-
...booleanConfigHelper(
|
|
186
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
151
187
|
},
|
|
152
188
|
fishermanMode: {
|
|
153
189
|
env: 'FISHERMAN_MODE',
|
|
154
190
|
description:
|
|
155
191
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
156
|
-
...booleanConfigHelper(
|
|
192
|
+
...booleanConfigHelper(DefaultSequencerConfig.fishermanMode),
|
|
157
193
|
},
|
|
158
194
|
shuffleAttestationOrdering: {
|
|
159
195
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
160
|
-
...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),
|
|
161
207
|
},
|
|
162
208
|
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
|
|
163
209
|
};
|
|
@@ -8,8 +8,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
8
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
10
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
11
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
12
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
CheckpointGlobalVariables,
|
|
15
|
+
GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
16
|
+
} from '@aztec/stdlib/tx';
|
|
13
17
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
14
18
|
|
|
15
19
|
import { createPublicClient, fallback, http } from 'viem';
|
|
@@ -19,26 +23,37 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
19
23
|
*/
|
|
20
24
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
21
25
|
private log = createLogger('sequencer:global_variable_builder');
|
|
22
|
-
private
|
|
26
|
+
private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
23
27
|
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
24
28
|
|
|
25
29
|
private readonly rollupContract: RollupContract;
|
|
26
30
|
private readonly publicClient: ViemPublicClient;
|
|
27
31
|
private readonly ethereumSlotDuration: number;
|
|
32
|
+
private readonly aztecSlotDuration: number;
|
|
33
|
+
private readonly l1GenesisTime: bigint;
|
|
28
34
|
|
|
29
|
-
private chainId
|
|
30
|
-
private version
|
|
35
|
+
private chainId: Fr;
|
|
36
|
+
private version: Fr;
|
|
31
37
|
|
|
32
|
-
constructor(
|
|
38
|
+
constructor(
|
|
39
|
+
config: L1ReaderConfig &
|
|
40
|
+
Pick<L1ContractsConfig, 'ethereumSlotDuration'> &
|
|
41
|
+
Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
|
|
42
|
+
) {
|
|
33
43
|
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
34
44
|
|
|
35
45
|
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
36
46
|
|
|
47
|
+
this.version = new Fr(config.rollupVersion);
|
|
48
|
+
this.chainId = new Fr(chainId);
|
|
49
|
+
|
|
37
50
|
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
51
|
+
this.aztecSlotDuration = config.slotDuration;
|
|
52
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
38
53
|
|
|
39
54
|
this.publicClient = createPublicClient({
|
|
40
55
|
chain: chain.chainInfo,
|
|
41
|
-
transport: fallback(chain.rpcUrls.map(url => http(url))),
|
|
56
|
+
transport: fallback(chain.rpcUrls.map(url => http(url, { batch: false }))),
|
|
42
57
|
pollingInterval: config.viemPollingIntervalMS,
|
|
43
58
|
});
|
|
44
59
|
|
|
@@ -46,48 +61,38 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
/**
|
|
49
|
-
* Computes the "current"
|
|
50
|
-
* @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
|
|
51
66
|
*/
|
|
52
|
-
private async
|
|
67
|
+
private async computeCurrentMinFees(): Promise<GasFees> {
|
|
53
68
|
// Since this might be called in the middle of a slot where a block might have been published,
|
|
54
69
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
55
70
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
56
71
|
|
|
57
|
-
const
|
|
72
|
+
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
58
73
|
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
59
|
-
SlotNumber.fromBigInt(
|
|
74
|
+
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
60
75
|
);
|
|
61
76
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
62
77
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
63
78
|
|
|
64
|
-
return new GasFees(0, await this.rollupContract.
|
|
79
|
+
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
65
80
|
}
|
|
66
81
|
|
|
67
|
-
public async
|
|
82
|
+
public async getCurrentMinFees(): Promise<GasFees> {
|
|
68
83
|
// Get the current block number
|
|
69
84
|
const blockNumber = await this.publicClient.getBlockNumber();
|
|
70
85
|
|
|
71
|
-
// 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
|
|
72
87
|
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
73
88
|
this.currentL1BlockNumber = blockNumber;
|
|
74
|
-
this.
|
|
75
|
-
}
|
|
76
|
-
return this.currentBaseFees;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public async getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>> {
|
|
80
|
-
if (!this.chainId) {
|
|
81
|
-
this.chainId = new Fr(this.publicClient.chain.id);
|
|
82
|
-
}
|
|
83
|
-
if (!this.version) {
|
|
84
|
-
this.version = new Fr(await this.rollupContract.getVersion());
|
|
89
|
+
this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
|
|
85
90
|
}
|
|
86
|
-
return
|
|
91
|
+
return this.currentMinFees;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
/**
|
|
90
|
-
* Simple builder of global variables
|
|
95
|
+
* Simple builder of global variables.
|
|
91
96
|
* @param blockNumber - The block number to build global variables for.
|
|
92
97
|
* @param coinbase - The address to receive block reward.
|
|
93
98
|
* @param feeRecipient - The address to receive fees.
|
|
@@ -98,34 +103,35 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
98
103
|
blockNumber: BlockNumber,
|
|
99
104
|
coinbase: EthAddress,
|
|
100
105
|
feeRecipient: AztecAddress,
|
|
101
|
-
|
|
106
|
+
maybeSlot?: SlotNumber,
|
|
102
107
|
): Promise<GlobalVariables> {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
}
|
|
112
117
|
|
|
113
|
-
|
|
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;
|
|
114
125
|
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
const timestamp = getTimestampForSlot(slotNumber, {
|
|
127
|
+
slotDuration: this.aztecSlotDuration,
|
|
128
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
129
|
+
});
|
|
117
130
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
blockNumber,
|
|
122
|
-
slot,
|
|
123
|
-
timestamp,
|
|
124
|
-
coinbase,
|
|
125
|
-
feeRecipient,
|
|
126
|
-
gasFees,
|
|
127
|
-
);
|
|
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));
|
|
128
134
|
|
|
129
|
-
return
|
|
135
|
+
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
130
136
|
}
|
|
131
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,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
2
|
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
3
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
|
|
4
4
|
import {
|
|
@@ -28,7 +28,7 @@ export type TxSenderConfig = L1ReaderConfig & {
|
|
|
28
28
|
* Configuration of the L1Publisher.
|
|
29
29
|
*/
|
|
30
30
|
export type PublisherConfig = L1TxUtilsConfig &
|
|
31
|
-
|
|
31
|
+
BlobClientConfig & {
|
|
32
32
|
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
33
33
|
publisherAllowInvalidStates?: boolean;
|
|
34
34
|
/** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
|
|
@@ -80,7 +80,7 @@ export const getPublisherConfigMappings: (
|
|
|
80
80
|
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
81
81
|
},
|
|
82
82
|
...l1TxUtilsConfigMappings,
|
|
83
|
-
...
|
|
83
|
+
...blobClientConfigMapping,
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
|
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
6
|
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
@@ -33,7 +33,7 @@ export class SequencerPublisherFactory {
|
|
|
33
33
|
private deps: {
|
|
34
34
|
telemetry: TelemetryClient;
|
|
35
35
|
publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
|
|
36
|
-
|
|
36
|
+
blobClient: BlobClientInterface;
|
|
37
37
|
dateProvider: DateProvider;
|
|
38
38
|
epochCache: EpochCache;
|
|
39
39
|
rollupContract: RollupContract;
|
|
@@ -72,7 +72,7 @@ export class SequencerPublisherFactory {
|
|
|
72
72
|
const publisher = new SequencerPublisher(this.sequencerConfig, {
|
|
73
73
|
l1TxUtils: l1Publisher,
|
|
74
74
|
telemetry: this.deps.telemetry,
|
|
75
|
-
|
|
75
|
+
blobClient: this.deps.blobClient,
|
|
76
76
|
rollupContract: this.deps.rollupContract,
|
|
77
77
|
epochCache: this.deps.epochCache,
|
|
78
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) {
|