Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion spartan/environments/tps-scenario.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion spartan/scripts/deploy_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions spartan/terraform/deploy-aztec-infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 0 additions & 6 deletions spartan/terraform/deploy-aztec-infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('reqresp effectiveness under tx drop', () => {
try {
await setValidatorTxDrop({
namespace: config.NAMESPACE,
enabled: false,
probability: 0,
logger,
});
Expand Down Expand Up @@ -101,7 +100,6 @@ describe('reqresp effectiveness under tx drop', () => {
if (!(probability == 0)) {
await setValidatorTxDrop({
namespace: config.NAMESPACE,
enabled: true,
probability,
logger,
});
Expand Down
9 changes: 3 additions & 6 deletions yarn-project/end-to-end/src/spartan/utils/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,18 @@ export async function initHADb(namespace: string): Promise<void> {
}

/**
* 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'];
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions yarn-project/p2p/src/client/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export async function createP2PClient<T extends P2PClientType>(
maxPendingTxCount: config.maxPendingTxCount,
archivedTxLimit: config.archivedTxLimit,
minTxPoolAgeMs: config.minTxPoolAgeMs,
dropTransactionsProbability: config.dropTransactionsProbability,
},
dateProvider,
);
Expand Down
10 changes: 1 addition & 9 deletions yarn-project/p2p/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -430,11 +427,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
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',
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/p2p/src/mem_pools/tx_pool_v2/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand All @@ -54,6 +56,7 @@ export const DEFAULT_TX_POOL_V2_CONFIG: TxPoolV2Config = {
archivedTxLimit: 0, // 0 = disabled
minTxPoolAgeMs: 2_000,
evictedTxCacheSize: 10_000,
dropTransactionsProbability: 0,
};

/**
Expand Down
6 changes: 6 additions & 0 deletions yarn-project/p2p/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' };
Expand Down
Loading