Skip to content

Commit ebbb317

Browse files
authored
Merge pull request #3064 from Taraxa-project/testnet
v1.13.4
2 parents 8823da1 + 3a06689 commit ebbb317

File tree

81 files changed

+1734
-1317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1734
-1317
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1111
# Set current version of the project
1212
set(TARAXA_MAJOR_VERSION 1)
1313
set(TARAXA_MINOR_VERSION 13)
14-
set(TARAXA_PATCH_VERSION 3)
14+
set(TARAXA_PATCH_VERSION 4)
1515
set(TARAXA_VERSION ${TARAXA_MAJOR_VERSION}.${TARAXA_MINOR_VERSION}.${TARAXA_PATCH_VERSION})
1616
message(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR})
1717
# Include Conan toolchain file

conanfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def requirements(self):
2323
self.requires("rocksdb/9.10.0")
2424
self.requires("prometheus-cpp/1.3.0")
2525
self.requires("jsoncpp/1.9.6")
26-
self.requires("mpfr/4.2.1")
26+
self.requires("mpfr/4.2.2")
2727
self.requires("gmp/6.3.0")
2828
self.requires("rapidjson/1.1.0")
2929

@@ -100,4 +100,4 @@ def generate(self):
100100
tc.generate()
101101

102102
deps = CMakeDeps(self)
103-
deps.generate()
103+
deps.generate()

for_devs/local-net

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python3.9
22
import click
33
import subprocess
44
import threading
@@ -300,7 +300,7 @@ def start_workers(binary, consensus_nodes, rpc_nodes, tps, enable_test_rpc):
300300
def node_worker(binary, worker_name, enable_test_rpc):
301301
cmd = f'{binary} --config ./{data_dir}/conf-{worker_name}.json --wallet ./{data_dir}/wallet-{worker_name}.json --genesis ./{data_dir}/genesis-{worker_name}.json'
302302
if enable_test_rpc:
303-
cmd += ' --enable-test-rpc '
303+
cmd += ' --rpc.enable-test-rpc '
304304

305305
process = subprocess.Popen(cmd,
306306
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -312,7 +312,7 @@ def faucet_worker(tps):
312312
time.sleep(10)
313313
web3 = Web3(Web3.HTTPProvider('http://127.0.0.1:7017'))
314314
nonce = web3.eth.get_transaction_count(
315-
Web3.to_checksum_address(faucet_public_address))
315+
Web3.toChecksumAddress(faucet_public_address))
316316

317317
consensus_nodes = list(consensus_nodes_public_addresses.keys())
318318

@@ -322,8 +322,8 @@ def faucet_worker(tps):
322322
0, len(consensus_nodes)-1)]]
323323
tx = {
324324
'nonce': nonce,
325-
'to': Web3.to_checksum_address(to),
326-
'value': web3.to_wei(1, 'gwei'),
325+
'to': Web3.toChecksumAddress(to),
326+
'value': web3.toWei(1, 'gwei'),
327327
'gas': 21000,
328328
'gasPrice': web3.eth.gas_price,
329329
'chainId': int(chain_id)
@@ -337,7 +337,7 @@ def faucet_worker(tps):
337337
try:
338338
tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction)
339339
log_format(
340-
'faucet', f'{t} Dripped to {to}, tx_hash: {web3.to_hex(tx_hash)}')
340+
'faucet', f'{t} Dripped to {to}, tx_hash: {web3.toHex(tx_hash)}')
341341
except Exception as e:
342342
log_format('faucet', f'{t} Failed to drip to {to}. Error: {str(e)}')
343343
pass

libraries/app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ target_link_libraries(app PUBLIC
1212
common
1313
core_libs
1414
rpc_plugin
15+
light_plugin
1516
)
1617

1718
install(TARGETS app

libraries/app/include/app/app.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class App : public std::enable_shared_from_this<App>, public AppBase {
2828
App& operator=(App&&) = delete;
2929
void init(const cli::Config& cli_conf);
3030
void start();
31+
FullNodeConfig& getMutableConfig() { return conf_; }
3132
const FullNodeConfig& getConfig() const { return conf_; }
3233
std::shared_ptr<Network> getNetwork() const { return network_; }
3334
std::shared_ptr<TransactionManager> getTransactionManager() const { return trx_mgr_; }
@@ -43,8 +44,6 @@ class App : public std::enable_shared_from_this<App>, public AppBase {
4344
std::shared_ptr<GasPricer> getGasPricer() const { return gas_pricer_; }
4445
std::shared_ptr<pillar_chain::PillarChainManager> getPillarChainManager() const { return pillar_chain_mgr_; }
4546

46-
const dev::Address& getAddress() const { return kp_->address(); }
47-
4847
void rebuildDb();
4948

5049
void initialize(const std::filesystem::path& data_dir,

libraries/app/src/app.cpp

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ App::~App() { close(); }
3535

3636
void App::addAvailablePlugin(std::shared_ptr<Plugin> plugin) { available_plugins_[plugin->name()] = plugin; }
3737

38+
std::shared_ptr<Plugin> App::getPlugin(const std::string &name) const {
39+
auto it = active_plugins_.find(name);
40+
if (it != active_plugins_.end()) {
41+
return it->second;
42+
}
43+
return nullptr;
44+
}
45+
3846
void App::enablePlugin(const std::string &name) {
3947
if (available_plugins_[name] == nullptr) {
4048
throw std::runtime_error("Plugin " + name + " not found");
@@ -46,23 +54,30 @@ bool App::isPluginEnabled(const std::string &name) const { return active_plugins
4654

4755
void App::init(const cli::Config &cli_conf) {
4856
conf_ = cli_conf.getNodeConfiguration();
49-
kp_ = std::make_shared<dev::KeyPair>(conf_.node_secret);
5057

5158
fs::create_directories(conf_.db_path);
5259
fs::create_directories(conf_.log_path);
5360

5461
// Initialize logging
55-
const auto &node_addr = kp_->address();
62+
const auto &node_addr = conf_.getFirstWallet().node_addr;
5663
for (auto &logging : conf_.log_configs) {
5764
logging.InitLogging(node_addr);
5865
}
5966

6067
LOG_OBJECTS_CREATE("FULLND");
6168

62-
LOG(log_si_) << "Node public key: " << EthGreen << kp_->pub().toString() << std::endl
63-
<< EthReset << "Node address: " << EthRed << node_addr.toString() << std::endl
64-
<< EthReset << "Node VRF public key: " << EthGreen
65-
<< vrf_wrapper::getVrfPublicKey(conf_.vrf_secret).toString() << EthReset;
69+
std::string node_addresses;
70+
std::string node_public_keys;
71+
std::string node_vrf_public_keys;
72+
std::for_each(conf_.wallets.begin(), conf_.wallets.end(), [&](const WalletConfig &wallet) {
73+
node_addresses += wallet.node_addr.toString() + " ";
74+
node_public_keys += wallet.node_pk.toString() + " ";
75+
node_vrf_public_keys += wallet.vrf_pk.toString() + " ";
76+
});
77+
78+
LOG(log_si_) << "Node public keys: " << EthGreen << "[" << node_public_keys << "]" << std::endl
79+
<< EthReset << "Node addresses: " << EthRed << "[" << node_addresses << "]" << std::endl
80+
<< EthReset << "Node VRF public keys: " << EthGreen << "[" << node_vrf_public_keys << "]" << EthReset;
6681

6782
if (!conf_.genesis.dag_genesis_block.verifySig()) {
6883
LOG(log_er_) << "Genesis block is invalid";
@@ -117,9 +132,9 @@ void App::init(const cli::Config &cli_conf) {
117132
}
118133

119134
final_chain_ = std::make_shared<final_chain::FinalChain>(db_, conf_, node_addr);
120-
gas_pricer_ = std::make_shared<GasPricer>(conf_.genesis, conf_.is_light_node, db_);
121135
key_manager_ = std::make_shared<KeyManager>(final_chain_);
122136
trx_mgr_ = std::make_shared<TransactionManager>(conf_, db_, final_chain_, node_addr);
137+
gas_pricer_ = std::make_shared<GasPricer>(conf_.genesis, conf_.is_light_node, conf_.blocks_gas_pricer, trx_mgr_, db_);
123138

124139
auto genesis_hash = conf_.genesis.genesisHash();
125140
auto genesis_hash_from_db = db_->getGenesisHash();
@@ -143,9 +158,9 @@ void App::init(const cli::Config &cli_conf) {
143158
pillar_chain_mgr_);
144159
dag_block_proposer_ = std::make_shared<DagBlockProposer>(conf_, dag_mgr_, trx_mgr_, final_chain_, db_, key_manager_);
145160

146-
network_ =
147-
std::make_shared<Network>(conf_, genesis_hash, conf_.net_file_path().string(), *kp_, db_, pbft_mgr_, pbft_chain_,
148-
vote_mgr_, dag_mgr_, trx_mgr_, std::move(slashing_manager), pillar_chain_mgr_);
161+
network_ = std::make_shared<Network>(conf_, genesis_hash, conf_.net_file_path().string(), db_, pbft_mgr_, pbft_chain_,
162+
vote_mgr_, dag_mgr_, trx_mgr_, std::move(slashing_manager), pillar_chain_mgr_,
163+
final_chain_);
149164
auto cli_options = cli_conf.getCliOptions();
150165
for (auto &plugin : active_plugins_) {
151166
plugin.second->init(cli_options);
@@ -192,22 +207,23 @@ void App::start() {
192207
LOG(log_si_) << "DB migrated successfully, please restart the node without the flag";
193208
started_ = false;
194209
return;
195-
} else {
196-
network_->start();
197-
dag_block_proposer_->setNetwork(network_);
198-
dag_block_proposer_->start();
199210
}
200211

212+
for (auto &plugin : active_plugins_) {
213+
LOG(log_nf_) << "Starting plugin " << plugin.first;
214+
plugin.second->start();
215+
}
216+
217+
network_->start();
218+
dag_block_proposer_->setNetwork(network_);
219+
dag_block_proposer_->start();
220+
201221
pbft_mgr_->start();
202222

203223
if (metrics_) {
204224
setupMetricsUpdaters();
205225
metrics_->start();
206226
}
207-
for (auto &plugin : active_plugins_) {
208-
LOG(log_nf_) << "Starting plugin " << plugin.first;
209-
plugin.second->start();
210-
}
211227
started_ = true;
212228
LOG(log_nf_) << "Node started ... ";
213229
}
@@ -218,7 +234,6 @@ void App::scheduleLoggingConfigUpdate() {
218234
return;
219235
}
220236

221-
static auto node_address = dev::KeyPair(conf_.node_secret).address();
222237
config_update_executor_.post([&]() {
223238
while (started_ && !stopped_) {
224239
auto path = std::filesystem::path(conf_.json_file_name);
@@ -234,7 +249,7 @@ void App::scheduleLoggingConfigUpdate() {
234249
try {
235250
auto config = getJsonFromFileOrString(conf_.json_file_name);
236251
conf_.log_configs = conf_.loadLoggingConfigs(config["logging"]);
237-
conf_.InitLogging(node_address);
252+
conf_.InitLogging(conf_.getFirstWallet().node_addr);
238253
} catch (const ConfigException &e) {
239254
std::cerr << "FullNodeConfig: Failed to update logging config: " << e.what() << std::endl;
240255
continue;

libraries/cli/include/cli/config.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ static constexpr const char* HELP = "help";
2525
static constexpr const char* VERSION = "version";
2626
static constexpr const char* PLUGINS = "plugins";
2727
static constexpr const char* WALLET = "wallet";
28-
static constexpr const char* PRUNE_STATE_DB = "prune-state-db";
2928

3029
static constexpr const char* NODE_COMMAND = "node";
3130
static constexpr const char* ACCOUNT_COMMAND = "account";
@@ -79,9 +78,10 @@ class Config {
7978

8079
bool overwrite_config;
8180
std::string data_dir;
81+
8282
std::string genesis;
8383
std::string config;
84-
std::string wallet;
84+
std::vector<std::string> wallets;
8585
};
8686

8787
} // namespace taraxa::cli

0 commit comments

Comments
 (0)