@aztec/sequencer-client 0.0.1-commit.d3ec352c → 0.0.1-commit.fcb71a6
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 +10 -9
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +32 -25
- package/dest/config.d.ts +12 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +68 -30
- package/dest/global_variable_builder/global_builder.d.ts +18 -9
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +39 -29
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- 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.d.ts +32 -25
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +122 -65
- package/dest/sequencer/block_builder.d.ts +2 -4
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +6 -11
- package/dest/sequencer/checkpoint_builder.d.ts +63 -0
- package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_builder.js +131 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +642 -0
- package/dest/sequencer/checkpoint_voter.d.ts +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +85 -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 +5 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +4 -0
- package/dest/sequencer/metrics.d.ts +22 -2
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +154 -0
- package/dest/sequencer/sequencer.d.ts +93 -127
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +218 -574
- package/dest/sequencer/timetable.d.ts +54 -14
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +148 -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 -2
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +83 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +179 -0
- package/dest/test/utils.d.ts +49 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +94 -0
- package/dest/tx_validator/tx_validator_factory.js +1 -1
- package/package.json +27 -27
- package/src/client/sequencer-client.ts +28 -38
- package/src/config.ts +73 -34
- package/src/global_variable_builder/global_builder.ts +52 -48
- package/src/index.ts +2 -0
- package/src/publisher/config.ts +12 -9
- package/src/publisher/sequencer-publisher-factory.ts +5 -4
- package/src/publisher/sequencer-publisher-metrics.ts +2 -2
- package/src/publisher/sequencer-publisher.ts +180 -84
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/block_builder.ts +7 -12
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +706 -0
- package/src/sequencer/checkpoint_voter.ts +105 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +4 -0
- package/src/sequencer/metrics.ts +203 -1
- package/src/sequencer/sequencer.ts +322 -779
- package/src/sequencer/timetable.ts +173 -79
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +3 -1
- package/src/test/mock_checkpoint_builder.ts +247 -0
- package/src/test/utils.ts +137 -0
- package/src/tx_validator/tx_validator_factory.ts +1 -1
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,12 @@ 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
14
|
import { type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
19
|
-
import
|
|
15
|
+
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
16
|
+
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
20
17
|
|
|
21
18
|
import {
|
|
22
19
|
type PublisherConfig,
|
|
@@ -30,6 +27,31 @@ export type { SequencerConfig };
|
|
|
30
27
|
|
|
31
28
|
export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
|
|
32
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Default values for SequencerConfig.
|
|
32
|
+
* Centralized location for all sequencer configuration defaults.
|
|
33
|
+
*/
|
|
34
|
+
export const DefaultSequencerConfig: ResolvedSequencerConfig = {
|
|
35
|
+
sequencerPollingIntervalMS: 500,
|
|
36
|
+
maxTxsPerBlock: 32,
|
|
37
|
+
minTxsPerBlock: 1,
|
|
38
|
+
buildCheckpointIfEmpty: false,
|
|
39
|
+
publishTxsWithProposals: false,
|
|
40
|
+
maxL2BlockGas: 10e9,
|
|
41
|
+
maxDABlockGas: 10e9,
|
|
42
|
+
maxBlockSizeInBytes: 1024 * 1024,
|
|
43
|
+
enforceTimeTable: true,
|
|
44
|
+
attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
|
|
45
|
+
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
46
|
+
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
47
|
+
skipCollectingAttestations: false,
|
|
48
|
+
skipInvalidateBlockAsProposer: false,
|
|
49
|
+
broadcastInvalidBlockProposal: false,
|
|
50
|
+
injectFakeAttestation: false,
|
|
51
|
+
fishermanMode: false,
|
|
52
|
+
shuffleAttestationOrdering: false,
|
|
53
|
+
};
|
|
54
|
+
|
|
33
55
|
/**
|
|
34
56
|
* Configuration settings for the SequencerClient.
|
|
35
57
|
*/
|
|
@@ -44,35 +66,39 @@ export type SequencerClientConfig = PublisherConfig &
|
|
|
44
66
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
45
67
|
|
|
46
68
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
47
|
-
|
|
48
|
-
env: '
|
|
49
|
-
description: 'The number of ms to wait between polling for
|
|
50
|
-
...numberConfigHelper(
|
|
69
|
+
sequencerPollingIntervalMS: {
|
|
70
|
+
env: 'SEQ_POLLING_INTERVAL_MS',
|
|
71
|
+
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
72
|
+
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
51
73
|
},
|
|
52
74
|
maxTxsPerBlock: {
|
|
53
75
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
54
76
|
description: 'The maximum number of txs to include in a block.',
|
|
55
|
-
...numberConfigHelper(
|
|
77
|
+
...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
|
|
56
78
|
},
|
|
57
79
|
minTxsPerBlock: {
|
|
58
80
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
59
81
|
description: 'The minimum number of txs to include in a block.',
|
|
60
|
-
...numberConfigHelper(
|
|
82
|
+
...numberConfigHelper(DefaultSequencerConfig.minTxsPerBlock),
|
|
83
|
+
},
|
|
84
|
+
minValidTxsPerBlock: {
|
|
85
|
+
description:
|
|
86
|
+
'The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock.',
|
|
61
87
|
},
|
|
62
88
|
publishTxsWithProposals: {
|
|
63
89
|
env: 'SEQ_PUBLISH_TXS_WITH_PROPOSALS',
|
|
64
90
|
description: 'Whether to publish txs with proposals.',
|
|
65
|
-
...booleanConfigHelper(
|
|
91
|
+
...booleanConfigHelper(DefaultSequencerConfig.publishTxsWithProposals),
|
|
66
92
|
},
|
|
67
93
|
maxL2BlockGas: {
|
|
68
94
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
69
95
|
description: 'The maximum L2 block gas.',
|
|
70
|
-
...numberConfigHelper(
|
|
96
|
+
...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
|
|
71
97
|
},
|
|
72
98
|
maxDABlockGas: {
|
|
73
99
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
74
100
|
description: 'The maximum DA block gas.',
|
|
75
|
-
...numberConfigHelper(
|
|
101
|
+
...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
|
|
76
102
|
},
|
|
77
103
|
coinbase: {
|
|
78
104
|
env: 'COINBASE',
|
|
@@ -95,73 +121,86 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
95
121
|
maxBlockSizeInBytes: {
|
|
96
122
|
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
97
123
|
description: 'Max block size',
|
|
98
|
-
...numberConfigHelper(
|
|
124
|
+
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
99
125
|
},
|
|
100
126
|
enforceTimeTable: {
|
|
101
127
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
102
128
|
description: 'Whether to enforce the time table when building blocks',
|
|
103
|
-
...booleanConfigHelper(),
|
|
104
|
-
defaultValue: true,
|
|
129
|
+
...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable),
|
|
105
130
|
},
|
|
106
131
|
governanceProposerPayload: {
|
|
107
132
|
env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
|
|
108
133
|
description: 'The address of the payload for the governanceProposer',
|
|
109
134
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
110
|
-
defaultValue: EthAddress.ZERO,
|
|
111
135
|
},
|
|
112
|
-
|
|
113
|
-
env: '
|
|
114
|
-
description: 'How
|
|
136
|
+
l1PublishingTime: {
|
|
137
|
+
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
138
|
+
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
115
139
|
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
116
140
|
},
|
|
117
141
|
attestationPropagationTime: {
|
|
118
142
|
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
119
143
|
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
|
|
120
|
-
...numberConfigHelper(
|
|
144
|
+
...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
|
|
121
145
|
},
|
|
122
146
|
fakeProcessingDelayPerTxMs: {
|
|
123
147
|
description: 'Used for testing to introduce a fake delay after processing each tx',
|
|
124
148
|
},
|
|
149
|
+
fakeThrowAfterProcessingTxCount: {
|
|
150
|
+
description: 'Used for testing to throw an error after processing N txs',
|
|
151
|
+
},
|
|
125
152
|
secondsBeforeInvalidatingBlockAsCommitteeMember: {
|
|
126
153
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER',
|
|
127
154
|
description:
|
|
128
155
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a committee member (zero to never invalidate).' +
|
|
129
156
|
' The next proposer is expected to invalidate, so the committee acts as a fallback.',
|
|
130
|
-
...numberConfigHelper(
|
|
157
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsCommitteeMember),
|
|
131
158
|
},
|
|
132
159
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: {
|
|
133
160
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER',
|
|
134
161
|
description:
|
|
135
162
|
'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
163
|
' The next proposer is expected to invalidate, then the committee, so other sequencers act as a fallback.',
|
|
137
|
-
...numberConfigHelper(
|
|
164
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsNonCommitteeMember),
|
|
138
165
|
},
|
|
139
166
|
skipCollectingAttestations: {
|
|
140
167
|
description:
|
|
141
168
|
'Whether to skip collecting attestations from validators and only use self-attestations (for testing only)',
|
|
142
|
-
...booleanConfigHelper(
|
|
169
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipCollectingAttestations),
|
|
143
170
|
},
|
|
144
171
|
skipInvalidateBlockAsProposer: {
|
|
145
172
|
description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
|
|
146
|
-
...booleanConfigHelper(
|
|
173
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
|
|
147
174
|
},
|
|
148
175
|
broadcastInvalidBlockProposal: {
|
|
149
176
|
description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
|
|
150
|
-
...booleanConfigHelper(
|
|
177
|
+
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
|
|
151
178
|
},
|
|
152
179
|
injectFakeAttestation: {
|
|
153
180
|
description: 'Inject a fake attestation (for testing only)',
|
|
154
|
-
...booleanConfigHelper(
|
|
181
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
155
182
|
},
|
|
156
183
|
fishermanMode: {
|
|
157
184
|
env: 'FISHERMAN_MODE',
|
|
158
185
|
description:
|
|
159
186
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
160
|
-
...booleanConfigHelper(
|
|
187
|
+
...booleanConfigHelper(DefaultSequencerConfig.fishermanMode),
|
|
161
188
|
},
|
|
162
189
|
shuffleAttestationOrdering: {
|
|
163
190
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
164
|
-
...booleanConfigHelper(
|
|
191
|
+
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
192
|
+
},
|
|
193
|
+
blockDurationMs: {
|
|
194
|
+
env: 'SEQ_BLOCK_DURATION_MS',
|
|
195
|
+
description:
|
|
196
|
+
'Duration per block in milliseconds when building multiple blocks per slot. ' +
|
|
197
|
+
'If undefined (default), builds a single block per slot using the full slot duration.',
|
|
198
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
199
|
+
},
|
|
200
|
+
buildCheckpointIfEmpty: {
|
|
201
|
+
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
202
|
+
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
203
|
+
...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
|
|
165
204
|
},
|
|
166
205
|
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
|
|
167
206
|
};
|
|
@@ -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';
|
|
@@ -27,20 +29,31 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
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
|
|
|
@@ -56,7 +69,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
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 lastBlock = await this.rollupContract.
|
|
72
|
+
const lastBlock = await this.rollupContract.getPendingCheckpoint();
|
|
60
73
|
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
61
74
|
SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
|
|
62
75
|
);
|
|
@@ -78,18 +91,8 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
78
91
|
return this.currentBaseFees;
|
|
79
92
|
}
|
|
80
93
|
|
|
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());
|
|
87
|
-
}
|
|
88
|
-
return { chainId: this.chainId, version: this.version };
|
|
89
|
-
}
|
|
90
|
-
|
|
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;
|
|
125
|
+
|
|
126
|
+
const timestamp = getTimestampForSlot(slotNumber, {
|
|
127
|
+
slotDuration: this.aztecSlotDuration,
|
|
128
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
129
|
+
});
|
|
116
130
|
|
|
117
131
|
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
132
|
+
// TODO(palla/mbps): Can we use a cached value here?
|
|
118
133
|
const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
|
|
119
134
|
|
|
120
|
-
|
|
121
|
-
chainId,
|
|
122
|
-
version,
|
|
123
|
-
blockNumber,
|
|
124
|
-
slot,
|
|
125
|
-
timestamp,
|
|
126
|
-
coinbase,
|
|
127
|
-
feeRecipient,
|
|
128
|
-
gasFees,
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
return globalVariables;
|
|
135
|
+
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
132
136
|
}
|
|
133
137
|
}
|
package/src/index.ts
CHANGED
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,
|
|
@@ -135,7 +135,7 @@ export class SequencerPublisherMetrics {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
recordProcessBlockTx(durationMs: number, stats:
|
|
138
|
+
recordProcessBlockTx(durationMs: number, stats: L1PublishCheckpointStats) {
|
|
139
139
|
this.recordTx('process', durationMs, stats);
|
|
140
140
|
|
|
141
141
|
if (stats.blobCount && stats.blobCount > 0) {
|