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

feat!: Insertion of best CL signature in CbTx #5262

Merged
merged 18 commits into from May 9, 2023

Conversation

ogabrielides
Copy link
Collaborator

@ogabrielides ogabrielides commented Mar 21, 2023

Issue being fixed or feature implemented

What was done?

  • Bumped version of CbTx. Added fields bestCLHeightDiff, bestCLSignature
  • Miner starting from v20 fork, includes best CL signature in CbTx (if available) or null signature.
  • All nodes should verify included CL signature before accepting the block.

How Has This Been Tested?

Basically, activated v20 on in the beginning of feature_llmq_chainlocks.py

Breaking Changes

Yes, new version of CbTx

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@ogabrielides ogabrielides added this to the 20 milestone Mar 21, 2023
@ogabrielides ogabrielides force-pushed the cb_clsig branch 2 times, most recently from a0e595d to 6e24f7e Compare April 15, 2023 08:19
@github-actions
Copy link

This pull request has conflicts, please rebase.

src/evo/cbtx.cpp Outdated Show resolved Hide resolved
src/evo/cbtx.h Outdated Show resolved Hide resolved
@github-actions
Copy link

This pull request has conflicts, please rebase.

@thephez
Copy link
Collaborator

thephez commented Apr 18, 2023

@ogabrielides We'll have to update DIP(s) with this change, right?

@ogabrielides
Copy link
Collaborator Author

@thephez Correct. Once this PR is merged I will open a new one for the DIPs.

knst pushed a commit to knst/dash that referenced this pull request Apr 19, 2023
PastaPastaPasta pushed a commit to knst/dash that referenced this pull request Apr 19, 2023
@ogabrielides ogabrielides marked this pull request as draft April 20, 2023 19:37
knst pushed a commit to knst/dash that referenced this pull request Apr 21, 2023
@ogabrielides ogabrielides marked this pull request as ready for review April 23, 2023 10:09
@ogabrielides
Copy link
Collaborator Author

@PastaPastaPasta @UdjinM6 Adjusted to latest decisions. (Why CI isn't starting?)

src/evo/cbtx.cpp Outdated
Comment on lines 41 to 42
bool isCbV20 = cbTx.nVersion == CCbTx::CB_V20_VERSION;
if (isV20 != isCbV20) return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-cbtx-version");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool isCbV20 = cbTx.nVersion == CCbTx::CB_V20_VERSION;
if (isV20 != isCbV20) return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-cbtx-version");
if (isV20 && cbTx.nVersion != CCbTx::CB_V20_VERSION) return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-cbtx-version");

src/evo/cbtx.cpp Show resolved Hide resolved
src/evo/cbtx.cpp Outdated
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-payload");
}

if (cbTx.nVersion >= CCbTx::CB_V20_VERSION) {
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't allow a version greater than current version

src/evo/cbtx.cpp Outdated Show resolved Hide resolved
src/evo/cbtx.cpp Outdated
// IsNull() doesn't exist for CBLSSignature: we assume that a non valid BLS sig is null
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-clsig");
}
int prevBlockCoinbaseCLHeight = pindexPrev->nHeight - static_cast<int>(prevBlockCoinbaseChainlock.value().second) - 1;
Copy link
Member

Choose a reason for hiding this comment

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

give this variable a name :) maybe expand prevBlockCoinbaseChainlock.value() earlier into blsSig and blockHeightDiff or something like that

src/evo/cbtx.cpp Outdated Show resolved Hide resolved
src/evo/cbtx.cpp Outdated Show resolved Hide resolved
src/evo/cbtx.cpp Outdated
return true;
}

bool EmplaceBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, const int nHeight, std::optional<std::pair<CBLSSignature, uint32_t>> prevBlockCoinbaseChainlock, uint32_t& bestCLHeightDiff, CBLSSignature& bestCLSignature)
Copy link
Member

Choose a reason for hiding this comment

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

we also should probably not use return parameters

src/evo/cbtx.cpp Outdated Show resolved Hide resolved

std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
{
auto opt_cbtx = GetCoinbaseTx(pindex);
Copy link
Member

Choose a reason for hiding this comment

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

we should probably storecbtx.bestCLSignature, cbtx.bestCLHeightDiff in state somewhere so we don't have to load blocks from disk

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean to cache {cbtx.bestCLSignature, cbtx.bestCLHeightDiff} per block ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Implemented in #5347 by the way

@UdjinM6
Copy link

UdjinM6 commented Apr 24, 2023

pls see https://github.com/UdjinM6/dash/commits/pr5262 for some suggestions

@ogabrielides
Copy link
Collaborator Author

@PastaPastaPasta @UdjinM6 Applied (most of) the suggestions

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

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 for squash merge, let's do it :)

@PastaPastaPasta PastaPastaPasta added the Needs Release Notes This PR includes breaking changes for which release notes have not yet been merged. label May 9, 2023
@PastaPastaPasta PastaPastaPasta merged commit b1626f9 into dashpay:develop May 9, 2023
5 of 8 checks passed
@ogabrielides ogabrielides deleted the cb_clsig branch May 9, 2023 07:54
UdjinM6 added a commit that referenced this pull request May 17, 2023
## Issue being fixed or feature implemented

Implementation of Randomness Beacon Part 2.
This PR is the next step of #5262.

Starting from v20 activation fork, members for quorums are sorted using
(if available) the best CL signature found in Coinbase.
If no CL signature is present yet, then the usual way is used (By using
Blockhash instead)

## What was done?

## How Has This Been Tested?
Test `feature_llmq_rotation.py` was updated to cover both rotated and
non-rotated quorums.
2 quorums are mined first to ensure Chainlock are working earlier.
Then dip_24 activation is replaced by v20 activation.

The only direct way to test this change is to make sure that all
expected quorums after v20 activation are properly formed.

Note: A `wait_for_chainlocked_block_all_nodes` is called between every
rotation cycle to ensure that Coinbase will use a different Chainlock
signature.

## Breaking Changes
Yes, quorum members will be calculated differently.

## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_

---------

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
thephez added a commit to thephez/docs-core that referenced this pull request Aug 16, 2023
thephez added a commit to dashpay/docs-core that referenced this pull request Aug 30, 2023
* docs: deprecate MSG_LEGACY_TXLOCK_REQUEST

Aligns with dashpay/dash#5483

* chore: update link to prev version of docs

* docs: update mnlistdiff nversion location

Relates to dashpay/dash#5450

* docs(p2p): update mnlistdiff

Relates to dashpay/dash#5377

* docs: update cbtx for v3

Relates to dashpay/dash#5262

* docs: update mnhf with details of final implementation

Relates to dashpay/dash#5469 and dashpay/dash#5505

* docs: note removal of NODE_GETUTXO

Relates to dashpay/dash#5500

* chore: revert "docs: update mnhf with details of final implementation"

This reverts commit 8e4bf6c since there
may still be additional changes to the implementation (it's not merged)
PastaPastaPasta added a commit that referenced this pull request Sep 5, 2023
## Issue being fixed or feature implemented


## What was done?
Added release notes for #5262.

## How Has This Been Tested?


## Breaking Changes


## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [x] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_

---------

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: thephez <thephez@users.noreply.github.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
thephez added a commit to thephez/docs-core that referenced this pull request Sep 27, 2023
* docs: deprecate MSG_LEGACY_TXLOCK_REQUEST

Aligns with dashpay/dash#5483

* chore: update link to prev version of docs

* docs: update mnlistdiff nversion location

Relates to dashpay/dash#5450

* docs(p2p): update mnlistdiff

Relates to dashpay/dash#5377

* docs: update cbtx for v3

Relates to dashpay/dash#5262

* docs: update mnhf with details of final implementation

Relates to dashpay/dash#5469 and dashpay/dash#5505

* docs: note removal of NODE_GETUTXO

Relates to dashpay/dash#5500

* chore: revert "docs: update mnhf with details of final implementation"

This reverts commit 8e4bf6c since there
may still be additional changes to the implementation (it's not merged)
thephez added a commit to dashpay/docs-core that referenced this pull request Nov 15, 2023
* docs: deprecate MSG_LEGACY_TXLOCK_REQUEST

Aligns with dashpay/dash#5483

* chore: update link to prev version of docs

* docs: update mnlistdiff nversion location

Relates to dashpay/dash#5450

* docs(p2p): update mnlistdiff

Relates to dashpay/dash#5377

* docs: update cbtx for v3

Relates to dashpay/dash#5262

* docs: update mnhf with details of final implementation

Relates to dashpay/dash#5469 and dashpay/dash#5505

* docs: note removal of NODE_GETUTXO

Relates to dashpay/dash#5500

* chore: revert "docs: update mnhf with details of final implementation"

This reverts commit 8e4bf6c since there
may still be additional changes to the implementation (it's not merged)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Release Notes This PR includes breaking changes for which release notes have not yet been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants