Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devnet cornus test #2904

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,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 @@ -286,7 +286,7 @@
"bridge_contract_address": "0xcAF2b453FE8382a4B8110356DF0508f6d71F22BF"
},
"cornus_hf": {
"block_num": 0,
"block_num": 1000,
"delegation_locking_period": 5,
"dag_gas_limit": "0x1908B100",
"pbft_gas_limit": "0x7d2b7500"
Expand Down
4 changes: 1 addition & 3 deletions libraries/config/include/config/config_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ Json::Value getConfigData(Json::Value root, const std::vector<std::string> &path
std::string getConfigDataAsString(const Json::Value &root, const std::vector<std::string> &path, bool optional = false,
const std::string &value = {});

uint32_t getConfigDataAsUInt(const Json::Value &root, const std::vector<std::string> &path, bool optional = false,
uint64_t getConfigDataAsUInt(const Json::Value &root, const std::vector<std::string> &path, bool optional = false,
uint32_t value = 0);

uint64_t getConfigDataAsUInt64(const Json::Value &root, const std::vector<std::string> &path);

bool getConfigDataAsBoolean(const Json::Value &root, const std::vector<std::string> &path, bool optional = false,
bool value = false);

Expand Down
20 changes: 2 additions & 18 deletions libraries/config/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ std::vector<logger::Config> FullNodeConfig::loadLoggingConfigs(const Json::Value
output.target = log_path;
output.file_name = (log_path / getConfigDataAsString(o, {"file_name"})).string();
output.format = getConfigDataAsString(o, {"format"});
output.max_size = getConfigDataAsUInt64(o, {"max_size"});
output.rotation_size = getConfigDataAsUInt64(o, {"rotation_size"});
output.max_size = getConfigDataAsUInt(o, {"max_size"});
output.rotation_size = getConfigDataAsUInt(o, {"rotation_size"});
output.time_based_rotation = getConfigDataAsString(o, {"time_based_rotation"});
}
logging.outputs.push_back(output);
Expand Down Expand Up @@ -202,22 +202,6 @@ void FullNodeConfig::validate() const {
throw ConfigException("transactions_pool_size cannot be smaller than " + std::to_string(kMinTransactionPoolSize));
}

if (genesis.pbft.gas_limit < propose_pbft_gas_limit ||
(genesis.state.hardforks.cornus_hf.block_num != uint64_t(-1) &&
genesis.state.hardforks.cornus_hf.pbft_gas_limit < propose_pbft_gas_limit)) {
throw ConfigException("Propose pbft gas limit:" + std::to_string(propose_pbft_gas_limit) +
" greater than max allowed pbft gas limit:" + std::to_string(genesis.pbft.gas_limit) + ":" +
std::to_string(genesis.state.hardforks.cornus_hf.pbft_gas_limit));
}

if (genesis.dag.gas_limit < propose_dag_gas_limit ||
(genesis.state.hardforks.cornus_hf.block_num != uint64_t(-1) &&
genesis.state.hardforks.cornus_hf.dag_gas_limit < propose_dag_gas_limit)) {
throw ConfigException("Propose dag gas limit:" + std::to_string(propose_pbft_gas_limit) +
" greater than max allowed pbft gas limit:" + std::to_string(genesis.pbft.gas_limit) + ":" +
std::to_string(genesis.state.hardforks.cornus_hf.pbft_gas_limit));
}

// TODO: add validation of other config values
}

Expand Down
13 changes: 3 additions & 10 deletions libraries/config/src/config_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <fstream>

#include "common/config_exception.hpp"
#include "libdevcore/CommonJS.h"

namespace taraxa {

Expand Down Expand Up @@ -44,14 +45,14 @@ std::string getConfigDataAsString(const Json::Value &root, const std::vector<std
}
}

uint32_t getConfigDataAsUInt(const Json::Value &root, const std::vector<std::string> &path, bool optional,
uint64_t getConfigDataAsUInt(const Json::Value &root, const std::vector<std::string> &path, bool optional,
uint32_t value) {
try {
Json::Value ret = getConfigData(root, path, optional);
if (ret.isNull()) {
return value;
} else {
return ret.asUInt();
return dev::getUInt(ret);
}
} catch (Json::Exception &e) {
if (optional) {
Expand All @@ -61,14 +62,6 @@ uint32_t getConfigDataAsUInt(const Json::Value &root, const std::vector<std::str
}
}

uint64_t getConfigDataAsUInt64(const Json::Value &root, const std::vector<std::string> &path) {
try {
return getConfigData(root, path).asUInt64();
} catch (Json::Exception &e) {
throw ConfigException(getConfigErr(path) + e.what());
}
}

bool getConfigDataAsBoolean(const Json::Value &root, const std::vector<std::string> &path, bool optional, bool value) {
try {
Json::Value ret = getConfigData(root, path, optional);
Expand Down
7 changes: 3 additions & 4 deletions libraries/config/src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ DdosProtectionConfig dec_ddos_protection_config_json(const Json::Value &json) {
ddos_protection.packets_stats_time_period_ms =
std::chrono::milliseconds{getConfigDataAsUInt(json, {"packets_stats_time_period_ms"})};
ddos_protection.peer_max_packets_processing_time_us =
std::chrono::microseconds{getConfigDataAsUInt64(json, {"peer_max_packets_processing_time_us"})};
ddos_protection.peer_max_packets_queue_size_limit =
getConfigDataAsUInt64(json, {"peer_max_packets_queue_size_limit"});
ddos_protection.max_packets_queue_size = getConfigDataAsUInt64(json, {"max_packets_queue_size"});
std::chrono::microseconds{getConfigDataAsUInt(json, {"peer_max_packets_processing_time_us"})};
ddos_protection.peer_max_packets_queue_size_limit = getConfigDataAsUInt(json, {"peer_max_packets_queue_size_limit"});
ddos_protection.max_packets_queue_size = getConfigDataAsUInt(json, {"max_packets_queue_size"});
return ddos_protection;
}

Expand Down
6 changes: 4 additions & 2 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,10 @@ 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.propose_pbft_gas_limit),
kDagGasLimit(config.propose_dag_gas_limit),
kPbftGasLimit(
std::min(config.propose_pbft_gas_limit, config.genesis.getGasLimits(final_chain_->lastBlockNumber()).second)),
kDagGasLimit(
std::min(config.propose_dag_gas_limit, config.genesis.getGasLimits(final_chain_->lastBlockNumber()).first)),
kHardforks(config.genesis.state.hardforks),
kValidatorMaxVote(config.genesis.state.dpos.validator_maximum_stake /
config.genesis.state.dpos.vote_eligibility_balance_step) {
Expand Down