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

Proposer finalization rewards #1081

Closed

Conversation

Nizametdinov
Copy link
Member

This pull request implements proposer finalization rewards.

The first block of every epoch must contain finalization rewards for the block proposers of the previous epoch. The number of finalization reward outputs equals the epoch length. The scripts to which finalization rewards are sent are taken from the reward (0th) outputs of the previous epoch coinbase transactions. The reward amount must depend on the percentage of votes included in the previous epoch, but this will be implemented in following PRs.

See some additional details in #418.

@pep8speaks

This comment has been minimized.

src/Makefile.am Outdated Show resolved Hide resolved
src/esperanza/walletextension.cpp Outdated Show resolved Hide resolved
@Nizametdinov Nizametdinov requested a review from scravy May 8, 2019 09:04
src/blockchain/blockchain_parameters.h Show resolved Hide resolved
src/coins.h Outdated Show resolved Hide resolved
@scravy
Copy link
Member

scravy commented May 10, 2019

Needs rebase.

@Nizametdinov Nizametdinov force-pushed the proposer-finalization-rewards branch from 32ba35c to 5be8a8f Compare May 15, 2019 15:20
@Nizametdinov Nizametdinov requested review from cmihai and scravy and removed request for cmihai May 15, 2019 15:21
const Dependency<BlockDB> m_block_db;

CScript GetRewardScript(const CBlockIndex &index) const {
// TODO UNIT-E: implement more efficient reward script retrieval
Copy link
Member

Choose a reason for hiding this comment

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

If I understood correct, this function will be called on every block in epoch, on every checkpoint. Then, reading blocks from disk is super inefficient. I faced with this when worked on commits and full-sync, on my machine every block read could pause the process for up to 500ms. I suggest avoid disk reading.

Copy link
Member

Choose a reason for hiding this comment

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

@Nizametdinov Is this comment resolved/acted upon?

Copy link
Member Author

Choose a reason for hiding this comment

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

@scravy I will create an issue when this branch is merged.

src/proposer/finalization_reward_logic.cpp Show resolved Hide resolved
Copy link
Member

@Gnappuraz Gnappuraz 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 to me, utACK 5be8a8f

if (num_reward_outputs > 1 && !(prev_block.pprev->nStatus & BLOCK_HAVE_DATA)) {
// prev_block is a parent block of the snapshot which was used for ISD.
// We do not have data for the ancestor blocks of prev_block.
// TODO UNIT-E: implement proper validation of finalization rewards after ISD
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to have an issue for this. It seems that we cannot check if the rewards are being payed to the correct scripts here, correct?

Copy link
Member

Choose a reason for hiding this comment

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

Did we create an issue for this?

@@ -60,7 +60,9 @@ def test_empty_blocks_balance(self, created_money, nodes):
coinstake_tx_id = block_info['tx'][0]
coinstake_tx_info = nodes[node_idx].gettransaction(coinstake_tx_id)

created_money += coinstake_tx_info['details'][0]['amount']
# TODO UNIT-E: gettransaction should not return fees for coinbase transactions
Copy link
Member

Choose a reason for hiding this comment

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

I would like to have an issue here as well. We don't want to forget this stuff.

Copy link
Member

Choose a reason for hiding this comment

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

Did we create an issue for this?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, can't find anything.

@Nizametdinov Nizametdinov force-pushed the proposer-finalization-rewards branch 3 times, most recently from 17ed35d to c27f7f3 Compare May 17, 2019 16:03
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
clang showed the following error:
wallet/wallet.cpp:2577:17: error: calling function 'IsLockedCoin'
  requires holding mutex 'cs_wallet' exclusively
  [-Werror,-Wthread-safety-analysis]
            if (IsLockedCoin(entry.first, i)) {
                ^

Signed-off-by: Azat Nizametdinov <[email protected]>
@Nizametdinov Nizametdinov force-pushed the proposer-finalization-rewards branch from cde2613 to a288d8c Compare May 28, 2019 08:37
src/wallet/wallet.h Outdated Show resolved Hide resolved
src/esperanza/walletextension.cpp Outdated Show resolved Hide resolved
@thothd thothd closed this Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants