Skip to content

Commit

Permalink
Merge pull request #150 from AdminXeq/burn
Browse files Browse the repository at this point in the history
Coinbase TX emission amounts fixed + hf_19 minted coins burn
  • Loading branch information
AdminXeq committed Jan 16, 2024
2 parents 991a7ed + d87f982 commit e339e12
Show file tree
Hide file tree
Showing 20 changed files with 101 additions and 109 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -611,7 +611,7 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAG}")

set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-variable")
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(ARM)
set(WARNINGS "${WARNINGS} -Wno-error=inline-asm")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -116,7 +116,7 @@ invokes cmake commands as needed.
* Change to the root of the source code directory, change to the most recent release branch, and build:

cd equilibria
git checkout v18
git checkout v19
make

*Optional*: If your machine has several cores and enough memory, enable
Expand Down Expand Up @@ -212,7 +212,7 @@ Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (
```bash
git clone https://github.com/equilibriacc/equilibria.git
cd equilibria
git checkout v18
git checkout v19
```

* Build:
Expand Down Expand Up @@ -326,7 +326,7 @@ application.

cd equilibria

git checkout v18
git checkout v19

* If you are on a 64-bit system, run:

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -133,7 +133,7 @@ if(NOT IOS)
add_subdirectory(simplewallet)
add_subdirectory(daemonizer)
add_subdirectory(daemon)
# add_subdirectory(blockchain_utilities)
#add_subdirectory(blockchain_utilities)
endif()

if(BUILD_DEBUG_UTILITIES)
Expand Down
Binary file modified src/blocks/checkpoints.dat
Binary file not shown.
13 changes: 9 additions & 4 deletions src/cryptonote_basic/cryptonote_format_utils.cpp
Expand Up @@ -485,13 +485,18 @@ namespace cryptonote
return get_transaction_weight(tx, blob_size);
}
//---------------------------------------------------------------
bool get_tx_miner_fee(const transaction& tx, uint64_t & fee, bool burning_enabled)
bool get_tx_miner_fee(const transaction& tx, uint64_t & fee, uint8_t hf_ver, bool burning_enabled)
{
if (tx.version >= txversion::v2)
{
fee = tx.rct_signatures.txnFee;
if (burning_enabled)
fee -= std::min(fee, get_burned_amount_from_tx_extra(tx.extra));
{
if (hf_ver < 19)
fee -= std::min(fee, get_burned_amount_from_tx_extra(tx.extra));
else
fee -= std::min(fee, (uint64_t)0);
}
return true;
}

Expand All @@ -504,10 +509,10 @@ namespace cryptonote
return true;
}
//---------------------------------------------------------------
uint64_t get_tx_miner_fee(const transaction& tx, bool burning_enabled)
uint64_t get_tx_miner_fee(const transaction& tx, uint8_t hf_ver, bool burning_enabled)
{
uint64_t r = 0;
if(!get_tx_miner_fee(tx, r, burning_enabled))
if(!get_tx_miner_fee(tx, r, hf_ver, burning_enabled))
return 0;
return r;
}
Expand Down
4 changes: 2 additions & 2 deletions src/cryptonote_basic/cryptonote_format_utils.h
Expand Up @@ -136,8 +136,8 @@ namespace cryptonote
boost::optional<subaddress_receive_info> is_out_to_acc_precomp(const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, const crypto::public_key& out_key, const crypto::key_derivation& derivation, const std::vector<crypto::key_derivation>& additional_derivations, size_t output_index, hw::device &hwdev);
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, const std::vector<crypto::public_key>& additional_tx_public_keys, std::vector<size_t>& outs, uint64_t& money_transfered);
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, std::vector<size_t>& outs, uint64_t& money_transfered);
bool get_tx_miner_fee(const transaction& tx, uint64_t & fee, bool burning_enabled);
uint64_t get_tx_miner_fee(const transaction& tx, bool burning_enabled);
bool get_tx_miner_fee(const transaction& tx, uint64_t & fee, uint8_t hf_ver, bool burning_enabled);
uint64_t get_tx_miner_fee(const transaction& tx, uint8_t hf_ver, bool burning_enabled);
bool generate_key_image_helper(const account_keys& ack, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, const crypto::public_key& out_key, const crypto::public_key& tx_public_key, const std::vector<crypto::public_key>& additional_tx_public_keys, size_t real_output_index, keypair& in_ephemeral, crypto::key_image& ki, hw::device &hwdev);
bool generate_key_image_helper_precomp(const account_keys& ack, const crypto::public_key& out_key, const crypto::key_derivation& recv_derivation, size_t real_output_index, const subaddress_index& received_index, keypair& in_ephemeral, crypto::key_image& ki, hw::device &hwdev);
void get_blob_hash(const blobdata& blob, crypto::hash& res);
Expand Down
8 changes: 7 additions & 1 deletion src/cryptonote_config.h
Expand Up @@ -277,6 +277,8 @@ namespace config
std::string const BRIDGE_WALLET_ADDRESS = "Tw16wVGVwjqY2sSKx11UNjQ8NAosTSwzzitYZfVrXt3iP3DgL5beLz55quDcqpqUvoQTvjyNyRb7mUXf3JKDAyLd36AtDf2ei";
std::string const NEW_BRIDGE_WALLET_ADDRESS = "TvyjwByVHjgCqNKrngt4TQRDgJL7cazWnTXYHXmbFewsKMuN6ozKNcBVkgcpyQwVPRYZCyaAe1W7xN8SdgxqnT4S1UMStejYx";
std::string const DEV_FUND_WALLET = "TvzdbKGga5fSr7fgCTuvR1GY4g9v3No28a6QrcdnnwBkFtisk4MKPLnARAunWBxQJ82L96nGS3ET7BQMhzM788Kp1pweuUfPD";
std::string const NEW_GOV_WALLET = "TvzXGov4tNr6jYG2gdox7bcuEBwwSTpQYAb6w7qgSxuu4hsxY9CMgMgaL6EeqVcQ6hS7Cppn73W8ZSMU8gLMi4N42yTShfkP9";
std::string const NEW_DEV_WALLET = "Tw1XDEVkfVsRFhvjPQJgTjFi4uXDBiMomYeaaaj43SHPSTyLj8nBkdv2KBV8t9CzuCUy1fgYkk9tse6xA3B5oPJZjLfHLDrh";

namespace testnet
{
Expand Down Expand Up @@ -336,6 +338,7 @@ namespace cryptonote
network_version_16,
network_version_17,
network_version_18,
network_version_19,

network_version_count,
};
Expand Down Expand Up @@ -363,6 +366,8 @@ namespace cryptonote
std::string const *BRIDGE_WALLET_ADDRESS;
std::string const *NEW_BRIDGE_WALLET_ADDRESS;
std::string const *DEV_FUND_WALLET;
std::string const *NEW_GOV_WALLET;
std::string const *NEW_DEV_WALLET;

};
inline const config_t& get_config(network_type nettype)
Expand All @@ -381,6 +386,8 @@ namespace cryptonote
&::config::BRIDGE_WALLET_ADDRESS,
&::config::NEW_BRIDGE_WALLET_ADDRESS,
&::config::DEV_FUND_WALLET,
&::config::NEW_GOV_WALLET,
&::config::NEW_DEV_WALLET,
};
static config_t testnet = {
::config::testnet::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX,
Expand All @@ -395,7 +402,6 @@ namespace cryptonote
&::config::testnet::GOVERNANCE_WALLET_ADDRESS,
&::config::testnet::BRIDGE_WALLET_ADDRESS,
&::config::testnet::NEW_BRIDGE_WALLET_ADDRESS,

};
static config_t stagenet = {
::config::stagenet::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX,
Expand Down
53 changes: 43 additions & 10 deletions src/cryptonote_core/blockchain.cpp
Expand Up @@ -1320,10 +1320,21 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
return false;
}

if (!validate_governance_reward_key(height, *cryptonote::get_config(m_nettype).NEW_BRIDGE_WALLET_ADDRESS, vout_end - 2, boost::get<cryptonote::txout_to_key>(b.miner_tx.vout[vout_end - 2].target).key, m_nettype))
if (hard_fork_version >= 19)
{
MERROR("Governance reward public key incorrect");
return false;
if (!validate_governance_reward_key(height, *cryptonote::get_config(m_nettype).NEW_GOV_WALLET, vout_end - 2, boost::get<cryptonote::txout_to_key>(b.miner_tx.vout[vout_end - 2].target).key, m_nettype))
{
MERROR("Governance reward public key incorrect");
return false;
}
}
else
{
if (!validate_governance_reward_key(height, *cryptonote::get_config(m_nettype).NEW_BRIDGE_WALLET_ADDRESS, vout_end - 2, boost::get<cryptonote::txout_to_key>(b.miner_tx.vout[vout_end - 2].target).key, m_nettype))
{
MERROR("Governance reward public key incorrect");
return false;
}
}

if (b.miner_tx.vout[vout_end - 1].amount != reward_parts.dev_fund)
Expand All @@ -1332,10 +1343,21 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
return false;
}

if (!validate_dev_fund_reward_key(height, *cryptonote::get_config(m_nettype).DEV_FUND_WALLET, vout_end - 1, boost::get<cryptonote::txout_to_key>(b.miner_tx.vout[vout_end - 1].target).key, m_nettype))
if (hard_fork_version >= 19)
{
MERROR("Dev Fund reward public key incorrect");
return false;
if (!validate_dev_fund_reward_key(height, *cryptonote::get_config(m_nettype).NEW_DEV_WALLET, vout_end - 1, boost::get<cryptonote::txout_to_key>(b.miner_tx.vout[vout_end - 1].target).key, m_nettype))
{
MERROR("Dev fund reward public key incorrect");
return false;
}
}
else
{
if (!validate_dev_fund_reward_key(height, *cryptonote::get_config(m_nettype).DEV_FUND_WALLET, vout_end - 1, boost::get<cryptonote::txout_to_key>(b.miner_tx.vout[vout_end - 1].target).key, m_nettype))
{
MERROR("Dev Fund reward public key incorrect");
return false;
}
}
}

Expand All @@ -1347,10 +1369,21 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
return false;
}

if (!validate_dev_fund_reward_key(height, *cryptonote::get_config(m_nettype).DEV_FUND_WALLET, b.miner_tx.vout.size() - 1, boost::get<txout_to_key>(b.miner_tx.vout.back().target).key, m_nettype))
if (hard_fork_version >= 19)
{
MERROR("Dev Fund reward public key incorrect");
return false;
if (!validate_dev_fund_reward_key(height, *cryptonote::get_config(m_nettype).NEW_DEV_WALLET, b.miner_tx.vout.size() - 1, boost::get<txout_to_key>(b.miner_tx.vout.back().target).key, m_nettype))
{
MERROR("Dev Fund reward public key incorrect");
return false;
}
}
else
{
if (!validate_dev_fund_reward_key(height, *cryptonote::get_config(m_nettype).DEV_FUND_WALLET, b.miner_tx.vout.size() - 1, boost::get<txout_to_key>(b.miner_tx.vout.back().target).key, m_nettype))
{
MERROR("Dev Fund reward public key incorrect");
return false;
}
}
}
}
Expand Down Expand Up @@ -5280,7 +5313,7 @@ void Blockchain::cancel()
}

#if defined(PER_BLOCK_CHECKPOINT)
static const char expected_block_hashes_hash[] = "92e0036fa613473da6c85d943a995ef13c5c4b372f74a8c04fdae68847dba2eb";
static const char expected_block_hashes_hash[] = "ae324a90b8498518249a6ea800694034914772871968a5b68a94d07faa2e9df5";
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
{
if (get_checkpoints == nullptr || !m_fast_sync)
Expand Down
24 changes: 5 additions & 19 deletions src/cryptonote_core/cryptonote_core.cpp
Expand Up @@ -1191,7 +1191,7 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------
size_t core::get_block_sync_size(uint64_t height) const
{
static const uint64_t quick_height = m_nettype == MAINNET ? 1210000 : 0;
static const uint64_t quick_height = m_nettype == MAINNET ? 1245000 : 0;
if (block_sync_size > 0)
return block_sync_size;
if (height >= quick_height)
Expand All @@ -1206,17 +1206,16 @@ namespace cryptonote
return m_mempool.check_for_key_images(key_im, spent);
}
//-----------------------------------------------------------------------------------------------
std::tuple<uint64_t, uint64_t, uint64_t, uint64_t> core::get_coinbase_tx_sum(const uint64_t start_offset, const size_t count)
std::tuple<uint64_t, uint64_t, uint64_t> core::get_coinbase_tx_sum(const uint64_t start_offset, const size_t count)
{
uint64_t emission_amount = 0;
uint64_t total_fee_amount = 0;
uint64_t burnt_xeq = 0;
uint64_t token_swap = 0;
if (count)
{
const uint64_t end = start_offset + count - 1;
m_blockchain_storage.for_blocks_range(start_offset, end,
[this, &emission_amount, &total_fee_amount, &burnt_xeq, &token_swap](uint64_t, const crypto::hash& hash, const block& b){
[this, &emission_amount, &total_fee_amount, &burnt_xeq](uint64_t, const crypto::hash& hash, const block& b){
std::vector <transaction> txs;
std::vector<crypto::hash> missed_txs;
uint64_t coinbase_amount = get_outs_money_amount(b.miner_tx);
Expand All @@ -1225,7 +1224,7 @@ namespace cryptonote
uint64_t b_xeq = 0;
for(const auto& tx: txs)
{
tx_fee_amount += get_tx_miner_fee(tx, b.major_version >= HF_VERSION_FEE_BURNING);
tx_fee_amount += get_tx_miner_fee(tx, b.major_version, b.major_version >= HF_VERSION_FEE_BURNING);
if (b.major_version >= HF_VERSION_FEE_BURNING)
{
b_xeq += get_burned_amount_from_tx_extra(tx.extra);
Expand All @@ -1237,22 +1236,9 @@ namespace cryptonote
burnt_xeq += b_xeq;
return true;
});

const uint8_t hf_ver = m_blockchain_storage.get_current_hard_fork_version();
if (hf_ver > 16)
{
emission_amount -= (uint64_t)0x1176592e000;
token_swap += (uint64_t)0x2e90edd000;
}
if (hf_ver > 17)
{
emission_amount -= (uint64_t)0x1c2a4cad740;
token_swap += (uint64_t)0x36d4e56f40;
burnt_xeq += (uint64_t)0x5d21dba000;
}
}

return std::tuple<uint64_t, uint64_t, uint64_t, uint64_t>(burnt_xeq, emission_amount, total_fee_amount, token_swap);
return std::tuple<uint64_t, uint64_t, uint64_t>(burnt_xeq, emission_amount, total_fee_amount);
}
//-----------------------------------------------------------------------------------------------
bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/cryptonote_core.h
Expand Up @@ -785,7 +785,7 @@ namespace cryptonote
*
* @return the number of blocks to sync in one go
*/
std::tuple<uint64_t, uint64_t, uint64_t, uint64_t> get_coinbase_tx_sum(const uint64_t start_offset, const size_t count);
std::tuple<uint64_t, uint64_t, uint64_t> get_coinbase_tx_sum(const uint64_t start_offset, const size_t count);

/**
* @brief get the network type we're on
Expand Down
10 changes: 8 additions & 2 deletions src/cryptonote_core/cryptonote_tx_utils.cpp
Expand Up @@ -474,8 +474,10 @@ namespace cryptonote
cryptonote::get_account_address_from_str(governance_wallet_address, nettype, *cryptonote::get_config(nettype).GOVERNANCE_WALLET_ADDRESS);
} else if(hard_fork_version < 14) {
cryptonote::get_account_address_from_str(governance_wallet_address, nettype, *cryptonote::get_config(nettype).BRIDGE_WALLET_ADDRESS);
} else {
} else if (hard_fork_version < 19) {
cryptonote::get_account_address_from_str(governance_wallet_address, nettype, *cryptonote::get_config(nettype).NEW_BRIDGE_WALLET_ADDRESS);
} else {
cryptonote::get_account_address_from_str(governance_wallet_address, nettype, *cryptonote::get_config(nettype).NEW_GOV_WALLET);
}
crypto::public_key out_eph_public_key{};

Expand All @@ -497,7 +499,11 @@ namespace cryptonote
if (hard_fork_version >= 17 && reward_parts.dev_fund > 0)
{
cryptonote::address_parse_info dev_fund_wallet_address;
cryptonote::get_account_address_from_str(dev_fund_wallet_address, nettype, *cryptonote::get_config(nettype).DEV_FUND_WALLET);
if (hard_fork_version < 19) {
cryptonote::get_account_address_from_str(dev_fund_wallet_address, nettype, *cryptonote::get_config(nettype).DEV_FUND_WALLET);
} else {
cryptonote::get_account_address_from_str(dev_fund_wallet_address, nettype, *cryptonote::get_config(nettype).NEW_DEV_WALLET);
}
crypto::public_key out_eph_public_key{};

if(!get_deterministic_output_key(dev_fund_wallet_address.address, sn_key, tx.vout.size(), out_eph_public_key))
Expand Down
4 changes: 2 additions & 2 deletions src/cryptonote_core/service_node_list.cpp
Expand Up @@ -419,7 +419,7 @@ namespace service_nodes
{
uint64_t burned_amount = cryptonote::get_burned_amount_from_tx_extra(tx.extra);
uint64_t total_fee = tx.rct_signatures.txnFee;
uint64_t miner_fee = get_tx_miner_fee(tx, true);
uint64_t miner_fee = get_tx_miner_fee(tx, hf_version, true);
uint64_t burn_fee = total_fee - miner_fee;

if (burned_amount < burn_fee) return false;
Expand Down Expand Up @@ -631,7 +631,7 @@ namespace service_nodes
{
uint64_t burned_amount = cryptonote::get_burned_amount_from_tx_extra(tx.extra);
uint64_t total_fee = tx.rct_signatures.txnFee;
uint64_t miner_fee = get_tx_miner_fee(tx, true);
uint64_t miner_fee = get_tx_miner_fee(tx, hf_version, true);
uint64_t burn_fee = total_fee - miner_fee;
uint64_t b_fee;

Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/tx_pool.cpp
Expand Up @@ -199,7 +199,7 @@ namespace cryptonote
// fee per kilobyte, size rounded up.
uint64_t fee;

if (!get_tx_miner_fee(tx, fee, version >= HF_VERSION_FEE_BURNING))
if (!get_tx_miner_fee(tx, fee, version, version >= HF_VERSION_FEE_BURNING))
{
tvc.m_verification_failed = true;
tvc.m_fee_too_low = true;
Expand Down
5 changes: 0 additions & 5 deletions src/cryptonote_protocol/cryptonote_protocol_handler.inl
Expand Up @@ -2533,11 +2533,6 @@ skip:
{
MINFO("Target height decreasing from " << previous_target << " to " << target);
m_core.set_target_blockchain_height(target);
if (target == 0 && context.m_state > cryptonote_connection_context::state_before_handshake && !m_stopping)
{
MCWARNING("global", "Equilibria is now disconnected from the network");
m_ask_for_txpool_complement = true;
}
}

m_block_queue.flush_spans(context.m_connection_id, false);
Expand Down
3 changes: 1 addition & 2 deletions src/daemon/rpc_command_executor.cpp
Expand Up @@ -1952,8 +1952,7 @@ bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t height, uint64_t cou
<< "consisting of " << cryptonote::print_money(res.emission_amount)
<< " in emissions,\nand " << cryptonote::print_money(res.fee_amount)
<< " in fees,\nand " << cryptonote::print_money(res.burn_amount)
<< " was burnt,\nand " << cryptonote::print_money(res.token_amount)
<< " was locked at cross-chain bridge.";
<< " was burnt.";
return true;
}

Expand Down
3 changes: 2 additions & 1 deletion src/hardforks/hardforks.cpp
Expand Up @@ -49,7 +49,8 @@ const hardfork_t mainnet_hard_forks[] = {
{ 15, 991430, 0, 1672174800 },
{ 16, 1001320, 0, 1673377200 },
{ 17, 1056414, 0, 1680070995 },
{ 18, 1238350, 0, 1704230052 }
{ 18, 1238350, 0, 1704230052 },
{ 19, 1248886, 0, 1705611030 }
};
const size_t num_mainnet_hard_forks = sizeof(mainnet_hard_forks) / sizeof(mainnet_hard_forks[0]);

Expand Down
9 changes: 4 additions & 5 deletions src/p2p/net_node.inl
Expand Up @@ -621,11 +621,10 @@ namespace nodetool
full_addrs.insert("154.38.165.93:9230");
full_addrs.insert("38.242.135.157:9230");
full_addrs.insert("213.155.160.222:9230");
full_addrs.insert("xeq.supporters.ml:9230");
full_addrs.insert("xeq.gntl.uk:9230");
full_addrs.insert("equilibria.fastnode.eu:9230");
full_addrs.insert("144.91.88.92:9230");
//Amsterdam
full_addrs.insert("194.233.64.43:9230");
full_addrs.insert("207.244.249.105:9230");
full_addrs.insert("161.97.102.172:9230");
full_addrs.insert("62.171.181.142:9230");
}
return full_addrs;
}
Expand Down

0 comments on commit e339e12

Please sign in to comment.