Skip to content

Commit 074d122

Browse files
committed
chore(fast-inbox): remove legacy inHash and per-checkpoint index helpers from stdlib/p2p (A-1388)
Deletes computeInHashFromL1ToL2Messages and the inHash field from BlockProposal (including its signed-payload slot), the CheckpointProposal getBlockProposal pass-through, and the createBlockProposal inHash argument on the validator interface. Removes the padded per-checkpoint InboxLeaf helpers (smallestIndexForCheckpoint / indexRangeForCheckpoint / checkpointNumberFromIndex) and the legacy getL1ToL2Messages(checkpointNumber) member from the L1ToL2MessageSource and archiver RPC interfaces. Regenerates the block-proposal golden wire fixtures for the shrunk payload; the p2p wire format changes at a release boundary (fresh networks), matching the A-1381 optional-tail precedent.
1 parent bee1d34 commit 074d122

14 files changed

Lines changed: 13 additions & 94 deletions

File tree

yarn-project/p2p/src/services/libp2p/libp2p_service.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
makeCheckpointProposal,
2121
mockTx,
2222
} from '@aztec/stdlib/testing';
23-
import { TxArray, TxHashArray } from '@aztec/stdlib/tx';
23+
import { TxArray, TxHash, TxHashArray } from '@aztec/stdlib/tx';
2424
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
2525
import { ServerWorldStateSynchronizer } from '@aztec/world-state';
2626

@@ -809,8 +809,8 @@ describe('LibP2PService', () => {
809809
});
810810

811811
// Regression for A-1013: payloads sharing (slot, position, archive) but differing on another
812-
// signed field (e.g. inHash) used to dedup by archive only and silently drop the second one.
813-
// The pool now dedups by signed-payload hash, so the equivocation surfaces.
812+
// signed field (e.g. the transaction set) used to dedup by archive only and silently drop the
813+
// second one. The pool now dedups by signed-payload hash, so the equivocation surfaces.
814814
it('same archive but different signed payload triggers slash callback', async () => {
815815
const blockHeader = makeBlockHeader(1, { slotNumber: targetSlot });
816816
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
@@ -820,7 +820,7 @@ describe('LibP2PService', () => {
820820
signer,
821821
blockHeader,
822822
indexWithinCheckpoint,
823-
inHash: Fr.fromString('0x1'),
823+
txHashes: [TxHash.fromField(new Fr(1))],
824824
archiveRoot: sharedArchive,
825825
});
826826
await service.processBlockFromPeer(proposal1.toBuffer(), 'msg-1', mockPeerId);
@@ -830,7 +830,7 @@ describe('LibP2PService', () => {
830830
signer,
831831
blockHeader,
832832
indexWithinCheckpoint,
833-
inHash: Fr.fromString('0x2'),
833+
txHashes: [TxHash.fromField(new Fr(2))],
834834
archiveRoot: sharedArchive,
835835
});
836836
expect(proposal2.archive.toString()).toBe(proposal1.archive.toString());

yarn-project/stdlib/src/block/l2_block.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ export class L2Block {
155155
* @param txsPerBlock - The number of transactions to include in the block.
156156
* @param numPublicCallsPerTx - The number of public function calls to include in each transaction.
157157
* @param numPublicLogsPerCall - The number of public logs per 1 public function invocation.
158-
* @param inHash - The hash of the L1 to L2 messages subtree which got inserted in this block.
159158
* @returns The L2 block.
160159
*/
161160
static async random(

yarn-project/stdlib/src/interfaces/archiver.test.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ describe('ArchiverApiSchema', () => {
204204
expect(result).toEqual([expect.any(Fr)]);
205205
});
206206

207-
it('getL1ToL2Messages', async () => {
208-
const result = await context.client.getL1ToL2Messages(CheckpointNumber(1));
209-
expect(result).toEqual([expect.any(Fr)]);
210-
});
211-
212207
it('getL1ToL2MessageIndex', async () => {
213208
const result = await context.client.getL1ToL2MessageIndex(Fr.random());
214209
expect(result).toBe(1n);
@@ -564,10 +559,6 @@ class MockArchiver implements ArchiverApi {
564559
expect(Array.isArray(signatures)).toBe(true);
565560
return Promise.resolve();
566561
}
567-
getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]> {
568-
expect(checkpointNumber).toEqual(CheckpointNumber(1));
569-
return Promise.resolve([Fr.random()]);
570-
}
571562
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
572563
expect(l1ToL2Message).toBeInstanceOf(Fr);
573564
return Promise.resolve(1n);

yarn-project/stdlib/src/interfaces/archiver.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
128128
}),
129129
getContractClassIds: z.function({ input: z.tuple([]), output: z.array(schemas.Fr) }),
130130
registerContractFunctionSignatures: z.function({ input: z.tuple([z.array(z.string())]), output: z.void() }),
131-
getL1ToL2Messages: z.function({ input: z.tuple([CheckpointNumberSchema]), output: z.array(schemas.Fr) }),
132131
getL1ToL2MessageIndex: z.function({ input: z.tuple([schemas.Fr]), output: schemas.BigInt.optional() }),
133132
getLatestInboxBucketAtOrBefore: z.function({
134133
input: z.tuple([schemas.BigInt]),

yarn-project/stdlib/src/interfaces/validator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export interface Validator {
153153
blockHeader: BlockHeader,
154154
checkpointNumber: CheckpointNumber,
155155
indexWithinCheckpoint: number,
156-
inHash: Fr,
157156
archive: Fr,
158157
txs: Tx[],
159158
proposerAddress: EthAddress | undefined,

yarn-project/stdlib/src/messaging/in_hash.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { INITIAL_CHECKPOINT_NUMBER, MAX_L1_TO_L2_MSGS_PER_CHECKPOINT } from '@aztec/constants';
21
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
3-
import { CheckpointNumber } from '@aztec/foundation/branded-types';
42
import { Fr } from '@aztec/foundation/curves/bn254';
53
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
64

@@ -22,23 +20,4 @@ export class InboxLeaf {
2220
const leaf = reader.readObject(Fr);
2321
return new InboxLeaf(index, leaf);
2422
}
25-
26-
static smallestIndexForCheckpoint(checkpointNumber: CheckpointNumber): bigint {
27-
return BigInt(checkpointNumber - INITIAL_CHECKPOINT_NUMBER) * BigInt(MAX_L1_TO_L2_MSGS_PER_CHECKPOINT);
28-
}
29-
30-
/**
31-
* Returns the range of valid indices for a given checkpoint.
32-
* Start index is inclusive, end index is exclusive.
33-
*/
34-
static indexRangeForCheckpoint(checkpointNumber: CheckpointNumber): [bigint, bigint] {
35-
const start = this.smallestIndexForCheckpoint(checkpointNumber);
36-
const end = start + BigInt(MAX_L1_TO_L2_MSGS_PER_CHECKPOINT);
37-
return [start, end];
38-
}
39-
40-
/** Returns the checkpoint number for a given leaf index */
41-
static checkpointNumberFromIndex(index: bigint): CheckpointNumber {
42-
return CheckpointNumber(Number(index / BigInt(MAX_L1_TO_L2_MSGS_PER_CHECKPOINT)) + INITIAL_CHECKPOINT_NUMBER);
43-
}
4423
}

yarn-project/stdlib/src/messaging/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './append_l1_to_l2_messages.js';
2-
export * from './in_hash.js';
32
export * from './inbox_bucket.js';
43
export * from './inbox_consumption.js';
54
export * from './inbox_leaf.js';

yarn-project/stdlib/src/messaging/l1_to_l2_message_source.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
21
import type { Fr } from '@aztec/foundation/curves/bn254';
32

43
import type { L2Tips } from '../block/l2_block_source.js';
@@ -8,15 +7,6 @@ import type { InboxBucket } from './inbox_bucket.js';
87
* Interface of classes allowing for the retrieval of L1 to L2 messages.
98
*/
109
export interface L1ToL2MessageSource {
11-
/**
12-
* Gets new L1 to L2 message (to be) included in a given checkpoint.
13-
* @param checkpointNumber - Checkpoint number to get messages for.
14-
* @returns The L1 to L2 messages/leaves of the messages subtree.
15-
* @throws If the message tree for the given checkpoint has not yet been sealed on L1
16-
* (i.e., checkpointNumber >= inbox treeInProgress).
17-
*/
18-
getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]>;
19-
2010
/**
2111
* Gets the L1 to L2 message index in the L1 to L2 message tree.
2212
* @param l1ToL2Message - The L1 to L2 message.

yarn-project/stdlib/src/p2p/block_proposal.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const makeLegacyFixtureProposal = () =>
2323
new BlockProposal(
2424
BlockHeader.empty(),
2525
IndexWithinCheckpoint(3),
26-
new Fr(42n),
2726
new Fr(99n),
2827
[TxHash.fromField(new Fr(7n)), TxHash.fromField(new Fr(8n))],
2928
Signature.empty(),
@@ -105,7 +104,6 @@ describe('Block Proposal serialization / deserialization', () => {
105104
const tampered = new BlockProposal(
106105
proposal.blockHeader,
107106
proposal.indexWithinCheckpoint,
108-
proposal.inHash,
109107
proposal.archiveRoot,
110108
proposal.txHashes,
111109
proposal.signature,
@@ -161,7 +159,6 @@ describe('Block Proposal serialization / deserialization', () => {
161159
const withoutRef = await makeBlockProposal({
162160
blockHeader: withRef.blockHeader,
163161
indexWithinCheckpoint: withRef.indexWithinCheckpoint,
164-
inHash: withRef.inHash,
165162
archiveRoot: withRef.archiveRoot,
166163
txHashes: withRef.txHashes,
167164
});
@@ -195,7 +192,6 @@ describe('Block Proposal serialization / deserialization', () => {
195192
const tampered = new BlockProposal(
196193
proposal.blockHeader,
197194
proposal.indexWithinCheckpoint,
198-
proposal.inHash,
199195
proposal.archiveRoot,
200196
proposal.txHashes,
201197
proposal.signature,
@@ -215,7 +211,6 @@ describe('Block Proposal serialization / deserialization', () => {
215211
const injected = new BlockProposal(
216212
proposal.blockHeader,
217213
proposal.indexWithinCheckpoint,
218-
proposal.inHash,
219214
proposal.archiveRoot,
220215
proposal.txHashes,
221216
proposal.signature,

0 commit comments

Comments
 (0)