Skip to content

Conversation

@codablock
Copy link

This PR includes an initial implementation of LLMQ based InstantSend. It is meant to be present in parallel to the old InstantSend system.

Switching between the old and the new system happens via SPORK_2_INSTANTSEND_ENABLED, which became a new meaning. When set to 0 (as on testnet/mainet right now), it will use the old system. When set to 1, it will use the new system. When set to anything else, it's considered disabled. This is only meant to be temporary until the old system is removed, at which time we can revert back to the old meaning of spork 2.

The new system is very likely not going to be ready for v14, so we won't activate it. Reason is that more testing is required, especially in regard to performance and load.

The new system has a few differences to the old system:

  1. There is no explicit lock request required. All TXs are meant to be ixlocked, no matter how many inputs or how much funds they move. We might need to add limits to the amount of inputs, or add some kind of prioritization logic that prefers to sign small TXs first, so that DDoS is not that easily pulled off.
  2. The minimum number of confirmations required for TX inputs is lifted when the input is part of a ChainLocked chain (it's enough to have a CLSIG for the current tip). In case inputs were too young and there were no ChainLocks, the system will retry later when with confirmations or when a ChainLock comes in.
  3. The system will also lock TXs for which inputs are not confirmed on-chain, but only when the parent TXs are in the local mempool and also locked by InstantSend. This means that InstantSend can be chained now! In case the conditions are not met, the system will retry locking later when it determines that parents got locked.
  4. ixlocks do not timeout anymore. They are only removed from the system when TXs get confirmed through ChainLocked blocks. This gives some risk in regard to RAM filling up, but only when ChainLocks are disabled. I will also add (cached) persistence for ixlocks in a later PR, so that the risk of filled RAM is removed.

I did quite a bit of load testing on private devnets and also plan to make a public devnet in the next days so that people can play around. Results of the load testing so far:

  1. When there is no load on the network, ixlocks get created in 2-3 seconds, even with simulated network latency and low avg bandwidth
  2. When there is high load, for example 1000 TXs sent in a few seconds, it takes around 35 seconds to lock all TXs. When latency (e.g. 50ms) and low bandwidth (e.g. 2mbit) is simulated, it takes about 90 seconds for 1000 TXs to get IX confirmed. I'm not very happy with these numbers, and it looks like we'll need a rewrite of the signing session code (hint: UDP + direkt push instead of custom inv system). This is the main reason I believe that LLMQ based InstantSend might not be ready when v14 is deployed.
  3. Bandwidth usage is pretty high. I reduced it to the absolute minimum with the optimizations that got merged in the last days, but IMHO its still too high. Only solution I see right now is what I mentioned in 2. already (UDP).

As an alternative to the signing session code rewrite for UDP and targeting v15 (or whatever the next version would be), another option is to add another minimum TX fee for large TXs. This would allow to add LLMQ based InstantSend to v14 and then later optimize it so that all TXs can use it, independent from their size.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few quick comments

@codablock codablock force-pushed the pr_llmq_instantsend branch from b650a05 to 72d220c Compare March 1, 2019 15:12
@codablock codablock added this to the 14.0 milestone Mar 1, 2019
@codablock
Copy link
Author

codablock commented Mar 1, 2019

Forgot to mention in the PR description that this PR also changes the behavior of ChainLocks when the new InstantSend system is activated. It will only try to ChainLock the tip when all included TXs were locked before or are old enough to be sure that there won't be conflicting InstantSend locks popping up.

This disincentives miners to include TXs that are not publicly known/propagated for now, as they risk creating a block that never gets ChainLocked. I'll later implement InstantSend locking of transactions that were published through mined blocks, which will then allow retroactive ChainLocking of the affected blocks.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple more

@codablock codablock force-pushed the pr_llmq_instantsend branch from c141700 to d185f90 Compare March 4, 2019 14:24
@codablock
Copy link
Author

Rebased on develop and force-pushed

@codablock codablock force-pushed the pr_llmq_instantsend branch from 991c4e6 to 2da8d74 Compare March 7, 2019 05:42
codablock added 21 commits March 7, 2019 21:14
We can reconstruct recovered sigs from other P2P messages to avoid
re-validation of those. We will do this later in InstantSend code.
This also includes handling of TXs that were previously orphanced
The new system does not require explicit lock requests, so we downgrade
TXLOCKREQUEST to TX and start propagating it instead of the original.
Later commits will introduce checks for "safe TXs" which might abort the
signing on first try, but succeed a few seconds later, so we periodically
retry to sign the tip.
Safe means that the TX is either ixlocked or known since at least 10
minutes.

Also change miner code to only include safe TXs in block templates.
@codablock codablock force-pushed the pr_llmq_instantsend branch from 8d7bcc6 to 06fc655 Compare March 7, 2019 20:15
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ACK

@codablock codablock merged commit 64ae912 into dashpay:develop Mar 8, 2019
@codablock codablock deleted the pr_llmq_instantsend branch March 8, 2019 10:32
@UdjinM6 UdjinM6 mentioned this pull request Mar 9, 2019
@UdjinM6 UdjinM6 added the P2P Some notable changes on p2p level label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2P Some notable changes on p2p level

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants