Skip to content

Conversation

naumenkogs
Copy link
Member

@naumenkogs naumenkogs commented Nov 5, 2021

This is a part of the Erlay project:


This PR adds a new p2p message sendtxrcncl signaling for reconciliation support.
Before sending that message, a node is supposed to "pre-register" the peer by generating and storing an associated reconciliation salt component.
Once the salts are exchanged within this new message, nodes "register" each other for future reconciliations by computing and storing the aggregate salt, along with the reconciliation parameters based on the connection direction.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 5, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26151 (refactor: Guard TxRequestTracker by its own lock instead of cs_main by dergoegge)
  • #25957 (wallet: fast rescan with BIP157 block filters for descriptor wallets by theStack)
  • #25572 (refactor: Introduce EvictionManager and use it for the inbound eviction logic by dergoegge)
  • #24545 (BIP324: Enable v2 P2P encrypted transport by dhruv)
  • #23233 (BIP324: Add encrypted p2p transport {de}serializer by dhruv)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Coverage

Coverage Change (pull 23443, 4dc7bac) Reference (master, ed4eeaf)
Lines +0.0276 % 83.7655 %
Functions +0.0294 % 80.7326 %
Branches +0.0133 % 51.3151 %

Updated at: 2022-05-10T14:16:22.523123.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

Reviewed until 85992f3. So far only minor comments.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

Finished a first parse, including verifying unit test coverage of the new TxReconciliationTracker class. LGTM

@rebroad
Copy link
Contributor

rebroad commented Nov 25, 2021

txreconciliation.cpp:43:20: warning: private field 'm_k0' is not used [-Wunused-private-field]
    const uint64_t m_k0, m_k1;
                   ^
txreconciliation.cpp:43:26: warning: private field 'm_k1' is not used [-Wunused-private-field]
    const uint64_t m_k0, m_k1;

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

left some nits

@maflcko
Copy link
Member

maflcko commented Nov 29, 2021

Run process_message with args ['/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz', '-runs=1', '/tmp/cirrus-ci-build/ci/scratch/qa-assets/fuzz_seed_corpus/process_message']fuzz: test/fuzz/process_message.cpp:57: auto initialize_process_message()::(anonymous class)::operator()() const: Assertion "GetNumMsgTypes() == getAllNetMessageTypes().size()" && check' failed.

@naumenkogs naumenkogs force-pushed the 2021-11-erlay1 branch 2 times, most recently from cdaabda to ea3b87a Compare December 2, 2021 11:38
Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

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

Did you think about a -disablerecon command or something similar, to not activate Erlay until all the parts have been merged?
Providing the opportunity to opt in/out would probably make sense anyway, but it would also make the review process of its parts independent from releases - e.g. I also don't think it makes sense to have nodes running master exchange SENDRECON before Erlay has been fully merged.

@naumenkogs
Copy link
Member Author

Did you think about a -disablerecon command or something similar, to not activate Erlay until all the parts have been merged?

Yeah I was also thinking about how it's weird to send SENDRECON messages while they don't mean anything, but couldn't come up with any good solution.
For starters, I could comment out sending the message at least I guess.

I guess a flag is better if someone wants to test this stuff via functional tests (without modifying the source code), so yeah, that's probably an ultimate solution. I'll add a commit for that.

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

Concept ACK, thanks for splitting it up. I did a first pass, mostly comparing to the BIP330 specification, looking at test coverage, and a little bit of implementation.

@GeneFerneau
Copy link

utACK ea3b87a

Code review, everything looks good to me outside nits raised by others.

Will run the fuzzer for some cycles, and report back results.

Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

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

Approach ACK, code review until 103e52d - didn't look at tests yet.

This PR introduces the logic to register newly connected peers as peers that support transaction reconciliation, and initialize the necessary data structures required to do the reconciliation later on.

I think everything is well laid out and implemented, so most of my comments are quite nitty and focus on readability etc. They're subjective, feel free to ignore.

Some general thoughts/suggestions:

  • "SENDRECON" does not hint that it corresponds to transactions, would it make sense to rename this to "SENDTXRECON" so people can quickly understand what it's about without know the Erlay code?
  • I understand you're renaming the two roles to "initiator" & "responder", there are still quite a few instances of "requestor", "sender", "receiver" throughout the code and in BIP300. Would suggest to replace them all in both documentation and variable names, consistent naming makes it much easier to follow.

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Did you think about a -disablerecon command or something similar, to not activate Erlay until all the parts have been merged?

I agree that this should be added, although to bikeshed I'd call it -erlay and default to false.

@naumenkogs naumenkogs force-pushed the 2021-11-erlay1 branch 2 times, most recently from 5136f50 to 07b9357 Compare December 10, 2021 14:14
@naumenkogs
Copy link
Member Author

Still going through comments, beware it's not the final shape from my side.

Once we received a reconciliation announcement support
message from a peer and it doesn't violate our protocol,
we store the negotiated parameters which will be used
for future reconciliations.
We optimistically pre-register a peer for txreconciliations
upon sending txreconciliation support announcement.
But if, at VERACK, we realize that the peer never sent
WTXIDRELAY message, we should unregister the peer
from txreconciliations, because txreconciliations rely on wtxids.
@glozow
Copy link
Member

glozow commented Oct 17, 2022

Looks like rebased for #25667.
Pinging @sipa @dergoegge @vasild @ariard @mzumsande for re-ACK

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK e56d1d2

@vasild
Copy link
Contributor

vasild commented Oct 17, 2022

The newly added test p2p_sendtxrcncl.py failed just on "Win64 native" 😭

@dergoegge
Copy link
Member

re-ACK e56d1d2

@sipa
Copy link
Member

sipa commented Oct 17, 2022

re-ACK e56d1d2. No differences with a rebase of previously reviewed e91690e.

@glozow
Copy link
Member

glozow commented Oct 17, 2022

The newly added test p2p_sendtxrcncl.py failed just on "Win64 native" sob

Job: https://cirrus-ci.com/task/6088863331385344
Reran and it turned green. Maybe coincidental timeout?

@maflcko
Copy link
Member

maflcko commented Oct 17, 2022

The reason was likely

node0 2022-10-17T10:37:19.451252Z [C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\src\net_processing.cpp:3460] [ProcessMessage] [net] wtxidrelay received after verack from peer=8; disconnecting

https://cirrus-ci.com/task/6088863331385344?logs=functional_tests#L605

However, I can't see how this could possibly happen in the framework. (peer8 is a python node)

@mzumsande
Copy link
Contributor

re-ACK e56d1d2

@glozow glozow merged commit e7a0e96 into bitcoin:master Oct 17, 2022
@naumenkogs
Copy link
Member Author

Thank you all for making this happen! I will create a PR for fixups, and finish the second PR shortly.

@ariard
Copy link

ariard commented Oct 17, 2022

Post-Merge ACK e91690e

// - we intended to exchange transactions over this connection while establishing it
// and the peer indicated support for transaction relay in the VERSION message;
// - we are not in -blocksonly mode.
if (pfrom.m_relays_txs && !m_ignore_incoming_txs) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to send SENDTXRCNCL to feeler connections?

@@ -484,6 +485,7 @@ void SetupServerArgs(ArgsManager& argsman)
argsman.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-timeout=<n>", strprintf("Specify socket connection timeout in milliseconds. If an initial attempt to connect is unsuccessful after this amount of time, drop it (minimum: 1, default: %d)", DEFAULT_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
Copy link
Member

Choose a reason for hiding this comment

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

Probably unrelated, but it might be good to split the connection section into net and net_processing options. (This one would go into net_processing)

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 23, 2022
@naumenkogs naumenkogs mentioned this pull request Oct 13, 2023
17 tasks
@bitcoin bitcoin locked and limited conversation to collaborators Oct 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.