diff --git a/spartan/environments/tps-scenario.env b/spartan/environments/tps-scenario.env index abdaf40948b0..a238e0183b30 100644 --- a/spartan/environments/tps-scenario.env +++ b/spartan/environments/tps-scenario.env @@ -78,7 +78,6 @@ PROVER_L1_PRIORITY_FEE_RETRY_BUMP_PERCENTAGE=0 # Enable latency mesaruement for p2p messages DEBUG_P2P_INSTRUMENT_MESSAGES=true -P2P_DROP_TX=true P2P_DROP_TX_CHANCE=0.2 # Inject artificial delay of proof verification for all nodes diff --git a/spartan/scripts/deploy_network.sh b/spartan/scripts/deploy_network.sh index ad40060dee94..9b8b4d116968 100755 --- a/spartan/scripts/deploy_network.sh +++ b/spartan/scripts/deploy_network.sh @@ -182,7 +182,6 @@ P2P_GOSSIPSUB_D=${P2P_GOSSIPSUB_D:-6} P2P_GOSSIPSUB_DLO=${P2P_GOSSIPSUB_DLO:-4} P2P_GOSSIPSUB_DHI=${P2P_GOSSIPSUB_DHI:-12} -P2P_DROP_TX=${P2P_DROP_TX:-false} P2P_DROP_TX_CHANCE=${P2P_DROP_TX_CHANCE:-0} # Compute validator addresses (skip if no validators) diff --git a/spartan/terraform/deploy-aztec-infra/main.tf b/spartan/terraform/deploy-aztec-infra/main.tf index 338cef6dffeb..3cbaf69c5f9d 100644 --- a/spartan/terraform/deploy-aztec-infra/main.tf +++ b/spartan/terraform/deploy-aztec-infra/main.tf @@ -216,7 +216,6 @@ locals { "validator.node.env.P2P_GOSSIPSUB_D" = var.P2P_GOSSIPSUB_D "validator.node.env.P2P_GOSSIPSUB_DLO" = var.P2P_GOSSIPSUB_DLO "validator.node.env.P2P_GOSSIPSUB_DHI" = var.P2P_GOSSIPSUB_DHI - "validator.node.env.P2P_DROP_TX" = var.P2P_DROP_TX "validator.node.env.P2P_DROP_TX_CHANCE" = var.P2P_DROP_TX_CHANCE "validator.node.env.WS_NUM_HISTORIC_CHECKPOINTS" = var.WS_NUM_HISTORIC_CHECKPOINTS "validator.node.env.TX_COLLECTION_FILE_STORE_URLS" = var.TX_COLLECTION_FILE_STORE_URLS @@ -356,7 +355,6 @@ locals { "node.node.env.P2P_GOSSIPSUB_D" = var.P2P_GOSSIPSUB_D "node.node.env.P2P_GOSSIPSUB_DLO" = var.P2P_GOSSIPSUB_DLO "node.node.env.P2P_GOSSIPSUB_DHI" = var.P2P_GOSSIPSUB_DHI - "node.node.env.P2P_DROP_TX" = var.P2P_DROP_TX "node.node.env.P2P_DROP_TX_CHANCE" = var.P2P_DROP_TX_CHANCE "node.node.env.WS_NUM_HISTORIC_CHECKPOINTS" = var.WS_NUM_HISTORIC_CHECKPOINTS "node.node.env.TX_COLLECTION_FILE_STORE_URLS" = var.TX_COLLECTION_FILE_STORE_URLS @@ -435,7 +433,6 @@ locals { "node.env.P2P_GOSSIPSUB_D" = var.P2P_GOSSIPSUB_D "node.env.P2P_GOSSIPSUB_DLO" = var.P2P_GOSSIPSUB_DLO "node.env.P2P_GOSSIPSUB_DHI" = var.P2P_GOSSIPSUB_DHI - "node.env.P2P_DROP_TX" = var.P2P_DROP_TX "node.env.P2P_DROP_TX_CHANCE" = var.P2P_DROP_TX_CHANCE "node.env.WS_NUM_HISTORIC_CHECKPOINTS" = var.WS_NUM_HISTORIC_CHECKPOINTS "node.env.TX_FILE_STORE_ENABLED" = var.TX_FILE_STORE_ENABLED @@ -492,7 +489,6 @@ locals { "node.env.P2P_GOSSIPSUB_D" = var.P2P_GOSSIPSUB_D "node.env.P2P_GOSSIPSUB_DLO" = var.P2P_GOSSIPSUB_DLO "node.env.P2P_GOSSIPSUB_DHI" = var.P2P_GOSSIPSUB_DHI - "node.env.P2P_DROP_TX" = var.P2P_DROP_TX "node.env.P2P_DROP_TX_CHANCE" = var.P2P_DROP_TX_CHANCE "node.env.WS_NUM_HISTORIC_CHECKPOINTS" = var.WS_NUM_HISTORIC_CHECKPOINTS "node.env.TX_COLLECTION_FILE_STORE_URLS" = var.TX_COLLECTION_FILE_STORE_URLS @@ -532,7 +528,6 @@ locals { "node.env.P2P_GOSSIPSUB_D" = var.P2P_GOSSIPSUB_D "node.env.P2P_GOSSIPSUB_DLO" = var.P2P_GOSSIPSUB_DLO "node.env.P2P_GOSSIPSUB_DHI" = var.P2P_GOSSIPSUB_DHI - "node.env.P2P_DROP_TX" = var.P2P_DROP_TX "node.env.P2P_DROP_TX_CHANCE" = var.P2P_DROP_TX_CHANCE "node.env.WS_NUM_HISTORIC_CHECKPOINTS" = var.WS_NUM_HISTORIC_CHECKPOINTS "node.env.TX_COLLECTION_FILE_STORE_URLS" = var.TX_COLLECTION_FILE_STORE_URLS @@ -569,7 +564,6 @@ locals { "node.env.P2P_GOSSIPSUB_D" = var.P2P_GOSSIPSUB_D "node.env.P2P_GOSSIPSUB_DLO" = var.P2P_GOSSIPSUB_DLO "node.env.P2P_GOSSIPSUB_DHI" = var.P2P_GOSSIPSUB_DHI - "node.env.P2P_DROP_TX" = var.P2P_DROP_TX "node.env.P2P_DROP_TX_CHANCE" = var.P2P_DROP_TX_CHANCE "node.env.WS_NUM_HISTORIC_CHECKPOINTS" = var.WS_NUM_HISTORIC_CHECKPOINTS } diff --git a/spartan/terraform/deploy-aztec-infra/variables.tf b/spartan/terraform/deploy-aztec-infra/variables.tf index 358e2b0ec335..cd395ea30db6 100644 --- a/spartan/terraform/deploy-aztec-infra/variables.tf +++ b/spartan/terraform/deploy-aztec-infra/variables.tf @@ -760,12 +760,6 @@ variable "P2P_GOSSIPSUB_DHI" { default = "12" } -variable "P2P_DROP_TX" { - description = "Whether to randomly drop incoming transactions in the P2P layer (for testing)" - type = bool - default = false -} - variable "P2P_DROP_TX_CHANCE" { description = "The chance (0-1) of dropping an incoming transaction in the P2P layer (for testing)" type = number diff --git a/yarn-project/end-to-end/src/spartan/reqresp_effectiveness.test.ts b/yarn-project/end-to-end/src/spartan/reqresp_effectiveness.test.ts index 11f3e1b220d7..3c740fdba873 100644 --- a/yarn-project/end-to-end/src/spartan/reqresp_effectiveness.test.ts +++ b/yarn-project/end-to-end/src/spartan/reqresp_effectiveness.test.ts @@ -44,7 +44,6 @@ describe('reqresp effectiveness under tx drop', () => { try { await setValidatorTxDrop({ namespace: config.NAMESPACE, - enabled: false, probability: 0, logger, }); @@ -101,7 +100,6 @@ describe('reqresp effectiveness under tx drop', () => { if (!(probability == 0)) { await setValidatorTxDrop({ namespace: config.NAMESPACE, - enabled: true, probability, logger, }); diff --git a/yarn-project/end-to-end/src/spartan/utils/nodes.ts b/yarn-project/end-to-end/src/spartan/utils/nodes.ts index 864a9608c0e9..0a3166395afd 100644 --- a/yarn-project/end-to-end/src/spartan/utils/nodes.ts +++ b/yarn-project/end-to-end/src/spartan/utils/nodes.ts @@ -255,21 +255,18 @@ export async function initHADb(namespace: string): Promise { } /** - * Enables or disables probabilistic transaction dropping on validators and waits for rollout. - * Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values. + * Sets probabilistic transaction dropping on validators and waits for rollout. + * Use probability=0 to disable. Wired to env var P2P_DROP_TX_CHANCE via Helm values. */ export async function setValidatorTxDrop({ namespace, - enabled, probability, logger: log, }: { namespace: string; - enabled: boolean; probability: number; logger: Logger; }) { - const drop = enabled ? 'true' : 'false'; const prob = String(probability); const selectors = ['app.kubernetes.io/name=validator', 'app.kubernetes.io/component=validator', 'app=validator']; @@ -284,7 +281,7 @@ export async function setValidatorTxDrop({ if (names.length === 0) { continue; } - const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`; + const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`; log.info(`command: ${cmd}`); await execAsync(cmd); updated = true; diff --git a/yarn-project/foundation/src/config/env_var.ts b/yarn-project/foundation/src/config/env_var.ts index e35c23bcd20f..86eb431ce298 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -148,7 +148,6 @@ export type EnvVar = | 'P2P_PREFERRED_PEERS' | 'P2P_MAX_PENDING_TX_COUNT' | 'P2P_SEEN_MSG_CACHE_SIZE' - | 'P2P_DROP_TX' | 'P2P_DROP_TX_CHANCE' | 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG' | 'P2P_MIN_TX_POOL_AGE_MS' diff --git a/yarn-project/p2p/src/client/factory.ts b/yarn-project/p2p/src/client/factory.ts index 08d1dd209343..805500ee22c1 100644 --- a/yarn-project/p2p/src/client/factory.ts +++ b/yarn-project/p2p/src/client/factory.ts @@ -121,6 +121,7 @@ export async function createP2PClient( maxPendingTxCount: config.maxPendingTxCount, archivedTxLimit: config.archivedTxLimit, minTxPoolAgeMs: config.minTxPoolAgeMs, + dropTransactionsProbability: config.dropTransactionsProbability, }, dateProvider, ); diff --git a/yarn-project/p2p/src/config.ts b/yarn-project/p2p/src/config.ts index f7c54eb1e191..f9f951019191 100644 --- a/yarn-project/p2p/src/config.ts +++ b/yarn-project/p2p/src/config.ts @@ -173,10 +173,7 @@ export interface P2PConfig /** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */ disableTransactions: boolean; - /** True to simulate discarding transactions. - For testing purposes only*/ - dropTransactions: boolean; - - /** The probability that a transaction is discarded. - For testing purposes only */ + /** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */ dropTransactionsProbability: number; /** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */ @@ -430,11 +427,6 @@ export const p2pConfigMappings: ConfigMappingsType = { description: 'Number of auth attempts to allow before peer is banned. Number is inclusive', ...numberConfigHelper(3), }, - dropTransactions: { - env: 'P2P_DROP_TX', - description: 'True to simulate discarding transactions. - For testing purposes only', - ...booleanConfigHelper(false), - }, dropTransactionsProbability: { env: 'P2P_DROP_TX_CHANCE', description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only', diff --git a/yarn-project/p2p/src/mem_pools/tx_pool_v2/interfaces.ts b/yarn-project/p2p/src/mem_pools/tx_pool_v2/interfaces.ts index 52eb176d7cb8..4f706cfc720c 100644 --- a/yarn-project/p2p/src/mem_pools/tx_pool_v2/interfaces.ts +++ b/yarn-project/p2p/src/mem_pools/tx_pool_v2/interfaces.ts @@ -44,6 +44,8 @@ export type TxPoolV2Config = { minTxPoolAgeMs: number; /** Maximum number of evicted tx hashes to remember for metrics tracking */ evictedTxCacheSize: number; + /** The probability (0-1) that a transaction is discarded. 0 disables dropping. For testing purposes only. */ + dropTransactionsProbability: number; }; /** @@ -54,6 +56,7 @@ export const DEFAULT_TX_POOL_V2_CONFIG: TxPoolV2Config = { archivedTxLimit: 0, // 0 = disabled minTxPoolAgeMs: 2_000, evictedTxCacheSize: 10_000, + dropTransactionsProbability: 0, }; /** diff --git a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts index c35a28455fd8..a5b27bcdfe02 100644 --- a/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +++ b/yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts @@ -316,6 +316,12 @@ export class TxPoolV2Impl { } } + // Randomly drop the transaction for testing purposes (report as accepted so it propagates) + if (this.#config.dropTransactionsProbability > 0 && Math.random() < this.#config.dropTransactionsProbability) { + this.#log.debug(`Dropping tx ${txHashStr} (simulated drop for testing)`); + return { status: 'accepted' }; + } + // Add the transaction await this.#addTx(tx, 'pending', opts); return { status: 'accepted' };