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!: add an implementation of DIP 0027 Credit Asset Locks #5026

Merged
merged 37 commits into from
Jul 24, 2023

Conversation

knst
Copy link
Collaborator

@knst knst commented Sep 23, 2022

Issue being fixed or feature implemented

This is an implementation of DIP0027 "Credit Asset Locks".
It's a mechanism to fluidly exchange between Dash and credits.

What was done?

This pull request includes:
- Asset Lock transaction
- Asset Unlock transaction (withdrawal)
- Credit Pool in coinbase
- Unit tests for Asset Lock/Unlock tx
- New functional test feature_asset_locks.py

RPC: currently locked amount (credit pool) is available through rpc call getblock.

How Has This Been Tested?

There added new unit tests for basic checks of transaction validity (asset lock/unlock).
Also added new functional test "feature_asset_locks.py" that cover typical cases, but not all corner cases yet.

Breaking Changes

This feature should be activated as soft-fork because:

  • It adds 2 new special transaction and one of them [asset unlock tx] requires update consensus rulels
  • It adds new data in coinbase tx (credit pool)

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

@thephez thephez added the RPC Some notable changes to RPC params/behaviour/descriptions label Sep 26, 2022
@knst knst changed the title Added implementation of asset locks Add an implementation of DIP 0027 Credit Asset Locks Sep 29, 2022
@knst knst added this to the 19 milestone Sep 29, 2022
@knst knst marked this pull request as ready for review September 29, 2022 18:57
@PastaPastaPasta
Copy link
Member

Please change PR title to follow conventional commits :)

Comment on lines 548 to 451
// TODO or which one?
consensus.llmqTypeAssetLocks = Consensus::LLMQType::LLMQ_50_60;
Copy link
Member

Choose a reason for hiding this comment

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

probably fine

Comment on lines 754 to 624
consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_60_75;
consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_100_67;
consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_50_60;
// TODO or which one?
consensus.llmqTypeAssetLocks = Consensus::LLMQType::LLMQ_50_60;
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused... I thought all of these should be llmq_devnet...

@knst knst changed the title Add an implementation of DIP 0027 Credit Asset Locks feat!: add an implementation of DIP 0027 Credit Asset Locks Sep 29, 2022
@knst knst force-pushed the asset-locks branch 3 times, most recently from 18e1141 to 16478ce Compare October 4, 2022 14:35
@github-actions
Copy link

This pull request has conflicts, please rebase.

@github-actions
Copy link

This pull request has conflicts, please rebase.

@knst knst marked this pull request as draft November 24, 2022 19:01
@knst knst force-pushed the asset-locks branch 2 times, most recently from 53f5d52 to d2e9e20 Compare November 29, 2022 10:52
@knst knst marked this pull request as ready for review November 29, 2022 10:55
@knst knst force-pushed the asset-locks branch 2 times, most recently from 879f60f to d894f13 Compare December 9, 2022 11:37
knst added 2 commits July 15, 2023 01:18
assert can be triggered if Add() is called without validation of SkipSet conditions
}

index = assetUnlockTx.getIndex();
toUnlock = assetUnlockTx.getFee();
Copy link

Choose a reason for hiding this comment

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

ping re min fee

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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 added 2 commits July 19, 2023 16:16
Now blocks mined and transaction are created by different nodes to be sure that transaction are relayed
@knst knst requested a review from UdjinM6 July 20, 2023 14:28
@UdjinM6
Copy link

UdjinM6 commented Jul 20, 2023

Looks good! 👍

What about

Also would be nice to see a test for unlock txes with different fees (from 0 to >0.1 DASH).

?

@knst
Copy link
Collaborator Author

knst commented Jul 20, 2023

Also would be nice to see a test for unlock txes with different fees (from 0 to >0.1 DASH).

added just now, thanks for reminding!

@UdjinM6
Copy link

UdjinM6 commented Jul 20, 2023

Ok, so this

diff --git a/test/functional/feature_asset_locks.py b/test/functional/feature_asset_locks.py
index 725d290f6e..32176e309c 100755
--- a/test/functional/feature_asset_locks.py
+++ b/test/functional/feature_asset_locks.py
@@ -295,7 +295,7 @@ class AssetLocksTest(DashTestFramework):
 
         self.log.info("Generating several txes by same quorum....")
         self.validate_credit_pool_amount(locked_1)
-        asset_unlock_tx = self.create_assetunlock(101, COIN, pubkey)
+        asset_unlock_tx = self.create_assetunlock(101, COIN, pubkey, fee=1)
         asset_unlock_tx_late = self.create_assetunlock(102, COIN, pubkey)
         asset_unlock_tx_too_late = self.create_assetunlock(103, COIN, pubkey)
         asset_unlock_tx_too_big_fee = self.create_assetunlock(104, COIN, pubkey, fee=int(Decimal("0.1") * COIN))

results in failures like

AssertionError: not([{'allowed': True, 'txid': '27d3357231f0f877d69a94d72d5f0e374a40fe8936974f868ba069439eb13aea'}] == [{'txid': '27d3357231f0f877d69a94d72d5f0e374a40fe8936974f868ba069439eb13aea', 'allowed': False, 'reject-reason': 'min relay fee not met'}])

That's exactly what I was worried about. 0f35ff3 should help. Or maybe we need to think more about unlocking vs min fees.

@UdjinM6
Copy link

UdjinM6 commented Jul 20, 2023

Why do we need to bypass limit? If fee is too low and tx is not mined - platform will generate new one after expiration. There's nothing special about asset-unlock. Tests works as I expected when implemented it...

For some txes such as quorum/etc there are nowhere to take reward/fee, so, checks are bypassed. But unlock txes are not special in this terms. If fee is too small - it's okay to request "more fee, please"

https://github.com/dashpay/dash/pull/5026/files#r1269915571

oh, so it's ok for unlock tx to fail? for example when fees are high or mempool is full

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 then :)

Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

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

re-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

@PastaPastaPasta PastaPastaPasta merged commit 8a0e681 into dashpay:develop Jul 24, 2023
knst added a commit to knst/dash that referenced this pull request Aug 3, 2023
knst added a commit to knst/dash that referenced this pull request Aug 3, 2023
PastaPastaPasta pushed a commit that referenced this pull request Aug 8, 2023
…5526)

## Issue being fixed or feature implemented
Bad naming is noticed in #5026 by
thephez

## What was done?
Renamed `assetLockedAmount` in CbTx to `creditPoolBalance`
Renamed also some local variables and functions to make it matched also.

## How Has This Been Tested?
Run functional/unit tests - succeed
Called python's rpc binding `node.getblock(block_hash)['cbTx']`:
Got this result:
```
{'version': 3, 'height': 1556, 'merkleRootMNList': '978b2b4d1b884de62799b9eaee75c7812fea59f98f80d5ff9c963b0f0f195e14', 'merkleRootQuorums': 'bc7a34eb114f4e4bf38a11080b5d8ac41bdb36dd41e17467bae23c94ba06b013', 'bestCLHeightDiff': 0, 'bestCLSignature': '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'creditPoolBalance': Decimal('7.00141421')}
```

## Breaking Changes
Renamed `assetLockedAmount` in CbTx to `creditPoolBalance`. @shumkov be
informed


## Checklist:
- [x] I have performed a self-review of my own code
- [ ] 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
knst added a commit to knst/dash that referenced this pull request Aug 24, 2023
…ashpay#5526)

## Issue being fixed or feature implemented
Bad naming is noticed in dashpay#5026 by
thephez

## What was done?
Renamed `assetLockedAmount` in CbTx to `creditPoolBalance`
Renamed also some local variables and functions to make it matched also.

## How Has This Been Tested?
Run functional/unit tests - succeed
Called python's rpc binding `node.getblock(block_hash)['cbTx']`:
Got this result:
```
{'version': 3, 'height': 1556, 'merkleRootMNList': '978b2b4d1b884de62799b9eaee75c7812fea59f98f80d5ff9c963b0f0f195e14', 'merkleRootQuorums': 'bc7a34eb114f4e4bf38a11080b5d8ac41bdb36dd41e17467bae23c94ba06b013', 'bestCLHeightDiff': 0, 'bestCLSignature': '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'creditPoolBalance': Decimal('7.00141421')}
```

## Breaking Changes
Renamed `assetLockedAmount` in CbTx to `creditPoolBalance`. @shumkov be
informed


## Checklist:
- [x] I have performed a self-review of my own code
- [ ] 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
@PastaPastaPasta PastaPastaPasta added the Needs Release Notes This PR includes breaking changes for which release notes have not yet been merged. label Aug 30, 2023
PastaPastaPasta pushed a commit that referenced this pull request Oct 23, 2023
## Issue being fixed or feature implemented
The bug was introduced in the original PR #5026 and refactored later
(which is good actually cause we shouldn't mix refactoring and
bug-fixing :) )

## What was done?
fix conditions, add tests

## How Has This Been Tested?
`feature_asset_locks.py`

## Breaking Changes
n/a

## 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
- [ ] 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)_
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. RPC Some notable changes to RPC params/behaviour/descriptions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants