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

fix: new fork 'withdrawals' and fixes for asset unlock signature verification #6279

Merged
merged 6 commits into from
Oct 21, 2024

Conversation

knst
Copy link
Collaborator

@knst knst commented Sep 18, 2024

Issue being fixed or feature implemented

https://github.com/dashpay/dash-issues/issues/83

What was done?

Introduces new fork "withdrawals" which let Asset Unlock be valid for any active quorum + 1 extra inactive (in opposite of hard-coded 2 of them).

How Has This Been Tested?

See new test section test_withdrawals_fork in functional test feature_asset_locks.py

Breaking Changes

  • new fork "withdrawals"
  • new logic of validation of Asset Unlock transactions's signature. Even no asset-unlock is mined yet, previous version of clients will refuse blocks which is fine for current system

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
  • I have assigned this pull request to a milestone

@knst knst added this to the 22 milestone Sep 18, 2024
@knst knst force-pushed the fix-withdrawal-quorums branch from 7b33395 to 1870106 Compare September 19, 2024 19:20
@knst knst changed the title WIP: fix withdrawal quorums fix: new fork 'withdrawals' and fixes for asset unlock signature verification Sep 19, 2024
Comment on lines 213 to 214
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nStartTime = 1704067200; // January 1, 2024
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nTimeout = 1767225600; // January 1, 2026
Copy link
Collaborator

Choose a reason for hiding this comment

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

Start time and timeout values for each network should be updated to something more relevant before merging

Copy link

Choose a reason for hiding this comment

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

  1. nStartTime should be somewhere in the (near) future
  2. nStartTime and nTimeout should be 1 year apart on mainnet

Copy link

This pull request has conflicts, please rebase.

@PastaPastaPasta
Copy link
Member

Needs rebase?

@knst
Copy link
Collaborator Author

knst commented Sep 27, 2024

Needs rebase?

it depends on #6275 (bury mn_rr) also, which is not merged yet; will rebase after

@knst knst force-pushed the fix-withdrawal-quorums branch from b5237f3 to 4a473a1 Compare September 30, 2024 08:55
Copy link

github-actions bot commented Oct 1, 2024

This pull request has conflicts, please rebase.

@knst knst force-pushed the fix-withdrawal-quorums branch from 4a473a1 to 7bc3698 Compare October 1, 2024 19:10
@knst knst added the Needs Release Notes This PR includes breaking changes for which release notes have not yet been merged. label Oct 1, 2024
Comment on lines 213 to 214
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nStartTime = 1704067200; // January 1, 2024
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nTimeout = 1767225600; // January 1, 2026
Copy link

Choose a reason for hiding this comment

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

  1. nStartTime should be somewhere in the (near) future
  2. nStartTime and nTimeout should be 1 year apart on mainnet

assert(llmq_params_opt.has_value());

// after deployment WITHDRAWALS activated we check not to quorum, but all active quorums + 1 the latest inactive
const int quorums_to_scan = DeploymentActiveAt(*pindexTip, Params().GetConsensus(), Consensus::DEPLOYMENT_WITHDRAWALS) ? (llmq_params_opt->signingActiveQuorumCount + 1) : 2;
Copy link

Choose a reason for hiding this comment

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

could use keepOldConnections here

Suggested change
const int quorums_to_scan = DeploymentActiveAt(*pindexTip, Params().GetConsensus(), Consensus::DEPLOYMENT_WITHDRAWALS) ? (llmq_params_opt->signingActiveQuorumCount + 1) : 2;
const int quorums_to_scan = DeploymentActiveAt(*pindexTip, Params().GetConsensus(), Consensus::DEPLOYMENT_WITHDRAWALS) ? llmq_params_opt->keepOldConnections : 2;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

could use keepOldConnections here

technically, yes

But logically I can't explain myself how signingActiveQuorumCount and keepOldConnections are related.

Copy link

Choose a reason for hiding this comment

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

    // Used for intra-quorum communication. This is the number of quorums for which we should keep old connections.
    // For non-rotated quorums it should be at least one more than the active quorums set.
    // For rotated quorums it should be equal to 2 x active quorums set.
    int keepOldConnections;

https://github.com/dashpay/dash/blob/develop/src/llmq/params.h#L102-L105

i.e. active set + 1 quorum that became inactive recently, exactly what you need here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd still says, that in some particular cases it is matched with "+1" indeed, but I can't justify use "keep old connections" as amount of quorums which makes signature valid; also "2x active quorums" for rotating is not relevant for this situation.

@UdjinM6
Copy link

UdjinM6 commented Oct 3, 2024

tests failed

@knst knst force-pushed the fix-withdrawal-quorums branch from 7bc3698 to 5fd7b07 Compare October 7, 2024 20:16
@knst
Copy link
Collaborator Author

knst commented Oct 8, 2024

@knst knst force-pushed the fix-withdrawal-quorums branch from 7bc3698 to 5fd7b07

fixed test, activation date and rebased to the newer commit - base commit was pretty old

@knst knst requested a review from UdjinM6 October 8, 2024 09:58
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.

@knst
Copy link
Collaborator Author

knst commented Oct 15, 2024

int CAssetUnlockPayload::getHeightToExpiry() const
{
    const auto& llmq_params_opt = Params().GetLLMQ(Params().GetConsensus().llmqTypePlatform);
    assert(llmq_params_opt.has_value());
    return requestedHeight + llmq_params_opt->dkgInterval * (llmq_params_opt->signingActiveQuorumCount + 1);
}

@UdjinM6 no, accordingly DIP and by design, getHeightToExpire is not related to the amount of active quorums at all, it's a mechanism to refuse withdrawal in a short time (48 blocks) if it has not been mined, for example due to limits, or due to small fee; so it can be re-issued without waiting 24+ hours

@knst knst requested a review from UdjinM6 October 15, 2024 13:34
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 0c8b377

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.

invalid syntax in while attempts < 10 (missing:), also pls see below

test/functional/feature_asset_locks.py Outdated Show resolved Hide resolved
@knst knst force-pushed the fix-withdrawal-quorums branch from fea8821 to d690309 Compare October 17, 2024 16:10
@knst knst requested a review from UdjinM6 October 18, 2024 06:22
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 d690309

Comment on lines -122 to +131
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-not-active-quorum");
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-too-old-quorum");
Copy link
Member

Choose a reason for hiding this comment

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

why change this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because (active quorums + the latest inactive) are matched. So, quorum can be not-active, but still valid.

? (llmq_params_opt->signingActiveQuorumCount + 1)

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 d690309

@PastaPastaPasta PastaPastaPasta merged commit b7d5430 into dashpay:develop Oct 21, 2024
34 of 39 checks passed
@knst knst deleted the fix-withdrawal-quorums branch October 24, 2024 15:14
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.

4 participants