@aztec/p2p 4.0.0-devnet.2-patch.4 → 4.0.0-devnet.3-patch.0

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.
Files changed (212) hide show
  1. package/README.md +129 -3
  2. package/dest/client/factory.d.ts +4 -5
  3. package/dest/client/factory.d.ts.map +1 -1
  4. package/dest/client/factory.js +30 -28
  5. package/dest/client/interface.d.ts +8 -13
  6. package/dest/client/interface.d.ts.map +1 -1
  7. package/dest/client/p2p_client.d.ts +6 -13
  8. package/dest/client/p2p_client.d.ts.map +1 -1
  9. package/dest/client/p2p_client.js +22 -88
  10. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +2 -4
  11. package/dest/config.d.ts +29 -10
  12. package/dest/config.d.ts.map +1 -1
  13. package/dest/config.js +80 -31
  14. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  15. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  16. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +2 -1
  17. package/dest/mem_pools/tx_pool/priority.d.ts +2 -2
  18. package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
  19. package/dest/mem_pools/tx_pool/priority.js +4 -4
  20. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
  21. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  22. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -1
  23. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  24. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  25. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -2
  26. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
  27. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  28. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +2 -0
  29. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +7 -1
  30. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
  31. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
  32. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
  33. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  34. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +10 -6
  35. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
  36. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
  37. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +8 -6
  38. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
  39. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
  41. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
  42. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool_v2/index.js +1 -1
  44. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +9 -5
  45. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  46. package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
  47. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +46 -8
  48. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +81 -17
  50. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
  51. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  52. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +9 -10
  53. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +5 -3
  54. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  55. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +3 -0
  56. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +2 -2
  57. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  58. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +179 -151
  59. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
  60. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  61. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
  62. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
  63. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  64. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
  65. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
  66. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  67. package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
  68. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
  69. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  70. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
  71. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  72. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  73. package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
  74. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  75. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  76. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  77. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  78. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  79. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  80. package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
  81. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  82. package/dest/msg_validators/tx_validator/data_validator.js +35 -2
  83. package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
  84. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  85. package/dest/msg_validators/tx_validator/factory.js +247 -60
  86. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
  87. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
  88. package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
  89. package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
  90. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  91. package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
  92. package/dest/msg_validators/tx_validator/index.d.ts +3 -1
  93. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  94. package/dest/msg_validators/tx_validator/index.js +2 -0
  95. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
  96. package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
  97. package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
  98. package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
  99. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  100. package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
  101. package/dest/services/dummy_service.d.ts +4 -4
  102. package/dest/services/dummy_service.d.ts.map +1 -1
  103. package/dest/services/dummy_service.js +4 -4
  104. package/dest/services/encoding.d.ts +6 -2
  105. package/dest/services/encoding.d.ts.map +1 -1
  106. package/dest/services/encoding.js +14 -8
  107. package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
  108. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  109. package/dest/services/gossipsub/topic_score_params.js +32 -10
  110. package/dest/services/libp2p/libp2p_service.d.ts +16 -13
  111. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  112. package/dest/services/libp2p/libp2p_service.js +97 -93
  113. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
  114. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
  115. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  116. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
  117. package/dest/services/reqresp/reqresp.d.ts +1 -1
  118. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  119. package/dest/services/reqresp/reqresp.js +16 -8
  120. package/dest/services/service.d.ts +5 -3
  121. package/dest/services/service.d.ts.map +1 -1
  122. package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
  123. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  124. package/dest/services/tx_collection/file_store_tx_source.js +39 -29
  125. package/dest/services/tx_collection/tx_source.d.ts +6 -5
  126. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  127. package/dest/services/tx_collection/tx_source.js +9 -7
  128. package/dest/services/tx_provider.d.ts +3 -3
  129. package/dest/services/tx_provider.d.ts.map +1 -1
  130. package/dest/services/tx_provider.js +4 -4
  131. package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
  132. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  133. package/dest/test-helpers/make-test-p2p-clients.js +1 -2
  134. package/dest/test-helpers/mock-pubsub.d.ts +4 -4
  135. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  136. package/dest/test-helpers/mock-pubsub.js +8 -2
  137. package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
  138. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  139. package/dest/test-helpers/reqresp-nodes.js +2 -2
  140. package/dest/test-helpers/testbench-utils.d.ts +2 -2
  141. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  142. package/dest/test-helpers/testbench-utils.js +2 -1
  143. package/dest/testbench/p2p_client_testbench_worker.js +7 -6
  144. package/dest/testbench/worker_client_manager.d.ts +3 -1
  145. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  146. package/dest/testbench/worker_client_manager.js +4 -1
  147. package/dest/util.d.ts +2 -2
  148. package/dest/util.d.ts.map +1 -1
  149. package/package.json +14 -14
  150. package/src/client/factory.ts +49 -45
  151. package/src/client/interface.ts +8 -13
  152. package/src/client/p2p_client.ts +24 -117
  153. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +2 -3
  154. package/src/config.ts +115 -33
  155. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +2 -1
  156. package/src/mem_pools/tx_pool/priority.ts +4 -4
  157. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
  158. package/src/mem_pools/tx_pool_v2/README.md +9 -1
  159. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +3 -2
  160. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -0
  161. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
  162. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +2 -2
  163. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +10 -6
  164. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
  165. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
  166. package/src/mem_pools/tx_pool_v2/index.ts +1 -1
  167. package/src/mem_pools/tx_pool_v2/interfaces.ts +9 -4
  168. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +113 -18
  169. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +11 -11
  170. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +14 -2
  171. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +188 -153
  172. package/src/msg_validators/attestation_validator/README.md +49 -0
  173. package/src/msg_validators/proposal_validator/README.md +123 -0
  174. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
  175. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
  176. package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -40
  177. package/src/msg_validators/tx_validator/README.md +119 -0
  178. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
  179. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  180. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  181. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  182. package/src/msg_validators/tx_validator/data_validator.ts +42 -1
  183. package/src/msg_validators/tx_validator/factory.ts +394 -78
  184. package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
  185. package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
  186. package/src/msg_validators/tx_validator/index.ts +2 -0
  187. package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
  188. package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
  189. package/src/services/dummy_service.ts +6 -6
  190. package/src/services/encoding.ts +14 -7
  191. package/src/services/gossipsub/README.md +29 -14
  192. package/src/services/gossipsub/topic_score_params.ts +49 -13
  193. package/src/services/libp2p/libp2p_service.ts +111 -101
  194. package/src/services/reqresp/README.md +229 -0
  195. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
  196. package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
  197. package/src/services/reqresp/reqresp.ts +18 -10
  198. package/src/services/service.ts +11 -2
  199. package/src/services/tx_collection/file_store_tx_source.ts +43 -31
  200. package/src/services/tx_collection/tx_source.ts +8 -7
  201. package/src/services/tx_provider.ts +2 -2
  202. package/src/test-helpers/make-test-p2p-clients.ts +0 -2
  203. package/src/test-helpers/mock-pubsub.ts +13 -6
  204. package/src/test-helpers/reqresp-nodes.ts +2 -5
  205. package/src/test-helpers/testbench-utils.ts +2 -1
  206. package/src/testbench/p2p_client_testbench_worker.ts +3 -6
  207. package/src/testbench/worker_client_manager.ts +11 -4
  208. package/src/util.ts +7 -1
  209. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
  210. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
  211. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
  212. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
@@ -1,4 +1,10 @@
1
- import { AVM_MAX_PROCESSABLE_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS } from '@aztec/constants';
1
+ import {
2
+ MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
3
+ MAX_PROCESSABLE_L2_GAS,
4
+ PRIVATE_TX_L2_GAS_OVERHEAD,
5
+ PUBLIC_TX_L2_GAS_OVERHEAD,
6
+ TX_DA_GAS_OVERHEAD,
7
+ } from '@aztec/constants';
2
8
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
9
  import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
4
10
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -16,26 +22,138 @@ import {
16
22
 
17
23
  import { getFeePayerClaimAmount, getTxFeeLimit } from './fee_payer_balance.js';
18
24
 
25
+ /** Structural interface for types that carry gas limit data, used by {@link GasLimitsValidator}. */
26
+ export interface HasGasLimitData {
27
+ txHash: { toString(): string };
28
+ data: {
29
+ // We just need to know whether there is something here or not
30
+ forPublic?: unknown;
31
+ constants: {
32
+ txContext: {
33
+ gasSettings: { gasLimits: Gas };
34
+ };
35
+ };
36
+ };
37
+ }
38
+
39
+ /**
40
+ * Validates that a transaction's gas limits are within acceptable bounds.
41
+ *
42
+ * Rejects transactions whose gas limits fall below the fixed minimums (FIXED_DA_GAS,
43
+ * FIXED_L2_GAS) or exceed the AVM's maximum processable L2 gas. This is a cheap,
44
+ * stateless check that operates on gas settings alone.
45
+ *
46
+ * Generic over T so it can validate both full {@link Tx} objects and {@link TxMetaData}
47
+ * (used during pending pool migration).
48
+ *
49
+ * Used by: pending pool migration (via factory), and indirectly by {@link GasTxValidator}.
50
+ */
51
+ export class GasLimitsValidator<T extends HasGasLimitData> implements TxValidator<T> {
52
+ #log: Logger;
53
+ #effectiveMaxL2Gas: number;
54
+ #effectiveMaxDAGas: number;
55
+ #rollupManaLimit: number;
56
+ #maxBlockL2Gas: number;
57
+ #maxBlockDAGas: number;
58
+
59
+ constructor(opts?: {
60
+ rollupManaLimit?: number;
61
+ maxBlockL2Gas?: number;
62
+ maxBlockDAGas?: number;
63
+ bindings?: LoggerBindings;
64
+ }) {
65
+ this.#log = createLogger('sequencer:tx_validator:tx_gas', opts?.bindings);
66
+ this.#rollupManaLimit = opts?.rollupManaLimit ?? Infinity;
67
+ this.#maxBlockL2Gas = opts?.maxBlockL2Gas ?? Infinity;
68
+ this.#maxBlockDAGas = opts?.maxBlockDAGas ?? Infinity;
69
+ this.#effectiveMaxL2Gas = Math.min(MAX_PROCESSABLE_L2_GAS, this.#rollupManaLimit, this.#maxBlockL2Gas);
70
+ this.#effectiveMaxDAGas = Math.min(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, this.#maxBlockDAGas);
71
+ }
72
+
73
+ validateTx(tx: T): Promise<TxValidationResult> {
74
+ return Promise.resolve(this.validateGasLimit(tx));
75
+ }
76
+
77
+ /** Checks gas limits are >= fixed minimums and <= effective max gas (L2 and DA). */
78
+ validateGasLimit(tx: T): TxValidationResult {
79
+ const gasLimits = tx.data.constants.txContext.gasSettings.gasLimits;
80
+ const minGasLimits = new Gas(
81
+ TX_DA_GAS_OVERHEAD,
82
+ tx.data.forPublic ? PUBLIC_TX_L2_GAS_OVERHEAD : PRIVATE_TX_L2_GAS_OVERHEAD,
83
+ );
84
+
85
+ if (minGasLimits.gtAny(gasLimits)) {
86
+ this.#log.verbose(`Rejecting transaction due to the gas limit(s) not being above the minimum gas limit`, {
87
+ gasLimits,
88
+ minGasLimits,
89
+ });
90
+ return { result: 'invalid', reason: [TX_ERROR_INSUFFICIENT_GAS_LIMIT] };
91
+ }
92
+
93
+ if (gasLimits.l2Gas > this.#effectiveMaxL2Gas) {
94
+ this.#log.verbose(`Rejecting transaction due to the L2 gas limit being higher than the effective maximum`, {
95
+ gasLimits,
96
+ effectiveMaxL2Gas: this.#effectiveMaxL2Gas,
97
+ rollupManaLimit: this.#rollupManaLimit,
98
+ maxBlockL2Gas: this.#maxBlockL2Gas,
99
+ });
100
+ return { result: 'invalid', reason: [TX_ERROR_GAS_LIMIT_TOO_HIGH] };
101
+ }
102
+
103
+ if (gasLimits.daGas > this.#effectiveMaxDAGas) {
104
+ this.#log.verbose(`Rejecting transaction due to the DA gas limit being higher than the effective maximum`, {
105
+ gasLimits,
106
+ effectiveMaxDAGas: this.#effectiveMaxDAGas,
107
+ maxBlockDAGas: this.#maxBlockDAGas,
108
+ });
109
+ return { result: 'invalid', reason: [TX_ERROR_GAS_LIMIT_TOO_HIGH] };
110
+ }
111
+
112
+ return { result: 'valid' };
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Validates that a transaction can pay its gas fees.
118
+ *
119
+ * Runs three checks in order:
120
+ * 1. **Gas limits** (delegates to {@link GasLimitsValidator}) — rejects if limits are
121
+ * out of bounds.
122
+ * 2. **Max fee per gas** — skips (not rejects) the tx if its maxFeesPerGas is below
123
+ * the current block's gas fees. We skip rather than reject because the tx may
124
+ * become eligible in a later block with lower fees.
125
+ * 3. **Fee payer balance** — reads the fee payer's FeeJuice balance from public state,
126
+ * adds any pending claim from a setup-phase `_increase_public_balance` call, and
127
+ * rejects if the total is less than the tx's fee limit (gasLimits * maxFeePerGas).
128
+ *
129
+ * Used by: gossip (stage 1), RPC, and block building validators.
130
+ */
19
131
  export class GasTxValidator implements TxValidator<Tx> {
20
132
  #log: Logger;
21
133
  #publicDataSource: PublicStateSource;
22
134
  #feeJuiceAddress: AztecAddress;
23
135
  #gasFees: GasFees;
136
+ #gasLimitOpts?: { rollupManaLimit?: number; maxBlockL2Gas?: number; maxBlockDAGas?: number };
24
137
 
25
138
  constructor(
26
139
  publicDataSource: PublicStateSource,
27
140
  feeJuiceAddress: AztecAddress,
28
141
  gasFees: GasFees,
29
- bindings?: LoggerBindings,
142
+ private bindings?: LoggerBindings,
143
+ opts?: { rollupManaLimit?: number; maxBlockL2Gas?: number; maxBlockDAGas?: number },
30
144
  ) {
31
145
  this.#log = createLogger('sequencer:tx_validator:tx_gas', bindings);
32
146
  this.#publicDataSource = publicDataSource;
33
147
  this.#feeJuiceAddress = feeJuiceAddress;
34
148
  this.#gasFees = gasFees;
149
+ this.#gasLimitOpts = opts;
35
150
  }
36
151
 
37
152
  async validateTx(tx: Tx): Promise<TxValidationResult> {
38
- const gasLimitValidation = this.#validateGasLimit(tx);
153
+ const gasLimitValidation = new GasLimitsValidator({
154
+ ...this.#gasLimitOpts,
155
+ bindings: this.bindings,
156
+ }).validateGasLimit(tx);
39
157
  if (gasLimitValidation.result === 'invalid') {
40
158
  return Promise.resolve(gasLimitValidation);
41
159
  }
@@ -69,31 +187,9 @@ export class GasTxValidator implements TxValidator<Tx> {
69
187
  }
70
188
 
71
189
  /**
72
- * Check whether the tx's gas limit is above the minimum amount.
190
+ * Checks the fee payer has enough FeeJuice balance to cover the tx's fee limit.
191
+ * Accounts for any pending claim from a setup-phase `_increase_public_balance` call.
73
192
  */
74
- #validateGasLimit(tx: Tx): TxValidationResult {
75
- const gasLimits = tx.data.constants.txContext.gasSettings.gasLimits;
76
- const minGasLimits = new Gas(FIXED_DA_GAS, FIXED_L2_GAS);
77
-
78
- if (minGasLimits.gtAny(gasLimits)) {
79
- this.#log.verbose(`Rejecting transaction due to the gas limit(s) not being above the minimum gas limit`, {
80
- gasLimits,
81
- minGasLimits,
82
- });
83
- return { result: 'invalid', reason: [TX_ERROR_INSUFFICIENT_GAS_LIMIT] };
84
- }
85
-
86
- if (gasLimits.l2Gas > AVM_MAX_PROCESSABLE_L2_GAS) {
87
- this.#log.verbose(`Rejecting transaction due to the gas limit(s) being higher than the maximum processable gas`, {
88
- gasLimits,
89
- minGasLimits,
90
- });
91
- return { result: 'invalid', reason: [TX_ERROR_GAS_LIMIT_TOO_HIGH] };
92
- }
93
-
94
- return { result: 'valid' };
95
- }
96
-
97
193
  public async validateTxFee(tx: Tx): Promise<TxValidationResult> {
98
194
  const feePayer = tx.data.feePayer;
99
195
 
@@ -8,7 +8,9 @@ export * from './gas_validator.js';
8
8
  export * from './phases_validator.js';
9
9
  export * from './test_utils.js';
10
10
  export * from './allowed_public_setup.js';
11
+ export * from './allowed_setup_helpers.js';
11
12
  export * from './archive_cache.js';
12
13
  export * from './tx_permitted_validator.js';
13
14
  export * from './timestamp_validator.js';
14
15
  export * from './size_validator.js';
16
+ export * from './factory.js';
@@ -0,0 +1,30 @@
1
+ import type { NullifierSource } from '@aztec/p2p';
2
+ import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
3
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
4
+
5
+ /**
6
+ * Implements a nullifier source by checking a DB and an in-memory collection.
7
+ * Intended for validating transactions as they are added to a block.
8
+ */
9
+ export class NullifierCache implements NullifierSource {
10
+ nullifiers: Set<string>;
11
+
12
+ constructor(private db: MerkleTreeReadOperations) {
13
+ this.nullifiers = new Set();
14
+ }
15
+
16
+ public async nullifiersExist(nullifiers: Buffer[]): Promise<boolean[]> {
17
+ const cacheResults = nullifiers.map(n => this.nullifiers.has(n.toString()));
18
+ const toCheckDb = nullifiers.filter((_n, index) => !cacheResults[index]);
19
+ const dbHits = await this.db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, toCheckDb);
20
+
21
+ let dbIndex = 0;
22
+ return nullifiers.map((_n, index) => cacheResults[index] || dbHits[dbIndex++] !== undefined);
23
+ }
24
+
25
+ public addNullifiers(nullifiers: Buffer[]) {
26
+ for (const nullifier of nullifiers) {
27
+ this.nullifiers.add(nullifier.toString());
28
+ }
29
+ }
30
+ }
@@ -1,11 +1,17 @@
1
+ import { NULL_MSG_SENDER_CONTRACT_ADDRESS } from '@aztec/constants';
1
2
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
3
  import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
5
  import type { ContractDataSource } from '@aztec/stdlib/contract';
4
6
  import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
5
7
  import {
6
8
  type PublicCallRequestWithCalldata,
7
9
  TX_ERROR_DURING_VALIDATION,
8
10
  TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED,
11
+ TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT,
12
+ TX_ERROR_SETUP_NULL_MSG_SENDER,
13
+ TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER,
14
+ TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH,
9
15
  Tx,
10
16
  TxExecutionPhase,
11
17
  type TxValidationResult,
@@ -34,7 +40,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
34
40
  // which are needed for public FPC flows, but fail if the account contract hasnt been deployed yet,
35
41
  // which is what we're trying to do as part of the current txs.
36
42
  // We only need to create/revert checkpoint here because of this addNewContracts call.
37
- await this.contractsDB.addNewContracts(tx);
43
+ this.contractsDB.addNewContracts(tx);
38
44
 
39
45
  if (!tx.data.forPublic) {
40
46
  this.#log.debug(
@@ -45,7 +51,8 @@ export class PhasesTxValidator implements TxValidator<Tx> {
45
51
 
46
52
  const setupFns = getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP);
47
53
  for (const setupFn of setupFns) {
48
- if (!(await this.isOnAllowList(setupFn, this.setupAllowList))) {
54
+ const rejectionReason = await this.checkAllowList(setupFn, this.setupAllowList);
55
+ if (rejectionReason) {
49
56
  this.#log.verbose(
50
57
  `Rejecting tx ${tx.getTxHash().toString()} because it calls setup function not on allow list: ${
51
58
  setupFn.request.contractAddress
@@ -53,7 +60,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
53
60
  { allowList: this.setupAllowList },
54
61
  );
55
62
 
56
- return { result: 'invalid', reason: [TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED] };
63
+ return { result: 'invalid', reason: [rejectionReason] };
57
64
  }
58
65
  }
59
66
 
@@ -66,53 +73,101 @@ export class PhasesTxValidator implements TxValidator<Tx> {
66
73
  }
67
74
  }
68
75
 
69
- private async isOnAllowList(
76
+ /** Returns a rejection reason if the call is not on the allow list, or undefined if it is allowed. */
77
+ private async checkAllowList(
70
78
  publicCall: PublicCallRequestWithCalldata,
71
79
  allowList: AllowedElement[],
72
- ): Promise<boolean> {
80
+ ): Promise<string | undefined> {
73
81
  if (publicCall.isEmpty()) {
74
- return true;
82
+ return undefined;
75
83
  }
76
84
 
77
85
  const contractAddress = publicCall.request.contractAddress;
78
86
  const functionSelector = publicCall.functionSelector;
79
87
 
80
- // do these checks first since they don't require the contract class
88
+ // Check address-based entries first since they don't require the contract class.
81
89
  for (const entry of allowList) {
82
- if ('address' in entry && !('selector' in entry)) {
83
- if (contractAddress.equals(entry.address)) {
84
- return true;
85
- }
86
- }
87
-
88
- if ('address' in entry && 'selector' in entry) {
90
+ if ('address' in entry) {
89
91
  if (contractAddress.equals(entry.address) && entry.selector.equals(functionSelector)) {
90
- return true;
92
+ if (entry.calldataLength !== undefined && publicCall.calldata.length !== entry.calldataLength) {
93
+ return TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH;
94
+ }
95
+ if (entry.onlySelf && !publicCall.request.msgSender.equals(contractAddress)) {
96
+ return TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER;
97
+ }
98
+ if (
99
+ entry.rejectNullMsgSender &&
100
+ publicCall.request.msgSender.equals(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS))
101
+ ) {
102
+ return TX_ERROR_SETUP_NULL_MSG_SENDER;
103
+ }
104
+ return undefined;
91
105
  }
92
106
  }
107
+ }
93
108
 
94
- const contractClass = await this.contractsDB.getContractInstance(contractAddress, this.timestamp);
95
-
96
- if (!contractClass) {
97
- throw new Error(`Contract not found: ${contractAddress}`);
109
+ // Check class-based entries. Fetch the contract instance lazily (only once).
110
+ let contractClassId: undefined | { value: string | undefined };
111
+ for (const entry of allowList) {
112
+ if (!('classId' in entry)) {
113
+ continue;
98
114
  }
99
115
 
100
- if ('classId' in entry && !('selector' in entry)) {
101
- if (contractClass.currentContractClassId.equals(entry.classId)) {
102
- return true;
116
+ if (contractClassId === undefined) {
117
+ const instance = await this.contractsDB.getContractInstance(contractAddress, this.timestamp);
118
+ contractClassId = { value: instance?.currentContractClassId.toString() };
119
+ if (!contractClassId.value) {
120
+ return TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT;
103
121
  }
104
122
  }
105
123
 
106
- if ('classId' in entry && 'selector' in entry) {
124
+ if (contractClassId.value === entry.classId.toString() && entry.selector.equals(functionSelector)) {
125
+ if (entry.calldataLength !== undefined && publicCall.calldata.length !== entry.calldataLength) {
126
+ return TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH;
127
+ }
128
+ if (entry.onlySelf && !publicCall.request.msgSender.equals(contractAddress)) {
129
+ return TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER;
130
+ }
107
131
  if (
108
- contractClass.currentContractClassId.equals(entry.classId) &&
109
- (entry.selector === undefined || entry.selector.equals(functionSelector))
132
+ entry.rejectNullMsgSender &&
133
+ publicCall.request.msgSender.equals(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS))
110
134
  ) {
111
- return true;
135
+ return TX_ERROR_SETUP_NULL_MSG_SENDER;
112
136
  }
137
+ return undefined;
113
138
  }
114
139
  }
115
140
 
116
- return false;
141
+ return TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED;
142
+ }
143
+ }
144
+
145
+ /** Structural interface for the allowed-setup-calls flag check. */
146
+ export interface HasAllowedSetupCallsData {
147
+ txHash: { toString(): string };
148
+ allowedSetupCalls: boolean;
149
+ }
150
+
151
+ /**
152
+ * Validates that a transaction's setup-phase calls were allowed at receipt time.
153
+ *
154
+ * Checks the precomputed `allowedSetupCalls` flag on TxMetaData. The flag is
155
+ * computed by running the PhasesTxValidator on the full Tx when it first enters
156
+ * the pool. This lightweight validator is used during pending pool migration to
157
+ * reject txs whose setup calls are not on the allow list.
158
+ */
159
+ export class AllowedSetupCallsMetaValidator<T extends HasAllowedSetupCallsData> implements TxValidator<T> {
160
+ #log: Logger;
161
+
162
+ constructor(bindings?: LoggerBindings) {
163
+ this.#log = createLogger('sequencer:tx_validator:tx_phases_meta', bindings);
164
+ }
165
+
166
+ validateTx(tx: T): Promise<TxValidationResult> {
167
+ if (!tx.allowedSetupCalls) {
168
+ this.#log.verbose(`Rejecting tx ${tx.txHash} because its setup calls are not on the allow list`);
169
+ return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED] });
170
+ }
171
+ return Promise.resolve({ result: 'valid' });
117
172
  }
118
173
  }
@@ -1,6 +1,6 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
- import type { Gossipable, PeerErrorSeverity } from '@aztec/stdlib/p2p';
3
+ import type { Gossipable, PeerErrorSeverity, TopicType } from '@aztec/stdlib/p2p';
4
4
  import { Tx, TxHash } from '@aztec/stdlib/tx';
5
5
 
6
6
  import type { PeerId } from '@libp2p/interface';
@@ -44,6 +44,10 @@ export class DummyP2PService implements P2PService {
44
44
  return [];
45
45
  }
46
46
 
47
+ getGossipMeshPeerCount(_topicType: TopicType): number {
48
+ return 0;
49
+ }
50
+
47
51
  /**
48
52
  * Starts the dummy implementation.
49
53
  * @returns A resolved promise.
@@ -137,14 +141,10 @@ export class DummyP2PService implements P2PService {
137
141
  return undefined;
138
142
  }
139
143
 
140
- validate(_txs: Tx[]): Promise<void> {
144
+ validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
141
145
  return Promise.resolve();
142
146
  }
143
147
 
144
- validatePropagatedTx(_tx: Tx, _peerId: PeerId): Promise<boolean> {
145
- return Promise.resolve(true);
146
- }
147
-
148
148
  addReqRespSubProtocol(
149
149
  _subProtocol: ReqRespSubProtocol,
150
150
  _handler: ReqRespSubProtocolHandler,
@@ -1,14 +1,22 @@
1
1
  // Taken from lodestar: https://github.com/ChainSafe/lodestar
2
- import { sha256 } from '@aztec/foundation/crypto/sha256';
3
2
  import { createLogger } from '@aztec/foundation/log';
4
3
  import { MAX_TX_SIZE_KB, TopicType, getTopicFromString } from '@aztec/stdlib/p2p';
5
4
 
6
5
  import type { RPC } from '@chainsafe/libp2p-gossipsub/message';
7
6
  import type { DataTransform } from '@chainsafe/libp2p-gossipsub/types';
8
7
  import type { Message } from '@libp2p/interface';
8
+ import { webcrypto } from 'node:crypto';
9
9
  import { compressSync, uncompressSync } from 'snappy';
10
10
  import xxhashFactory from 'xxhash-wasm';
11
11
 
12
+ /** Thrown when a Snappy-compressed response exceeds the allowed decompressed size. */
13
+ export class OversizedSnappyResponseError extends Error {
14
+ constructor(decompressedSize: number, maxSizeKb: number) {
15
+ super(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);
16
+ this.name = 'OversizedSnappyResponseError';
17
+ }
18
+ }
19
+
12
20
  // Load WASM
13
21
  const xxhash = await xxhashFactory();
14
22
 
@@ -44,11 +52,10 @@ export function msgIdToStrFn(msgId: Uint8Array): string {
44
52
  * @param message - The libp2p message
45
53
  * @returns The message identifier
46
54
  */
47
- export function getMsgIdFn(message: Message) {
48
- const { topic } = message;
49
-
50
- const vec = [Buffer.from(topic), message.data];
51
- return sha256(Buffer.concat(vec)).subarray(0, 20);
55
+ export async function getMsgIdFn({ topic, data }: Message): Promise<Uint8Array> {
56
+ const buffer = Buffer.concat([Buffer.from(topic), data]);
57
+ const hash = await webcrypto.subtle.digest('SHA-256', buffer);
58
+ return Buffer.from(hash.slice(0, 20));
52
59
  }
53
60
 
54
61
  const DefaultMaxSizesKb: Record<TopicType, number> = {
@@ -87,7 +94,7 @@ export class SnappyTransform implements DataTransform {
87
94
  const { decompressedSize } = readSnappyPreamble(data);
88
95
  if (decompressedSize > maxSizeKb * 1024) {
89
96
  this.logger.warn(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);
90
- throw new Error(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);
97
+ throw new OversizedSnappyResponseError(decompressedSize, maxSizeKb);
91
98
  }
92
99
 
93
100
  return Buffer.from(uncompressSync(data, { asBuffer: true }));
@@ -40,7 +40,7 @@ We configure all parameters (P1-P4) with values calculated dynamically from netw
40
40
  | P3b: meshFailurePenalty | -34 per topic | Sticky penalty after pruning |
41
41
  | P4: invalidMessageDeliveries | -20 per message | Attack detection |
42
42
 
43
- **Important:** P1 and P2 are only enabled on topics with P3 enabled (block_proposal, checkpoint_proposal, checkpoint_attestation). The tx topic has all scoring disabled except P4, to prevent free positive score accumulation that would offset penalties from other topics.
43
+ **Important:** P1 and P2 are only enabled on topics with P3 enabled. By default, P3 is enabled for checkpoint_proposal and checkpoint_attestation (2 topics). Block proposal scoring is controlled by `expectedBlockProposalsPerSlot` (current default: `0`, including when env var is unset, so disabled) - see [Block Proposals](#block-proposals-block_proposal) for details. The tx topic has all scoring disabled except P4, to prevent free positive score accumulation that would offset penalties from other topics.
44
44
 
45
45
  ## Exponential Decay
46
46
 
@@ -217,7 +217,21 @@ Transactions are submitted unpredictably by users, so we cannot set meaningful d
217
217
 
218
218
  ### Block Proposals (block_proposal)
219
219
 
220
- In Multi-Block-Per-Slot (MBPS) mode, N-1 block proposals are gossiped per slot (the last block is bundled with the checkpoint). In single-block mode, this is 0.
220
+ Block proposal scoring is controlled by the `expectedBlockProposalsPerSlot` config (`SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT` env var):
221
+
222
+ | Config Value | Behavior |
223
+ |-------------|----------|
224
+ | `0` (current default) | Block proposal P3 scoring is **disabled** |
225
+ | Positive number | Uses the provided value as expected proposals per slot |
226
+ | `undefined` | Falls back to `blocksPerSlot - 1` (MBPS mode: N-1, single block: 0) |
227
+
228
+ **Current behavior note:** In the current implementation, if `SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT` is not set, config mapping applies `0` by default (scoring disabled). The `undefined` fallback above is currently reachable only if the value is explicitly provided as `undefined` in code.
229
+
230
+ **Future intent:** Once throughput is stable, we may change env parsing/defaults so an unset env var resolves to `undefined` again (re-enabling automatic fallback to `blocksPerSlot - 1`).
231
+
232
+ **Why disabled by default?** In MBPS mode, gossipsub expects N-1 block proposals per slot. When transaction throughput is low (as expected at launch), fewer blocks are actually built, causing peers to be incorrectly penalized for under-delivering block proposals. The default of 0 disables this scoring. Set to a positive value when throughput increases and block production is consistent.
233
+
234
+ In MBPS mode (when enabled), N-1 block proposals are gossiped per slot (the last block is bundled with the checkpoint). In single-block mode, this is 0.
221
235
 
222
236
  ### Checkpoint Proposals (checkpoint_proposal)
223
237
 
@@ -241,6 +255,7 @@ The scoring parameters depend on:
241
255
  | `targetCommitteeSize` | L1RollupConstants | 48 |
242
256
  | `heartbeatInterval` | P2PConfig.gossipsubInterval | 700ms |
243
257
  | `blockDurationMs` | P2PConfig.blockDurationMs | undefined (single block) |
258
+ | `expectedBlockProposalsPerSlot` | P2PConfig.expectedBlockProposalsPerSlot | 0 (disabled; current unset-env behavior) |
244
259
 
245
260
  ## Invalid Message Handling (P4)
246
261
 
@@ -320,9 +335,9 @@ Conversely, if topic scores are low, a peer slightly above the disconnect thresh
320
335
 
321
336
  Topic scores provide **burst response** to attacks, while app score provides **stable baseline**:
322
337
 
323
- - P1 (time in mesh): Max +8 per topic (+24 across 3 topics)
324
- - P2 (first deliveries): Max +25 per topic (+75 across 3 topics, but decays fast)
325
- - P3 (under-delivery): Max -34 per topic (-102 across 3 topics in MBPS; -68 in single-block mode)
338
+ - P1 (time in mesh): Max +8 per topic (+16 default, +24 with block proposal scoring enabled)
339
+ - P2 (first deliveries): Max +25 per topic (+50 default, +75 with block proposal scoring, but decays fast)
340
+ - P3 (under-delivery): Max -34 per topic (-68 default with 2 topics, -102 with block proposal scoring enabled)
326
341
  - P4 (invalid messages): -20 per invalid message, can spike to -2000+ during attacks
327
342
 
328
343
  Example attack scenario:
@@ -373,21 +388,21 @@ When a peer is pruned from the mesh:
373
388
  3. **P3b captures the penalty**: The P3 deficit at prune time becomes P3b, which decays slowly
374
389
 
375
390
  After pruning, the peer's score consists mainly of P3b:
376
- - **Total P3b across 3 topics: -102** (max)
391
+ - **Total P3b: -68** (default, 2 topics) or **-102** (with block proposal scoring enabled, 3 topics)
377
392
  - **Recovery time**: P3b decays to ~1% over one decay window (2-5 slots = 2-6 minutes)
378
393
  - **Grafting eligibility**: Peer can be grafted when score ≥ 0, but asymptotic decay means recovery is slow
379
394
 
380
395
  ### Why Non-Contributors Aren't Disconnected
381
396
 
382
- With P3b capped at -102 total after pruning (MBPS mode). In single-block mode, the cap is -68:
397
+ With P3b capped at -68 (default, 2 topics) or -102 (with block proposal scoring, 3 topics) after pruning:
383
398
 
384
399
  | Threshold | Value | P3b Score | Triggered? |
385
400
  |-----------|-------|-----------|------------|
386
- | gossipThreshold | -500 | -102 (MBPS) / -68 (single) | No |
387
- | publishThreshold | -1000 | -102 (MBPS) / -68 (single) | No |
388
- | graylistThreshold | -2000 | -102 (MBPS) / -68 (single) | No |
401
+ | gossipThreshold | -500 | -68 (default) / -102 (block scoring on) | No |
402
+ | publishThreshold | -1000 | -68 (default) / -102 (block scoring on) | No |
403
+ | graylistThreshold | -2000 | -68 (default) / -102 (block scoring on) | No |
389
404
 
390
- **A score of -102 (MBPS) or -68 (single-block) is well above -500**, so non-contributing peers:
405
+ **A score of -68 or -102 is well above -500**, so non-contributing peers:
391
406
  - Are pruned from mesh (good - stops them slowing propagation)
392
407
  - Still receive gossip (can recover by reconnecting/restarting)
393
408
  - Are NOT disconnected unless they also have application-level penalties
@@ -547,7 +562,7 @@ What happens when a peer experiences a network outage and stops delivering messa
547
562
  While the peer is disconnected:
548
563
 
549
564
  1. **P3 penalty accumulates**: The message delivery counter decays toward 0, causing increasing P3 penalty
550
- 2. **Max P3 penalty reached**: Once counter drops below threshold, penalty hits -34 per topic (-102 total in MBPS; -68 single-block)
565
+ 2. **Max P3 penalty reached**: Once counter drops below threshold, penalty hits -34 per topic (-68 default, -102 with block proposal scoring)
551
566
  3. **Mesh pruning**: Topic score goes negative → peer is pruned from mesh
552
567
  4. **P3b captures penalty**: The P3 deficit at prune time becomes P3b (sticky penalty)
553
568
 
@@ -569,13 +584,13 @@ Note: If the peer just joined the mesh, P3 penalties only start after
569
584
  During a network outage, the peer:
570
585
  - **Does NOT send invalid messages** → No P4 penalty
571
586
  - **Does NOT violate protocols** → No application-level penalty
572
- - **Only accumulates topic-level penalties** → Max -102 (P3b, MBPS) or -68 (single-block)
587
+ - **Only accumulates topic-level penalties** → Max -68 (default) or -102 (with block proposal scoring)
573
588
 
574
589
  This is the crucial difference from malicious behavior:
575
590
 
576
591
  | Scenario | App Score | Topic Score | Total | Threshold Hit |
577
592
  |----------|-----------|-------------|-------|---------------|
578
- | Network outage | 0 | -102 (MBPS) / -68 (single) | -102 / -68 | None |
593
+ | Network outage | 0 | -68 (default) / -102 (block scoring on) | -68 / -102 | None |
579
594
  | Validation failure | -50 | -20 | -520 | gossipThreshold |
580
595
  | Malicious peer | -100 | -2000+ | -2100+ | graylistThreshold |
581
596