feat(p2p): implement --disable-relay-tx flag#888
Open
RossKU wants to merge 2 commits intokaspanet:masterfrom
Open
feat(p2p): implement --disable-relay-tx flag#888RossKU wants to merge 2 commits intokaspanet:masterfrom
RossKU wants to merge 2 commits intokaspanet:masterfrom
Conversation
Add CLI flag to disable transaction relay, allowing API-only nodes to skip mempool overhead and bandwidth from tx propagation. Changes: - Add --disable-relay-tx to CLI args and Config - Populate disable_relay_tx in version handshake message - Filter tx broadcasts to skip peers with disable_relay_tx set - Drain incoming tx inv messages when our node has relay disabled Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
wdyt about the possible starvation issue @someone235 @michaelsutton? |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #228.
Implements the
--disable-relay-txCLI flag, allowing API-only nodes to opt out of transaction relay, reducing mempool overhead and bandwidth.What it does
--disable-relay-txCLI flag (also configurable viaKASPAD_DISABLE_RELAY_TXenv var or config file)disableRelayTxin the version handshake message so peers know not to send us transactionsdisable_relay_txin their version handshakeChanges by file
kaspad/src/args.rs— CLI arg, Args struct field, parsing, apply_to_configconsensus/core/src/config/mod.rs— Config struct field + defaultprotocol/flows/src/flow_context.rs— Populatedisable_relay_txin version message (resolves the TODO at line 716)protocol/flows/src/flowcontext/transactions.rs— Usebroadcast_filtered/broadcast_to_some_peers_filteredto skipdisable_relay_txpeersprotocol/p2p/src/core/hub.rs— Addbroadcast_filtered()andbroadcast_to_some_peers_filtered()methodsprotocol/flows/src/v7/txrelay/flow.rs— Drain inbound tx inv when relay is disabled (v8 reuses v7 txrelay, so both versions are covered)Design decisions
--disable-relay-txcan still accept transactions via RPCOut of scope: starvation mitigation
As noted by @coderofstuff in #228, if a node wants txs but all its peers have
disable_relay_tx=true, no transactions arrive. Mitigation (peer eviction + reconnection logic) is deferred to a follow-up issue — in practice,disable_relay_txnodes will be a small minority (API-only), so this scenario is unlikely.Test plan
cargo check --workspacepassescargo test --workspacepasses (all tests)--disable-relay-tx, verify no tx inv messages are processed🤖 Generated with Claude Code