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

Including tx fee into block rewards #752

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
coinbaseTx.vout.resize(2);

// Explicitly set miner reward
coinbaseTx.vout[0].nValue = CalculateCoinbaseReward(blockReward, consensus.dist.masternode);
coinbaseTx.vout[0].nValue = nFees + CalculateCoinbaseReward(blockReward, consensus.dist.masternode);
Copy link
Contributor

@bvbfan bvbfan Sep 27, 2021

Choose a reason for hiding this comment

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

It should be covered by hardfork height

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The validation should still pass even without fork height.

if (cbValues.at(DCT_ID{0}) > blockReward + nFees)

Copy link
Contributor

Choose a reason for hiding this comment

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

If we go without hardfork, newer nodes will generate bigger reward than older one, It's inconstancy.

Copy link
Contributor Author

@ShengguangXiao ShengguangXiao Sep 30, 2021

Choose a reason for hiding this comment

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

I will make the change in another PR based on 1.9.x.
#764


// Community payment always expected
coinbaseTx.vout[1].scriptPubKey = consensus.foundationShareScript;
Expand Down
39 changes: 39 additions & 0 deletions test/functional/feature_block_reward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
# Copyright (c) 2014-2019 The Bitcoin Core developers
# Copyright (c) DeFi Blockchain Developers
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
"""Test account mining behaviour"""

from test_framework.test_framework import DefiTestFramework
from test_framework.util import (
assert_greater_than,
assert_equal
)

class BlockRewardTest(DefiTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
self.extra_args = [['-txnotokens=0', '-amkheight=50', '-eunosheight=100', '-eunosheight=100', '-subsidytest=1']]

def run_test(self):
node = self.nodes[0]
node.generate(120)

result = node.listaccounthistory("mine", {"depth":0})
assert_equal(result[0]["amounts"][0], '134.99983200@DFI')

account = node.getnewaddress()
node.utxostoaccount({account: "1.1@0"})
node.utxostoaccount({account: "1.2@0"})
node.utxostoaccount({account: "1.3@0"})
node.generate(1)

result = node.listaccounthistory("mine", {"depth":0})
for subResult in result:
if subResult["type"] == "blockReward":
assert_greater_than(subResult["amounts"][0], '134.99983200@DFI')

if __name__ == '__main__':
BlockRewardTest().main ()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
'feature_burn_address.py',
'feature_eunos_balances.py',
'feature_sendutxosfrom.py',
'feature_block_reward.py',
# Don't append tests at the end to avoid merge conflicts
# Put them in a random line within the section that fits their approximate run-time
]
Expand Down