Skip to content

Check block reward maturity instead of block maturity#714

Merged
scravy merged 18 commits into
dtr-org:masterfrom
Gnappuraz:getblocktomaturity-per-vout
Mar 5, 2019
Merged

Check block reward maturity instead of block maturity#714
scravy merged 18 commits into
dtr-org:masterfrom
Gnappuraz:getblocktomaturity-per-vout

Conversation

@Gnappuraz

@Gnappuraz Gnappuraz commented Mar 1, 2019

Copy link
Copy Markdown
Member

In preparation to PoS we change how some checks are performed in the wallet to determine the maturity of some balance. Before this PR the whole coinbase is considered either mature or not for accounting purposes, this PR differentiates the maturity of the first output of the coinbase from the others (at the moment there is none except the commitment that has value = 0 anyway).

This PR should be merged after #709 since it cointains some of its code.

@Gnappuraz Gnappuraz requested review from a team and scravy March 1, 2019 16:45
@Gnappuraz Gnappuraz added the feature New functionality label Mar 1, 2019
@Gnappuraz Gnappuraz self-assigned this Mar 1, 2019
Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/wallet/wallet.cpp Outdated
@cmihai

cmihai commented Mar 1, 2019

Copy link
Copy Markdown
Member

this PR differentiates the maturity of the first output of the coinbase from the others (at the moment there is none except the commitment that has value = 0 anyway).

How does this interact with the stake_split_threshold? If the user is staking a coin worth over 5000 UTE, he'll get several outputs: one immature and the rest mature. Is this what we want?

Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/wallet/wallet.cpp Outdated
@thothd

thothd commented Mar 1, 2019

Copy link
Copy Markdown
Member

this PR differentiates the maturity of the first output of the coinbase from the others (at the moment there is none except the commitment that has value = 0 anyway).

How does this interact with the stake_split_threshold? If the user is staking a coin worth over 5000 UTE, he'll get several outputs: one immature and the rest mature. Is this what we want?

It's gonna change later when implementing the rewards pool (already started) for now we can treat it as keeping the reward functionality which is also relevant for Unit-e and adding another output for PoS (the stake).
Sounds like it's complementary to stake_split_threshold and it's anyway just doing it for the immediate reward which again gonna be very small when implementing the rewards pool in #504

Comment thread src/wallet/wallet.cpp
CAmount CWalletTx::GetImmatureCredit() const
{
if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) {
if (fUseCache && fImmatureCreditCached) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm removing the cache cause it is only used by rpc and it would be way more tricky to invalidate the cache for coinbases without every time checking if the maturity of the reward output changed.

@scravy

scravy commented Mar 3, 2019

Copy link
Copy Markdown
Member

@Gnappuraz I took the liberty and rebased this to get the fix from #715 and make the tests pass.

@Gnappuraz

Copy link
Copy Markdown
Member Author

@scravy thx

@Ruteri Ruteri left a comment

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.

utACK 1c6c501

Comment thread src/wallet/test/wallet_tests.cpp
Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/wallet/wallet.cpp Outdated

@kostyantyn kostyantyn left a comment

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.

utACK 9083694

Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/wallet/test/wallet_tests.cpp Outdated

@AM5800 AM5800 left a comment

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.

ACK 9083694
Compiled and debugged unit-test

However would like few nits to be addressed

@scravy scravy left a comment

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.

Concept ACK 9083694

Matteo Sumberaz added 7 commits March 5, 2019 21:01
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Matteo Sumberaz and others added 11 commits March 5, 2019 21:01
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Mateusz Morusiewicz <mateusz@thirdhash.com>
Signed-off-by: Mateusz Morusiewicz <mateusz@thirdhash.com>
Signed-off-by: Matteo Sumberaz <matteo@thirdhash.com>
Signed-off-by: Julian Fleischer <julian@thirdhash.com>
Signed-off-by: Julian Fleischer <julian@thirdhash.com>
@scravy

scravy commented Mar 5, 2019

Copy link
Copy Markdown
Member

Rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants