@aztec/p2p 2.1.0-rc.10 → 2.1.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/factory.d.ts +1 -0
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +4 -2
- package/dest/client/p2p_client.d.ts +1 -0
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +5 -0
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +5 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -2
- package/package.json +14 -14
- package/src/client/factory.ts +9 -2
- package/src/client/p2p_client.ts +4 -0
- package/src/mem_pools/attestation_pool/mocks.ts +6 -3
- package/src/msg_validators/attestation_validator/attestation_validator.ts +29 -2
package/dest/client/factory.d.ts
CHANGED
|
@@ -26,5 +26,6 @@ export type P2PClientDeps<T extends P2PClientType> = {
|
|
|
26
26
|
export declare const P2P_STORE_NAME = "p2p";
|
|
27
27
|
export declare const P2P_ARCHIVE_STORE_NAME = "p2p-archive";
|
|
28
28
|
export declare const P2P_PEER_STORE_NAME = "p2p-peers";
|
|
29
|
+
export declare const P2P_ATTESTATION_STORE_NAME = "p2p-attestation";
|
|
29
30
|
export declare function createP2PClient<T extends P2PClientType>(clientType: T, inputConfig: P2PConfig & DataStoreConfig & ChainConfig, archiver: L2BlockSource & ContractDataSource, proofVerifier: ClientProtocolCircuitVerifier, worldStateSynchronizer: WorldStateSynchronizer, epochCache: EpochCacheInterface, packageVersion: string, dateProvider?: DateProvider, telemetry?: TelemetryClient, deps?: P2PClientDeps<T>): Promise<P2PClient<T>>;
|
|
30
31
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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ory.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
4
4
|
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
5
5
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
6
6
|
import { P2PClient } from '../client/p2p_client.js';
|
|
7
|
-
import {
|
|
7
|
+
import { KvAttestationPool } from '../mem_pools/attestation_pool/kv_attestation_pool.js';
|
|
8
8
|
import { AztecKVTxPool } from '../mem_pools/tx_pool/index.js';
|
|
9
9
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
10
10
|
import { LibP2PService } from '../services/index.js';
|
|
@@ -14,6 +14,7 @@ import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerI
|
|
|
14
14
|
export const P2P_STORE_NAME = 'p2p';
|
|
15
15
|
export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
16
16
|
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
17
|
+
export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
|
|
17
18
|
export async function createP2PClient(clientType, inputConfig, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), deps = {}) {
|
|
18
19
|
const config = await configureP2PClientAddresses({
|
|
19
20
|
...inputConfig,
|
|
@@ -26,13 +27,14 @@ export async function createP2PClient(clientType, inputConfig, archiver, proofVe
|
|
|
26
27
|
const store = deps.store ?? await createStore(P2P_STORE_NAME, 2, config, createLogger('p2p:lmdb-v2'));
|
|
27
28
|
const archive = await createStore(P2P_ARCHIVE_STORE_NAME, 1, config, createLogger('p2p-archive:lmdb-v2'));
|
|
28
29
|
const peerStore = await createStore(P2P_PEER_STORE_NAME, 1, config, createLogger('p2p-peer:lmdb-v2'));
|
|
30
|
+
const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME, 1, config, createLogger('p2p-attestation:lmdb-v2'));
|
|
29
31
|
const l1Constants = await archiver.getL1Constants();
|
|
30
32
|
const mempools = {
|
|
31
33
|
txPool: deps.txPool ?? new AztecKVTxPool(store, archive, worldStateSynchronizer, telemetry, {
|
|
32
34
|
maxTxPoolSize: config.maxTxPoolSize,
|
|
33
35
|
archivedTxLimit: config.archivedTxLimit
|
|
34
36
|
}),
|
|
35
|
-
attestationPool: clientType === P2PClientType.Full ? deps.attestationPool ?? new
|
|
37
|
+
attestationPool: clientType === P2PClientType.Full ? deps.attestationPool ?? new KvAttestationPool(attestationStore, telemetry) : undefined
|
|
36
38
|
};
|
|
37
39
|
const p2pService = await createP2PService(config, clientType, archiver, proofVerifier, worldStateSynchronizer, epochCache, store, peerStore, mempools, deps.p2pServiceFactory, packageVersion, logger.createChild('libp2p_service'), telemetry);
|
|
38
40
|
const nodeSources = [
|
|
@@ -83,6 +83,7 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
83
83
|
broadcastProposal(proposal: BlockProposal): Promise<void>;
|
|
84
84
|
getAttestationsForSlot(slot: bigint, proposalId?: string): Promise<BlockAttestation[]>;
|
|
85
85
|
addAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
86
|
+
deleteAttestation(attestation: BlockAttestation): Promise<void>;
|
|
86
87
|
registerBlockProposalHandler(handler: P2PBlockReceivedCallback): void;
|
|
87
88
|
/**
|
|
88
89
|
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAsC,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EACV,UAAU,EAGV,aAAa,EAEb,kBAAkB,EAClB,MAAM,EAEP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB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AI,OAAO,CAAC,MAAM,CAAC;IAI1D,iEAAiE;IACpD,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInD;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IAgB/C;;;;OAIG;YACW,wBAAwB;IAOtC;;;;OAIG;YACW,oBAAoB;IAyBlC,uFAAuF;YACzE,yBAAyB;IA4BvC;;;;OAIG;YACW,uBAAuB;IAsBrC;;;OAGG;YACW,mBAAmB;YA+CnB,qBAAqB;IA0BnC;;;OAGG;IACH,OAAO,CAAC,eAAe;IAMhB,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC;;;OAGG;IACI,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,yBAAyB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAGnG"}
|
|
@@ -291,6 +291,11 @@ import { P2PClientState } from './interface.js';
|
|
|
291
291
|
addAttestations(attestations) {
|
|
292
292
|
return this.attestationPool?.addAttestations(attestations) ?? Promise.resolve();
|
|
293
293
|
}
|
|
294
|
+
deleteAttestation(attestation) {
|
|
295
|
+
return this.attestationPool?.deleteAttestations([
|
|
296
|
+
attestation
|
|
297
|
+
]) ?? Promise.resolve();
|
|
298
|
+
}
|
|
294
299
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
295
300
|
// ^ This pattern is not my favorite (md)
|
|
296
301
|
registerBlockProposalHandler(handler) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,2BAA2B,CAAC;AAEvG;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,YAGlC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,eAAe,EACvB,OAAM,MAAU,EAChB,UAAS,EAAgB,KACxB,
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,2BAA2B,CAAC;AAEvG;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,YAGlC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,eAAe,EACvB,OAAM,MAAU,EAChB,UAAS,EAAgB,KACxB,gBAYF,CAAC"}
|
|
@@ -19,7 +19,9 @@ import { generatePrivateKey, privateKeyToAccount } from '@spalladino/viem/accoun
|
|
|
19
19
|
// Use arbitrary numbers for all other than slot
|
|
20
20
|
const header = makeHeader(1, 2, slot);
|
|
21
21
|
const payload = new ConsensusPayload(header.toPropose(), archive, header.state);
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
22
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
23
|
+
const attestationSignature = signer.sign(attestationHash);
|
|
24
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
25
|
+
const proposerSignature = signer.sign(proposalHash);
|
|
26
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
25
27
|
};
|
|
@@ -2,6 +2,7 @@ import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
|
2
2
|
import { type BlockAttestation, type P2PValidator, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
3
|
export declare class AttestationValidator implements P2PValidator<BlockAttestation> {
|
|
4
4
|
private epochCache;
|
|
5
|
+
private logger;
|
|
5
6
|
constructor(epochCache: EpochCacheInterface);
|
|
6
7
|
validate(message: BlockAttestation): Promise<PeerErrorSeverity | undefined>;
|
|
7
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestation_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/attestation_validator/attestation_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"attestation_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/attestation_validator/attestation_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEhG,qBAAa,oBAAqB,YAAW,YAAY,CAAC,gBAAgB,CAAC;IACzE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAS;gBAEX,UAAU,EAAE,mBAAmB;IAKrC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;CA8ClF"}
|
|
@@ -1,25 +1,43 @@
|
|
|
1
1
|
import { NoCommitteeError } from '@aztec/ethereum';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
4
|
export class AttestationValidator {
|
|
4
5
|
epochCache;
|
|
6
|
+
logger;
|
|
5
7
|
constructor(epochCache){
|
|
6
8
|
this.epochCache = epochCache;
|
|
9
|
+
this.logger = createLogger('p2p:attestation-validator');
|
|
7
10
|
}
|
|
8
11
|
async validate(message) {
|
|
12
|
+
const slotNumberBigInt = message.payload.header.slotNumber.toBigInt();
|
|
9
13
|
try {
|
|
10
|
-
const { currentSlot, nextSlot } = await this.epochCache.getProposerAttesterAddressInCurrentOrNextSlot();
|
|
11
|
-
const slotNumberBigInt = message.payload.header.slotNumber.toBigInt();
|
|
14
|
+
const { currentProposer, nextProposer, currentSlot, nextSlot } = await this.epochCache.getProposerAttesterAddressInCurrentOrNextSlot();
|
|
12
15
|
if (slotNumberBigInt !== currentSlot && slotNumberBigInt !== nextSlot) {
|
|
16
|
+
this.logger.warn(`Attestation slot ${slotNumberBigInt} is not current (${currentSlot}) or next (${nextSlot}) slot`);
|
|
13
17
|
return PeerErrorSeverity.HighToleranceError;
|
|
14
18
|
}
|
|
19
|
+
// Verify the attester is in the committee for this slot
|
|
15
20
|
const attester = message.getSender();
|
|
16
21
|
if (!await this.epochCache.isInCommittee(slotNumberBigInt, attester)) {
|
|
22
|
+
this.logger.warn(`Attester ${attester.toString()} is not in committee for slot ${slotNumberBigInt}`);
|
|
23
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
24
|
+
}
|
|
25
|
+
// Verify the proposer signature matches the expected proposer for this slot
|
|
26
|
+
const proposer = message.getProposer();
|
|
27
|
+
const expectedProposer = slotNumberBigInt === currentSlot ? currentProposer : nextProposer;
|
|
28
|
+
if (!expectedProposer) {
|
|
29
|
+
this.logger.warn(`No proposer defined for slot ${slotNumberBigInt}`);
|
|
30
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
31
|
+
}
|
|
32
|
+
if (!proposer.equals(expectedProposer)) {
|
|
33
|
+
this.logger.warn(`Proposer signature mismatch in attestation. ` + `Expected ${expectedProposer?.toString() ?? 'none'} but got ${proposer.toString()} for slot ${slotNumberBigInt}`);
|
|
17
34
|
return PeerErrorSeverity.HighToleranceError;
|
|
18
35
|
}
|
|
19
36
|
return undefined;
|
|
20
37
|
} catch (e) {
|
|
21
38
|
// People shouldn't be sending us attestations if the committee doesn't exist
|
|
22
39
|
if (e instanceof NoCommitteeError) {
|
|
40
|
+
this.logger.warn(`No committee exists for attestation for slot ${slotNumberBigInt}`);
|
|
23
41
|
return PeerErrorSeverity.LowToleranceError;
|
|
24
42
|
}
|
|
25
43
|
throw e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "2.1.0-rc.
|
|
71
|
-
"@aztec/epoch-cache": "2.1.0-rc.
|
|
72
|
-
"@aztec/ethereum": "2.1.0-rc.
|
|
73
|
-
"@aztec/foundation": "2.1.0-rc.
|
|
74
|
-
"@aztec/kv-store": "2.1.0-rc.
|
|
75
|
-
"@aztec/noir-contracts.js": "2.1.0-rc.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "2.1.0-rc.
|
|
77
|
-
"@aztec/protocol-contracts": "2.1.0-rc.
|
|
78
|
-
"@aztec/simulator": "2.1.0-rc.
|
|
79
|
-
"@aztec/stdlib": "2.1.0-rc.
|
|
80
|
-
"@aztec/telemetry-client": "2.1.0-rc.
|
|
70
|
+
"@aztec/constants": "2.1.0-rc.12",
|
|
71
|
+
"@aztec/epoch-cache": "2.1.0-rc.12",
|
|
72
|
+
"@aztec/ethereum": "2.1.0-rc.12",
|
|
73
|
+
"@aztec/foundation": "2.1.0-rc.12",
|
|
74
|
+
"@aztec/kv-store": "2.1.0-rc.12",
|
|
75
|
+
"@aztec/noir-contracts.js": "2.1.0-rc.12",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "2.1.0-rc.12",
|
|
77
|
+
"@aztec/protocol-contracts": "2.1.0-rc.12",
|
|
78
|
+
"@aztec/simulator": "2.1.0-rc.12",
|
|
79
|
+
"@aztec/stdlib": "2.1.0-rc.12",
|
|
80
|
+
"@aztec/telemetry-client": "2.1.0-rc.12",
|
|
81
81
|
"@chainsafe/discv5": "9.0.0",
|
|
82
82
|
"@chainsafe/enr": "3.0.0",
|
|
83
83
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "2.1.0-rc.
|
|
108
|
-
"@aztec/world-state": "2.1.0-rc.
|
|
107
|
+
"@aztec/archiver": "2.1.0-rc.12",
|
|
108
|
+
"@aztec/world-state": "2.1.0-rc.12",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@spalladino/viem": "2.38.2-eip7594.0",
|
|
111
111
|
"@types/jest": "^30.0.0",
|
package/src/client/factory.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-clien
|
|
|
14
14
|
import { P2PClient } from '../client/p2p_client.js';
|
|
15
15
|
import type { P2PConfig } from '../config.js';
|
|
16
16
|
import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
17
|
-
import {
|
|
17
|
+
import { KvAttestationPool } from '../mem_pools/attestation_pool/kv_attestation_pool.js';
|
|
18
18
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
19
19
|
import { AztecKVTxPool, type TxPool } from '../mem_pools/tx_pool/index.js';
|
|
20
20
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
@@ -35,6 +35,7 @@ export type P2PClientDeps<T extends P2PClientType> = {
|
|
|
35
35
|
export const P2P_STORE_NAME = 'p2p';
|
|
36
36
|
export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
37
37
|
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
38
|
+
export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
|
|
38
39
|
|
|
39
40
|
export async function createP2PClient<T extends P2PClientType>(
|
|
40
41
|
clientType: T,
|
|
@@ -64,6 +65,12 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
64
65
|
const store = deps.store ?? (await createStore(P2P_STORE_NAME, 2, config, createLogger('p2p:lmdb-v2')));
|
|
65
66
|
const archive = await createStore(P2P_ARCHIVE_STORE_NAME, 1, config, createLogger('p2p-archive:lmdb-v2'));
|
|
66
67
|
const peerStore = await createStore(P2P_PEER_STORE_NAME, 1, config, createLogger('p2p-peer:lmdb-v2'));
|
|
68
|
+
const attestationStore = await createStore(
|
|
69
|
+
P2P_ATTESTATION_STORE_NAME,
|
|
70
|
+
1,
|
|
71
|
+
config,
|
|
72
|
+
createLogger('p2p-attestation:lmdb-v2'),
|
|
73
|
+
);
|
|
67
74
|
const l1Constants = await archiver.getL1Constants();
|
|
68
75
|
|
|
69
76
|
const mempools: MemPools<T> = {
|
|
@@ -75,7 +82,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
75
82
|
}),
|
|
76
83
|
attestationPool:
|
|
77
84
|
clientType === P2PClientType.Full
|
|
78
|
-
? ((deps.attestationPool ?? new
|
|
85
|
+
? ((deps.attestationPool ?? new KvAttestationPool(attestationStore, telemetry)) as T extends P2PClientType.Full
|
|
79
86
|
? AttestationPool
|
|
80
87
|
: undefined)
|
|
81
88
|
: undefined,
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -387,6 +387,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
387
387
|
return this.attestationPool?.addAttestations(attestations) ?? Promise.resolve();
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
+
public deleteAttestation(attestation: BlockAttestation): Promise<void> {
|
|
391
|
+
return this.attestationPool?.deleteAttestations([attestation]) ?? Promise.resolve();
|
|
392
|
+
}
|
|
393
|
+
|
|
390
394
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
391
395
|
// ^ This pattern is not my favorite (md)
|
|
392
396
|
public registerBlockProposalHandler(handler: P2PBlockReceivedCallback): void {
|
|
@@ -35,8 +35,11 @@ export const mockAttestation = (
|
|
|
35
35
|
const header = makeHeader(1, 2, slot);
|
|
36
36
|
const payload = new ConsensusPayload(header.toPropose(), archive, header.state);
|
|
37
37
|
|
|
38
|
-
const
|
|
39
|
-
const
|
|
38
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
39
|
+
const attestationSignature = signer.sign(attestationHash);
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
42
|
+
const proposerSignature = signer.sign(proposalHash);
|
|
43
|
+
|
|
44
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
42
45
|
};
|
|
@@ -1,31 +1,58 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import { NoCommitteeError } from '@aztec/ethereum';
|
|
3
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { type BlockAttestation, type P2PValidator, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
4
5
|
|
|
5
6
|
export class AttestationValidator implements P2PValidator<BlockAttestation> {
|
|
6
7
|
private epochCache: EpochCacheInterface;
|
|
8
|
+
private logger: Logger;
|
|
7
9
|
|
|
8
10
|
constructor(epochCache: EpochCacheInterface) {
|
|
9
11
|
this.epochCache = epochCache;
|
|
12
|
+
this.logger = createLogger('p2p:attestation-validator');
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
async validate(message: BlockAttestation): Promise<PeerErrorSeverity | undefined> {
|
|
16
|
+
const slotNumberBigInt = message.payload.header.slotNumber.toBigInt();
|
|
17
|
+
|
|
13
18
|
try {
|
|
14
|
-
const { currentSlot, nextSlot } =
|
|
19
|
+
const { currentProposer, nextProposer, currentSlot, nextSlot } =
|
|
20
|
+
await this.epochCache.getProposerAttesterAddressInCurrentOrNextSlot();
|
|
15
21
|
|
|
16
|
-
const slotNumberBigInt = message.payload.header.slotNumber.toBigInt();
|
|
17
22
|
if (slotNumberBigInt !== currentSlot && slotNumberBigInt !== nextSlot) {
|
|
23
|
+
this.logger.warn(
|
|
24
|
+
`Attestation slot ${slotNumberBigInt} is not current (${currentSlot}) or next (${nextSlot}) slot`,
|
|
25
|
+
);
|
|
18
26
|
return PeerErrorSeverity.HighToleranceError;
|
|
19
27
|
}
|
|
20
28
|
|
|
29
|
+
// Verify the attester is in the committee for this slot
|
|
21
30
|
const attester = message.getSender();
|
|
22
31
|
if (!(await this.epochCache.isInCommittee(slotNumberBigInt, attester))) {
|
|
32
|
+
this.logger.warn(`Attester ${attester.toString()} is not in committee for slot ${slotNumberBigInt}`);
|
|
33
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Verify the proposer signature matches the expected proposer for this slot
|
|
37
|
+
const proposer = message.getProposer();
|
|
38
|
+
const expectedProposer = slotNumberBigInt === currentSlot ? currentProposer : nextProposer;
|
|
39
|
+
if (!expectedProposer) {
|
|
40
|
+
this.logger.warn(`No proposer defined for slot ${slotNumberBigInt}`);
|
|
23
41
|
return PeerErrorSeverity.HighToleranceError;
|
|
24
42
|
}
|
|
43
|
+
if (!proposer.equals(expectedProposer)) {
|
|
44
|
+
this.logger.warn(
|
|
45
|
+
`Proposer signature mismatch in attestation. ` +
|
|
46
|
+
`Expected ${expectedProposer?.toString() ?? 'none'} but got ${proposer.toString()} for slot ${slotNumberBigInt}`,
|
|
47
|
+
);
|
|
48
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
49
|
+
}
|
|
50
|
+
|
|
25
51
|
return undefined;
|
|
26
52
|
} catch (e) {
|
|
27
53
|
// People shouldn't be sending us attestations if the committee doesn't exist
|
|
28
54
|
if (e instanceof NoCommitteeError) {
|
|
55
|
+
this.logger.warn(`No committee exists for attestation for slot ${slotNumberBigInt}`);
|
|
29
56
|
return PeerErrorSeverity.LowToleranceError;
|
|
30
57
|
}
|
|
31
58
|
throw e;
|