@aztec/sequencer-client 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942
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 +3 -1
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +3 -4
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +8 -11
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +128 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +58 -0
- package/dest/global_variable_builder/global_builder.d.ts +4 -9
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +3 -41
- package/dest/global_variable_builder/index.d.ts +3 -1
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/publisher/config.d.ts +1 -1
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +2 -2
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +3 -4
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +1 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +0 -1
- package/dest/publisher/sequencer-publisher.d.ts +16 -35
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +60 -92
- package/dest/sequencer/chain_state_overrides.d.ts +25 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +39 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +27 -22
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +294 -155
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/events.d.ts +6 -1
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +7 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +27 -20
- package/dest/sequencer/sequencer.d.ts +5 -2
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +31 -23
- package/dest/sequencer/timetable.d.ts +14 -1
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +45 -36
- package/package.json +27 -27
- package/src/client/sequencer-client.ts +5 -7
- package/src/config.ts +8 -11
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +172 -0
- package/src/global_variable_builder/fee_provider.ts +75 -0
- package/src/global_variable_builder/global_builder.ts +7 -54
- package/src/global_variable_builder/index.ts +2 -0
- package/src/publisher/config.ts +6 -4
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +3 -1
- package/src/publisher/sequencer-publisher-factory.ts +0 -3
- package/src/publisher/sequencer-publisher.ts +106 -152
- package/src/sequencer/README.md +83 -13
- package/src/sequencer/chain_state_overrides.ts +87 -0
- package/src/sequencer/checkpoint_proposal_job.ts +365 -205
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/events.ts +5 -0
- package/src/sequencer/metrics.ts +35 -25
- package/src/sequencer/sequencer.ts +44 -26
- package/src/sequencer/timetable.ts +57 -45
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { getNextL1SlotTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
7
|
+
import type { FeeProvider } from '@aztec/stdlib/tx';
|
|
8
|
+
|
|
9
|
+
import { FeePredictor } from './fee_predictor.js';
|
|
10
|
+
import type { GlobalVariableBuilderConfig } from './global_builder.js';
|
|
11
|
+
|
|
12
|
+
/** Provides current and predicted fee information based on on-chain state. */
|
|
13
|
+
export class FeeProviderImpl implements FeeProvider {
|
|
14
|
+
private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
15
|
+
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
16
|
+
|
|
17
|
+
private readonly rollupContract: RollupContract;
|
|
18
|
+
private readonly feePredictor: FeePredictor;
|
|
19
|
+
private readonly ethereumSlotDuration: number;
|
|
20
|
+
private readonly l1GenesisTime: bigint;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly dateProvider: DateProvider,
|
|
24
|
+
private readonly publicClient: ViemPublicClient,
|
|
25
|
+
config: GlobalVariableBuilderConfig,
|
|
26
|
+
) {
|
|
27
|
+
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
28
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
29
|
+
|
|
30
|
+
this.rollupContract = new RollupContract(this.publicClient, config.l1Contracts.rollupAddress);
|
|
31
|
+
this.feePredictor = new FeePredictor(this.rollupContract, this.publicClient, this.dateProvider, {
|
|
32
|
+
slotDuration: config.slotDuration,
|
|
33
|
+
l1GenesisTime: config.l1GenesisTime,
|
|
34
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
40
|
+
* @returns Min fees for the next block
|
|
41
|
+
*/
|
|
42
|
+
private async computeCurrentMinFees(): Promise<GasFees> {
|
|
43
|
+
// Since this might be called in the middle of a slot where a block might have been published,
|
|
44
|
+
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
45
|
+
// The timestamp of that last block will act as a lower bound for the next block.
|
|
46
|
+
|
|
47
|
+
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
48
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
49
|
+
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
50
|
+
);
|
|
51
|
+
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
52
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
53
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
54
|
+
});
|
|
55
|
+
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
56
|
+
|
|
57
|
+
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public async getCurrentMinFees(): Promise<GasFees> {
|
|
61
|
+
// Get the current block number
|
|
62
|
+
const blockNumber = await this.publicClient.getBlockNumber();
|
|
63
|
+
|
|
64
|
+
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
65
|
+
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
66
|
+
this.currentL1BlockNumber = blockNumber;
|
|
67
|
+
this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
|
|
68
|
+
}
|
|
69
|
+
return this.currentMinFees;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
|
|
73
|
+
return this.feePredictor.getPredictedMinFees(manaUsage ?? ManaUsageEstimate.Target);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
RollupContract,
|
|
3
|
+
type SimulationOverridesPlan,
|
|
4
|
+
buildSimulationOverridesStateOverride,
|
|
5
|
+
} from '@aztec/ethereum/contracts';
|
|
2
6
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
7
|
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
4
8
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
5
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
10
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
8
11
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
9
12
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
13
|
import { type L1RollupConstants, getNextL1SlotTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
11
14
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
12
15
|
import type {
|
|
13
|
-
BuildCheckpointGlobalVariablesOpts,
|
|
14
16
|
CheckpointGlobalVariables,
|
|
15
17
|
GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
16
18
|
} from '@aztec/stdlib/tx';
|
|
@@ -27,10 +29,6 @@ export type GlobalVariableBuilderConfig = {
|
|
|
27
29
|
* Simple global variables builder.
|
|
28
30
|
*/
|
|
29
31
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
30
|
-
private log = createLogger('sequencer:global_variable_builder');
|
|
31
|
-
private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
32
|
-
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
33
|
-
|
|
34
32
|
private readonly rollupContract: RollupContract;
|
|
35
33
|
private readonly ethereumSlotDuration: number;
|
|
36
34
|
private readonly aztecSlotDuration: number;
|
|
@@ -54,40 +52,6 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
54
52
|
this.rollupContract = new RollupContract(this.publicClient, config.l1Contracts.rollupAddress);
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
/**
|
|
58
|
-
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
59
|
-
* @returns Min fees for the next block
|
|
60
|
-
*/
|
|
61
|
-
private async computeCurrentMinFees(): Promise<GasFees> {
|
|
62
|
-
// Since this might be called in the middle of a slot where a block might have been published,
|
|
63
|
-
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
64
|
-
// The timestamp of that last block will act as a lower bound for the next block.
|
|
65
|
-
|
|
66
|
-
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
67
|
-
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
68
|
-
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
69
|
-
);
|
|
70
|
-
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
71
|
-
l1GenesisTime: this.l1GenesisTime,
|
|
72
|
-
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
73
|
-
});
|
|
74
|
-
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
75
|
-
|
|
76
|
-
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public async getCurrentMinFees(): Promise<GasFees> {
|
|
80
|
-
// Get the current block number
|
|
81
|
-
const blockNumber = await this.publicClient.getBlockNumber();
|
|
82
|
-
|
|
83
|
-
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
84
|
-
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
85
|
-
this.currentL1BlockNumber = blockNumber;
|
|
86
|
-
this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
|
|
87
|
-
}
|
|
88
|
-
return this.currentMinFees;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
55
|
/**
|
|
92
56
|
* Simple builder of global variables.
|
|
93
57
|
* @param blockNumber - The block number to build global variables for.
|
|
@@ -120,7 +84,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
120
84
|
coinbase: EthAddress,
|
|
121
85
|
feeRecipient: AztecAddress,
|
|
122
86
|
slotNumber: SlotNumber,
|
|
123
|
-
|
|
87
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
124
88
|
): Promise<CheckpointGlobalVariables> {
|
|
125
89
|
const { chainId, version } = this;
|
|
126
90
|
|
|
@@ -129,18 +93,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
129
93
|
l1GenesisTime: this.l1GenesisTime,
|
|
130
94
|
});
|
|
131
95
|
|
|
132
|
-
|
|
133
|
-
// the fee computation matches what L1 will see when the previous pipelined checkpoint has landed.
|
|
134
|
-
const pendingNumberOverride = await this.rollupContract.makePendingCheckpointNumberOverride(
|
|
135
|
-
opts?.forcePendingCheckpointNumber,
|
|
136
|
-
);
|
|
137
|
-
const feeHeaderOverride = opts?.forceProposedFeeHeader
|
|
138
|
-
? await this.rollupContract.makeFeeHeaderOverride(
|
|
139
|
-
opts.forceProposedFeeHeader.checkpointNumber,
|
|
140
|
-
opts.forceProposedFeeHeader.feeHeader,
|
|
141
|
-
)
|
|
142
|
-
: [];
|
|
143
|
-
const stateOverride = RollupContract.mergeStateOverrides(pendingNumberOverride, feeHeaderOverride);
|
|
96
|
+
const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
144
97
|
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
145
98
|
|
|
146
99
|
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
package/src/publisher/config.ts
CHANGED
|
@@ -120,7 +120,8 @@ export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSende
|
|
|
120
120
|
proverPublisherPrivateKeys: {
|
|
121
121
|
env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
|
|
122
122
|
description: 'The private keys to be used by the prover publisher.',
|
|
123
|
-
parseEnv: (val: string) =>
|
|
123
|
+
parseEnv: (val: string) =>
|
|
124
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
124
125
|
defaultValue: [],
|
|
125
126
|
fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
|
|
126
127
|
},
|
|
@@ -137,7 +138,8 @@ export const sequencerTxSenderConfigMappings: ConfigMappingsType<Omit<SequencerT
|
|
|
137
138
|
sequencerPublisherPrivateKeys: {
|
|
138
139
|
env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
139
140
|
description: 'The private keys to be used by the sequencer publisher.',
|
|
140
|
-
parseEnv: (val: string) =>
|
|
141
|
+
parseEnv: (val: string) =>
|
|
142
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
141
143
|
defaultValue: [],
|
|
142
144
|
fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
143
145
|
},
|
|
@@ -166,7 +168,7 @@ export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPubli
|
|
|
166
168
|
sequencerPublisherForwarderAddress: {
|
|
167
169
|
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
168
170
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
169
|
-
parseEnv: (val: string) =>
|
|
171
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
170
172
|
},
|
|
171
173
|
l1TxFailedStore: {
|
|
172
174
|
env: 'L1_TX_FAILED_STORE',
|
|
@@ -192,7 +194,7 @@ export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherCo
|
|
|
192
194
|
proverPublisherForwarderAddress: {
|
|
193
195
|
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
194
196
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
195
|
-
parseEnv: (val: string) =>
|
|
197
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
196
198
|
},
|
|
197
199
|
...publisherFundingConfigMappings,
|
|
198
200
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Branded } from '@aztec/foundation/branded-types';
|
|
2
|
+
|
|
1
3
|
import type { Hex } from 'viem';
|
|
2
4
|
|
|
3
5
|
/** URI pointing to a stored failed L1 transaction. */
|
|
4
|
-
export type FailedL1TxUri = string
|
|
6
|
+
export type FailedL1TxUri = Branded<string, 'FailedL1TxUri'>;
|
|
5
7
|
|
|
6
8
|
/** A failed L1 transaction captured for debugging and replay. */
|
|
7
9
|
export type FailedL1Tx = {
|
|
@@ -7,7 +7,6 @@ import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
|
7
7
|
import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
8
8
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
9
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
-
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
11
10
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
12
11
|
import { NodeKeystoreAdapter } from '@aztec/validator-client';
|
|
13
12
|
|
|
@@ -40,7 +39,6 @@ export class SequencerPublisherFactory {
|
|
|
40
39
|
epochCache: EpochCache;
|
|
41
40
|
rollupContract: RollupContract;
|
|
42
41
|
governanceProposerContract: GovernanceProposerContract;
|
|
43
|
-
slashFactoryContract: SlashFactoryContract;
|
|
44
42
|
nodeKeyStore: NodeKeystoreAdapter;
|
|
45
43
|
logger?: Logger;
|
|
46
44
|
},
|
|
@@ -104,7 +102,6 @@ export class SequencerPublisherFactory {
|
|
|
104
102
|
epochCache: this.deps.epochCache,
|
|
105
103
|
governanceProposerContract: this.deps.governanceProposerContract,
|
|
106
104
|
slashingProposerContract,
|
|
107
|
-
slashFactoryContract: this.deps.slashFactoryContract,
|
|
108
105
|
dateProvider: this.deps.dateProvider,
|
|
109
106
|
metrics: this.publisherMetrics,
|
|
110
107
|
lastActions: this.lastActions,
|