@aztec/sequencer-client 5.0.0-rc.1 → 5.0.0-rc.2
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/config.js +1 -1
- package/dest/global_variable_builder/global_builder.d.ts +3 -16
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +2 -25
- package/dest/publisher/config.d.ts +5 -1
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +11 -1
- package/dest/publisher/sequencer-publisher.d.ts +17 -4
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +113 -20
- package/dest/sequencer/automine/automine_sequencer.d.ts +8 -3
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -1
- package/dest/sequencer/automine/automine_sequencer.js +16 -4
- package/dest/sequencer/checkpoint_proposal_job.d.ts +1 -1
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +2 -3
- package/dest/sequencer/sequencer.d.ts +9 -7
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +46 -41
- package/dest/test/utils.d.ts +1 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +1 -1
- package/package.json +27 -27
- package/src/config.ts +1 -1
- package/src/global_variable_builder/global_builder.ts +2 -34
- package/src/publisher/config.ts +22 -1
- package/src/publisher/sequencer-publisher.ts +108 -21
- package/src/sequencer/automine/automine_sequencer.ts +16 -4
- package/src/sequencer/checkpoint_proposal_job.ts +3 -5
- package/src/sequencer/sequencer.ts +52 -48
- package/src/test/utils.ts +1 -0
- package/dest/sequencer/chain_state_overrides.d.ts +0 -61
- package/dest/sequencer/chain_state_overrides.d.ts.map +0 -1
- package/dest/sequencer/chain_state_overrides.js +0 -98
- package/src/sequencer/chain_state_overrides.ts +0 -169
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { RollupContract, SimulationOverridesBuilder } from '@aztec/ethereum/contracts';
|
|
2
|
-
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
-
import { computeCheckpointPayloadDigest } from '@aztec/stdlib/checkpoint';
|
|
4
|
-
/**
|
|
5
|
-
* Builds the SimulationOverridesPlan describing the simulated L1 rollup state for a checkpoint's
|
|
6
|
-
* enqueue-time simulations: `canProposeAt` (in Sequencer.doWork) and the propose-related sims
|
|
7
|
-
* (validateBlockHeader, simulateProposeTx). The plan reflects "as if our pipelined parent
|
|
8
|
-
* checkpoint has landed and any required invalidation has executed" — the gap that needs to be
|
|
9
|
-
* bridged at enqueue time.
|
|
10
|
-
*
|
|
11
|
-
* Pipelining (`proposedCheckpointData`) and invalidation (`invalidateToPendingCheckpointNumber`)
|
|
12
|
-
* are mutually exclusive; passing both throws.
|
|
13
|
-
*/ export async function buildCheckpointSimulationOverridesPlan(input) {
|
|
14
|
-
if (input.proposedCheckpointData && input.invalidateToPendingCheckpointNumber !== undefined) {
|
|
15
|
-
throw new Error('Error in buildCheckpointSimulationOverridesPlan: proposedCheckpointData and invalidateToPendingCheckpointNumber are mutually exclusive');
|
|
16
|
-
}
|
|
17
|
-
const builder = new SimulationOverridesBuilder();
|
|
18
|
-
const pendingCheckpointNumber = derivePendingCheckpointNumber(input);
|
|
19
|
-
// Override the latest checkpoint number when invalidating or pipelining, so our checkpoint
|
|
20
|
-
// follows from it. We also override the proven chain tip so we dont need to worry about
|
|
21
|
-
// prunes kicking in that would break out simulation if there's a prune pending. We always
|
|
22
|
-
// assume that a proof will land in time. If we don't have a pending checkpoint number to force,
|
|
23
|
-
// we still set both tips to the current checkpoint number to avoid the prune trigger.
|
|
24
|
-
const overridenChainTip = pendingCheckpointNumber ?? input.checkpointedCheckpointNumber;
|
|
25
|
-
builder.withChainTips({
|
|
26
|
-
pending: overridenChainTip,
|
|
27
|
-
proven: overridenChainTip
|
|
28
|
-
});
|
|
29
|
-
if (input.proposedCheckpointData) {
|
|
30
|
-
const { header, archive, checkpointOutHash, feeAssetPriceModifier } = input.proposedCheckpointData;
|
|
31
|
-
builder.withPendingArchive(archive.root);
|
|
32
|
-
// Override every locally-derivable `tempCheckpointLogs[parent]` field that L1 will eventually
|
|
33
|
-
// write. `slotNumber` is load-bearing for `STFLib.canPruneAtTime`: without it the cell reads
|
|
34
|
-
// slotNumber 0, the contract treats the pending tip as belonging to an expired epoch, and
|
|
35
|
-
// `getEffectivePendingCheckpointNumber` silently collapses pending back to proven — producing
|
|
36
|
-
// a spurious `Rollup__InvalidArchive` against the on-chain genesis archive. The other fields
|
|
37
|
-
// (headerHash, outHash, payloadDigest) are not strictly load-bearing for `canProposeAt` /
|
|
38
|
-
// `validateBlockHeader`, but mirroring the full cell keeps the simulation byte-faithful with
|
|
39
|
-
// what the actual `propose()` send will observe, which is a defense against future reads
|
|
40
|
-
// taking dependencies on them.
|
|
41
|
-
builder.withPendingTempCheckpointLogFields({
|
|
42
|
-
headerHash: header.hash(),
|
|
43
|
-
outHash: checkpointOutHash,
|
|
44
|
-
slotNumber: header.slotNumber,
|
|
45
|
-
payloadDigest: computeCheckpointPayloadDigest({
|
|
46
|
-
header,
|
|
47
|
-
archiveRoot: archive.root,
|
|
48
|
-
feeAssetPriceModifier,
|
|
49
|
-
signatureContext: input.signatureContext
|
|
50
|
-
})
|
|
51
|
-
});
|
|
52
|
-
const feeHeader = await computePipelinedParentFeeHeader({
|
|
53
|
-
checkpointNumber: input.checkpointNumber,
|
|
54
|
-
proposedCheckpointData: input.proposedCheckpointData,
|
|
55
|
-
rollup: input.rollup,
|
|
56
|
-
log: input.log
|
|
57
|
-
});
|
|
58
|
-
if (feeHeader) {
|
|
59
|
-
builder.withPendingFeeHeader(feeHeader);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return builder.build();
|
|
63
|
-
}
|
|
64
|
-
function derivePendingCheckpointNumber(input) {
|
|
65
|
-
if (input.invalidateToPendingCheckpointNumber !== undefined) {
|
|
66
|
-
return input.invalidateToPendingCheckpointNumber;
|
|
67
|
-
}
|
|
68
|
-
if (!input.proposedCheckpointData) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
if (input.checkpointNumber < 1) {
|
|
72
|
-
throw new Error(`Cannot build simulation override for checkpoint ${input.checkpointNumber}: no parent exists`);
|
|
73
|
-
}
|
|
74
|
-
const expectedParent = CheckpointNumber(input.checkpointNumber - 1);
|
|
75
|
-
if (input.proposedCheckpointData.checkpointNumber !== expectedParent) {
|
|
76
|
-
throw new Error(`Cannot build simulation override for checkpoint ${input.checkpointNumber}: proposedCheckpointData.checkpointNumber (${input.proposedCheckpointData.checkpointNumber}) does not match expected parent ${expectedParent}`);
|
|
77
|
-
}
|
|
78
|
-
return expectedParent;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Derives the pending parent fee header used during pipelined proposal simulation. Returns
|
|
82
|
-
* `undefined` only when no grandparent exists (i.e. the proposed parent is the genesis
|
|
83
|
-
* checkpoint); all other failure modes (missing grandparent state, missing fee header, RPC
|
|
84
|
-
* errors) throw so callers don't silently desync the fee-header override.
|
|
85
|
-
*/ export async function computePipelinedParentFeeHeader(input) {
|
|
86
|
-
if (input.checkpointNumber < 2) {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
const grandparentCheckpointNumber = CheckpointNumber(input.checkpointNumber - 2);
|
|
90
|
-
const [grandparentCheckpoint, manaTarget] = await Promise.all([
|
|
91
|
-
input.rollup.getCheckpoint(grandparentCheckpointNumber),
|
|
92
|
-
input.rollup.getManaTarget()
|
|
93
|
-
]);
|
|
94
|
-
if (!grandparentCheckpoint?.feeHeader) {
|
|
95
|
-
throw new Error(`Grandparent checkpoint or feeHeader missing for checkpoint ${grandparentCheckpointNumber.toString()}`);
|
|
96
|
-
}
|
|
97
|
-
return RollupContract.computeChildFeeHeader(grandparentCheckpoint.feeHeader, input.proposedCheckpointData.totalManaUsed, input.proposedCheckpointData.feeAssetPriceModifier, manaTarget);
|
|
98
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type FeeHeader,
|
|
3
|
-
RollupContract,
|
|
4
|
-
SimulationOverridesBuilder,
|
|
5
|
-
type SimulationOverridesPlan,
|
|
6
|
-
} from '@aztec/ethereum/contracts';
|
|
7
|
-
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
8
|
-
import type { Logger } from '@aztec/foundation/log';
|
|
9
|
-
import { type ProposedCheckpointData, computeCheckpointPayloadDigest } from '@aztec/stdlib/checkpoint';
|
|
10
|
-
import type { CoordinationSignatureContext } from '@aztec/stdlib/p2p';
|
|
11
|
-
|
|
12
|
-
type CheckpointSimulationOverridesPlanInput = {
|
|
13
|
-
/** Target rollup contract. */
|
|
14
|
-
rollup: RollupContract;
|
|
15
|
-
/** Checkpoint number to be proposed. */
|
|
16
|
-
checkpointNumber: CheckpointNumber;
|
|
17
|
-
/** Logger instance. */
|
|
18
|
-
log: Logger;
|
|
19
|
-
/**
|
|
20
|
-
* The proposed parent checkpoint when pipelining. Its `checkpointNumber` must equal
|
|
21
|
-
* `checkpointNumber - 1`; the helper enforces this. Mutually exclusive with
|
|
22
|
-
* `invalidateToPendingCheckpointNumber`.
|
|
23
|
-
*/
|
|
24
|
-
proposedCheckpointData?: ProposedCheckpointData;
|
|
25
|
-
/**
|
|
26
|
-
* The pending checkpoint number we'll end up at after invalidation lands. Mutually exclusive
|
|
27
|
-
* with `proposedCheckpointData`.
|
|
28
|
-
*/
|
|
29
|
-
invalidateToPendingCheckpointNumber?: CheckpointNumber;
|
|
30
|
-
/**
|
|
31
|
-
* The real on-chain pending checkpoint number (typically `syncedTo.checkpointedCheckpointNumber`).
|
|
32
|
-
* Used as the snapshot we pin both `pending` and `proven` to avoid prunes in simulation.
|
|
33
|
-
*/
|
|
34
|
-
checkpointedCheckpointNumber: CheckpointNumber;
|
|
35
|
-
/**
|
|
36
|
-
* Chain-level consensus signature context. Used to recompute the parent's `payloadDigest` for the
|
|
37
|
-
* pipelined simulation override so it matches what `propose` will write into `tempCheckpointLogs[parent]`
|
|
38
|
-
* once the parent lands.
|
|
39
|
-
*/
|
|
40
|
-
signatureContext: CoordinationSignatureContext;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Builds the SimulationOverridesPlan describing the simulated L1 rollup state for a checkpoint's
|
|
45
|
-
* enqueue-time simulations: `canProposeAt` (in Sequencer.doWork) and the propose-related sims
|
|
46
|
-
* (validateBlockHeader, simulateProposeTx). The plan reflects "as if our pipelined parent
|
|
47
|
-
* checkpoint has landed and any required invalidation has executed" — the gap that needs to be
|
|
48
|
-
* bridged at enqueue time.
|
|
49
|
-
*
|
|
50
|
-
* Pipelining (`proposedCheckpointData`) and invalidation (`invalidateToPendingCheckpointNumber`)
|
|
51
|
-
* are mutually exclusive; passing both throws.
|
|
52
|
-
*/
|
|
53
|
-
export async function buildCheckpointSimulationOverridesPlan(
|
|
54
|
-
input: CheckpointSimulationOverridesPlanInput,
|
|
55
|
-
): Promise<SimulationOverridesPlan | undefined> {
|
|
56
|
-
if (input.proposedCheckpointData && input.invalidateToPendingCheckpointNumber !== undefined) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
'Error in buildCheckpointSimulationOverridesPlan: proposedCheckpointData and invalidateToPendingCheckpointNumber are mutually exclusive',
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const builder = new SimulationOverridesBuilder();
|
|
63
|
-
const pendingCheckpointNumber = derivePendingCheckpointNumber(input);
|
|
64
|
-
|
|
65
|
-
// Override the latest checkpoint number when invalidating or pipelining, so our checkpoint
|
|
66
|
-
// follows from it. We also override the proven chain tip so we dont need to worry about
|
|
67
|
-
// prunes kicking in that would break out simulation if there's a prune pending. We always
|
|
68
|
-
// assume that a proof will land in time. If we don't have a pending checkpoint number to force,
|
|
69
|
-
// we still set both tips to the current checkpoint number to avoid the prune trigger.
|
|
70
|
-
const overridenChainTip = pendingCheckpointNumber ?? input.checkpointedCheckpointNumber;
|
|
71
|
-
builder.withChainTips({ pending: overridenChainTip, proven: overridenChainTip });
|
|
72
|
-
|
|
73
|
-
if (input.proposedCheckpointData) {
|
|
74
|
-
const { header, archive, checkpointOutHash, feeAssetPriceModifier } = input.proposedCheckpointData;
|
|
75
|
-
builder.withPendingArchive(archive.root);
|
|
76
|
-
// Override every locally-derivable `tempCheckpointLogs[parent]` field that L1 will eventually
|
|
77
|
-
// write. `slotNumber` is load-bearing for `STFLib.canPruneAtTime`: without it the cell reads
|
|
78
|
-
// slotNumber 0, the contract treats the pending tip as belonging to an expired epoch, and
|
|
79
|
-
// `getEffectivePendingCheckpointNumber` silently collapses pending back to proven — producing
|
|
80
|
-
// a spurious `Rollup__InvalidArchive` against the on-chain genesis archive. The other fields
|
|
81
|
-
// (headerHash, outHash, payloadDigest) are not strictly load-bearing for `canProposeAt` /
|
|
82
|
-
// `validateBlockHeader`, but mirroring the full cell keeps the simulation byte-faithful with
|
|
83
|
-
// what the actual `propose()` send will observe, which is a defense against future reads
|
|
84
|
-
// taking dependencies on them.
|
|
85
|
-
builder.withPendingTempCheckpointLogFields({
|
|
86
|
-
headerHash: header.hash(),
|
|
87
|
-
outHash: checkpointOutHash,
|
|
88
|
-
slotNumber: header.slotNumber,
|
|
89
|
-
payloadDigest: computeCheckpointPayloadDigest({
|
|
90
|
-
header,
|
|
91
|
-
archiveRoot: archive.root,
|
|
92
|
-
feeAssetPriceModifier,
|
|
93
|
-
signatureContext: input.signatureContext,
|
|
94
|
-
}),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const feeHeader = await computePipelinedParentFeeHeader({
|
|
98
|
-
checkpointNumber: input.checkpointNumber,
|
|
99
|
-
proposedCheckpointData: input.proposedCheckpointData,
|
|
100
|
-
rollup: input.rollup,
|
|
101
|
-
log: input.log,
|
|
102
|
-
});
|
|
103
|
-
if (feeHeader) {
|
|
104
|
-
builder.withPendingFeeHeader(feeHeader);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return builder.build();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function derivePendingCheckpointNumber(input: CheckpointSimulationOverridesPlanInput): CheckpointNumber | undefined {
|
|
112
|
-
if (input.invalidateToPendingCheckpointNumber !== undefined) {
|
|
113
|
-
return input.invalidateToPendingCheckpointNumber;
|
|
114
|
-
}
|
|
115
|
-
if (!input.proposedCheckpointData) {
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
if (input.checkpointNumber < 1) {
|
|
119
|
-
throw new Error(`Cannot build simulation override for checkpoint ${input.checkpointNumber}: no parent exists`);
|
|
120
|
-
}
|
|
121
|
-
const expectedParent = CheckpointNumber(input.checkpointNumber - 1);
|
|
122
|
-
if (input.proposedCheckpointData.checkpointNumber !== expectedParent) {
|
|
123
|
-
throw new Error(
|
|
124
|
-
`Cannot build simulation override for checkpoint ${input.checkpointNumber}: proposedCheckpointData.checkpointNumber (${input.proposedCheckpointData.checkpointNumber}) does not match expected parent ${expectedParent}`,
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
return expectedParent;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
type PipelinedParentFeeHeaderInput = {
|
|
131
|
-
checkpointNumber: CheckpointNumber;
|
|
132
|
-
proposedCheckpointData: ProposedCheckpointData;
|
|
133
|
-
rollup: RollupContract;
|
|
134
|
-
log: Logger;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Derives the pending parent fee header used during pipelined proposal simulation. Returns
|
|
139
|
-
* `undefined` only when no grandparent exists (i.e. the proposed parent is the genesis
|
|
140
|
-
* checkpoint); all other failure modes (missing grandparent state, missing fee header, RPC
|
|
141
|
-
* errors) throw so callers don't silently desync the fee-header override.
|
|
142
|
-
*/
|
|
143
|
-
export async function computePipelinedParentFeeHeader(
|
|
144
|
-
input: PipelinedParentFeeHeaderInput,
|
|
145
|
-
): Promise<FeeHeader | undefined> {
|
|
146
|
-
if (input.checkpointNumber < 2) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const grandparentCheckpointNumber = CheckpointNumber(input.checkpointNumber - 2);
|
|
151
|
-
|
|
152
|
-
const [grandparentCheckpoint, manaTarget] = await Promise.all([
|
|
153
|
-
input.rollup.getCheckpoint(grandparentCheckpointNumber),
|
|
154
|
-
input.rollup.getManaTarget(),
|
|
155
|
-
]);
|
|
156
|
-
|
|
157
|
-
if (!grandparentCheckpoint?.feeHeader) {
|
|
158
|
-
throw new Error(
|
|
159
|
-
`Grandparent checkpoint or feeHeader missing for checkpoint ${grandparentCheckpointNumber.toString()}`,
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return RollupContract.computeChildFeeHeader(
|
|
164
|
-
grandparentCheckpoint.feeHeader,
|
|
165
|
-
input.proposedCheckpointData.totalManaUsed,
|
|
166
|
-
input.proposedCheckpointData.feeAssetPriceModifier,
|
|
167
|
-
manaTarget,
|
|
168
|
-
);
|
|
169
|
-
}
|