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

merge spec generation and dependecy update #117

Merged
merged 6 commits into from
Jul 2, 2024
Merged
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
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/oe/logger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ lazy_static = "1.0"
regex = "1.0"
time = "0.1"
parking_lot = "0.11.1"
arrayvec = "0.4"
arrayvec = "0.7"
ansi_term = "0.10"
6 changes: 3 additions & 3 deletions bin/oe/logger/src/rotating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct RotatingLogger {
/// Defined logger levels
levels: String,
/// Logs array. Latest log is always at index 0
logs: RwLock<ArrayVec<[String; LOG_SIZE]>>,
logs: RwLock<ArrayVec<String, LOG_SIZE>>,
}

impl RotatingLogger {
Expand All @@ -59,7 +59,7 @@ impl RotatingLogger {
pub fn new(levels: String) -> Self {
RotatingLogger {
levels: levels,
logs: RwLock::new(ArrayVec::<[_; LOG_SIZE]>::new()),
logs: RwLock::new(ArrayVec::<_, LOG_SIZE>::new()),
}
}

Expand All @@ -78,7 +78,7 @@ impl RotatingLogger {
}

/// Return logs
pub fn logs(&self) -> RwLockReadGuard<ArrayVec<[String; LOG_SIZE]>> {
pub fn logs(&self) -> RwLockReadGuard<ArrayVec<String, LOG_SIZE>> {
self.logs.read()
}
}
Expand Down
83 changes: 45 additions & 38 deletions crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ fn to_toml_array(vec: Vec<&str>) -> Value {

fn to_toml(
i: usize,
open_ports: bool,
config_type: &ConfigType,
external_ip: Option<&str>,
signer_address: &Address,
Expand All @@ -116,6 +117,7 @@ fn to_toml(
base_ws_port: u16,
) -> Value {
let mut parity = Map::new();

match config_type {
ConfigType::PosdaoSetup => {
parity.insert("chain".into(), Value::String("./spec/spec.json".into()));
Expand Down Expand Up @@ -169,33 +171,37 @@ fn to_toml(
}

let mut rpc = Map::new();
rpc.insert("interface".into(), Value::String("all".into()));
rpc.insert("cors".into(), to_toml_array(vec!["all"]));
rpc.insert("hosts".into(), to_toml_array(vec!["all"]));
let apis = to_toml_array(vec![
"web3",
"eth",
"pubsub",
"net",
"parity",
"parity_set",
"parity_pubsub",
"personal",
"traces",
]);
rpc.insert("apis".into(), apis);
rpc.insert(
"port".into(),
Value::Integer((base_rpc_port as usize + i) as i64),
);

let mut websockets = Map::new();
websockets.insert("interface".into(), Value::String("all".into()));
websockets.insert("origins".into(), to_toml_array(vec!["all"]));
websockets.insert(
"port".into(),
Value::Integer((base_ws_port as usize + i) as i64),
);

if open_ports {
rpc.insert("interface".into(), Value::String("all".into()));
rpc.insert("cors".into(), to_toml_array(vec!["all"]));
rpc.insert("hosts".into(), to_toml_array(vec!["all"]));
let apis = to_toml_array(vec![
"web3",
"eth",
"pubsub",
"net",
"parity",
"parity_pubsub",
"traces",
]);
rpc.insert("apis".into(), apis);
rpc.insert(
"port".into(),
Value::Integer((base_rpc_port as usize + i) as i64),
);

websockets.insert("interface".into(), Value::String("all".into()));
websockets.insert("origins".into(), to_toml_array(vec!["all"]));
websockets.insert(
"port".into(),
Value::Integer((base_ws_port as usize + i) as i64),
);
} else {
rpc.insert("disable".into(), Value::Boolean(true));
websockets.insert("disable".into(), Value::Boolean(true));
}

let mut ipc = Map::new();
ipc.insert("disable".into(), Value::Boolean(true));
Expand Down Expand Up @@ -231,11 +237,10 @@ fn to_toml(
}

mining.insert("force_sealing".into(), Value::Boolean(true));
mining.insert("min_gas_price".into(), Value::Integer(1000000000));
mining.insert(
"gas_floor_target".into(),
Value::String("1000000000".into()),
);
// we put an extremly low min gas price in the config
// the min gas price is gathered from the DAO
// this makes sure that the min_gas_price wont be higher then the gas pricce the DAO decides.
mining.insert("min_gas_price".into(), Value::Integer(1000));
mining.insert("reseal_on_txs".into(), Value::String("none".into()));
mining.insert("reseal_min_period".into(), Value::Integer(0));

Expand All @@ -252,7 +257,7 @@ fn to_toml(
// Value::String("txqueue=trace,consensus=debug,engine=trace,own_tx=trace,miner=trace,tx_filter=trace".into())
misc.insert(
"logging".into(),
Value::String("txqueue=info,consensus=debug,engine=trace,tx_own=trace".into()),
Value::String("txqueue=info,consensus=debug,engine=debug,tx_own=trace".into()),
);
misc.insert("log_file".into(), Value::String("diamond-node.log".into()));

Expand Down Expand Up @@ -431,12 +436,12 @@ fn main() {
)
});

let fork_block_number: Option<i64> = matches.value_of("fork_block_number").map_or(None, |v| {
Some(
v.parse::<i64>()
.expect("fork_block_number need to be of integer type"),
)
});
// let fork_block_number: Option<i64> = matches.value_of("fork_block_number").map_or(None, |v| {
// Some(
// v.parse::<i64>()
// .expect("fork_block_number need to be of integer type"),
// )
// });

let metrics_port_base: Option<u16> = matches.value_of("metrics_port_base").map_or(None, |v| {
Some(
Expand Down Expand Up @@ -525,6 +530,7 @@ fn main() {
// the unwrap is safe, because there is a default value defined.
let toml_string = toml::to_string(&to_toml(
i,
false,
&config_type,
external_ip,
&enode.address,
Expand Down Expand Up @@ -565,6 +571,7 @@ fn main() {
// Write rpc node config
let rpc_string = toml::to_string(&to_toml(
0,
true,
&ConfigType::Rpc,
external_ip,
&Address::default(), // todo: insert HBBFT Contracts pot here.
Expand Down
1 change: 0 additions & 1 deletion crates/ethcore/src/engines/hbbft/hbbft_engine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::{
block_reward_hbbft::BlockRewardContract,
hbbft_early_epoch_end_manager::HbbftEarlyEpochEndManager,
hbbft_network_fork_manager::HbbftNetworkForkManager,
};
use crate::{
client::BlockChainClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
sync::Arc,
};

use ethereum_types::{Address, H512};
use ethereum_types::H512;
use ethjson::spec::hbbft::HbbftNetworkFork;
use hbbft::{
crypto::PublicKeySet,
sync_key_gen::{Ack, AckOutcome, Part, PartOutcome, SyncKeyGen},
util::max_faulty,
NetworkInfo,
Expand Down Expand Up @@ -299,14 +298,14 @@
#[cfg(test)]
mod tests {

use std::{fs, str::FromStr};

Check warning on line 301 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `fs`

Check warning on line 301 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused import: `fs`

Check warning on line 301 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused import: `fs`

use crate::engines::{hbbft::test::hbbft_test_client::HbbftTestClient, signer::from_keypair};

Check warning on line 303 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `hbbft::test::hbbft_test_client::HbbftTestClient`

Check warning on line 303 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused import: `hbbft::test::hbbft_test_client::HbbftTestClient`

Check warning on line 303 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused import: `hbbft::test::hbbft_test_client::HbbftTestClient`

use super::*;
use ethereum_types::Address;

Check warning on line 306 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `ethereum_types::Address`

Check warning on line 306 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused import: `ethereum_types::Address`

Check warning on line 306 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused import: `ethereum_types::Address`
use ethjson::spec::hbbft::HbbftNetworkFork;
use hbbft::sync_key_gen::{Ack, Part};

Check warning on line 308 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused imports: `Ack`, `Part`

Check warning on line 308 in crates/ethcore/src/engines/hbbft/hbbft_network_fork_manager.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.72)

unused imports: `Ack`, `Part`

use crypto::publickey::{KeyPair, Secret};
//use parity_crypto::publickey::{KeyPair, Secret};
Expand Down
Loading