Skip to content

DoS transactions params #48

@tearodactyl

Description

@tearodactyl

Parameters on transactions, blocks, mempool that could prevent or mitigate DoS or lockups under heavy load scenarios. Which of these require consensus changes is TBD.

  1. Tracking of the state of DoS
    main.cpp: const int dosLevel,

  2. Max Transaction size, increased from the Bitcoin value of 100,000 Raise 100kB transaction size limit from Sapling activation zcash/zcash#3212:

consensus.h:
static const unsigned int MAX_BLOCK_SIZE = 4000000;
/** The maximum allowed number of signature check operations in a block (network rule) */
static const unsigned int MAX_BLOCK_SIGOPS = 40000;
/** The maximum size of a transaction (network rule) */
static const unsigned int MAX_TX_SIZE_BEFORE_SAPLING = 100000;
static const unsigned int MAX_TX_SIZE_AFTER_SAPLING = MAX_BLOCK_SIZE;

This should affect transactions being accepted into the mempool, not only a consensus rule. Mempool should not attempt to store more than say 100,000 pending transactions, maybe even much fewer, but do need an efficient data structure to timeout and purge. Could even keep history of rejected or purged transactions to prevent re-introduction zcash#2414

Separately, Bitcoin considered a cache to recognize transactions that have already been validated https://news.bitcoin.com/new-bitcoin-cachin-features-could-improve-block-verification/

  1. Timing out transactions from the mempool. Bitcoin was 72 hours, now 7 days, which seems way way high bitcoin/bitcoin@5f0e27f
    Zcash possibly did not have a timeout initially, but after Overwinter uses block height based tracking, 20 2.5 min blocks (50 min). Transaction expiry height zcash/zcash#2874
    Seems like a very large change.
    main.h: static const unsigned int DEFAULT_TX_EXPIRY_DELTA = 20;
    Zero would be like 40 min, which is a bit short during network congestion, etc. Maybe several hours? Block height tracking is best for consensus, but wall time tracking is better for the node health, like with Bitcoin.

  2. Alert system retirement Denial of Service via alert subsystem zcash/zcash#3367

  3. Ban score and node disconnect logic - could use a more sophisticated system Kick-on-Ban zcash/zcash#2512
    Possibly use configurable white and black listing
    Track IP addresses and even subnets, maybe even geolocation Only allow one connection from a given IP address zcash/zcash#3757

  4. UTXO selection algo defaults to use-up smallest amounts first zcash@0afd368#diff-63ec75bfb71c2d4e26f2a95d5168f5e5R795
    That leads to unusable (effectively locked-up) wallets with addresses that accumulated too many spam or small (i.e. coinbase) transactions. Was noted to Zcash Change transparent input selection to avoid excessive number of inputs zcash/zcash#2411
    Patch pending Speed up coin selection by pre-selecting only as many UTXOs as we need zcash/zcash#2819

  5. Min transaction fees to make spam leading to DoS more expensive. Ecosystem-wide standard transaction fee zcash/zcash#2942
    Current 0.0001 value is too small for Zero, and should be more like 0.01. That would be fine even when ZER becomes a $1 coin, but can adapt in future releases.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions