Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llmq|rpc|test|version: Implement P2P messages QGETDATA <-> QDATA #3953

Merged
merged 50 commits into from
Jan 28, 2021

Conversation

xdustinface
Copy link

@xdustinface xdustinface commented Jan 19, 2021

This PR introduces two new P2P messages and with that it bumps the protocol version to 70219. They will in a follow up PR be used for DKG data sharing between masternodes. Means this PR only contains the implementation of the messages and their tests.

The messages:

  • QGETDATA - Ask a masternode for DKG data. Can be both or either of the following:
    • The quorum verification vector a specific quorum
    • The encrypted DKG contributions from member of the quorum
  • QDATA - Respond with the requested DKG data.

5e858cf, 269ce38 and 38bde3f Contain the most part of the messages implementation

6b55815 Implements tests

285c9bd Introduces a RPC wrapper around QGETDATA called quorum getdata (I actually only did that to be able to test everything related to the new messages independently in this PR)

The other commits are mostly helper around the implementation.

This PR is based on #3929 #3930 #3937 #3943 #3948

@xdustinface xdustinface added RPC Some notable changes to RPC params/behaviour/descriptions P2P Some notable changes on p2p level labels Jan 19, 2021
@xdustinface xdustinface added this to the 17 milestone Jan 19, 2021
@xdustinface xdustinface marked this pull request as draft January 19, 2021 05:53
@xdustinface xdustinface force-pushed the pr-p2p-llmq-data branch 2 times, most recently from 51c69a3 to eed0929 Compare January 20, 2021 03:15
@xdustinface xdustinface marked this pull request as ready for review January 25, 2021 09:25
@xdustinface xdustinface marked this pull request as draft January 25, 2021 10:16
@xdustinface xdustinface marked this pull request as ready for review January 25, 2021 10:27
@xdustinface
Copy link
Author

Okay so now it should be ready here.. d8466b4 and 1b7519e are needed after #3943.
d8466b4 reverts changing the cache value there from non-const to const. Want to rather see it in its own PR? Let me know.
1b7519e Just adjusts cache usage

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.

👍

Pls see https://github.com/UdjinM6/dash/commits/pr3953 for some suggestions.

(4c6729e is #3969)

@xdustinface
Copy link
Author

Pls see https://github.com/UdjinM6/dash/commits/pr3953 for some suggestions.

Looks good! Will push them with the rebase after #3969 :)

In the meantime, back to draft here one more time 😄

@xdustinface xdustinface marked this pull request as draft January 25, 2021 17:43
@PastaPastaPasta
Copy link
Member

PastaPastaPasta commented Jan 26, 2021

PEP8 format, which we mostly follow, wants all lines wrapped at 80 chars. That's not practical in a lot of situations / is annoying to do for EVERY line, but here it is

Comment on lines 208 to 212
p2p_mn1.test_qgetdata(qgetdata_contributions, 0, 0, self.llmq_size)
wait_for_banscore(mn1.node, id_p2p_mn1, 25)
# Request both
p2p_mn1.test_qgetdata(qgetdata_all, 0, self.llmq_threshold, self.llmq_size)
wait_for_banscore(mn1.node, id_p2p_mn1, 50)
Copy link
Member

Choose a reason for hiding this comment

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

Why does this bump ban score?

Copy link
Author

Choose a reason for hiding this comment

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

I requests more than once within EXPIRATION_TIMEOUT window

errorHandler("Request limit exceeded", 25);

Signed-off-by: pasta <pasta@dashboost.org>
@xdustinface
Copy link
Author

PEP8 format, which we mostly follow, wants all lines wrapped at 80 chars. That's not practical in a lot of situations / is annoying to do for EVERY line, but here it is

I got the general idea behind its just that the execution of the idea looks arbitrary because you picked just two random lines out the many which are above 80 chars. But okay, picked it..🙈

UdjinM6
UdjinM6 previously approved these changes Jan 27, 2021
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.

LGTM, utACK

@PastaPastaPasta
Copy link
Member

Please see 07a906d

I think I'm emotionally done with it for now

PastaPastaPasta and others added 9 commits January 28, 2021 01:33
Signed-off-by: pasta <pasta@dashboost.org>
Just takes a lot time and isn't required imo.
"test_mnauth_restriction", "test_invalid_messages" and "test_invalid_unexpected_qdata" with the resulting name "test_basics" because i don't feel like DKG recovery thing should be part of a test called "test_invalid_messages" and giving it an own test probably wouldn't make a lot sense because it would still depend on "test_invalid_messages". I also think there is no need for a separated "test_invalid_unexpected_qdata".
Thats the default "draw annoying warnings" setting for PyCharm (and IMO a reasonable line length).
@xdustinface
Copy link
Author

Please see 07a906d

Picked 👍 Added some more commits to clean it up a bit, see commit messages. (224a98a + be7c66d are just two more unrelated tweaks)

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

I don't think I'm a fan of c1a3387, seems like a regression creating a more complex testing method, instead of having small as reasonable, atomic tests

@UdjinM6
Copy link

UdjinM6 commented Jan 28, 2021

Pls see UdjinM6@4bcd660

@xdustinface
Copy link
Author

xdustinface commented Jan 28, 2021

@PastaPastaPasta I don't see how this makes anything "too complex".. it just additionally tests a bunch of error codes in one function with mostly the same lines of code.

instead of having small as reasonable, atomic tests

IMO we should rather see p2p_quorum_data.py as the atomic test here like we have many tests in separate files and they are all independent from each other (atomic tests), and not worry too much about "making parts of the tests inside the test atomic" because inside the test file they probably always depend on each other due to using the same nodes/blockchain. Now, the sections inside test_basics() are still as "atomic" as they were before (they still share resources btw so they anyway aren't atomic, are they?) with the difference that they are not longer separated by the name of the function but with a log line. Don't get me wrong, i like to give it a bit more structure in general but i honestly don't see a lot value in splitting them up into multiple functions where each function is just written and called below the other in the same file while they still all dependent on the same resources of the function they are written in i.e. the variables defined in run_test() and everything which belongs to the class QuorumDataMessagesTest. It's IMO basically the same effect then just separating them by just a log message with the only difference, that you can navigate into the separate functions which is IMO not a huge benefit in a file with 460 lines which is just an autonomous test for one feature.


Pls see UdjinM6@4bcd660

@UdjinM6 I like that approach in general and i had it like this in the evolution of the test but for some reason it seems to fail to get the correct ID on CI sometimes, see https://gitlab.com/UdjinM6/dash/-/jobs/991707418#L3241 (assert node.mnauth(node_id, protx_hash, operator_pubkey) fails which can obviously only happen if the provided nodeId is incorrect/does not belong to a connected node?. Thats why i ended up with the "directly return the found ID" approach :D If you have any idea how this can happen, tell me!

@xdustinface
Copy link
Author

xdustinface commented Jan 28, 2021

Okay i just saw this one https://gitlab.com/xdustinface/dash/-/jobs/991429505 where it fails the same for be7c66d so its obviously not related to cc38df2. But i think i at least didn't see this failure before all the recent refactoring.

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.

utACK

(#3971 should fix random mnauth failures mentioned above)

@xdustinface
Copy link
Author

xdustinface commented Jan 28, 2021

Nice, so if #3971 fixes it, this means the issue is that mininode didn't send verack the moment we do the mnauth call which leads to not having fSuccessfullyConnected (in core) set to true for the mininode connection and thats why then doesn't find it in the "fully connected" peers? i.e. 2220d61 should also do it?

I suspect the actual issue then to be this change where it initially slept 1s which then was maybe just enough to get the verack sent?

@UdjinM6
Copy link

UdjinM6 commented Jan 28, 2021

this means the issue is that mininode didn't send verack the moment we do the mnauth call

Not necessarily, could be that mininnode sent it but core was simply too slow at processing the message queue or busy with smth else. But yeah, 2220d61 would do it too I think 👍

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK

@PastaPastaPasta PastaPastaPasta merged commit 21cfb4c into dashpay:develop Jan 28, 2021
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 12, 2022
…hpay#3953)

* version: Bump PROTOCOL_VERSION and MIN_MASTERNODE_PROTO_VERSION

* version: Introduce LLMQ_DATA_MESSAGES_VERSION for QGETDATA/QDATA support

* test: Bump MY_VERSION to 70219 (LLMQ_DATA_MESSAGES_VERSION)

* llmq: Introduce CQuorumDataRequest as wrapper for QGETDATA requests

* llmq: Implement CQuorum::{SetVerificationVector, SetSecretKeyShare}

* llmq|net|protocol: Implement QGETDATA/QDATA P2P messages

* llmq: Restrict processing QGETDATA/QDATA to masternodes only

* llmq: Implement request limiting for QGETDATA/QDATA

* llmq: Implement CQuorumManger::RequestQuorumData

* rpc: Implement "quorum getdata" as wrapper around QGETDATA

Allows to trigger sending QGETDATA messages to connected peers by RPC.

* test: Handle QGETDATA/QDATA messages in mininode

* test: Add data structures to support QGETDATA/QDATA

* test: Add some helper in test_framework.py

* test: Implement tests for QGETDATA/QDATA in p2p_quorum_data.py

* test: Add p2p_quorum_data.py to BASE_SCRIPTS

* llmq|test: Add QWATCH support for QGETDATA/QDATA

* llmq: Store CQuorumPtr in cache, not CQuorumCPtr

* llmq: Fix cache usage after recent changes

* Use uacomment to create/find specific p2ps

* No need to use network adjusted time here, GetTime should be enough

* rpc: check proTxHash

* minor tweaks

* test: Adjustments after 4e27d65

* llmq: Rename and improve error lambda in CQuorumManager::ProcessMessage

* llmq: Process QDATA if -watchquorums is enabled

* test: Handle qwatch messages in mininode

* test: Add test for -watchquorums support

* test: Just some empty lines

* test: Properly stop the p2p network thread at the end of the test

* rpc: Adjust "quorum getdata" parameter descriptions

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* rpc: Fix optionality of proTxHash in "quorum getdata" command

* test: Test optionality of proTxHash for "quorum getdata" command

* test: Be more specific about imports in p2p_quorum_data.py

* llmq|rpc: Add some comments about the request.GetDataMask checks

* test: Some more empty lines

* rpc: One more parameter description

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* test: Unify assert statements / drop parentheses for all of them

* fix typo

Signed-off-by: pasta <pasta@dashboost.org>

* adjust some line wrapping to 80 chars

Signed-off-by: pasta <pasta@dashboost.org>

* tests: Seperate out into dif atomic methods, add logging

Signed-off-by: pasta <pasta@dashboost.org>

* test: Avoid restarting masternodes, just let available requests expire

Just takes a lot time and isn't required imo.

* test: Drop redundant code/tests after separation

This was introduced in 9e224ec

* test: Merge three tests

"test_mnauth_restriction", "test_invalid_messages" and "test_invalid_unexpected_qdata" with the resulting name "test_basics" because i don't feel like DKG recovery thing should be part of a test called "test_invalid_messages" and giving it an own test probably wouldn't make a lot sense because it would still depend on "test_invalid_messages". I also think there is no need for a separated "test_invalid_unexpected_qdata".

* test: Rename test_ratelimiting_banscore -> test_request_limit

* test: Apply python style

* test: Wrap all at 120 characters

Thats the default "draw annoying warnings" setting for PyCharm (and IMO a reasonable line length).

* test: Move some variables

* test: Optimize for speed

* tests: use wait_until in get_mininode_id

* test: Don't use `!=` to check for `None`

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: pasta <pasta@dashboost.org>
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 RPC Some notable changes to RPC params/behaviour/descriptions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants