Skip to content

Commit

Permalink
chore: increase gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrankovi committed Nov 28, 2024
1 parent 2c4008b commit cdeb953
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
}
}
}
2 changes: 2 additions & 0 deletions libraries/config/include/config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 13 additions & 3 deletions libraries/config/include/config/hardfork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 isCornusHardfork(uint64_t block_number) const { return block_number >= ficus_hf.block_num; }

HAS_RLP_FIELDS
};
Expand Down
3 changes: 3 additions & 0 deletions libraries/config/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 18 additions & 4 deletions libraries/config/src/hardfork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions libraries/core_libs/consensus/include/dag/dag_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class DagManager : public std::enable_shared_from_this<DagManager> {
ExpirationCacheMap<blk_hash_t, std::shared_ptr<DagBlock>> seen_blocks_;
std::shared_ptr<final_chain::FinalChain> final_chain_;
const uint64_t kPbftGasLimit;
const uint64_t kDagGasLimit;
const HardforksConfig kHardforks;
const uint64_t kValidatorMaxVote;

Expand Down
6 changes: 3 additions & 3 deletions libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(std::min(config.genesis.pbft.gas_limit, config.propose_pbft_gas_limit)),
kDagGasLimit(std::min(config.genesis.dag.gas_limit, 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) {
Expand Down Expand Up @@ -117,7 +117,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;
Expand Down
7 changes: 4 additions & 3 deletions libraries/core_libs/consensus/src/dag/dag_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ DagManager::DagManager(const FullNodeConfig &config, addr_t node_addr, std::shar
seen_blocks_(cache_max_size_, cache_delete_step_),
final_chain_(std::move(final_chain)),
kPbftGasLimit(config.genesis.pbft.gas_limit),
kDagGasLimit(config.genesis.dag.gas_limit),
kHardforks(config.genesis.state.hardforks),
kValidatorMaxVote(config.genesis.state.dpos.validator_maximum_stake /
config.genesis.state.dpos.vote_eligibility_balance_step) {
Expand Down Expand Up @@ -715,14 +716,14 @@ std::pair<DagManager::VerifyBlockReturnType, SharedTransactions> 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
if (total_block_weight > kDagGasLimit) {
LOG(log_er_) << "BlockTooBig. DAG block " << blk->getHash() << " gas_limit: " << kDagGasLimit
<< " 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) > kPbftGasLimit / kDagGasLimit) {
for (const auto &t : blk->getTips()) {
const auto tip_blk = getDagBlock(t);
if (tip_blk == nullptr) {
Expand Down
46 changes: 33 additions & 13 deletions tests/rewards_stats_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ struct RewardsStatsTest : NodesTest {};
class TestableRewardsStats : public rewards::Stats {
public:
TestableRewardsStats(const HardforksConfig::RewardsDistributionMap& rdm, std::shared_ptr<DbStorage> 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_; }
};

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit cdeb953

Please sign in to comment.