Skip to content

Commit

Permalink
Merge pull request #80 from SurfingNerd/sn/rust-upgrade
Browse files Browse the repository at this point in the history
Multithreading for hbbft message analysis and logging
  • Loading branch information
SurfingNerd authored Mar 24, 2022
2 parents 9197213 + 77e896b commit 6357ac3
Show file tree
Hide file tree
Showing 21 changed files with 215 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
platform:
- windows2019 # custom runner
toolchain:
- 1.52.1
- latest
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- ubuntu-16.04
- macos-latest
toolchain:
- 1.52.1
- latest
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- ubuntu-16.04
- macos-latest
toolchain:
- 1.52.1
- latest
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ on:
jobs:
check:
name: Check
runs-on: ubuntu-16.04
runs-on: ubuntu-20.04
steps:
- name: Checkout sources
uses: actions/checkout@main
with:
submodules: true
- name: Install 1.52.1 toolchain
- name: Install 1.59 toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.52.1
toolchain: 1.59
profile: minimal
override: true
- name: Run cargo check 1/3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docker-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.52.1
toolchain: latest
profile: minimal
override: true
- name: Deploy to docker hub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docker-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.52.1
toolchain: latest
profile: minimal
override: true
- name: Deploy to docker hub
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ name: rustfmt
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.52.1
toolchain: 1.59
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
Expand Down
52 changes: 16 additions & 36 deletions Cargo.lock

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

4 changes: 1 addition & 3 deletions bin/oe/cli/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ macro_rules! return_if_parse_error {
($e:expr) => {
match $e {
Err(
clap_error
@
ClapError {
clap_error @ ClapError {
kind: ClapErrorKind::ValueValidation,
..
},
Expand Down
2 changes: 0 additions & 2 deletions bin/oe/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,7 @@ impl ChainNotify for Informant<FullNodeInformantData> {
if new_blocks.has_more_blocks_to_import {
return;
}
info!(target: "import", "Informant: trying to get lock.");
let mut last_import = self.last_import.lock();
info!(target: "import", "Informant: got lock.");
let client = &self.target.client;

let importing = self.target.is_major_importing();
Expand Down
2 changes: 1 addition & 1 deletion crates/concensus/miner/src/local_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use ethereum_types::Address;
/// Local accounts checker
pub trait LocalAccounts: Send + Sync {
/// Returns true if given address should be considered local account.
fn is_local(&self, &Address) -> bool;
fn is_local(&self, address: &Address) -> bool;
}

impl LocalAccounts for HashSet<Address> {
Expand Down
12 changes: 6 additions & 6 deletions crates/ethcore/src/engines/hbbft/hbbft_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use engines::hbbft::{
contracts::validator_set::{
get_validator_available_since, send_tx_announce_availability, staking_by_mining_address,
},
hbbft_message_memorium::HbbftMessageMemorium,
hbbft_message_memorium::HbbftMessageDispatcher,
};
use std::{ops::Deref, sync::atomic::Ordering};

Expand All @@ -70,7 +70,7 @@ pub struct HoneyBadgerBFT {
signer: Arc<RwLock<Option<Box<dyn EngineSigner>>>>,
machine: EthereumMachine,
hbbft_state: RwLock<HbbftState>,
hbbft_message_memorial: RwLock<HbbftMessageMemorium>,
hbbft_message_dispatcher: RwLock<HbbftMessageDispatcher>,
sealing: RwLock<BTreeMap<BlockNumber, Sealing>>,
params: HbbftParams,
message_counter: RwLock<usize>,
Expand Down Expand Up @@ -210,7 +210,7 @@ impl HoneyBadgerBFT {
signer: Arc::new(RwLock::new(None)),
machine,
hbbft_state: RwLock::new(HbbftState::new()),
hbbft_message_memorial: RwLock::new(HbbftMessageMemorium::new()),
hbbft_message_dispatcher: RwLock::new(HbbftMessageDispatcher::new()),
sealing: RwLock::new(BTreeMap::new()),
params,
message_counter: RwLock::new(0),
Expand Down Expand Up @@ -332,7 +332,7 @@ impl HoneyBadgerBFT {
trace!(target: "consensus", "Received message of idx {} {:?} from {}", msg_idx, message, sender_id);

// store received messages here.
self.hbbft_message_memorial
self.hbbft_message_dispatcher
.write()
.on_message_received(&message);

Expand All @@ -357,7 +357,7 @@ impl HoneyBadgerBFT {
block_num: BlockNumber,
) -> Result<(), EngineError> {
// store received messages here.
self.hbbft_message_memorial
self.hbbft_message_dispatcher
.write()
.on_sealing_message_received(&message, block_num);

Expand Down Expand Up @@ -966,7 +966,7 @@ impl Engine<EthereumMachine> for HoneyBadgerBFT {
}
}

self.hbbft_message_memorial
self.hbbft_message_dispatcher
.write()
.free_memory(block.header.number());

Expand Down
Loading

0 comments on commit 6357ac3

Please sign in to comment.