mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
governance reward split
This commit is contained in:
parent
92c8bf3638
commit
15b2636677
6 changed files with 53 additions and 9 deletions
|
@ -91,7 +91,7 @@ namespace cryptonote {
|
||||||
//premine reward
|
//premine reward
|
||||||
if (already_generated_coins == 0)
|
if (already_generated_coins == 0)
|
||||||
{
|
{
|
||||||
reward = 40000000000000000;
|
reward = 22500000000000000;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,8 @@ namespace config
|
||||||
std::string const GENESIS_TX = "013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1";
|
std::string const GENESIS_TX = "013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1";
|
||||||
uint32_t const GENESIS_NONCE = 10000;
|
uint32_t const GENESIS_NONCE = 10000;
|
||||||
|
|
||||||
|
std::string const GOVERNANCE_WALLET_ADDRESS = "";
|
||||||
|
|
||||||
namespace testnet
|
namespace testnet
|
||||||
{
|
{
|
||||||
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 53;
|
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 53;
|
||||||
|
@ -174,5 +176,7 @@ namespace config
|
||||||
} }; // Bender's daydream
|
} }; // Bender's daydream
|
||||||
std::string const GENESIS_TX = "013c01ff0001ffffffffffff0f029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd0880712101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b";
|
std::string const GENESIS_TX = "013c01ff0001ffffffffffff0f029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd0880712101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b";
|
||||||
uint32_t const GENESIS_NONCE = 10001;
|
uint32_t const GENESIS_NONCE = 10001;
|
||||||
|
|
||||||
|
std::string const GOVERNANCE_WALLET_ADDRESS = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1182,7 +1182,7 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
|
||||||
//make blocks coin-base tx looks close to real coinbase tx to get truthful blob size
|
//make blocks coin-base tx looks close to real coinbase tx to get truthful blob size
|
||||||
uint8_t hf_version = m_hardfork->get_current_version();
|
uint8_t hf_version = m_hardfork->get_current_version();
|
||||||
size_t max_outs = hf_version >= 4 ? 1 : 11;
|
size_t max_outs = hf_version >= 4 ? 1 : 11;
|
||||||
bool r = construct_miner_tx(height, median_size, already_generated_coins, txs_size, fee, miner_address, b.miner_tx, ex_nonce, max_outs, hf_version);
|
bool r = construct_miner_tx(height, median_size, already_generated_coins, txs_size, fee, miner_address, b.miner_tx, ex_nonce, max_outs, hf_version, m_testnet);
|
||||||
CHECK_AND_ASSERT_MES(r, false, "Failed to construct miner tx, first chance");
|
CHECK_AND_ASSERT_MES(r, false, "Failed to construct miner tx, first chance");
|
||||||
size_t cumulative_size = txs_size + get_object_blobsize(b.miner_tx);
|
size_t cumulative_size = txs_size + get_object_blobsize(b.miner_tx);
|
||||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||||
|
@ -1191,7 +1191,7 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
|
||||||
#endif
|
#endif
|
||||||
for (size_t try_count = 0; try_count != 10; ++try_count)
|
for (size_t try_count = 0; try_count != 10; ++try_count)
|
||||||
{
|
{
|
||||||
r = construct_miner_tx(height, median_size, already_generated_coins, cumulative_size, fee, miner_address, b.miner_tx, ex_nonce, max_outs, hf_version);
|
r = construct_miner_tx(height, median_size, already_generated_coins, cumulative_size, fee, miner_address, b.miner_tx, ex_nonce, max_outs, hf_version, m_testnet);
|
||||||
|
|
||||||
CHECK_AND_ASSERT_MES(r, false, "Failed to construct miner tx, second chance");
|
CHECK_AND_ASSERT_MES(r, false, "Failed to construct miner tx, second chance");
|
||||||
size_t coinbase_blob_size = get_object_blobsize(b.miner_tx);
|
size_t coinbase_blob_size = get_object_blobsize(b.miner_tx);
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace cryptonote
|
||||||
LOG_PRINT_L2("destinations include " << num_stdaddresses << " standard addresses and " << num_subaddresses << " subaddresses");
|
LOG_PRINT_L2("destinations include " << num_stdaddresses << " standard addresses and " << num_subaddresses << " subaddresses");
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, transaction& tx, const blobdata& extra_nonce, size_t max_outs, uint8_t hard_fork_version) {
|
bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, transaction& tx, const blobdata& extra_nonce, size_t max_outs, uint8_t hard_fork_version, bool testnet) {
|
||||||
tx.vin.clear();
|
tx.vin.clear();
|
||||||
tx.vout.clear();
|
tx.vout.clear();
|
||||||
tx.extra.clear();
|
tx.extra.clear();
|
||||||
|
@ -98,6 +98,25 @@ namespace cryptonote
|
||||||
LOG_PRINT_L1("Creating block template: reward " << block_reward <<
|
LOG_PRINT_L1("Creating block template: reward " << block_reward <<
|
||||||
", fee " << fee);
|
", fee " << fee);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//TODO: declining governance reward schedule
|
||||||
|
uint64_t governance_reward = 0;
|
||||||
|
if (already_generated_coins != 0)
|
||||||
|
{
|
||||||
|
governance_reward = block_reward / 20;
|
||||||
|
block_reward -= governance_reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
cryptonote::address_parse_info governance_wallet_address;
|
||||||
|
if (testnet)
|
||||||
|
{
|
||||||
|
cryptonote::get_account_address_from_str(governance_wallet_address, true, ::config::testnet::GOVERNANCE_WALLET_ADDRESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cryptonote::get_account_address_from_str(governance_wallet_address, false, ::config::GOVERNANCE_WALLET_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
block_reward += fee;
|
block_reward += fee;
|
||||||
|
|
||||||
// from hard fork 2, we cut out the low significant digits. This makes the tx smaller, and
|
// from hard fork 2, we cut out the low significant digits. This makes the tx smaller, and
|
||||||
|
@ -154,7 +173,26 @@ namespace cryptonote
|
||||||
tx.vout.push_back(out);
|
tx.vout.push_back(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_AND_ASSERT_MES(summary_amounts == block_reward, false, "Failed to construct miner tx, summary_amounts = " << summary_amounts << " not equal block_reward = " << block_reward);
|
if (already_generated_coins != 0)
|
||||||
|
{
|
||||||
|
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);;
|
||||||
|
crypto::public_key out_eph_public_key = AUTO_VAL_INIT(out_eph_public_key);
|
||||||
|
bool r = crypto::generate_key_derivation(governance_wallet_address.address.m_view_public_key, txkey.sec, derivation);
|
||||||
|
CHECK_AND_ASSERT_MES(r, false, "while creating outs: failed to generate_key_derivation(" << governance_wallet_address.address.m_view_public_key << ", " << txkey.sec << ")");
|
||||||
|
|
||||||
|
r = crypto::derive_public_key(derivation, out_amounts.size(), governance_wallet_address.address.m_spend_public_key, out_eph_public_key);
|
||||||
|
CHECK_AND_ASSERT_MES(r, false, "while creating outs: failed to derive_public_key(" << derivation << ", " << out_amounts.size() << ", "<< governance_wallet_address.address.m_spend_public_key << ")");
|
||||||
|
|
||||||
|
txout_to_key tk;
|
||||||
|
tk.key = out_eph_public_key;
|
||||||
|
|
||||||
|
tx_out out;
|
||||||
|
summary_amounts += out.amount = governance_reward;
|
||||||
|
out.target = tk;
|
||||||
|
tx.vout.push_back(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_AND_ASSERT_MES(summary_amounts == (block_reward + governance_reward), false, "Failed to construct miner tx, summary_amounts = " << summary_amounts << " not equal total block_reward = " << (block_reward + governance_reward));
|
||||||
|
|
||||||
if (hard_fork_version >= 4)
|
if (hard_fork_version >= 4)
|
||||||
tx.version = 2;
|
tx.version = 2;
|
||||||
|
@ -627,6 +665,7 @@ namespace cryptonote
|
||||||
block& bl
|
block& bl
|
||||||
, std::string const & genesis_tx
|
, std::string const & genesis_tx
|
||||||
, uint32_t nonce
|
, uint32_t nonce
|
||||||
|
, bool testnet
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//genesis block
|
//genesis block
|
||||||
|
@ -635,7 +674,7 @@ namespace cryptonote
|
||||||
|
|
||||||
account_public_address ac = boost::value_initialized<account_public_address>();
|
account_public_address ac = boost::value_initialized<account_public_address>();
|
||||||
std::vector<size_t> sz;
|
std::vector<size_t> sz;
|
||||||
construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx); // zero fee in genesis
|
construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx, "", 999, 6, testnet); // zero fee in genesis
|
||||||
blobdata txb = tx_to_blob(bl.miner_tx);
|
blobdata txb = tx_to_blob(bl.miner_tx);
|
||||||
std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);
|
std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
namespace cryptonote
|
namespace cryptonote
|
||||||
{
|
{
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, transaction& tx, const blobdata& extra_nonce = blobdata(), size_t max_outs = 999, uint8_t hard_fork_version = 1);
|
bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, transaction& tx, const blobdata& extra_nonce = blobdata(), size_t max_outs = 999, uint8_t hard_fork_version = 1, bool testnet = false);
|
||||||
|
|
||||||
struct tx_source_entry
|
struct tx_source_entry
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,7 @@ namespace cryptonote
|
||||||
block& bl
|
block& bl
|
||||||
, std::string const & genesis_tx
|
, std::string const & genesis_tx
|
||||||
, uint32_t nonce
|
, uint32_t nonce
|
||||||
|
, bool testnet = false
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9653,11 +9653,11 @@ std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t mi
|
||||||
void wallet2::generate_genesis(cryptonote::block& b) const {
|
void wallet2::generate_genesis(cryptonote::block& b) const {
|
||||||
if (m_testnet)
|
if (m_testnet)
|
||||||
{
|
{
|
||||||
cryptonote::generate_genesis_block(b, config::testnet::GENESIS_TX, config::testnet::GENESIS_NONCE);
|
cryptonote::generate_genesis_block(b, config::testnet::GENESIS_TX, config::testnet::GENESIS_NONCE, m_testnet);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cryptonote::generate_genesis_block(b, config::GENESIS_TX, config::GENESIS_NONCE);
|
cryptonote::generate_genesis_block(b, config::GENESIS_TX, config::GENESIS_NONCE, m_testnet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue