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
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d08b8ab
version: Bump PROTOCOL_VERSION and MIN_MASTERNODE_PROTO_VERSION
xdustinface Jan 17, 2021
4768c5e
version: Introduce LLMQ_DATA_MESSAGES_VERSION for QGETDATA/QDATA support
xdustinface Jan 18, 2021
2fedc66
test: Bump MY_VERSION to 70219 (LLMQ_DATA_MESSAGES_VERSION)
xdustinface Jan 17, 2021
4a1c833
llmq: Introduce CQuorumDataRequest as wrapper for QGETDATA requests
xdustinface Jan 13, 2021
2bc6534
llmq: Implement CQuorum::{SetVerificationVector, SetSecretKeyShare}
xdustinface Jan 13, 2021
987f210
llmq|net|protocol: Implement QGETDATA/QDATA P2P messages
xdustinface Jan 13, 2021
6b5d6d7
llmq: Restrict processing QGETDATA/QDATA to masternodes only
xdustinface Jan 13, 2021
74aecc0
llmq: Implement request limiting for QGETDATA/QDATA
xdustinface Jan 13, 2021
1c70e1d
llmq: Implement CQuorumManger::RequestQuorumData
xdustinface Jan 18, 2021
5045cbb
rpc: Implement "quorum getdata" as wrapper around QGETDATA
xdustinface Jan 13, 2021
006ace6
test: Handle QGETDATA/QDATA messages in mininode
xdustinface Jan 18, 2021
06ece29
test: Add data structures to support QGETDATA/QDATA
xdustinface Jan 18, 2021
61e56b2
test: Add some helper in test_framework.py
xdustinface Jan 18, 2021
5c7c565
test: Implement tests for QGETDATA/QDATA in p2p_quorum_data.py
xdustinface Jan 18, 2021
fdf00bb
test: Add p2p_quorum_data.py to BASE_SCRIPTS
xdustinface Jan 13, 2021
06e05b6
llmq|test: Add QWATCH support for QGETDATA/QDATA
xdustinface Jan 19, 2021
db4e9b4
llmq: Store CQuorumPtr in cache, not CQuorumCPtr
xdustinface Jan 25, 2021
5408d5d
llmq: Fix cache usage after recent changes
xdustinface Jan 25, 2021
1418257
Use uacomment to create/find specific p2ps
UdjinM6 Jan 25, 2021
b70a12a
No need to use network adjusted time here, GetTime should be enough
UdjinM6 Jan 25, 2021
8b6f047
rpc: check proTxHash
UdjinM6 Jan 25, 2021
4e27d65
minor tweaks
UdjinM6 Jan 25, 2021
4206ad6
test: Adjustments after 4e27d6513e0073ed848ede262cfec82a9134abc0
xdustinface Jan 25, 2021
8fdb7b9
llmq: Rename and improve error lambda in CQuorumManager::ProcessMessage
xdustinface Jan 25, 2021
7fe5f31
llmq: Process QDATA if -watchquorums is enabled
xdustinface Jan 25, 2021
57f3ee3
test: Handle qwatch messages in mininode
xdustinface Jan 25, 2021
e49a9a9
test: Add test for -watchquorums support
xdustinface Jan 25, 2021
9862afc
test: Just some empty lines
xdustinface Jan 25, 2021
b4693b7
test: Properly stop the p2p network thread at the end of the test
xdustinface Jan 25, 2021
c97f18f
rpc: Adjust "quorum getdata" parameter descriptions
xdustinface Jan 26, 2021
6710fbd
rpc: Fix optionality of proTxHash in "quorum getdata" command
xdustinface Jan 26, 2021
5661a81
test: Test optionality of proTxHash for "quorum getdata" command
xdustinface Jan 26, 2021
af7ff72
test: Be more specific about imports in p2p_quorum_data.py
xdustinface Jan 26, 2021
5afc806
llmq|rpc: Add some comments about the request.GetDataMask checks
xdustinface Jan 26, 2021
fae5c25
test: Some more empty lines
xdustinface Jan 26, 2021
5e31e5b
rpc: One more parameter description
xdustinface Jan 26, 2021
26859fd
test: Unify assert statements / drop parentheses for all of them
xdustinface Jan 26, 2021
0b0a7a0
fix typo
PastaPastaPasta Jan 26, 2021
c97f1a1
adjust some line wrapping to 80 chars
PastaPastaPasta Jan 26, 2021
9e224ec
tests: Seperate out into dif atomic methods, add logging
PastaPastaPasta Jan 27, 2021
e562313
test: Avoid restarting masternodes, just let available requests expire
xdustinface Jan 28, 2021
09e4b3b
test: Drop redundant code/tests after separation
xdustinface Jan 28, 2021
c1a3387
test: Merge three tests
xdustinface Jan 28, 2021
672afa4
test: Rename test_ratelimiting_banscore -> test_request_limit
xdustinface Jan 28, 2021
ea30c19
test: Apply python style
xdustinface Jan 28, 2021
e59e034
test: Wrap all at 120 characters
xdustinface Jan 28, 2021
224a98a
test: Move some variables
xdustinface Jan 28, 2021
be7c66d
test: Optimize for speed
xdustinface Jan 28, 2021
cc38df2
tests: use wait_until in get_mininode_id
UdjinM6 Jan 28, 2021
3eb405a
test: Don't use `!=` to check for `None`
xdustinface Jan 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
llmq: Introduce CQuorumDataRequest as wrapper for QGETDATA requests
  • Loading branch information
xdustinface committed Jan 25, 2021
commit 4a1c8333187c5b1ea7280819ffe2e94452fe4118
102 changes: 102 additions & 0 deletions src/llmq/quorums.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,106 @@ namespace llmq

class CDKGSessionManager;

/**
* An object of this class represents a QGETDATA request or a QDATA response header
*/
class CQuorumDataRequest
{
public:

enum Flags : uint16_t {
QUORUM_VERIFICATION_VECTOR = 0x0001,
ENCRYPTED_CONTRIBUTIONS = 0x0002,
};
enum Errors : uint8_t {
NONE = 0x00,
QUORUM_TYPE_INVALID = 0x01,
QUORUM_BLOCK_NOT_FOUND = 0x02,
QUORUM_NOT_FOUND = 0x03,
MASTERNODE_IS_NO_MEMBER = 0x04,
QUORUM_VERIFICATION_VECTOR_MISSING = 0x05,
ENCRYPTED_CONTRIBUTIONS_MISSING = 0x06,
UNDEFINED = 0xFF,
};

private:
Consensus::LLMQType llmqType;
uint256 quorumHash;
uint16_t nDataMask;
uint256 proTxHash;
Errors nError;

int64_t nTime;
bool fProcessed;

static const int64_t nExpirySeconds{300};

public:

CQuorumDataRequest() : nTime(GetAdjustedTime()) {}
CQuorumDataRequest(const Consensus::LLMQType llmqTypeIn, const uint256& quorumHashIn, const uint16_t nDataMaskIn, const uint256& proTxHashIn = uint256()) :
llmqType(llmqTypeIn),
quorumHash(quorumHashIn),
nDataMask(nDataMaskIn),
proTxHash(proTxHashIn),
nError(UNDEFINED),
nTime(GetAdjustedTime()),
fProcessed(false) {}

ADD_SERIALIZE_METHODS

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(llmqType);
READWRITE(quorumHash);
READWRITE(nDataMask);
READWRITE(proTxHash);
if (ser_action.ForRead()) {
try {
READWRITE(nError);
} catch (...) {
nError = UNDEFINED;
}
} else if (nError != UNDEFINED) {
READWRITE(nError);
}
}

const Consensus::LLMQType GetLLMQType() const { return llmqType; }
const uint256& GetQuorumHash() const { return quorumHash; }
const uint16_t GetDataMask() const { return nDataMask; }
const uint256& GetProTxHash() const { return proTxHash; }

void SetError(Errors nErrorIn) { nError = nErrorIn; }
const Errors GetError() const { return nError; }

bool IsExpired() const
{
return (GetAdjustedTime() - nTime) >= nExpirySeconds;
}
bool IsProcessed() const
{
return fProcessed;
}
void SetProcessed()
{
fProcessed = true;
}

bool operator==(const CQuorumDataRequest& other)
{
return llmqType == other.llmqType &&
quorumHash == other.quorumHash &&
nDataMask == other.nDataMask &&
proTxHash == other.proTxHash;
}
bool operator!=(const CQuorumDataRequest& other)
{
return !(*this == other);
}
};

/**
* An object of this class represents a quorum which was mined on-chain (through a quorum commitment)
* It at least contains information about the members and the quorum public key which is needed to verify recovered
Expand Down Expand Up @@ -117,4 +217,6 @@ extern CQuorumManager* quorumManager;

} // namespace llmq

template<> struct is_serializable_enum<llmq::CQuorumDataRequest::Errors> : std::true_type {};
Copy link
Member

Choose a reason for hiding this comment

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

Comment this? / what is this doing?

Copy link
Author

Choose a reason for hiding this comment

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

It ensures the de(serialization) code knows what to use / uses the correct type of the enum which is uint8_t in this case of the new enum Errors. Without it you would even trigger this static_assert. See here.


#endif // BITCOIN_LLMQ_QUORUMS_H