@aztec/sequencer-client 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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/README.md +283 -21
- package/dest/client/sequencer-client.d.ts +34 -11
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +77 -39
- package/dest/config.d.ts +34 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +103 -39
- 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 +138 -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 +80 -0
- package/dest/global_variable_builder/global_builder.d.ts +13 -28
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +9 -66
- package/dest/global_variable_builder/index.d.ts +4 -2
- 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 +51 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +131 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
- package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/publisher/l1_to_l2_messaging.js +70 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -3
- package/dest/publisher/sequencer-publisher.d.ts +112 -71
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +571 -392
- package/dest/publisher/write_json.d.ts +11 -0
- package/dest/publisher/write_json.d.ts.map +1 -0
- package/dest/publisher/write_json.js +57 -0
- package/dest/sequencer/automine/automine_factory.d.ts +56 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +85 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +696 -0
- package/dest/sequencer/automine/index.d.ts +3 -0
- package/dest/sequencer/automine/index.d.ts.map +1 -0
- package/dest/sequencer/automine/index.js +2 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +75 -19
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +886 -264
- 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/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/errors.d.ts +1 -8
- package/dest/sequencer/errors.d.ts.map +1 -1
- package/dest/sequencer/errors.js +0 -9
- package/dest/sequencer/events.d.ts +62 -5
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +23 -8
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +117 -21
- package/dest/sequencer/requests_tracker.d.ts +22 -0
- package/dest/sequencer/requests_tracker.d.ts.map +1 -0
- package/dest/sequencer/requests_tracker.js +33 -0
- package/dest/sequencer/sequencer.d.ts +181 -44
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +635 -218
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +5 -7
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +11 -11
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +45 -34
- package/dest/test/utils.d.ts +17 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +28 -9
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +110 -47
- package/src/config.ts +126 -44
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +182 -0
- package/src/global_variable_builder/fee_provider.ts +97 -0
- package/src/global_variable_builder/global_builder.ts +20 -89
- package/src/global_variable_builder/index.ts +3 -1
- package/src/publisher/config.ts +173 -40
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_to_l2_messaging.ts +85 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -9
- package/src/publisher/sequencer-publisher.ts +667 -484
- package/src/publisher/write_json.ts +78 -0
- package/src/sequencer/automine/README.md +60 -0
- package/src/sequencer/automine/automine_factory.ts +152 -0
- package/src/sequencer/automine/automine_sequencer.ts +800 -0
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1073 -290
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/errors.ts +0 -15
- package/src/sequencer/events.ts +66 -5
- package/src/sequencer/metrics.ts +138 -26
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +745 -243
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +4 -6
- package/src/test/mock_checkpoint_builder.ts +63 -49
- package/src/test/utils.ts +64 -10
- package/dest/sequencer/timetable.d.ts +0 -87
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -223
- package/src/sequencer/README.md +0 -531
- package/src/sequencer/timetable.ts +0 -283
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { MAX_FEE_ASSET_PRICE_MODIFIER_BPS } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import { getSlotAtNextL1Block, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
5
|
+
import { FEE_ORACLE_LAG, GasFees, MIN_ETH_PER_FEE_ASSET, ManaUsageEstimate, computeExcessMana, computeManaMinFee } from '@aztec/stdlib/gas';
|
|
6
|
+
/**
|
|
7
|
+
* Predicts min fees for LAG upcoming slots based on the L1 oracle state.
|
|
8
|
+
* A new oracle update can activate at startSlot + LAG, so only the first LAG entries
|
|
9
|
+
* are guaranteed stable. Caches L1 queries per L1 block and recomputes predictions
|
|
10
|
+
* for each mana usage estimate.
|
|
11
|
+
*/ export class FeePredictor {
|
|
12
|
+
rollupContract;
|
|
13
|
+
publicClient;
|
|
14
|
+
dateProvider;
|
|
15
|
+
cachedState;
|
|
16
|
+
cachedL1BlockNumber;
|
|
17
|
+
slotDuration;
|
|
18
|
+
l1GenesisTime;
|
|
19
|
+
ethereumSlotDuration;
|
|
20
|
+
constructor(rollupContract, publicClient, dateProvider, config){
|
|
21
|
+
this.rollupContract = rollupContract;
|
|
22
|
+
this.publicClient = publicClient;
|
|
23
|
+
this.dateProvider = dateProvider;
|
|
24
|
+
this.slotDuration = config.slotDuration;
|
|
25
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
26
|
+
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
27
|
+
}
|
|
28
|
+
/** Returns predicted min fees for each slot in the prediction window. */ async getPredictedMinFees(manaUsage) {
|
|
29
|
+
const state = await this.getState();
|
|
30
|
+
return this.computePredictions(state, manaUsage);
|
|
31
|
+
}
|
|
32
|
+
/** Fetches and caches rollup state. Refreshes when L1 block number advances. */ async getState() {
|
|
33
|
+
const blockNumber = await this.publicClient.getBlockNumber({
|
|
34
|
+
cacheTime: 0
|
|
35
|
+
});
|
|
36
|
+
if (this.cachedL1BlockNumber === undefined || blockNumber > this.cachedL1BlockNumber) {
|
|
37
|
+
this.cachedL1BlockNumber = blockNumber;
|
|
38
|
+
// Reset the cached block number on failure so a transient L1 RPC error does not leave a
|
|
39
|
+
// rejected promise cached for this block, which would replay the same rejection on every
|
|
40
|
+
// subsequent call until the next L1 block arrives. Only clear it if it still points at the
|
|
41
|
+
// block this attempt was for, so a stale rejection from an older block cannot wipe a marker
|
|
42
|
+
// a newer call already advanced (which would also defeat the monotonic block-number guard).
|
|
43
|
+
this.cachedState = this.fetchState(blockNumber).catch((err)=>{
|
|
44
|
+
if (this.cachedL1BlockNumber === blockNumber) {
|
|
45
|
+
this.cachedL1BlockNumber = undefined;
|
|
46
|
+
}
|
|
47
|
+
throw err;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return this.cachedState;
|
|
51
|
+
}
|
|
52
|
+
async fetchState(blockNumber) {
|
|
53
|
+
// Pin all non-constant queries to this L1 block number for a consistent snapshot.
|
|
54
|
+
const opts = {
|
|
55
|
+
blockNumber
|
|
56
|
+
};
|
|
57
|
+
// Cached constants don't need pinning
|
|
58
|
+
const [manaTarget, manaLimit, provingCostPerManaEth, epochDuration] = await Promise.all([
|
|
59
|
+
this.rollupContract.getManaTarget(),
|
|
60
|
+
this.rollupContract.getManaLimit(),
|
|
61
|
+
this.rollupContract.getProvingCostPerMana(),
|
|
62
|
+
this.rollupContract.getEpochDuration()
|
|
63
|
+
]);
|
|
64
|
+
// First, compute the earliest possible nextSlot independently of the checkpoint, so we can
|
|
65
|
+
// evaluate pruneability at the prediction start timestamp instead of the current L1 block time.
|
|
66
|
+
// This avoids an epoch-boundary edge case where the effective parent differs between now and nextSlot.
|
|
67
|
+
const slotConfig = {
|
|
68
|
+
slotDuration: this.slotDuration,
|
|
69
|
+
l1GenesisTime: this.l1GenesisTime
|
|
70
|
+
};
|
|
71
|
+
const currentSlot = await this.rollupContract.getSlotNumber(opts);
|
|
72
|
+
const slotAtNextL1Block = getSlotAtNextL1Block(BigInt(this.dateProvider.nowInSeconds()), {
|
|
73
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
74
|
+
slotDuration: this.slotDuration,
|
|
75
|
+
ethereumSlotDuration: this.ethereumSlotDuration
|
|
76
|
+
});
|
|
77
|
+
const preliminaryNextSlot = SlotNumber(Math.max(currentSlot, slotAtNextL1Block));
|
|
78
|
+
const nextSlotTimestamp = getTimestampForSlot(preliminaryNextSlot, slotConfig);
|
|
79
|
+
// Resolve the effective checkpoint at the prediction start timestamp
|
|
80
|
+
const lastCheckpoint = await this.rollupContract.getEffectivePendingCheckpoint(nextSlotTimestamp, opts);
|
|
81
|
+
const lastSlot = lastCheckpoint.slotNumber;
|
|
82
|
+
// Refine nextSlot: also account for the slot after the last checkpoint
|
|
83
|
+
const nextSlot = SlotNumber(Math.max(SlotNumber.add(lastSlot, 1), preliminaryNextSlot));
|
|
84
|
+
const feeHeader = lastCheckpoint.feeHeader;
|
|
85
|
+
const slotCount = FEE_ORACLE_LAG;
|
|
86
|
+
const timestamps = times(slotCount, (i)=>getTimestampForSlot(SlotNumber.add(nextSlot, i), slotConfig));
|
|
87
|
+
const l1FeesBySlot = await Promise.all(timestamps.map((ts)=>this.rollupContract.getL1FeesAt(ts, opts)));
|
|
88
|
+
return {
|
|
89
|
+
lastSlot,
|
|
90
|
+
excessMana: computeExcessMana(feeHeader.excessMana, feeHeader.manaUsed, manaTarget),
|
|
91
|
+
ethPerFeeAsset: feeHeader.ethPerFeeAsset,
|
|
92
|
+
manaTarget,
|
|
93
|
+
manaLimit,
|
|
94
|
+
provingCostPerManaEth,
|
|
95
|
+
epochDuration: BigInt(epochDuration),
|
|
96
|
+
l1FeesBySlot
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Computes per-slot fee predictions given cached state and a mana usage assumption. */ computePredictions(state, manaUsage) {
|
|
100
|
+
const assumedManaUsed = this.getAssumedManaUsed(state, manaUsage);
|
|
101
|
+
const result = [];
|
|
102
|
+
let { excessMana } = state;
|
|
103
|
+
let { ethPerFeeAsset } = state;
|
|
104
|
+
// Slot 0: current state (next available slot after last checkpoint)
|
|
105
|
+
result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[0]));
|
|
106
|
+
// Slots 1..LAG-1: advance excessMana with the assumed mana usage per checkpoint,
|
|
107
|
+
// and decay ethPerFeeAsset by MAX_FEE_ASSET_PRICE_MODIFIER_BPS per slot for conservative estimates.
|
|
108
|
+
// Lower ethPerFeeAsset means higher fees in fee asset terms.
|
|
109
|
+
for(let i = 1; i < state.l1FeesBySlot.length; i++){
|
|
110
|
+
excessMana = computeExcessMana(excessMana, assumedManaUsed, state.manaTarget);
|
|
111
|
+
const decayed = ethPerFeeAsset * (10000n - MAX_FEE_ASSET_PRICE_MODIFIER_BPS) / 10000n;
|
|
112
|
+
ethPerFeeAsset = decayed < MIN_ETH_PER_FEE_ASSET ? MIN_ETH_PER_FEE_ASSET : decayed;
|
|
113
|
+
result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[i]));
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
getAssumedManaUsed(state, manaUsage) {
|
|
118
|
+
switch(manaUsage){
|
|
119
|
+
case ManaUsageEstimate.None:
|
|
120
|
+
return 0n;
|
|
121
|
+
case ManaUsageEstimate.Target:
|
|
122
|
+
return state.manaTarget;
|
|
123
|
+
case ManaUsageEstimate.Limit:
|
|
124
|
+
return state.manaLimit;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
computeGasFees(state, excessMana, ethPerFeeAsset, l1Fees) {
|
|
128
|
+
return new GasFees(0, computeManaMinFee({
|
|
129
|
+
l1BaseFee: l1Fees.baseFee,
|
|
130
|
+
l1BlobFee: l1Fees.blobFee,
|
|
131
|
+
manaTarget: state.manaTarget,
|
|
132
|
+
epochDuration: state.epochDuration,
|
|
133
|
+
provingCostPerManaEth: state.provingCostPerManaEth,
|
|
134
|
+
excessMana,
|
|
135
|
+
ethPerFeeAsset
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
2
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
4
|
+
import type { FeeProvider } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { GlobalVariableBuilderConfig } from './global_builder.js';
|
|
6
|
+
/** Provides current and predicted fee information based on on-chain state. */
|
|
7
|
+
export declare class FeeProviderImpl implements FeeProvider {
|
|
8
|
+
private readonly dateProvider;
|
|
9
|
+
private readonly publicClient;
|
|
10
|
+
private currentMinFees;
|
|
11
|
+
private currentL1BlockNumber;
|
|
12
|
+
private readonly rollupContract;
|
|
13
|
+
private readonly feePredictor;
|
|
14
|
+
private readonly ethereumSlotDuration;
|
|
15
|
+
private readonly l1GenesisTime;
|
|
16
|
+
constructor(dateProvider: DateProvider, publicClient: ViemPublicClient, config: GlobalVariableBuilderConfig);
|
|
17
|
+
private computeCurrentMinFees;
|
|
18
|
+
getCurrentMinFees(): Promise<GasFees>;
|
|
19
|
+
getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3Byb3ZpZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZ2xvYmFsX3ZhcmlhYmxlX2J1aWxkZXIvZmVlX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFOUQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFNUQsT0FBTyxFQUFFLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQy9ELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR3BELE9BQU8sS0FBSyxFQUFFLDJCQUEyQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFFdkUsOEVBQThFO0FBQzlFLHFCQUFhLGVBQWdCLFlBQVcsV0FBVztJQVUvQyxPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFD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AAO,CAAC,QAAQ,CAAC,YAAY;IAV/B,OAAO,CAAC,cAAc,CAAwD;IAC9E,OAAO,CAAC,oBAAoB,CAAiC;IAE7D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC,YACmB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,gBAAgB,EAC/C,MAAM,EAAE,2BAA2B,EAWpC;YAMa,qBAAqB;IAkBtB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CA2BjD;IAEY,mBAAmB,CAAC,SAAS,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAOlF;CACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { getNextL1SlotTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
4
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
5
|
+
import { FeePredictor } from './fee_predictor.js';
|
|
6
|
+
/** Provides current and predicted fee information based on on-chain state. */ export class FeeProviderImpl {
|
|
7
|
+
dateProvider;
|
|
8
|
+
publicClient;
|
|
9
|
+
currentMinFees;
|
|
10
|
+
currentL1BlockNumber;
|
|
11
|
+
rollupContract;
|
|
12
|
+
feePredictor;
|
|
13
|
+
ethereumSlotDuration;
|
|
14
|
+
l1GenesisTime;
|
|
15
|
+
constructor(dateProvider, publicClient, config){
|
|
16
|
+
this.dateProvider = dateProvider;
|
|
17
|
+
this.publicClient = publicClient;
|
|
18
|
+
this.currentMinFees = Promise.resolve(new GasFees(0, 0));
|
|
19
|
+
this.currentL1BlockNumber = undefined;
|
|
20
|
+
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
21
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
22
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
23
|
+
this.feePredictor = new FeePredictor(this.rollupContract, this.publicClient, this.dateProvider, {
|
|
24
|
+
slotDuration: config.slotDuration,
|
|
25
|
+
l1GenesisTime: config.l1GenesisTime,
|
|
26
|
+
ethereumSlotDuration: config.ethereumSlotDuration
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
31
|
+
* @returns Min fees for the next block
|
|
32
|
+
*/ async computeCurrentMinFees() {
|
|
33
|
+
// Since this might be called in the middle of a slot where a block might have been published,
|
|
34
|
+
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
35
|
+
// The timestamp of that last block will act as a lower bound for the next block.
|
|
36
|
+
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
37
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n));
|
|
38
|
+
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
39
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
40
|
+
ethereumSlotDuration: this.ethereumSlotDuration
|
|
41
|
+
});
|
|
42
|
+
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
43
|
+
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
44
|
+
}
|
|
45
|
+
async getCurrentMinFees() {
|
|
46
|
+
// Get the current block number
|
|
47
|
+
const blockNumber = await this.publicClient.getBlockNumber({
|
|
48
|
+
cacheTime: 0
|
|
49
|
+
});
|
|
50
|
+
// If the L1 block number has changed then chain a new promise to get the current min fees.
|
|
51
|
+
// We chain off the previous promise's settlement (via a swallowing catch) rather than its
|
|
52
|
+
// fulfillment, so a prior rejection does not short-circuit the new computation. If the new
|
|
53
|
+
// computation fails (e.g. a transient L1 RPC error), reset the cached block number so the
|
|
54
|
+
// next call recomputes instead of permanently replaying the rejected promise — otherwise a
|
|
55
|
+
// single transient failure would wedge fee estimation until the next L1 block arrives. Only
|
|
56
|
+
// clear it if it still points at the block this attempt was for, so a stale rejection from an
|
|
57
|
+
// older block cannot wipe a marker a newer call already advanced (which would also defeat the
|
|
58
|
+
// monotonic block-number guard).
|
|
59
|
+
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
60
|
+
this.currentL1BlockNumber = blockNumber;
|
|
61
|
+
this.currentMinFees = this.currentMinFees.catch(()=>undefined).then(()=>this.computeCurrentMinFees().catch((err)=>{
|
|
62
|
+
if (this.currentL1BlockNumber === blockNumber) {
|
|
63
|
+
this.currentL1BlockNumber = undefined;
|
|
64
|
+
}
|
|
65
|
+
throw err;
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
return this.currentMinFees;
|
|
69
|
+
}
|
|
70
|
+
async getPredictedMinFees(manaUsage) {
|
|
71
|
+
const [currentMinFees, predictedMinFees] = await Promise.all([
|
|
72
|
+
this.getCurrentMinFees(),
|
|
73
|
+
this.feePredictor.getPredictedMinFees(manaUsage ?? ManaUsageEstimate.Target)
|
|
74
|
+
]);
|
|
75
|
+
return [
|
|
76
|
+
currentMinFees,
|
|
77
|
+
...predictedMinFees
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import { type SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
7
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
8
7
|
import type { CheckpointGlobalVariables, GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
|
|
9
|
-
|
|
8
|
+
/** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
|
|
9
|
+
export type GlobalVariableBuilderConfig = {
|
|
10
|
+
rollupAddress: EthAddress;
|
|
11
|
+
ethereumSlotDuration: number;
|
|
12
|
+
rollupVersion: bigint;
|
|
13
|
+
} & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
|
|
10
14
|
/**
|
|
11
15
|
* Simple global variables builder.
|
|
12
16
|
*/
|
|
13
17
|
export declare class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
14
|
-
private log;
|
|
15
|
-
private currentMinFees;
|
|
16
|
-
private currentL1BlockNumber;
|
|
17
|
-
private readonly rollupContract;
|
|
18
18
|
private readonly publicClient;
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly rollupContract;
|
|
20
20
|
private readonly aztecSlotDuration;
|
|
21
21
|
private readonly l1GenesisTime;
|
|
22
22
|
private chainId;
|
|
23
23
|
private version;
|
|
24
|
-
constructor(
|
|
25
|
-
rollupVersion: bigint;
|
|
26
|
-
});
|
|
27
|
-
private computeCurrentMinFees;
|
|
28
|
-
getCurrentMinFees(): Promise<GasFees>;
|
|
29
|
-
/**
|
|
30
|
-
* Simple builder of global variables.
|
|
31
|
-
* @param blockNumber - The block number to build global variables for.
|
|
32
|
-
* @param coinbase - The address to receive block reward.
|
|
33
|
-
* @param feeRecipient - The address to receive fees.
|
|
34
|
-
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
35
|
-
* @returns The global variables for the given block number.
|
|
36
|
-
*/
|
|
37
|
-
buildGlobalVariables(blockNumber: BlockNumber, coinbase: EthAddress, feeRecipient: AztecAddress, maybeSlot?: SlotNumber): Promise<GlobalVariables>;
|
|
24
|
+
constructor(publicClient: ViemPublicClient, config: GlobalVariableBuilderConfig);
|
|
38
25
|
/** Builds global variables that are constant throughout a checkpoint. */
|
|
39
|
-
buildCheckpointGlobalVariables(coinbase: EthAddress, feeRecipient: AztecAddress, slotNumber: SlotNumber): Promise<CheckpointGlobalVariables
|
|
40
|
-
timestamp: bigint;
|
|
41
|
-
}>;
|
|
26
|
+
buildCheckpointGlobalVariables(coinbase: EthAddress, feeRecipient: AztecAddress, slotNumber: SlotNumber, simulationOverridesPlan?: SimulationOverridesPlan): Promise<CheckpointGlobalVariables>;
|
|
42
27
|
}
|
|
43
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYmFsX2J1aWxkZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nbG9iYWxfdmFyaWFibGVfYnVpbGRlci9nbG9iYWxfYnVpbGRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBRUwsS0FBSyx1QkFBdUIsRUFFN0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRWxFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBRSxLQUFLLGlCQUFpQixFQUF1QixNQUFNLDZCQUE2QixDQUFDO0FBRTFGLE9BQU8sS0FBSyxFQUNWLHlCQUF5QixFQUN6QixxQkFBcUIsSUFBSSw4QkFBOEIsRUFDeEQsTUFBTSxrQkFBa0IsQ0FBQztBQUUxQiwrRUFBK0U7QUFDL0UsTUFBTSxNQUFNLDJCQUEyQixHQUFHO0lBQ3hDLGFBQWEsRUFBRSxVQUFVLENBQUM7SUFDMUIsb0JBQW9CLEVBQUUsTUFBTSxDQUFDO0lBQzdCLGFBQWEsRUFBRSxNQUFNLENBQUM7Q0FDdkIsR0FBRyxJQUFJLENBQUMsaUJBQWlCLEVBQUUsY0FBYyxHQUFHLGVBQWUsQ0FBQyxDQUFDO0FBRTlEOztHQUVHO0FBQ0gscUJBQWEscUJBQXNCLFlBQVcsOEJBQThCO0lBU3hFLE9BQU8sQ0FBQyxRQUFRLENBQUMsWUFBWTtJQVIvQixPQUFPLENBQUMsUUFBUSxDQUFDLGNBQWMsQ0FBaUI7SUFDaEQsT0FBTyxDQUFDLFFBQVEsQ0FBQyxpQkFBaUIsQ0FBUztJQUMzQyxPQUFPLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBUztJQUV2QyxPQUFPLENBQUMsT0FBTyxDQUFLO0lBQ3BCLE9BQU8sQ0FBQyxPQUFPLENBQUs7SUFFcEIsWUFDbUIsWUFBWSxFQUFFLGdCQUFnQixFQUMvQyxNQUFNLEVBQUUsMkJBQTJCLEVBU3BDO0lBRUQseUVBQXlFO0lBQzVELDhCQUE4QixDQUN6QyxRQUFRLEVBQUUsVUFBVSxFQUNwQixZQUFZLEVBQUUsWUFBWSxFQUMxQixVQUFVLEVBQUUsVUFBVSxFQUN0Qix1QkFBdUIsQ0FBQyxFQUFFLHVCQUF1QixHQUNoRCxPQUFPLENBQUMseUJBQXlCLENBQUMsQ0FZcEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/global_builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_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 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { RollupContract, buildSimulationOverridesStateOverride } from '@aztec/ethereum/contracts';
|
|
4
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
3
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
7
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
8
|
-
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
9
|
-
import { createPublicClient, fallback, http } from 'viem';
|
|
10
5
|
/**
|
|
11
6
|
* Simple global variables builder.
|
|
12
7
|
*/ export class GlobalVariableBuilder {
|
|
13
|
-
log = createLogger('sequencer:global_variable_builder');
|
|
14
|
-
currentMinFees = Promise.resolve(new GasFees(0, 0));
|
|
15
|
-
currentL1BlockNumber = undefined;
|
|
16
|
-
rollupContract;
|
|
17
8
|
publicClient;
|
|
18
|
-
|
|
9
|
+
rollupContract;
|
|
19
10
|
aztecSlotDuration;
|
|
20
11
|
l1GenesisTime;
|
|
21
12
|
chainId;
|
|
22
13
|
version;
|
|
23
|
-
constructor(config){
|
|
24
|
-
|
|
25
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
14
|
+
constructor(publicClient, config){
|
|
15
|
+
this.publicClient = publicClient;
|
|
26
16
|
this.version = new Fr(config.rollupVersion);
|
|
27
|
-
this.chainId = new Fr(
|
|
28
|
-
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
17
|
+
this.chainId = new Fr(this.publicClient.chain.id);
|
|
29
18
|
this.aztecSlotDuration = config.slotDuration;
|
|
30
19
|
this.l1GenesisTime = config.l1GenesisTime;
|
|
31
|
-
this.
|
|
32
|
-
chain: chain.chainInfo,
|
|
33
|
-
transport: fallback(chain.rpcUrls.map((url)=>http(url, {
|
|
34
|
-
batch: false
|
|
35
|
-
}))),
|
|
36
|
-
pollingInterval: config.viemPollingIntervalMS
|
|
37
|
-
});
|
|
38
|
-
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
42
|
-
* @returns Min fees for the next block
|
|
43
|
-
*/ async computeCurrentMinFees() {
|
|
44
|
-
// Since this might be called in the middle of a slot where a block might have been published,
|
|
45
|
-
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
46
|
-
// The timestamp of that last block will act as a lower bound for the next block.
|
|
47
|
-
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
48
|
-
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n));
|
|
49
|
-
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
50
|
-
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
51
|
-
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
52
|
-
}
|
|
53
|
-
async getCurrentMinFees() {
|
|
54
|
-
// Get the current block number
|
|
55
|
-
const blockNumber = await this.publicClient.getBlockNumber();
|
|
56
|
-
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
57
|
-
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
58
|
-
this.currentL1BlockNumber = blockNumber;
|
|
59
|
-
this.currentMinFees = this.currentMinFees.then(()=>this.computeCurrentMinFees());
|
|
60
|
-
}
|
|
61
|
-
return this.currentMinFees;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Simple builder of global variables.
|
|
65
|
-
* @param blockNumber - The block number to build global variables for.
|
|
66
|
-
* @param coinbase - The address to receive block reward.
|
|
67
|
-
* @param feeRecipient - The address to receive fees.
|
|
68
|
-
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
69
|
-
* @returns The global variables for the given block number.
|
|
70
|
-
*/ async buildGlobalVariables(blockNumber, coinbase, feeRecipient, maybeSlot) {
|
|
71
|
-
const slot = maybeSlot ?? await this.rollupContract.getSlotAt(BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)));
|
|
72
|
-
const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
|
|
73
|
-
return GlobalVariables.from({
|
|
74
|
-
blockNumber,
|
|
75
|
-
...checkpointGlobalVariables
|
|
76
|
-
});
|
|
20
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
77
21
|
}
|
|
78
|
-
/** Builds global variables that are constant throughout a checkpoint. */ async buildCheckpointGlobalVariables(coinbase, feeRecipient, slotNumber) {
|
|
22
|
+
/** Builds global variables that are constant throughout a checkpoint. */ async buildCheckpointGlobalVariables(coinbase, feeRecipient, slotNumber, simulationOverridesPlan) {
|
|
79
23
|
const { chainId, version } = this;
|
|
80
24
|
const timestamp = getTimestampForSlot(slotNumber, {
|
|
81
25
|
slotDuration: this.aztecSlotDuration,
|
|
82
26
|
l1GenesisTime: this.l1GenesisTime
|
|
83
27
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
28
|
+
const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
29
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
87
30
|
return {
|
|
88
31
|
chainId,
|
|
89
32
|
version,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export { FeeProviderImpl } from './fee_provider.js';
|
|
2
|
+
export { GlobalVariableBuilder, type GlobalVariableBuilderConfig } from './global_builder.js';
|
|
3
|
+
export { FeePredictor } from './fee_predictor.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nbG9iYWxfdmFyaWFibGVfYnVpbGRlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDcEQsT0FBTyxFQUFFLHFCQUFxQixFQUFFLEtBQUssMkJBQTJCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUM5RixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,KAAK,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -3,22 +3,24 @@ import { type L1ReaderConfig } from '@aztec/ethereum/l1-reader';
|
|
|
3
3
|
import { type L1TxUtilsConfig } from '@aztec/ethereum/l1-tx-utils/config';
|
|
4
4
|
import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
|
|
5
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
-
/**
|
|
7
|
-
* The configuration of the rollup transaction publisher.
|
|
8
|
-
*/
|
|
6
|
+
/** Configuration of the transaction publisher. */
|
|
9
7
|
export type TxSenderConfig = L1ReaderConfig & {
|
|
10
|
-
/**
|
|
11
|
-
* The private key to be used by the publisher.
|
|
12
|
-
*/
|
|
8
|
+
/** The private key to be used by the publisher. */
|
|
13
9
|
publisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
14
|
-
/**
|
|
15
|
-
* Publisher addresses to be used with a remote signer
|
|
16
|
-
*/
|
|
10
|
+
/** Publisher addresses to be used with a remote signer */
|
|
17
11
|
publisherAddresses?: EthAddress[];
|
|
18
12
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
export type ProverTxSenderConfig = L1ReaderConfig & {
|
|
14
|
+
proverPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
15
|
+
proverPublisherAddresses?: EthAddress[];
|
|
16
|
+
};
|
|
17
|
+
export type SequencerTxSenderConfig = L1ReaderConfig & {
|
|
18
|
+
sequencerPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
19
|
+
sequencerPublisherAddresses?: EthAddress[];
|
|
20
|
+
};
|
|
21
|
+
export declare function getTxSenderConfigFromProverConfig(config: ProverTxSenderConfig): TxSenderConfig;
|
|
22
|
+
export declare function getTxSenderConfigFromSequencerConfig(config: SequencerTxSenderConfig): TxSenderConfig;
|
|
23
|
+
/** Configuration of the L1Publisher. */
|
|
22
24
|
export type PublisherConfig = L1TxUtilsConfig & BlobClientConfig & {
|
|
23
25
|
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
24
26
|
publisherAllowInvalidStates?: boolean;
|
|
@@ -26,9 +28,41 @@ export type PublisherConfig = L1TxUtilsConfig & BlobClientConfig & {
|
|
|
26
28
|
fishermanMode?: boolean;
|
|
27
29
|
/** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
|
|
28
30
|
publisherForwarderAddress?: EthAddress;
|
|
31
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
32
|
+
l1TxFailedStore?: string;
|
|
33
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
34
|
+
publisherFundingThreshold?: bigint;
|
|
35
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
36
|
+
publisherFundingAmount?: bigint;
|
|
37
|
+
};
|
|
38
|
+
export type ProverPublisherConfig = L1TxUtilsConfig & BlobClientConfig & {
|
|
39
|
+
fishermanMode?: boolean;
|
|
40
|
+
proverPublisherAllowInvalidStates?: boolean;
|
|
41
|
+
proverPublisherForwarderAddress?: EthAddress;
|
|
42
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
43
|
+
publisherFundingThreshold?: bigint;
|
|
44
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
45
|
+
publisherFundingAmount?: bigint;
|
|
46
|
+
};
|
|
47
|
+
export type SequencerPublisherConfig = L1TxUtilsConfig & BlobClientConfig & {
|
|
48
|
+
fishermanMode?: boolean;
|
|
49
|
+
sequencerPublisherAllowInvalidStates?: boolean;
|
|
50
|
+
sequencerPublisherForwarderAddress?: EthAddress;
|
|
51
|
+
/** How long to wait for the previous L1 block before sending scheduled publisher txs anyway. */
|
|
52
|
+
sequencerPublisherPreviousL1BlockWaitTimeoutMs: number;
|
|
53
|
+
/** Poll interval while waiting for the previous L1 block before scheduled publisher txs. */
|
|
54
|
+
sequencerPublisherPreviousL1BlockWaitPollIntervalMs: number;
|
|
55
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
56
|
+
l1TxFailedStore?: string;
|
|
57
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
58
|
+
publisherFundingThreshold?: bigint;
|
|
59
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
60
|
+
publisherFundingAmount?: bigint;
|
|
29
61
|
};
|
|
30
|
-
export declare
|
|
31
|
-
export declare function
|
|
32
|
-
export declare const
|
|
33
|
-
export declare
|
|
34
|
-
|
|
62
|
+
export declare function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig;
|
|
63
|
+
export declare function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig;
|
|
64
|
+
export declare const proverTxSenderConfigMappings: ConfigMappingsType<ProverTxSenderConfig>;
|
|
65
|
+
export declare const sequencerTxSenderConfigMappings: ConfigMappingsType<SequencerTxSenderConfig>;
|
|
66
|
+
export declare const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig>;
|
|
67
|
+
export declare const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig>;
|
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBMkIsTUFBTSxrQ0FBa0MsQ0FBQztBQUNsRyxPQUFPLEVBQUUsS0FBSyxjQUFjLEVBQTBCLE1BQU0sMkJBQTJCLENBQUM7QUFDeEYsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUEyQixNQUFNLG9DQUFvQyxDQUFDO0FBQ25HLE9BQU8sRUFDTCxLQUFLLGtCQUFrQixFQUN2QixXQUFXLEVBR1osTUFBTSwwQkFBMEIsQ0FBQztBQUNsQyxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFJM0Qsa0RBQWtEO0FBQ2xELE1BQU0sTUFBTSxjQUFjLEdBQUcsY0FBYyxHQUFHO0lBQzVDLG1EQUFtRDtJQUNuRCxvQkFBb0IsQ0FBQyxFQUFFLFdBQVcsQ0FBQyxLQUFLLE1BQU0sRUFBRSxDQUFDLEVBQUU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LENBT3ZHO0FBRUQsZUFBTyxNQUFNLDRCQUE0QixFQUFFLGtCQUFrQixDQUFDLG9CQUFvQixDQWdCakYsQ0FBQztBQUVGLGVBQU8sTUFBTSwrQkFBK0IsRUFBRSxrQkFBa0IsQ0FBQyx1QkFBdUIsQ0FnQnZGLENBQUM7QUFFRixlQUFPLE1BQU0sZ0NBQWdDLEVBQUUsa0JBQWtCLENBQUMsd0JBQXdCLEdBQUcsZUFBZSxDQW9DM0csQ0FBQztBQUVGLGVBQU8sTUFBTSw2QkFBNkIsRUFBRSxrQkFBa0IsQ0FBQyxxQkFBcUIsR0FBRyxlQUFlLENBb0JyRyxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/publisher/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,KAAK,eAAe,EAA2B,MAAM,oCAAoC,CAAC;AACnG,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/publisher/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,KAAK,eAAe,EAA2B,MAAM,oCAAoC,CAAC;AACnG,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG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