diff --git a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp index 39295cf0c1..974a78ac70 100644 --- a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp +++ b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp @@ -6,12 +6,10 @@ #include "common/constants.hpp" #include "common/encoding_solidity.hpp" -#include "common/thread_pool.hpp" #include "final_chain/cache.hpp" #include "final_chain/trie_common.hpp" #include "rewards/rewards_stats.hpp" #include "transaction/system_transaction.hpp" -#include "vote/pbft_vote.hpp" namespace taraxa::final_chain { @@ -188,16 +186,17 @@ class FinalChainImpl final : public FinalChain { } } */ - std::vector evm_trxs; - append_evm_transactions(evm_trxs, new_blk.transactions); - - SharedTransactions system_transactions; + std::vector system_transactions; const auto blk_num = new_blk.pbft_blk->getPeriod(); if (kHardforksConfig.ficus_hf.isPillarBlockPeriod(blk_num)) { auto finalize_trx = make_bridge_finalization_transaction(); system_transactions.push_back(finalize_trx); } - append_evm_transactions(evm_trxs, system_transactions); + + auto all_transactions = new_blk.transactions; + all_transactions.insert(all_transactions.end(), system_transactions.begin(), system_transactions.end()); + std::vector evm_trxs; + append_evm_transactions(evm_trxs, all_transactions); const auto& [exec_results] = state_api_.execute_transactions({new_blk.pbft_blk->getBeneficiary(), kBlockGasLimit, @@ -227,17 +226,18 @@ class FinalChainImpl final : public FinalChain { auto rewards_stats = rewards_.processStats(new_blk, transactions_gas_used, batch); const auto& [state_root, total_reward] = state_api_.distribute_rewards(rewards_stats); - auto blk_header = append_block(batch, new_blk.pbft_blk->getBeneficiary(), new_blk.pbft_blk->getTimestamp(), - kBlockGasLimit, state_root, total_reward, new_blk.transactions, system_transactions, - receipts, new_blk.pbft_blk->getExtraDataRlp()); + auto blk_header = + append_block(batch, new_blk.pbft_blk->getBeneficiary(), new_blk.pbft_blk->getTimestamp(), kBlockGasLimit, + state_root, total_reward, all_transactions, receipts, new_blk.pbft_blk->getExtraDataRlp()); + // Update number of executed DAG blocks and transactions auto num_executed_dag_blk = num_executed_dag_blk_ + finalized_dag_blk_hashes.size(); - auto num_executed_trx = num_executed_trx_ + new_blk.transactions.size() + system_transactions.size(); + auto num_executed_trx = num_executed_trx_ + all_transactions.size(); if (!finalized_dag_blk_hashes.empty()) { db_->insert(batch, DB::Columns::status, StatusDbField::ExecutedBlkCount, num_executed_dag_blk); db_->insert(batch, DB::Columns::status, StatusDbField::ExecutedTrxCount, num_executed_trx); LOG(log_nf_) << "Executed dag blocks #" << num_executed_dag_blk_ - finalized_dag_blk_hashes.size() << "-" - << num_executed_dag_blk_ - 1 << " , Transactions count: " << new_blk.transactions.size(); + << num_executed_dag_blk_ - 1 << " , Transactions count: " << all_transactions.size(); } //// Update DAG lvl mapping @@ -268,7 +268,7 @@ class FinalChainImpl final : public FinalChain { new_blk.pbft_blk->getBlockHash(), }, blk_header, - std::move(new_blk.transactions), + std::move(all_transactions), std::move(receipts), }); @@ -321,7 +321,6 @@ class FinalChainImpl final : public FinalChain { std::shared_ptr append_block(DB::Batch& batch, const addr_t& author, uint64_t timestamp, uint64_t gas_limit, const h256& state_root, u256 total_reward, const SharedTransactions& transactions = {}, - const SharedTransactions& system_transactions = {}, const TransactionReceipts& receipts = {}, const bytes& extra_data = {}) { auto blk_header_ptr = std::make_shared(); auto& blk_header = *blk_header_ptr; @@ -349,19 +348,6 @@ class FinalChainImpl final : public FinalChain { blk_header.log_bloom |= receipt.bloom(); } - if (system_transactions.size()) { - for (const auto& sys_trx : system_transactions) { - auto i_rlp = util::rlp_enc(rlp_strm, trx_idx); - trxs_trie[i_rlp] = sys_trx->rlp(); - - const auto& receipt = receipts[trx_idx]; - receipts_trie[i_rlp] = util::rlp_enc(rlp_strm, receipt); - db_->insert(batch, DB::Columns::final_chain_receipt_by_trx_hash, sys_trx->getHash(), rlp_strm.out()); - - blk_header.log_bloom |= receipt.bloom(); - trx_idx++; - } - } blk_header.transactions_root = hash256(trxs_trie); blk_header.receipts_root = hash256(receipts_trie); rlp_strm.clear(), blk_header.ethereum_rlp(rlp_strm); diff --git a/libraries/core_libs/network/rpc/Taraxa.cpp b/libraries/core_libs/network/rpc/Taraxa.cpp index 8a755bc739..87e429e0fd 100644 --- a/libraries/core_libs/network/rpc/Taraxa.cpp +++ b/libraries/core_libs/network/rpc/Taraxa.cpp @@ -5,13 +5,9 @@ #include #include -#include - #include "dag/dag_manager.hpp" #include "json/reader.h" -#include "network/rpc/eth/data.hpp" #include "pbft/pbft_manager.hpp" -#include "pillar_chain/pillar_chain_manager.hpp" #include "transaction/transaction_manager.hpp" using namespace std; @@ -146,7 +142,7 @@ Json::Value Taraxa::taraxa_getConfig() { return enc_json(tryGetNode()->getConfig Json::Value Taraxa::taraxa_getChainStats() { Json::Value res; if (auto node = full_node_.lock()) { - res["pbft_period"] = Json::UInt64(node->getPbftChain()->getPbftChainSize()); + res["pbft_period"] = Json::UInt64(node->getFinalChain()->last_block_number()); res["dag_blocks_executed"] = Json::UInt64(node->getDB()->getNumBlockExecuted()); res["transactions_executed"] = Json::UInt64(node->getDB()->getNumTransactionExecuted()); } diff --git a/submodules/taraxa-evm b/submodules/taraxa-evm index 4f5c180b1e..fe33a97e30 160000 --- a/submodules/taraxa-evm +++ b/submodules/taraxa-evm @@ -1 +1 @@ -Subproject commit 4f5c180b1e815b5971c33c461787ad25e6ff7e3e +Subproject commit fe33a97e304bc864c798fdea8385976e5236924e