Skip to content

Conversation

@TheBlueMatt
Copy link
Contributor

CNodeState was added for validation-state-tracking, and thus,
logically, was protected by cs_main. However, as it has grown to
include non-validation state (taking state from CNode), and as
we've reduced cs_main usage for other unrelated things, CNodeState
is left with lots of cs_main locking in net_processing.

This starts the process of moving things out of cs_main (and into a new CPeerState) starting with nDoS and rejects.

This also solves the lowest-hanging fruit by wiping out 10+ (!) cs_main locks that are trivial to remove! It further removes a cs_main lock which is taken on every ProcessMessages iteration, which makes a future rebase of #12934 much more effective by being able to move onto the next peer for processing (at least sometimes) while a block is validating.

@sipa
Copy link
Member

sipa commented Jun 9, 2019

Big concept ACK

@practicalswift
Copy link
Contributor

Excellent!

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 9, 2019

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15921 (Tidy up ValidationState interface by jnewbery)
  • #15606 ([experimental] UTXO snapshots by jamesob)
  • #15206 (Immediately disconnect on invalid net message checksum by jonasschnelli)
  • #14046 (net: Refactor message parsing (CNetMessage), adds flexibility by jonasschnelli)
  • #14032 (Add p2p layer encryption with ECDH/ChaCha20Poly1305 by jonasschnelli)

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.

CNodeState was added for validation-state-tracking, and thus,
logically, was protected by cs_main. However, as it has grown to
include non-validation state (taking state from CNode), and as
we've reduced cs_main usage for other unrelated things, CNodeState
is left with lots of cs_main locking in net_processing.

In order to ease transition to something new, this adds only a
dummy CPeerState which is held as a reference for the duration of
message processing.
@TheBlueMatt TheBlueMatt force-pushed the 2019-06-net-processing-no-main-start branch from 055e99f to ce89efb Compare June 9, 2019 11:45
@TheBlueMatt
Copy link
Contributor Author

Next step/further justification can be seen in the form of #16175.

@DrahtBot DrahtBot added the P2P label Jun 9, 2019
@naumenkogs
Copy link
Contributor

Concept ACK

@TheBlueMatt
Copy link
Contributor Author

Oops, this is actually not possible to do on its own. See #16175.

@TheBlueMatt TheBlueMatt closed this Jun 9, 2019
@ryanofsky
Copy link
Contributor

Oops, this is actually not possible to do on its own. See #16175.

Relevant comment is #16175 (comment)

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
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.

6 participants