@@ -1664,7 +1664,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
16641664
16651665 if (b.major_version >= HF_VERSION_FCMP_PLUS_PLUS)
16661666 {
1667- m_db->get_tree_root_at_blk_idx (height, b.fcmp_pp_tree_root );
1667+ b. fcmp_pp_n_tree_layers = m_db->get_tree_root_at_blk_idx (height, b.fcmp_pp_tree_root );
16681668 }
16691669
16701670 size_t txs_weight;
@@ -1800,21 +1800,20 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
18001800 return create_block_template (b, NULL , miner_address, diffic, height, expected_reward, cumulative_weight, ex_nonce, seed_height, seed_hash);
18011801}
18021802// ------------------------------------------------------------------
1803- bool Blockchain::get_miner_data (uint8_t & major_version, uint64_t & height, crypto::hash& prev_id, crypto::ec_point& fcmp_pp_tree_root, crypto::hash& seed_hash, difficulty_type& difficulty, uint64_t & median_weight, uint64_t & already_generated_coins, std::vector<tx_block_template_backlog_entry>& tx_backlog)
1803+ bool Blockchain::get_miner_data (uint8_t & major_version, uint64_t & height, crypto::hash& prev_id, uint8_t & fcmp_pp_n_tree_layers, crypto::ec_point& fcmp_pp_tree_root, crypto::hash& seed_hash, difficulty_type& difficulty, uint64_t & median_weight, uint64_t & already_generated_coins, std::vector<tx_block_template_backlog_entry>& tx_backlog)
18041804{
18051805 prev_id = m_db->top_block_hash (&height);
18061806 ++height;
18071807
18081808 major_version = m_hardfork->get_ideal_version (height);
18091809
1810- const uint8_t cur_version = m_hardfork->get_current_version ();
1811-
1810+ fcmp_pp_n_tree_layers = 0 ;
18121811 fcmp_pp_tree_root = crypto::ec_point{};
1813- if (cur_version >= HF_VERSION_FCMP_PLUS_PLUS)
1814- m_db->get_tree_root_at_blk_idx (height, fcmp_pp_tree_root);
1812+ if (major_version >= HF_VERSION_FCMP_PLUS_PLUS)
1813+ fcmp_pp_n_tree_layers = m_db->get_tree_root_at_blk_idx (height, fcmp_pp_tree_root);
18151814
18161815 seed_hash = crypto::null_hash;
1817- if (cur_version >= RX_BLOCK_VERSION)
1816+ if (major_version >= RX_BLOCK_VERSION)
18181817 {
18191818 uint64_t seed_height, next_height;
18201819 crypto::rx_seedheights (height, &seed_height, &next_height);
@@ -2605,12 +2604,11 @@ static bool get_fcmp_tx_tree_root(const BlockchainDB *db, const cryptonote::tran
26052604 " tx included reference block that was too high" );
26062605
26072606 // Get the tree root and n tree layers at provided block
2608- const std:: size_t n_tree_layers = db->get_tree_root_at_blk_idx (tx.rct_signatures .p .reference_block , tree_root_out);
2607+ const uint8_t n_tree_layers = db->get_tree_root_at_blk_idx (tx.rct_signatures .p .reference_block , tree_root_out);
26092608
26102609 // Make sure the provided n tree layers matches expected
26112610 // IMPORTANT!
2612- static_assert (sizeof (std::size_t ) >= sizeof (uint8_t ), " unexpected size of size_t" );
2613- CHECK_AND_ASSERT_MES ((std::size_t )tx.rct_signatures .p .n_tree_layers == n_tree_layers, false ,
2611+ CHECK_AND_ASSERT_MES (tx.rct_signatures .p .n_tree_layers == n_tree_layers, false ,
26142612 " tx included incorrect number of tree layers" );
26152613
26162614 return true ;
@@ -4354,14 +4352,14 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash&
43544352
43554353 TIME_MEASURE_START (t3);
43564354
4357- // Make sure the block uses the correct FCMP++ tree root
4355+ // Make sure the block uses the correct FCMP++ tree root and n tree layers
43584356 if (hf_version >= HF_VERSION_FCMP_PLUS_PLUS)
43594357 {
43604358 crypto::ec_point fcmp_pp_tree_root;
4361- m_db->get_tree_root_at_blk_idx (blockchain_height, fcmp_pp_tree_root);
4362- if (bl.fcmp_pp_tree_root != fcmp_pp_tree_root)
4359+ const uint8_t n_tree_layers = m_db->get_tree_root_at_blk_idx (blockchain_height, fcmp_pp_tree_root);
4360+ if (bl.fcmp_pp_n_tree_layers != n_tree_layers || bl. fcmp_pp_tree_root != fcmp_pp_tree_root)
43634361 {
4364- MERROR_VER (" Block with id: " << id << " used incorrect FCMP++ tree root" );
4362+ MERROR_VER (" Block with id: " << id << " used incorrect FCMP++ n tree layers or tree root" );
43654363 bvc.m_verifivation_failed = true ;
43664364 goto leave;
43674365 }
@@ -5982,13 +5980,14 @@ void Blockchain::send_miner_notifications(uint64_t height, const crypto::hash &s
59825980 std::vector<tx_block_template_backlog_entry> tx_backlog;
59835981 m_tx_pool.get_block_template_backlog (tx_backlog);
59845982
5983+ uint8_t fcmp_pp_n_tree_layers = 0 ;
59855984 crypto::ec_point fcmp_pp_tree_root{};
5986- if (m_hardfork-> get_current_version () >= HF_VERSION_FCMP_PLUS_PLUS)
5987- m_db->get_tree_root_at_blk_idx (height, fcmp_pp_tree_root);
5985+ if (major_version >= HF_VERSION_FCMP_PLUS_PLUS)
5986+ fcmp_pp_n_tree_layers = m_db->get_tree_root_at_blk_idx (height, fcmp_pp_tree_root);
59885987
59895988 for (const auto & notifier : m_miner_notifiers)
59905989 {
5991- notifier (major_version, height, prev_id, fcmp_pp_tree_root, seed_hash, diff, median_weight, already_generated_coins, tx_backlog);
5990+ notifier (major_version, height, prev_id, fcmp_pp_n_tree_layers, fcmp_pp_tree_root, seed_hash, diff, median_weight, already_generated_coins, tx_backlog);
59925991 }
59935992}
59945993
0 commit comments