Skip to content

Implement LLMQ based ChainLocks#2643

Merged
codablock merged 15 commits into
dashpay:developfrom
codablock:pr_llmq_chainlocks
Jan 29, 2019
Merged

Implement LLMQ based ChainLocks#2643
codablock merged 15 commits into
dashpay:developfrom
codablock:pr_llmq_chainlocks

Conversation

@codablock
Copy link
Copy Markdown

This implements DIP8 - ChainLocks.

It currently only supports a single attempt and either fails or succeeds. Support for multiple attempts as described in the DIP will be added later.

Turned out there were also some errors in DIP8, which I'm going to fix in a few minutes. For example, attemptNum should not have been part of CLSIG and the verification of the signature in CLSIG is described wrong.

@codablock
Copy link
Copy Markdown
Author

See dashpay/dips#39 for the fixes in DIP8

@UdjinM6 UdjinM6 added this to the 14.0 milestone Jan 23, 2019
Copy link
Copy Markdown

@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.

👍

few comments/suggestions below

Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/validation.cpp Outdated
Comment thread src/validation.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/consensus/params.h Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should limit this to a certain height, otherwise a bug in CL code etc could invalidate the entire chain or something crazy like that

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hmm not sure if that would really help. If such a bug happens and we stop the invalidation at some point (e.g. -100 blocks)...how would this help the user of the node? In that case the node is in an undefined state nevertheless and you can't continue using that node.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm thinking of more of a network wide error, instead of a single client

Comment thread src/llmq/quorums_chainlocks.cpp Outdated
@PastaPastaPasta
Copy link
Copy Markdown
Member

I know with relaying txs we have a delay for privacy reasons. Is there any delay for relaying CL messages? I would think there shouldn't be (also applies to IS lock messages)

@codablock
Copy link
Copy Markdown
Author

@PastaPastaPasta No there is no delay for relaying CLSIG messages. The trickle logic only applies to TXs and only for non-MN nodes.

@codablock
Copy link
Copy Markdown
Author

Handled review comments and pushed new version.

Copy link
Copy Markdown

@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.

Looks good 👍

I have just one question #2643 (comment) i.e. do we need smth like 7c3f311 or should we just store the best chainlock only since this seems to be enough.

@codablock
Copy link
Copy Markdown
Author

codablock commented Jan 24, 2019

@UdjinM6 @PastaPastaPasta After the discussion in the comments and the discussion we had on Slack, I decided to reimplement CLSIG so that it commits to the height instead of prevBlockHash. It will also only store and propagate the current best CLSIG from now on and ignore older ones.

I also added a changes so that quorum selection happens based on a block that 8 blocks in the past. Otherwise receivers of CLSIG would not be able to verify the CLSIG before the header for that block arrives, which is not guaranteed to happen in a consistent order.

I will squash the changes into the initial commits to get a clean history after getting approvals. As I'll not do a rebase at the same time, it should then be easy to verify that no other changes came in so that re-ACKs can be given shortly after that.

I'll also update DIP8 later.

Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this increase misbehaving score?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I decided to not increase DoS score here as you don't know if it's the new CLSIG or the old CLSIG that's the misbehaving one. The peer that sends the bad CLSIG might just be unlucky and accepted it because it didn't know better (e.g. after start or because it missed the other one)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't it be fairly easy to tell if it's a valid but old CLSIG or malicious?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not really. Let's say there are 2 sigs for the same height, but both for different blocks. Node A receives S1 first, node B receives S2 first. Both will now propagate their sig to the other node, resulting in BOTH nodes believing that the other one is malicious. In such cases, it's better to not increase DoS score.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But there should never be two different CLSIGs for the same height... unless there is a fork eight blocks back (since that is what the quorum is based on)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Even such a small fork should not create conflicting CLSIGs. The fork would have to be at least as long as a quorum interval for the ChainLocks quorum is. That would have to be a 288 (12 hours) blocks long fork. And even then, the chance is only 25% to get a conflicting CLSIG (because 3 out of the 4 active quorums are still the same).

So yes, in practice there should never be 2 conflicting CLSIGs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean, if it would take a fork of over 12 hours to get a conflicting CLSIG I think it is safe to assume anyone who sends one is malicious (or you are messed up locally)

Copy link
Copy Markdown

@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.

see inline comments

Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.h Outdated
@codablock
Copy link
Copy Markdown
Author

@UdjinM6 applied your suggestions

Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.cpp Outdated
@UdjinM6 UdjinM6 dismissed their stale review January 25, 2019 23:47

changes were applied

Comment thread src/validation.cpp Outdated
Comment thread src/validation.cpp Outdated
Comment thread src/llmq/quorums_chainlocks.h Outdated
@codablock
Copy link
Copy Markdown
Author

codablock commented Jan 28, 2019

I've just squashed all changes which I've done after the initial PR into the original commits to get a clean history again. You can verify that the code has no changes by running:
git diff bf96814c0d4e bcff2006e (should give no output)
bf96814c0d4e14fd35fb7c43a41f756756e14fd3 is the last pushed commit from a few days ago. bcff2006e is the rebased/squashed and force-pushed commit.

@codablock
Copy link
Copy Markdown
Author

Rebased on develop to include #2652 and added 2 more commits to handle #2643 (comment) and partially #2643 (comment)

@UdjinM6
Copy link
Copy Markdown

UdjinM6 commented Jan 28, 2019

llmq-signing.py still fails sometimes it seems but other than that looks good now imo 👍

Copy link
Copy Markdown

@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, the test failure is (most likely) not related

@codablock codablock merged commit f6828b1 into dashpay:develop Jan 29, 2019
@codablock codablock deleted the pr_llmq_chainlocks branch January 29, 2019 14:59
@UdjinM6 UdjinM6 added the RPC Some notable changes to RPC params/behaviour/descriptions label Mar 5, 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 RPC Some notable changes to RPC params/behaviour/descriptions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants