@aztec-labs/archiver 6.0.0-rc.2 → 6.0.0-rc.4
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/archiver.d.ts +11 -2
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +94 -2
- package/dest/config.js +1 -1
- package/dest/errors.d.ts +12 -1
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +12 -0
- package/dest/l1/bin/retrieve-calldata.js +7 -5
- package/dest/l1/calldata_retriever.d.ts +5 -2
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +8 -3
- package/dest/l1/data_retrieval.d.ts +2 -1
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +14 -9
- package/dest/l1/validate_trace.d.ts +3 -1
- package/dest/l1/validate_trace.d.ts.map +1 -1
- package/dest/l1/validate_trace.js +8 -3
- package/dest/modules/checkpoint_ingestor.d.ts +71 -0
- package/dest/modules/checkpoint_ingestor.d.ts.map +1 -0
- package/dest/modules/checkpoint_ingestor.js +516 -0
- package/dest/modules/data_store_updater.d.ts +6 -11
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +4 -3
- package/dest/modules/instrumentation.d.ts +8 -4
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +8 -2
- package/dest/modules/l1_synchronizer.d.ts +3 -7
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +84 -420
- package/dest/modules/pending_chain_validation_tracker.d.ts +21 -0
- package/dest/modules/pending_chain_validation_tracker.d.ts.map +1 -0
- package/dest/modules/pending_chain_validation_tracker.js +32 -0
- package/dest/modules/validation.d.ts +2 -2
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +17 -11
- package/dest/store/block_store.d.ts +1 -1
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +8 -2
- package/dest/store/log_store_codec.d.ts +2 -1
- package/dest/store/log_store_codec.d.ts.map +1 -1
- package/dest/store/log_store_codec.js +1 -0
- package/dest/test/fake_l1_state.d.ts +21 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +82 -30
- package/package.json +15 -15
- package/src/archiver.ts +112 -3
- package/src/config.ts +1 -1
- package/src/errors.ts +21 -0
- package/src/l1/README.md +5 -0
- package/src/l1/bin/retrieve-calldata.ts +5 -3
- package/src/l1/calldata_retriever.ts +8 -3
- package/src/l1/data_retrieval.ts +13 -11
- package/src/l1/validate_trace.ts +11 -2
- package/src/modules/checkpoint_ingestor.ts +742 -0
- package/src/modules/data_store_updater.ts +7 -13
- package/src/modules/instrumentation.ts +17 -3
- package/src/modules/l1_synchronizer.ts +116 -563
- package/src/modules/pending_chain_validation_tracker.ts +43 -0
- package/src/modules/validation.ts +13 -9
- package/src/store/block_store.ts +6 -0
- package/src/store/log_store_codec.ts +1 -0
- package/src/test/fake_l1_state.ts +94 -31
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ValidateCheckpointResult } from '@aztec-labs/stdlib/block';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tracks the pending chain's validation status while one sync iteration screens checkpoints, so that the status
|
|
5
|
+
* persisted points at the first invalid checkpoint of a run. A later invalid checkpoint replaces it only when it
|
|
6
|
+
* carries the same number (an invalidated checkpoint replaced by another invalid one, which must itself become
|
|
7
|
+
* invalidatable); a descendant of a rejected checkpoint never replaces it, keeping the original invalidation target.
|
|
8
|
+
* `update` compares against the object the iteration started from, so once the status has moved it is reported on
|
|
9
|
+
* every batch of that iteration, and never while it is still the initial object.
|
|
10
|
+
*/
|
|
11
|
+
export class PendingChainValidationTracker {
|
|
12
|
+
private current: ValidateCheckpointResult | undefined;
|
|
13
|
+
|
|
14
|
+
constructor(private readonly initial: ValidateCheckpointResult | undefined) {
|
|
15
|
+
this.current = initial;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Records the screening result of one checkpoint. */
|
|
19
|
+
public observe(result: ValidateCheckpointResult, opts: { hasRejectedAncestor: boolean }): void {
|
|
20
|
+
// Update the validation result if it has changed, so we can keep track of the first invalid checkpoint
|
|
21
|
+
// in case there is a sequence of more than one invalid checkpoint, as we need to invalidate the first one.
|
|
22
|
+
// There is an exception though: if a checkpoint is invalidated and replaced with another invalid checkpoint,
|
|
23
|
+
// we need to update the validation result, since we need to be able to invalidate the new one.
|
|
24
|
+
// See test 'chain progresses if an invalid checkpoint is invalidated with an invalid one' for more info.
|
|
25
|
+
// Do not update the validation result if there is a rejected ancestor, since in that case we want to keep the
|
|
26
|
+
// original invalidation, as the new checkpoint is extending from a previous invalid one.
|
|
27
|
+
const validStatusChanged = this.current?.valid !== result.valid;
|
|
28
|
+
const invalidStatusWithSameCheckpointNumber =
|
|
29
|
+
!result.valid &&
|
|
30
|
+
this.current &&
|
|
31
|
+
!this.current.valid &&
|
|
32
|
+
this.current.checkpoint.checkpointNumber === result.checkpoint.checkpointNumber;
|
|
33
|
+
|
|
34
|
+
if (!opts.hasRejectedAncestor && (validStatusChanged || invalidStatusWithSameCheckpointNumber)) {
|
|
35
|
+
this.current = result;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The status to persist with the current batch, or undefined while it still equals the iteration's initial object. */
|
|
40
|
+
public get update(): ValidateCheckpointResult | undefined {
|
|
41
|
+
return this.current === this.initial ? undefined : this.current;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EpochCache, requireStableCommittee } from '@aztec-labs/epoch-cache';
|
|
2
2
|
import type { ViemCommitteeAttestations } from '@aztec-labs/ethereum/contracts';
|
|
3
3
|
import { type CheckpointNumber, EpochNumber } from '@aztec-labs/foundation/branded-types';
|
|
4
4
|
import { compactArray } from '@aztec-labs/foundation/collection';
|
|
@@ -66,22 +66,25 @@ export async function resolveCheckpointAttestationsFromCalldata(
|
|
|
66
66
|
): Promise<ResolvedCheckpointAttestations> {
|
|
67
67
|
const slot = checkpoint.header.slotNumber;
|
|
68
68
|
const epoch: EpochNumber = getEpochAtSlot(slot, constants);
|
|
69
|
-
// Read the hatch flag from the same cache entry as the committee, so both come from one snapshot.
|
|
70
|
-
|
|
69
|
+
// Read the hatch flag from the same cache entry as the committee, so both come from one snapshot. An unstable
|
|
70
|
+
// committee throws, so the sync retries the checkpoint once the seed is fixed.
|
|
71
|
+
const lookup = requireStableCommittee(await epochCache.getCommitteeForEpoch(epoch));
|
|
71
72
|
|
|
72
|
-
if (isEscapeHatchOpen) {
|
|
73
|
+
if (lookup.isEscapeHatchOpen) {
|
|
73
74
|
logger?.warn(
|
|
74
75
|
`Escape hatch open for epoch ${epoch} at slot ${slot}, skipping attestations of checkpoint ${checkpoint.checkpointNumber}`,
|
|
75
76
|
);
|
|
76
77
|
return { attestations: [], validationResult: { valid: true } };
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
if (
|
|
80
|
+
if (lookup.state !== 'members') {
|
|
80
81
|
logger?.warn(
|
|
81
82
|
`No committee found for epoch ${epoch} at slot ${slot}. Accepting checkpoint ${checkpoint.checkpointNumber} without validation.`,
|
|
83
|
+
{ committeeState: lookup.state },
|
|
82
84
|
);
|
|
83
85
|
return { attestations: [], validationResult: { valid: true } };
|
|
84
86
|
}
|
|
87
|
+
const { committee, seed } = lookup;
|
|
85
88
|
|
|
86
89
|
let attestations: CommitteeAttestation[];
|
|
87
90
|
try {
|
|
@@ -131,18 +134,19 @@ export async function validateAttestations(
|
|
|
131
134
|
): Promise<ValidateCheckpointResult> {
|
|
132
135
|
const slot = payload.header.slotNumber;
|
|
133
136
|
const epoch: EpochNumber = getEpochAtSlot(slot, constants);
|
|
134
|
-
const
|
|
137
|
+
const lookup = requireStableCommittee(await epochCache.getCommitteeForEpoch(epoch));
|
|
135
138
|
|
|
136
|
-
if (isEscapeHatchOpen) {
|
|
139
|
+
if (lookup.isEscapeHatchOpen) {
|
|
137
140
|
logger?.warn(`Escape hatch open for epoch ${epoch} at slot ${slot}, skipping checkpoint validation`);
|
|
138
141
|
return { valid: true };
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
if (
|
|
144
|
+
if (lookup.state !== 'members') {
|
|
142
145
|
logger?.warn(`No committee found for epoch ${epoch} at slot ${slot}. Accepting checkpoint without validation.`, {
|
|
143
146
|
checkpointNumber: checkpointInfo.checkpointNumber,
|
|
144
147
|
slot,
|
|
145
148
|
epoch,
|
|
149
|
+
committeeState: lookup.state,
|
|
146
150
|
});
|
|
147
151
|
return { valid: true };
|
|
148
152
|
}
|
|
@@ -152,7 +156,7 @@ export async function validateAttestations(
|
|
|
152
156
|
attestations,
|
|
153
157
|
verbatimAttestations,
|
|
154
158
|
checkpointInfo,
|
|
155
|
-
{ committee, seed, epoch },
|
|
159
|
+
{ committee: lookup.committee, seed: lookup.seed, epoch },
|
|
156
160
|
logger,
|
|
157
161
|
);
|
|
158
162
|
}
|
package/src/store/block_store.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { INITIAL_CHECKPOINT_NUMBER, INITIAL_L2_BLOCK_NUM } from '@aztec-labs/con
|
|
|
2
2
|
import type { ViemCommitteeAttestations } from '@aztec-labs/ethereum/contracts';
|
|
3
3
|
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec-labs/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
5
|
+
import { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
5
6
|
import { toArray } from '@aztec-labs/foundation/iterable';
|
|
6
7
|
import { createLogger } from '@aztec-labs/foundation/log';
|
|
7
8
|
import { BufferReader } from '@aztec-labs/foundation/serialize';
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
deserializeIndexedTxEffect,
|
|
42
43
|
serializeIndexedTxEffect,
|
|
43
44
|
} from '@aztec-labs/stdlib/tx';
|
|
45
|
+
import { Buffer } from 'buffer';
|
|
44
46
|
|
|
45
47
|
import {
|
|
46
48
|
BlockArchiveNotConsistentError,
|
|
@@ -146,6 +148,8 @@ type ProposedCheckpointStorage = CommonCheckpointStorage & {
|
|
|
146
148
|
totalManaUsed: string;
|
|
147
149
|
feeAssetPriceModifier: string;
|
|
148
150
|
inboxMsgTotal: string;
|
|
151
|
+
/** Absent when the signer is unknown, including on records written before signers were stored. */
|
|
152
|
+
signer?: string;
|
|
149
153
|
};
|
|
150
154
|
|
|
151
155
|
export type RemoveCheckpointsResult = { blocksRemoved: L2Block[] | undefined };
|
|
@@ -1089,6 +1093,7 @@ export class BlockStore {
|
|
|
1089
1093
|
totalManaUsed: BigInt(stored.totalManaUsed),
|
|
1090
1094
|
feeAssetPriceModifier: BigInt(stored.feeAssetPriceModifier),
|
|
1091
1095
|
inboxMsgTotal: BigInt(stored.inboxMsgTotal),
|
|
1096
|
+
signer: stored.signer ? EthAddress.fromString(stored.signer) : undefined,
|
|
1092
1097
|
};
|
|
1093
1098
|
}
|
|
1094
1099
|
|
|
@@ -1606,6 +1611,7 @@ export class BlockStore {
|
|
|
1606
1611
|
totalManaUsed: proposed.totalManaUsed.toString(),
|
|
1607
1612
|
feeAssetPriceModifier: proposed.feeAssetPriceModifier.toString(),
|
|
1608
1613
|
inboxMsgTotal: inboxMsgTotal.toString(),
|
|
1614
|
+
...(proposed.signer && { signer: proposed.signer.toString() }),
|
|
1609
1615
|
});
|
|
1610
1616
|
});
|
|
1611
1617
|
}
|
|
@@ -2,6 +2,7 @@ import { BlockNumber } from '@aztec-labs/foundation/branded-types';
|
|
|
2
2
|
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
3
3
|
import { BlockHash } from '@aztec-labs/stdlib/block';
|
|
4
4
|
import { TxHash } from '@aztec-labs/stdlib/tx';
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
5
6
|
|
|
6
7
|
export const NUMERIC_HEX_LEN = 8;
|
|
7
8
|
export const SEP = '-';
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
import { ConsensusPayload, getHashedSignaturePayloadTypedData } from '@aztec-labs/stdlib/p2p';
|
|
30
30
|
import { mockCheckpointAndMessages } from '@aztec-labs/stdlib/testing';
|
|
31
31
|
import { AppendOnlyTreeSnapshot } from '@aztec-labs/stdlib/trees';
|
|
32
|
+
import { Buffer } from 'buffer';
|
|
32
33
|
import { type MockProxy, mock } from 'jest-mock-extended';
|
|
33
34
|
import { type FormattedBlock, type Transaction, encodeFunctionData, multicall3Abi, toHex } from 'viem';
|
|
34
35
|
|
|
@@ -82,6 +83,12 @@ type AddCheckpointOptions = {
|
|
|
82
83
|
spareAttestationsBitmapBit?: boolean;
|
|
83
84
|
/** Overrides the posted attestations tuple, e.g. to model an escape-hatch proposer's arbitrary tuple. */
|
|
84
85
|
verbatimAttestations?: ViemCommitteeAttestations;
|
|
86
|
+
/**
|
|
87
|
+
* Puts a decoy `propose` call ahead of the real one in the multicall, allowed to fail and identical except that this
|
|
88
|
+
* key signs its attestations-and-signers bundle. L1 reverts the decoy, yet it matches the CheckpointProposed event's
|
|
89
|
+
* hashes just as the real call does, since those hashes cover neither the signers nor the bundle signature.
|
|
90
|
+
*/
|
|
91
|
+
decoyBundleSigner?: Secp256k1Signer;
|
|
85
92
|
};
|
|
86
93
|
|
|
87
94
|
/** Result from adding a checkpoint. */
|
|
@@ -107,6 +114,8 @@ type CheckpointData = {
|
|
|
107
114
|
verbatimAttestations: ViemCommitteeAttestations;
|
|
108
115
|
/** Payload digest, matching what the L1 event emits. */
|
|
109
116
|
payloadDigest: Buffer32;
|
|
117
|
+
/** The slot's proposer as L1 sees it: the key that signed the attestations bundle of the executed `propose`. */
|
|
118
|
+
proposer: EthAddress;
|
|
110
119
|
/** If true, archiveAt will ignore it */
|
|
111
120
|
pruned?: boolean;
|
|
112
121
|
};
|
|
@@ -261,11 +270,12 @@ export class FakeL1State {
|
|
|
261
270
|
this.addMessages(checkpointNumber, messagesL1BlockNumber, messages);
|
|
262
271
|
|
|
263
272
|
// Create the transaction, blobs, and event hashes
|
|
264
|
-
const { tx, attestationsHash, payloadDigest, verbatimAttestations } = await this.makeRollupTx(
|
|
273
|
+
const { tx, attestationsHash, payloadDigest, verbatimAttestations, proposer } = await this.makeRollupTx(
|
|
265
274
|
checkpoint,
|
|
266
275
|
signers,
|
|
267
276
|
options.spareAttestationsBitmapBit ?? false,
|
|
268
277
|
options.verbatimAttestations,
|
|
278
|
+
options.decoyBundleSigner,
|
|
269
279
|
);
|
|
270
280
|
const blobHashes = await this.makeVersionedBlobHashes(checkpoint);
|
|
271
281
|
const blobs = await this.makeBlobsFromCheckpoint(checkpoint);
|
|
@@ -282,6 +292,7 @@ export class FakeL1State {
|
|
|
282
292
|
attestationsHash,
|
|
283
293
|
payloadDigest,
|
|
284
294
|
verbatimAttestations,
|
|
295
|
+
proposer,
|
|
285
296
|
});
|
|
286
297
|
|
|
287
298
|
// Update last archive for auto-chaining
|
|
@@ -484,6 +495,40 @@ export class FakeL1State {
|
|
|
484
495
|
this.updatePendingCheckpointNumber();
|
|
485
496
|
}
|
|
486
497
|
|
|
498
|
+
/**
|
|
499
|
+
* Simulates the latest entry for a checkpoint number being invalidated on L1 and the identical checkpoint being
|
|
500
|
+
* proposed again at a later L1 block with a different set of signers. Both entries share the same archive root, and
|
|
501
|
+
* both remain visible as CheckpointProposed events.
|
|
502
|
+
*/
|
|
503
|
+
async repostCheckpoint(
|
|
504
|
+
checkpointNumber: CheckpointNumber,
|
|
505
|
+
opts: { l1BlockNumber: bigint; signers: Secp256k1Signer[] },
|
|
506
|
+
): Promise<void> {
|
|
507
|
+
const previous = this.checkpoints.findLast(cpData => cpData.checkpointNumber === checkpointNumber);
|
|
508
|
+
if (!previous) {
|
|
509
|
+
throw new Error(`Checkpoint ${checkpointNumber} not found`);
|
|
510
|
+
}
|
|
511
|
+
previous.pruned = true;
|
|
512
|
+
|
|
513
|
+
const { tx, attestationsHash, payloadDigest, verbatimAttestations } = await this.makeRollupTx(
|
|
514
|
+
previous.checkpoint,
|
|
515
|
+
opts.signers,
|
|
516
|
+
false,
|
|
517
|
+
);
|
|
518
|
+
this.checkpoints.push({
|
|
519
|
+
...previous,
|
|
520
|
+
pruned: false,
|
|
521
|
+
l1BlockNumber: opts.l1BlockNumber,
|
|
522
|
+
// The tx hash defaults to the archive root, which both entries share, so give the repost its own.
|
|
523
|
+
tx: { ...tx, hash: `0x${opts.l1BlockNumber.toString(16).padStart(64, '0')}` },
|
|
524
|
+
signers: opts.signers,
|
|
525
|
+
attestationsHash,
|
|
526
|
+
payloadDigest,
|
|
527
|
+
verbatimAttestations,
|
|
528
|
+
});
|
|
529
|
+
this.updatePendingCheckpointNumber();
|
|
530
|
+
}
|
|
531
|
+
|
|
487
532
|
/**
|
|
488
533
|
* Moves messages at a given L1 block to a new L1 block.
|
|
489
534
|
* Useful for simulating partial message visibility (messages at higher L1 blocks won't be fetched).
|
|
@@ -560,6 +605,14 @@ export class FakeL1State {
|
|
|
560
605
|
|
|
561
606
|
mockRollup.canPruneAtTime.mockImplementation(() => Promise.resolve(this.canPruneResult));
|
|
562
607
|
|
|
608
|
+
mockRollup.getProposerAt.mockImplementation((timestamp: bigint) => {
|
|
609
|
+
const slot = getSlotAtTimestamp(timestamp, this.config);
|
|
610
|
+
const proposer = this.checkpoints.findLast(
|
|
611
|
+
cp => !cp.pruned && cp.checkpoint.header.slotNumber === slot,
|
|
612
|
+
)?.proposer;
|
|
613
|
+
return Promise.resolve(proposer ?? EthAddress.ZERO);
|
|
614
|
+
});
|
|
615
|
+
|
|
563
616
|
// Mock the wrapper method for fetching checkpoint events
|
|
564
617
|
mockRollup.getCheckpointProposedEvents.mockImplementation((fromBlock: bigint, toBlock: bigint) =>
|
|
565
618
|
Promise.resolve(this.getCheckpointProposedLogs(fromBlock, toBlock)),
|
|
@@ -700,6 +753,7 @@ export class FakeL1State {
|
|
|
700
753
|
l1BlockNumber: cpData.l1BlockNumber,
|
|
701
754
|
l1BlockHash: Buffer32.fromBigInt(cpData.l1BlockNumber),
|
|
702
755
|
l1TransactionHash: cpData.tx.hash as `0x${string}`,
|
|
756
|
+
...this.getPositionInL1Block(this.checkpoints, cpData),
|
|
703
757
|
args: {
|
|
704
758
|
checkpointNumber: cpData.checkpointNumber,
|
|
705
759
|
archive: cpData.checkpoint.archive.root,
|
|
@@ -722,6 +776,7 @@ export class FakeL1State {
|
|
|
722
776
|
l1BlockNumber: msg.l1BlockNumber,
|
|
723
777
|
l1BlockHash: this.getL1BlockHash(msg.l1BlockNumber),
|
|
724
778
|
l1TransactionHash: `0x${msg.l1BlockNumber.toString(16)}` as `0x${string}`,
|
|
779
|
+
...this.getPositionInL1Block(this.messages, msg),
|
|
725
780
|
args: {
|
|
726
781
|
index: msg.index,
|
|
727
782
|
leaf: msg.leaf,
|
|
@@ -753,6 +808,7 @@ export class FakeL1State {
|
|
|
753
808
|
l1BlockNumber: msg.l1BlockNumber,
|
|
754
809
|
l1BlockHash: this.getL1BlockHash(msg.l1BlockNumber),
|
|
755
810
|
l1TransactionHash: `0x${msg.l1BlockNumber.toString(16)}` as `0x${string}`,
|
|
811
|
+
...this.getPositionInL1Block(this.messages, msg),
|
|
756
812
|
args: {
|
|
757
813
|
index: msg.index,
|
|
758
814
|
leaf: msg.leaf,
|
|
@@ -763,6 +819,18 @@ export class FakeL1State {
|
|
|
763
819
|
};
|
|
764
820
|
}
|
|
765
821
|
|
|
822
|
+
/**
|
|
823
|
+
* The transaction and log index of an entry's event within its L1 block, following insertion order among the entries
|
|
824
|
+
* in that block, with one event per transaction.
|
|
825
|
+
*/
|
|
826
|
+
private getPositionInL1Block<T extends { l1BlockNumber: bigint }>(
|
|
827
|
+
entries: T[],
|
|
828
|
+
entry: T,
|
|
829
|
+
): { l1TransactionIndex: number; l1LogIndex: number } {
|
|
830
|
+
const index = entries.filter(e => e.l1BlockNumber === entry.l1BlockNumber).indexOf(entry);
|
|
831
|
+
return { l1TransactionIndex: index, l1LogIndex: index };
|
|
832
|
+
}
|
|
833
|
+
|
|
766
834
|
// The fake tracks only leaves, so the emitted message carries placeholder fields; nothing in the archiver
|
|
767
835
|
// consumes them (it stores leaf and consensus metadata only).
|
|
768
836
|
private makeFakeMessageSentMessage(index: bigint) {
|
|
@@ -780,11 +848,13 @@ export class FakeL1State {
|
|
|
780
848
|
signers: Secp256k1Signer[],
|
|
781
849
|
spareAttestationsBitmapBit: boolean,
|
|
782
850
|
verbatimAttestationsOverride?: ViemCommitteeAttestations,
|
|
851
|
+
decoyBundleSigner?: Secp256k1Signer,
|
|
783
852
|
): Promise<{
|
|
784
853
|
tx: Transaction;
|
|
785
854
|
attestationsHash: Buffer32;
|
|
786
855
|
payloadDigest: Buffer32;
|
|
787
856
|
verbatimAttestations: ViemCommitteeAttestations;
|
|
857
|
+
proposer: EthAddress;
|
|
788
858
|
}> {
|
|
789
859
|
const signatureContext = this.getSignatureContext();
|
|
790
860
|
const consensusPayload = ConsensusPayload.fromCheckpoint(checkpoint, signatureContext);
|
|
@@ -805,9 +875,6 @@ export class FakeL1State {
|
|
|
805
875
|
// don't care about the proposer identity (e.g. sync tests) still produce a
|
|
806
876
|
// valid-looking signature for the attestationsAndSigners struct.
|
|
807
877
|
const proposerSigner = signers[0] ?? Secp256k1Signer.random();
|
|
808
|
-
const attestationsAndSignersSignature = proposerSigner.sign(
|
|
809
|
-
getHashedSignaturePayloadTypedData(attestationsAndSigners),
|
|
810
|
-
);
|
|
811
878
|
|
|
812
879
|
const packedAttestations = attestationsAndSigners.getPackedAttestations();
|
|
813
880
|
const verbatimAttestations =
|
|
@@ -816,37 +883,33 @@ export class FakeL1State {
|
|
|
816
883
|
? { ...packedAttestations, signatureIndices: setLastBitmapBit(packedAttestations.signatureIndices) }
|
|
817
884
|
: packedAttestations);
|
|
818
885
|
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
oracleInput: { feeAssetPriceModifier: 0n },
|
|
827
|
-
bucketHint: 0n,
|
|
828
|
-
},
|
|
829
|
-
verbatimAttestations,
|
|
830
|
-
attestationsAndSigners.getSigners().map(signer => signer.toString()),
|
|
831
|
-
attestationsAndSignersSignature.toViemSignature(),
|
|
832
|
-
blobInput,
|
|
833
|
-
],
|
|
834
|
-
});
|
|
835
|
-
|
|
836
|
-
const multiCallInput = encodeFunctionData({
|
|
837
|
-
abi: multicall3Abi,
|
|
838
|
-
functionName: 'aggregate3',
|
|
839
|
-
args: [
|
|
840
|
-
[
|
|
886
|
+
const makeProposeCall = (bundleSigner: Secp256k1Signer, allowFailure: boolean) => ({
|
|
887
|
+
target: this.config.rollupAddress.toString(),
|
|
888
|
+
allowFailure,
|
|
889
|
+
callData: encodeFunctionData({
|
|
890
|
+
abi: RollupAbi,
|
|
891
|
+
functionName: 'propose',
|
|
892
|
+
args: [
|
|
841
893
|
{
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
894
|
+
header,
|
|
895
|
+
archive,
|
|
896
|
+
oracleInput: { feeAssetPriceModifier: 0n },
|
|
897
|
+
bucketHint: 0n,
|
|
845
898
|
},
|
|
899
|
+
verbatimAttestations,
|
|
900
|
+
attestationsAndSigners.getSigners().map(signer => signer.toString()),
|
|
901
|
+
bundleSigner.sign(getHashedSignaturePayloadTypedData(attestationsAndSigners)).toViemSignature(),
|
|
902
|
+
blobInput,
|
|
846
903
|
],
|
|
847
|
-
|
|
904
|
+
}),
|
|
848
905
|
});
|
|
849
906
|
|
|
907
|
+
const calls = [
|
|
908
|
+
...(decoyBundleSigner ? [makeProposeCall(decoyBundleSigner, true)] : []),
|
|
909
|
+
makeProposeCall(proposerSigner, false),
|
|
910
|
+
];
|
|
911
|
+
const multiCallInput = encodeFunctionData({ abi: multicall3Abi, functionName: 'aggregate3', args: [calls] });
|
|
912
|
+
|
|
850
913
|
const attestationsHash = Buffer32.fromString(computeAttestationsHash(verbatimAttestations));
|
|
851
914
|
|
|
852
915
|
// Compute payloadDigest (same logic as CalldataRetriever)
|
|
@@ -859,7 +922,7 @@ export class FakeL1State {
|
|
|
859
922
|
to: MULTI_CALL_3_ADDRESS as `0x${string}`,
|
|
860
923
|
} as Transaction<bigint, number>;
|
|
861
924
|
|
|
862
|
-
return { tx, attestationsHash, payloadDigest, verbatimAttestations };
|
|
925
|
+
return { tx, attestationsHash, payloadDigest, verbatimAttestations, proposer: proposerSigner.address };
|
|
863
926
|
}
|
|
864
927
|
|
|
865
928
|
private getSignatureContext() {
|