From 7eb7debd2487b1c888893262a300361f56d4ba4d Mon Sep 17 00:00:00 2001 From: mfrankovi Date: Thu, 28 Nov 2024 11:58:40 +0100 Subject: [PATCH] chore: increase gas limit --- .../config_jsons/default/default_genesis.json | 6 ++- .../config_jsons/devnet/devnet_genesis.json | 6 ++- .../config_jsons/mainnet/mainnet_genesis.json | 6 ++- .../config_jsons/testnet/testnet_genesis.json | 10 ++-- libraries/config/include/config/config.hpp | 2 + libraries/config/include/config/genesis.hpp | 1 + libraries/config/include/config/hardfork.hpp | 16 +++++-- libraries/config/src/config.cpp | 3 ++ libraries/config/src/genesis.cpp | 11 ++++- libraries/config/src/hardfork.cpp | 22 +++++++-- .../consensus/include/dag/dag_manager.hpp | 3 +- .../consensus/include/pbft/pbft_manager.hpp | 3 +- .../consensus/src/dag/dag_block_proposer.cpp | 22 +++++++-- .../consensus/src/dag/dag_manager.cpp | 19 ++++---- .../consensus/src/final_chain/final_chain.cpp | 2 +- .../consensus/src/pbft/pbft_manager.cpp | 12 +++-- submodules/taraxa-evm | 2 +- tests/dag_block_test.cpp | 1 + tests/pbft_manager_test.cpp | 7 ++- tests/rewards_stats_test.cpp | 46 +++++++++++++------ tests/rpc_test.cpp | 6 +-- 21 files changed, 153 insertions(+), 53 deletions(-) diff --git a/libraries/cli/include/cli/config_jsons/default/default_genesis.json b/libraries/cli/include/cli/config_jsons/default/default_genesis.json index 4afcf79004..b56c69c31d 100644 --- a/libraries/cli/include/cli/config_jsons/default/default_genesis.json +++ b/libraries/cli/include/cli/config_jsons/default/default_genesis.json @@ -120,6 +120,10 @@ "pillar_blocks_interval": 10, "bridge_contract_address": "0xcAF2b453FE8382a4B8110356DF0508f6d71F22BF" }, - "cornus_hf_block_num": 100 + "cornus_hf": { + "block_num": 100, + "dag_gas_limit": "0x1908B100", + "pbft_gas_limit": "0x7d2b7500" + } } } \ No newline at end of file diff --git a/libraries/cli/include/cli/config_jsons/devnet/devnet_genesis.json b/libraries/cli/include/cli/config_jsons/devnet/devnet_genesis.json index d4afa4865c..c89fa91300 100644 --- a/libraries/cli/include/cli/config_jsons/devnet/devnet_genesis.json +++ b/libraries/cli/include/cli/config_jsons/devnet/devnet_genesis.json @@ -285,6 +285,10 @@ "pillar_blocks_interval": 10, "bridge_contract_address": "0xcAF2b453FE8382a4B8110356DF0508f6d71F22BF" }, - "cornus_hf_block_num": 0 + "cornus_hf": { + "block_num": 0, + "dag_gas_limit": "0x1908B100", + "pbft_gas_limit": "0x7d2b7500" + } } } \ No newline at end of file diff --git a/libraries/cli/include/cli/config_jsons/mainnet/mainnet_genesis.json b/libraries/cli/include/cli/config_jsons/mainnet/mainnet_genesis.json index 801a7f781b..d5abb3ffa6 100644 --- a/libraries/cli/include/cli/config_jsons/mainnet/mainnet_genesis.json +++ b/libraries/cli/include/cli/config_jsons/mainnet/mainnet_genesis.json @@ -1654,6 +1654,10 @@ "pillar_blocks_interval": 4000, "bridge_contract_address": "0xe126E0BaeAE904b8Cfd619Be1A8667A173b763a1" }, - "cornus_hf_block_num": -1 + "cornus_hf": { + "block_num": -1, + "dag_gas_limit": "0x1908B100", + "pbft_gas_limit": "0x7d2b7500" + } } } \ No newline at end of file diff --git a/libraries/cli/include/cli/config_jsons/testnet/testnet_genesis.json b/libraries/cli/include/cli/config_jsons/testnet/testnet_genesis.json index 658bc22702..3cff3a0d87 100644 --- a/libraries/cli/include/cli/config_jsons/testnet/testnet_genesis.json +++ b/libraries/cli/include/cli/config_jsons/testnet/testnet_genesis.json @@ -105,13 +105,13 @@ "dag_blocks_size": "0x32", "ghost_path_move_back": "0x0", "lambda_ms": "0x5DC", - "gas_limit": "0x7d2b7500" + "gas_limit": "0x12C684C0" }, "dag": { "block_proposer": { "shard": 1 }, - "gas_limit": "0x1908B100" + "gas_limit": "0x1E0A6E0" }, "sortition": { "changes_count_for_average": 10, @@ -154,6 +154,10 @@ "pillar_blocks_interval": 1000, "bridge_contract_address": "0xcAF2b453FE8382a4B8110356DF0508f6d71F22BF" }, - "cornus_hf_block_num": 1668000 + "cornus_hf": { + "block_num": 1668000, + "dag_gas_limit": "0x1908B100", + "pbft_gas_limit": "0x7d2b7500" + } } } \ No newline at end of file diff --git a/libraries/config/include/config/config.hpp b/libraries/config/include/config/config.hpp index 477c29019d..c5fa6e0b79 100644 --- a/libraries/config/include/config/config.hpp +++ b/libraries/config/include/config/config.hpp @@ -58,6 +58,8 @@ struct FullNodeConfig { bool enable_test_rpc = false; bool enable_debug = false; uint32_t final_chain_cache_in_blocks = 5; + uint64_t propose_dag_gas_limit = 0x1E0A6E0; + uint64_t propose_pbft_gas_limit = 0x12C684C0; // config values that limits transactions pool uint32_t transactions_pool_size = kDefaultTransactionPoolSize; diff --git a/libraries/config/include/config/genesis.hpp b/libraries/config/include/config/genesis.hpp index 18d6c15c83..11ef9b42e4 100644 --- a/libraries/config/include/config/genesis.hpp +++ b/libraries/config/include/config/genesis.hpp @@ -34,6 +34,7 @@ struct GenesisConfig { bytes rlp() const; blk_hash_t genesisHash() const; void updateBlocksPerYear(); + std::pair getGasLimits(uint64_t block_number) const; }; Json::Value enc_json(GenesisConfig const& obj); diff --git a/libraries/config/include/config/hardfork.hpp b/libraries/config/include/config/hardfork.hpp index a591ee860e..2268b31163 100644 --- a/libraries/config/include/config/hardfork.hpp +++ b/libraries/config/include/config/hardfork.hpp @@ -72,6 +72,16 @@ struct FicusHardforkConfig { Json::Value enc_json(const FicusHardforkConfig& obj); void dec_json(const Json::Value& json, FicusHardforkConfig& obj); +struct CornusHardforkConfig { + uint64_t block_num = -1; + uint64_t dag_gas_limit = 0; + uint64_t pbft_gas_limit = 0; + + HAS_RLP_FIELDS +}; +Json::Value enc_json(const CornusHardforkConfig& obj); +void dec_json(const Json::Value& json, CornusHardforkConfig& obj); + // Keeping it for next HF // struct BambooRedelegation { // taraxa::addr_t validator; @@ -130,10 +140,10 @@ struct HardforksConfig { // Ficus hardfork: implementation of pillar chain FicusHardforkConfig ficus_hf; - // Cornus hf - support multiple undelegations from the same validator at the same time - uint64_t cornus_hf_block_num{0}; + // Cornus hardfork + CornusHardforkConfig cornus_hf; - bool isCornusHardfork(uint64_t block_number) const { return block_number >= cornus_hf_block_num; } + bool isOnCornusHardfork(uint64_t block_number) const { return block_number >= cornus_hf.block_num; } HAS_RLP_FIELDS }; diff --git a/libraries/config/src/config.cpp b/libraries/config/src/config.cpp index 9e9bffdd19..4bc344585e 100644 --- a/libraries/config/src/config.cpp +++ b/libraries/config/src/config.cpp @@ -108,6 +108,9 @@ FullNodeConfig::FullNodeConfig(const Json::Value &string_or_object, const Json:: genesis = GenesisConfig(); } + propose_dag_gas_limit = getConfigDataAsUInt(root, {"propose_dag_gas_limit"}, true, propose_dag_gas_limit); + propose_pbft_gas_limit = getConfigDataAsUInt(root, {"propose_pbft_gas_limit"}, true, propose_pbft_gas_limit); + is_light_node = getConfigDataAsBoolean(root, {"is_light_node"}, true, is_light_node); const auto min_light_node_history = (genesis.state.dpos.blocks_per_year * kDefaultLightNodeHistoryDays) / 365; light_node_history = getConfigDataAsUInt(root, {"light_node_history"}, true, min_light_node_history); diff --git a/libraries/config/src/genesis.cpp b/libraries/config/src/genesis.cpp index fe24c5fc2f..dfb16e7184 100644 --- a/libraries/config/src/genesis.cpp +++ b/libraries/config/src/genesis.cpp @@ -86,10 +86,10 @@ GenesisConfig::GenesisConfig() { pbft.committee_size = 5; pbft.dag_blocks_size = 100; pbft.ghost_path_move_back = 1; - pbft.gas_limit = 60000000; + pbft.gas_limit = 315000000; // DAG config - dag.gas_limit = 10000000; + dag.gas_limit = 315000000; // DPOS config auto& dpos = state.dpos; @@ -129,4 +129,11 @@ bytes GenesisConfig::rlp() const { blk_hash_t GenesisConfig::genesisHash() const { return dev::sha3(rlp()); } +std::pair GenesisConfig::getGasLimits(uint64_t block_number) const { + if (this->state.hardforks.isOnCornusHardfork(block_number)) { + return {this->state.hardforks.cornus_hf.dag_gas_limit, this->state.hardforks.cornus_hf.pbft_gas_limit}; + } + return {dag.gas_limit, pbft.gas_limit}; +} + } // namespace taraxa diff --git a/libraries/config/src/hardfork.cpp b/libraries/config/src/hardfork.cpp index dd0c85d5b8..bda7bb43e2 100644 --- a/libraries/config/src/hardfork.cpp +++ b/libraries/config/src/hardfork.cpp @@ -104,6 +104,21 @@ void dec_json(const Json::Value& json, FicusHardforkConfig& obj) { RLP_FIELDS_DEFINE(FicusHardforkConfig, block_num, pillar_blocks_interval, bridge_contract_address) +Json::Value enc_json(const CornusHardforkConfig& obj) { + Json::Value json(Json::objectValue); + json["block_num"] = dev::toJS(obj.block_num); + json["dag_gas_limit"] = dev::toJS(obj.dag_gas_limit); + json["pbft_gas_limit"] = dev::toJS(obj.pbft_gas_limit); + return json; +} + +void dec_json(const Json::Value& json, CornusHardforkConfig& obj) { + obj.block_num = json["block_num"].isUInt64() ? dev::getUInt(json["block_num"]) : uint64_t(-1); + obj.dag_gas_limit = dev::getUInt(json["dag_gas_limit"]); + obj.pbft_gas_limit = dev::getUInt(json["pbft_gas_limit"]); +} +RLP_FIELDS_DEFINE(CornusHardforkConfig, block_num, dag_gas_limit, pbft_gas_limit) + // Json::Value enc_json(const BambooRedelegation& obj) { // Json::Value json(Json::objectValue); // json["validator"] = dev::toJS(obj.validator); @@ -158,7 +173,7 @@ Json::Value enc_json(const HardforksConfig& obj) { json["aspen_hf"] = enc_json(obj.aspen_hf); json["ficus_hf"] = enc_json(obj.ficus_hf); // json["bamboo_hf"] = enc_json(obj.bamboo_hf); - json["cornus_hf_block_num"] = dev::toJS(obj.cornus_hf_block_num); + json["cornus_hf"] = enc_json(obj.cornus_hf); return json; } @@ -190,10 +205,9 @@ void dec_json(const Json::Value& json, HardforksConfig& obj) { dec_json(json["aspen_hf"], obj.aspen_hf); dec_json(json["ficus_hf"], obj.ficus_hf); // dec_json(json["bamboo_hf"], obj.bamboo_hf); - obj.cornus_hf_block_num = - json["cornus_hf_block_num"].isUInt64() ? dev::getUInt(json["cornus_hf_block_num"]) : uint64_t(-1); + dec_json(json["cornus_hf"], obj.cornus_hf); } RLP_FIELDS_DEFINE(HardforksConfig, fix_redelegate_block_num, redelegations, rewards_distribution_frequency, magnolia_hf, - phalaenopsis_hf_block_num, fix_claim_all_block_num, aspen_hf, ficus_hf, cornus_hf_block_num) + phalaenopsis_hf_block_num, fix_claim_all_block_num, aspen_hf, ficus_hf, cornus_hf) } // namespace taraxa \ No newline at end of file diff --git a/libraries/core_libs/consensus/include/dag/dag_manager.hpp b/libraries/core_libs/consensus/include/dag/dag_manager.hpp index a2e077576a..634135ad17 100644 --- a/libraries/core_libs/consensus/include/dag/dag_manager.hpp +++ b/libraries/core_libs/consensus/include/dag/dag_manager.hpp @@ -279,8 +279,7 @@ class DagManager : public std::enable_shared_from_this { const uint32_t cache_delete_step_ = 100; ExpirationCacheMap> seen_blocks_; std::shared_ptr final_chain_; - const uint64_t kPbftGasLimit; - const HardforksConfig kHardforks; + const GenesisConfig kGenesis; const uint64_t kValidatorMaxVote; LOG_OBJECTS_DEFINE diff --git a/libraries/core_libs/consensus/include/pbft/pbft_manager.hpp b/libraries/core_libs/consensus/include/pbft/pbft_manager.hpp index 6e8d46fb6e..289307cdbd 100644 --- a/libraries/core_libs/consensus/include/pbft/pbft_manager.hpp +++ b/libraries/core_libs/consensus/include/pbft/pbft_manager.hpp @@ -224,9 +224,10 @@ class PbftManager { /** * @brief Check a block weight of gas estimation * @param dag_blocks dag blocks + * @param period period * @return true if total weight of gas estimation is less or equal to gas limit. Otherwise return false */ - bool checkBlockWeight(const std::vector> &dag_blocks) const; + bool checkBlockWeight(const std::vector> &dag_blocks, PbftPeriod period) const; blk_hash_t getLastPbftBlockHash(); diff --git a/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp b/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp index 510778868a..3c3d8efa20 100644 --- a/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp +++ b/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp @@ -26,8 +26,8 @@ DagBlockProposer::DagBlockProposer(const FullNodeConfig& config, std::shared_ptr node_sk_(config.node_secret), vrf_sk_(config.vrf_secret), vrf_pk_(vrf_wrapper::getVrfPublicKey(vrf_sk_)), - kPbftGasLimit(config.genesis.pbft.gas_limit), - kDagGasLimit(config.genesis.dag.gas_limit), + kPbftGasLimit(config.propose_pbft_gas_limit), + kDagGasLimit(config.propose_dag_gas_limit), kHardforks(config.genesis.state.hardforks), kValidatorMaxVote(config.genesis.state.dpos.validator_maximum_stake / config.genesis.state.dpos.vote_eligibility_balance_step) { @@ -41,6 +41,22 @@ DagBlockProposer::DagBlockProposer(const FullNodeConfig& config, std::shared_ptr auto addr = std::stoull(node_addr.toString().substr(0, 6).c_str(), NULL, 16); my_trx_shard_ = addr % bp_config_.shard; + const auto [dag_gas_limit, pbft_gas_limit] = config.genesis.getGasLimits(final_chain_->lastBlockNumber()); + + if (kPbftGasLimit > pbft_gas_limit) { + LOG(log_er_) << "Propose pbft gas limit:" << kPbftGasLimit + << " greater than max allowed pbft gas limit:" << pbft_gas_limit; + assert(false); + return; + } + + if (kDagGasLimit > dag_gas_limit) { + LOG(log_er_) << "Propose dag gas limit:" << kDagGasLimit + << " greater than max allowed dag gas limit:" << dag_gas_limit; + assert(false); + return; + } + LOG(log_nf_) << "Dag block proposer in " << my_trx_shard_ << " shard ..."; } @@ -117,7 +133,7 @@ bool DagBlockProposer::proposeDagBlock() { } } - auto [transactions, estimations] = getShardedTrxs(*proposal_period, dag_mgr_->getDagConfig().gas_limit); + auto [transactions, estimations] = getShardedTrxs(*proposal_period, kDagGasLimit); if (transactions.empty()) { last_propose_level_ = propose_level; num_tries_ = 0; diff --git a/libraries/core_libs/consensus/src/dag/dag_manager.cpp b/libraries/core_libs/consensus/src/dag/dag_manager.cpp index 301ee7c885..36b4f22628 100644 --- a/libraries/core_libs/consensus/src/dag/dag_manager.cpp +++ b/libraries/core_libs/consensus/src/dag/dag_manager.cpp @@ -35,8 +35,7 @@ DagManager::DagManager(const FullNodeConfig &config, addr_t node_addr, std::shar dag_expiry_limit_(config.dag_expiry_limit), seen_blocks_(cache_max_size_, cache_delete_step_), final_chain_(std::move(final_chain)), - kPbftGasLimit(config.genesis.pbft.gas_limit), - kHardforks(config.genesis.state.hardforks), + kGenesis(config.genesis), kValidatorMaxVote(config.genesis.state.dpos.validator_maximum_stake / config.genesis.state.dpos.vote_eligibility_balance_step) { LOG_OBJECTS_CREATE("DAGMGR"); @@ -512,7 +511,7 @@ void DagManager::recoverDag() { try { uint64_t max_vote_count = 0; const auto vote_count = final_chain_->dposEligibleVoteCount(*propose_period, blk->getSender()); - if (*propose_period < kHardforks.magnolia_hf.block_num) { + if (*propose_period < kGenesis.state.hardforks.magnolia_hf.block_num) { max_vote_count = final_chain_->dposEligibleTotalVoteCount(*propose_period); } else { max_vote_count = kValidatorMaxVote; @@ -673,7 +672,7 @@ std::pair DagManager::ver const auto proposal_period_hash = db_->getPeriodBlockHash(*propose_period); uint64_t max_vote_count = 0; const auto vote_count = final_chain_->dposEligibleVoteCount(*propose_period, blk->getSender()); - if (*propose_period < kHardforks.magnolia_hf.block_num) { + if (*propose_period < kGenesis.state.hardforks.magnolia_hf.block_num) { max_vote_count = final_chain_->dposEligibleTotalVoteCount(*propose_period); } else { max_vote_count = kValidatorMaxVote; @@ -715,14 +714,16 @@ std::pair DagManager::ver return {VerifyBlockReturnType::IncorrectTransactionsEstimation, {}}; } - if (total_block_weight > getDagConfig().gas_limit) { - LOG(log_er_) << "BlockTooBig. DAG block " << blk->getHash() << " gas_limit: " << getDagConfig().gas_limit + const auto [dag_gas_limit, pbft_gas_limit] = kGenesis.getGasLimits(*propose_period); + + if (total_block_weight > dag_gas_limit) { + LOG(log_er_) << "BlockTooBig. DAG block " << blk->getHash() << " gas_limit: " << dag_gas_limit << " total_block_weight " << total_block_weight << " current period " << final_chain_->lastBlockNumber(); return {VerifyBlockReturnType::BlockTooBig, {}}; } - if ((blk->getTips().size() + 1) > kPbftGasLimit / getDagConfig().gas_limit) { + if ((blk->getTips().size() + 1) > pbft_gas_limit / dag_gas_limit) { for (const auto &t : blk->getTips()) { const auto tip_blk = getDagBlock(t); if (tip_blk == nullptr) { @@ -731,8 +732,8 @@ std::pair DagManager::ver } block_gas_estimation += tip_blk->getGasEstimation(); } - if (block_gas_estimation > kPbftGasLimit) { - LOG(log_er_) << "BlockTooBig. DAG block " << blk->getHash() << " with tips has limit: " << kPbftGasLimit + if (block_gas_estimation > pbft_gas_limit) { + LOG(log_er_) << "BlockTooBig. DAG block " << blk->getHash() << " with tips has limit: " << pbft_gas_limit << " block_gas_estimation " << block_gas_estimation << " current period " << final_chain_->lastBlockNumber(); return {VerifyBlockReturnType::BlockTooBig, {}}; 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 19f5ea47a9..f17fc5583d 100644 --- a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp +++ b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp @@ -586,7 +586,7 @@ std::optional FinalChain::finalChainHash(EthBlockNumber n) const { return {}; } - if (kConfig.genesis.state.hardforks.isCornusHardfork(n)) { + if (kConfig.genesis.state.hardforks.isOnCornusHardfork(n)) { return header->hash; } return header->state_root; diff --git a/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp b/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp index ee8f338f23..178c3428b0 100644 --- a/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp +++ b/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp @@ -1287,7 +1287,8 @@ PbftManager::proposePbftBlock() { } const auto &dag_block_weight = dag_blk->getGasEstimation(); - if (total_weight + dag_block_weight > kGenesisConfig.pbft.gas_limit) { + const auto [dag_gas_limit, pbft_gas_limit] = kGenesisConfig.getGasLimits(current_pbft_period); + if (total_weight + dag_block_weight > pbft_gas_limit) { break; } total_weight += dag_block_weight; @@ -1553,7 +1554,7 @@ bool PbftManager::validatePbftBlock(const std::shared_ptr &pbft_block auto prev_pbft_block = pbft_chain_->getPbftBlockInChain(last_pbft_block_hash); auto ghost = dag_mgr_->getGhostPath(prev_pbft_block.getPivotDagBlockHash()); if (ghost.size() > 1 && anchor_hash != ghost[1]) { - if (!checkBlockWeight(anchor_dag_block_order_cache_[anchor_hash])) { + if (!checkBlockWeight(anchor_dag_block_order_cache_[anchor_hash], block_period)) { LOG(log_er_) << "PBFT block " << pbft_block_hash << " weight exceeded max limit"; anchor_dag_block_order_cache_.erase(anchor_hash); return false; @@ -2155,11 +2156,14 @@ void PbftManager::periodDataQueuePush(PeriodData &&period_data, dev::p2p::NodeID size_t PbftManager::periodDataQueueSize() const { return sync_queue_.size(); } -bool PbftManager::checkBlockWeight(const std::vector> &dag_blocks) const { +bool PbftManager::checkBlockWeight(const std::vector> &dag_blocks, PbftPeriod period) const { const u256 total_weight = std::accumulate(dag_blocks.begin(), dag_blocks.end(), u256(0), [](u256 value, const auto &dag_block) { return value + dag_block->getGasEstimation(); }); - if (total_weight > kGenesisConfig.pbft.gas_limit) { + auto pbft_gas_limit = kGenesisConfig.state.hardforks.isOnCornusHardfork(period) + ? kGenesisConfig.state.hardforks.cornus_hf.pbft_gas_limit + : kGenesisConfig.pbft.gas_limit; + if (total_weight > pbft_gas_limit) { return false; } return true; diff --git a/submodules/taraxa-evm b/submodules/taraxa-evm index 870992b61c..16a9607923 160000 --- a/submodules/taraxa-evm +++ b/submodules/taraxa-evm @@ -1 +1 @@ -Subproject commit 870992b61c7b183941622180880120c9662d9c14 +Subproject commit 16a9607923833097405cea6b2009024faa6d5875 diff --git a/tests/dag_block_test.cpp b/tests/dag_block_test.cpp index 6b3b3539c0..c01c5cc6e8 100644 --- a/tests/dag_block_test.cpp +++ b/tests/dag_block_test.cpp @@ -409,6 +409,7 @@ TEST_F(DagBlockMgrTest, too_big_dag_block) { // make config auto node_cfgs = make_node_cfgs(1, 1, 20); node_cfgs.front().genesis.dag.gas_limit = 500000; + node_cfgs.front().propose_dag_gas_limit = 500000; auto node = create_nodes(node_cfgs).front(); auto db = node->getDB(); diff --git a/tests/pbft_manager_test.cpp b/tests/pbft_manager_test.cpp index 942cdf241a..3a6a86c766 100644 --- a/tests/pbft_manager_test.cpp +++ b/tests/pbft_manager_test.cpp @@ -539,6 +539,7 @@ TEST_F(PbftManagerWithDagCreation, dag_generation) { TEST_F(PbftManagerWithDagCreation, limit_dag_block_size) { auto node_cfgs = make_node_cfgs(1, 1, 5, true); node_cfgs.front().genesis.dag.gas_limit = 500000; + node_cfgs.front().propose_dag_gas_limit = 500000; makeNodeFromConfig(node_cfgs); deployContract(); @@ -596,6 +597,8 @@ TEST_F(PbftManagerWithDagCreation, limit_pbft_block) { auto node_cfgs = make_node_cfgs(1, 1, 5, true); node_cfgs.front().genesis.dag.gas_limit = 500000; node_cfgs.front().genesis.pbft.gas_limit = 1100000; + node_cfgs.front().propose_dag_gas_limit = 500000; + node_cfgs.front().propose_pbft_gas_limit = 1100000; makeNodeFromConfig(node_cfgs); deployContract(); @@ -631,6 +634,8 @@ TEST_F(PbftManagerWithDagCreation, produce_overweighted_block) { auto node_cfgs = make_node_cfgs(1, 1, 5, true); auto dag_gas_limit = node_cfgs.front().genesis.dag.gas_limit = 500000; node_cfgs.front().genesis.pbft.gas_limit = 1100000; + node_cfgs.front().propose_dag_gas_limit = 500000; + node_cfgs.front().propose_pbft_gas_limit = 1100000; makeNodeFromConfig(node_cfgs); deployContract(); @@ -665,7 +670,7 @@ TEST_F(PbftManagerWithDagCreation, produce_overweighted_block) { const auto period = node->getFinalChain()->lastBlockNumber(); auto period_data = node->getDB()->getPeriodData(period); ASSERT_TRUE(period_data.has_value()); - EXPECT_FALSE(node->getPbftManager()->checkBlockWeight(period_data->dag_blocks)); + EXPECT_FALSE(node->getPbftManager()->checkBlockWeight(period_data->dag_blocks, period)); } TEST_F(PbftManagerWithDagCreation, proposed_blocks) { diff --git a/tests/rewards_stats_test.cpp b/tests/rewards_stats_test.cpp index 9b2e9d4272..d11b6d240f 100644 --- a/tests/rewards_stats_test.cpp +++ b/tests/rewards_stats_test.cpp @@ -20,11 +20,17 @@ struct RewardsStatsTest : NodesTest {}; class TestableRewardsStats : public rewards::Stats { public: TestableRewardsStats(const HardforksConfig::RewardsDistributionMap& rdm, std::shared_ptr db) - : rewards::Stats( - 100, - HardforksConfig{ - 0, {}, rdm, MagnoliaHardfork{0, 0}, 0, 0, AspenHardfork{0, 0}, FicusHardforkConfig{0, 0, {}}}, - db, [](auto) { return 100; }) {} + : rewards::Stats(100, + HardforksConfig{0, + {}, + rdm, + MagnoliaHardfork{0, 0}, + 0, + 0, + AspenHardfork{0, 0}, + FicusHardforkConfig{0, 0, {}}, + CornusHardforkConfig{0, 0, 0}}, + db, [](auto) { return 100; }) {} auto getStats() { return blocks_stats_; } }; @@ -242,14 +248,28 @@ TEST_F(RewardsStatsTest, dagBlockRewards) { hfc.aspen_hf.block_num_part_two = 4; // Create two reward stats to test before and after aspen hardfork part 1 - rewards::Stats pre_aspen_reward_stats( - 100, - HardforksConfig{0, {}, {}, MagnoliaHardfork{0, 0}, 0, 0, AspenHardfork{6, 999}, FicusHardforkConfig{0, 0, {}}}, - db, [](auto) { return 100; }); - rewards::Stats post_aspen_reward_stats( - 100, - HardforksConfig{0, {}, {}, MagnoliaHardfork{0, 0}, 0, 0, AspenHardfork{4, 999}, FicusHardforkConfig{0, 0, {}}}, - db, [](auto) { return 100; }); + rewards::Stats pre_aspen_reward_stats(100, + HardforksConfig{0, + {}, + {}, + MagnoliaHardfork{0, 0}, + 0, + 0, + AspenHardfork{6, 999}, + FicusHardforkConfig{0, 0, {}}, + CornusHardforkConfig{0, 0, 0}}, + db, [](auto) { return 100; }); + rewards::Stats post_aspen_reward_stats(100, + HardforksConfig{0, + {}, + {}, + MagnoliaHardfork{0, 0}, + 0, + 0, + AspenHardfork{4, 999}, + FicusHardforkConfig{0, 0, {}}, + CornusHardforkConfig{0, 0, 0}}, + db, [](auto) { return 100; }); // Create pbft block with 5 dag blocks auto dag_key1 = dev::KeyPair::create(); diff --git a/tests/rpc_test.cpp b/tests/rpc_test.cpp index ad34833237..eab52aaad1 100644 --- a/tests/rpc_test.cpp +++ b/tests/rpc_test.cpp @@ -30,9 +30,9 @@ TEST_F(RPCTest, eth_estimateGas) { { Json::Value trx(Json::objectValue); trx["data"] = samples::greeter_contract_code; - check_estimation_is_in_range(trx, "0x5ccc5"); + check_estimation_is_in_range(trx, "0x5dcc5"); trx["from"] = from; - check_estimation_is_in_range(trx, "0x5ccc5"); + check_estimation_is_in_range(trx, "0x5dcc5"); } // Contract creation with value @@ -40,7 +40,7 @@ TEST_F(RPCTest, eth_estimateGas) { Json::Value trx(Json::objectValue); trx["value"] = 1; trx["data"] = samples::greeter_contract_code; - check_estimation_is_in_range(trx, "0x5ccc5"); + check_estimation_is_in_range(trx, "0x5dcc5"); } // Simple transfer estimations with author + without author