@aztec/p2p 3.0.0-nightly.20251023 → 3.0.0-nightly.20251024
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/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +4 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +8 -1
- package/dest/services/libp2p/libp2p_service.js +3 -1
- package/package.json +14 -14
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +11 -1
- package/src/services/libp2p/libp2p_service.ts +1 -1
|
@@ -3,7 +3,10 @@ import { type BlockProposal, type P2PValidator, PeerErrorSeverity } from '@aztec
|
|
|
3
3
|
export declare class BlockProposalValidator implements P2PValidator<BlockProposal> {
|
|
4
4
|
private epochCache;
|
|
5
5
|
private logger;
|
|
6
|
-
|
|
6
|
+
private txsPermitted;
|
|
7
|
+
constructor(epochCache: EpochCacheInterface, opts: {
|
|
8
|
+
txsPermitted: boolean;
|
|
9
|
+
});
|
|
7
10
|
validate(block: BlockProposal): Promise<PeerErrorSeverity | undefined>;
|
|
8
11
|
}
|
|
9
12
|
//# sourceMappingURL=block_proposal_validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/block_proposal_validator/block_proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7F,qBAAa,sBAAuB,YAAW,YAAY,CAAC,aAAa,CAAC;IACxE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAS;
|
|
1
|
+
{"version":3,"file":"block_proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/block_proposal_validator/block_proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7F,qBAAa,sBAAuB,YAAW,YAAY,CAAC,aAAa,CAAC;IACxE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAU;gBAElB,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE;IAMtE,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;CAgE7E"}
|
|
@@ -4,8 +4,10 @@ import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
|
4
4
|
export class BlockProposalValidator {
|
|
5
5
|
epochCache;
|
|
6
6
|
logger;
|
|
7
|
-
|
|
7
|
+
txsPermitted;
|
|
8
|
+
constructor(epochCache, opts){
|
|
8
9
|
this.epochCache = epochCache;
|
|
10
|
+
this.txsPermitted = opts.txsPermitted;
|
|
9
11
|
this.logger = createLogger('p2p:block_proposal_validator');
|
|
10
12
|
}
|
|
11
13
|
async validate(block) {
|
|
@@ -16,6 +18,11 @@ export class BlockProposalValidator {
|
|
|
16
18
|
this.logger.debug(`Penalizing peer for block proposal with invalid signature`);
|
|
17
19
|
return PeerErrorSeverity.MidToleranceError;
|
|
18
20
|
}
|
|
21
|
+
// Check if transactions are permitted when the proposal contains transaction hashes
|
|
22
|
+
if (!this.txsPermitted && block.txHashes.length > 0) {
|
|
23
|
+
this.logger.debug(`Penalizing peer for block proposal with ${block.txHashes.length} transaction(s) when transactions are not permitted`);
|
|
24
|
+
return PeerErrorSeverity.MidToleranceError;
|
|
25
|
+
}
|
|
19
26
|
const { currentProposer, nextProposer, currentSlot, nextSlot } = await this.epochCache.getProposerAttesterAddressInCurrentOrNextSlot();
|
|
20
27
|
// Check that the attestation is for the current or next slot
|
|
21
28
|
const slotNumberBigInt = block.payload.header.slotNumber.toBigInt();
|
|
@@ -94,7 +94,9 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
94
94
|
this.topicStrings[TopicType.block_proposal] = createTopicString(TopicType.block_proposal, this.protocolVersion);
|
|
95
95
|
this.topicStrings[TopicType.block_attestation] = createTopicString(TopicType.block_attestation, this.protocolVersion);
|
|
96
96
|
this.attestationValidator = new AttestationValidator(epochCache);
|
|
97
|
-
this.blockProposalValidator = new BlockProposalValidator(epochCache
|
|
97
|
+
this.blockProposalValidator = new BlockProposalValidator(epochCache, {
|
|
98
|
+
txsPermitted: !config.disableTransactions
|
|
99
|
+
});
|
|
98
100
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
99
101
|
this.blockReceivedCallback = async (block)=>{
|
|
100
102
|
this.logger.debug(`Handler not yet registered: Block received callback not set. Received block for slot ${block.slotNumber.toNumber()} from peer.`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251024",
|
|
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": "3.0.0-nightly.
|
|
71
|
-
"@aztec/epoch-cache": "3.0.0-nightly.
|
|
72
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
73
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
74
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
75
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
77
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
78
|
-
"@aztec/simulator": "3.0.0-nightly.
|
|
79
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
80
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
70
|
+
"@aztec/constants": "3.0.0-nightly.20251024",
|
|
71
|
+
"@aztec/epoch-cache": "3.0.0-nightly.20251024",
|
|
72
|
+
"@aztec/ethereum": "3.0.0-nightly.20251024",
|
|
73
|
+
"@aztec/foundation": "3.0.0-nightly.20251024",
|
|
74
|
+
"@aztec/kv-store": "3.0.0-nightly.20251024",
|
|
75
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251024",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251024",
|
|
77
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251024",
|
|
78
|
+
"@aztec/simulator": "3.0.0-nightly.20251024",
|
|
79
|
+
"@aztec/stdlib": "3.0.0-nightly.20251024",
|
|
80
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251024",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "3.0.0-nightly.
|
|
108
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
107
|
+
"@aztec/archiver": "3.0.0-nightly.20251024",
|
|
108
|
+
"@aztec/world-state": "3.0.0-nightly.20251024",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
|
@@ -6,9 +6,11 @@ import { type BlockProposal, type P2PValidator, PeerErrorSeverity } from '@aztec
|
|
|
6
6
|
export class BlockProposalValidator implements P2PValidator<BlockProposal> {
|
|
7
7
|
private epochCache: EpochCacheInterface;
|
|
8
8
|
private logger: Logger;
|
|
9
|
+
private txsPermitted: boolean;
|
|
9
10
|
|
|
10
|
-
constructor(epochCache: EpochCacheInterface) {
|
|
11
|
+
constructor(epochCache: EpochCacheInterface, opts: { txsPermitted: boolean }) {
|
|
11
12
|
this.epochCache = epochCache;
|
|
13
|
+
this.txsPermitted = opts.txsPermitted;
|
|
12
14
|
this.logger = createLogger('p2p:block_proposal_validator');
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -21,6 +23,14 @@ export class BlockProposalValidator implements P2PValidator<BlockProposal> {
|
|
|
21
23
|
return PeerErrorSeverity.MidToleranceError;
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
// Check if transactions are permitted when the proposal contains transaction hashes
|
|
27
|
+
if (!this.txsPermitted && block.txHashes.length > 0) {
|
|
28
|
+
this.logger.debug(
|
|
29
|
+
`Penalizing peer for block proposal with ${block.txHashes.length} transaction(s) when transactions are not permitted`,
|
|
30
|
+
);
|
|
31
|
+
return PeerErrorSeverity.MidToleranceError;
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
const { currentProposer, nextProposer, currentSlot, nextSlot } =
|
|
25
35
|
await this.epochCache.getProposerAttesterAddressInCurrentOrNextSlot();
|
|
26
36
|
|
|
@@ -170,7 +170,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
170
170
|
);
|
|
171
171
|
|
|
172
172
|
this.attestationValidator = new AttestationValidator(epochCache);
|
|
173
|
-
this.blockProposalValidator = new BlockProposalValidator(epochCache);
|
|
173
|
+
this.blockProposalValidator = new BlockProposalValidator(epochCache, { txsPermitted: !config.disableTransactions });
|
|
174
174
|
|
|
175
175
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
176
176
|
|