Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/dharjeezy/bounds-on-enqueued-vot…
…es' into dharjeezy/bounds-on-enqueued-votes

# Conflicts:
#	client/beefy/src/lib.rs
#	client/beefy/src/worker.rs
  • Loading branch information
dharjeezy committed Nov 22, 2022
commit cc7183b8066e2a9c54b4a1394033c2108c5e04eb
32 changes: 1 addition & 31 deletions client/beefy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(map_try_insert)]
// This file is part of Substrate.

// Copyright (C) 2021-2022 Parity Technologies (UK) Ltd.
Expand All @@ -17,35 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use beefy_primitives::{BeefyApi, MmrRootHash, PayloadProvider};
use parking_lot::Mutex;
use prometheus::Registry;
use sc_client_api::{Backend, BlockBackend, BlockchainEvents, Finalizer};
use sc_consensus::BlockImport;
use sc_network::ProtocolName;
use sc_network_common::service::NetworkRequest;
use sc_network_gossip::Network as GossipNetwork;
use sp_api::{BlockT, HeaderT, NumberFor, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_consensus::{Error as ConsensusError, SyncOracle};
use sp_keystore::SyncCryptoStorePtr;
use sp_mmr_primitives::MmrApi;
use sp_runtime::traits::Block;
use std::{marker::PhantomData, sync::Arc};

mod error;
mod keystore;
mod metrics;
mod round;
mod worker;

pub mod communication;
pub mod import;
pub mod justification;

#[cfg(test)]
mod tests;

use crate::{
communication::{
notification::{
Expand Down Expand Up @@ -74,7 +44,7 @@ use sc_consensus::BlockImport;
use sc_network::ProtocolName;
use sc_network_common::service::NetworkRequest;
use sc_network_gossip::{GossipEngine, Network as GossipNetwork};
use sp_api::{HeaderT, NumberFor, ProvideRuntimeApi};
use sp_api::{BlockT, HeaderT, NumberFor, ProvideRuntimeApi};
use sp_blockchain::{
Backend as BlockchainBackend, Error as ClientError, HeaderBackend, Result as ClientResult,
};
Expand Down
21 changes: 13 additions & 8 deletions client/beefy/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::{
collections::{BTreeMap, BTreeSet, VecDeque, BufferedVec},
collections::{BTreeMap, BTreeSet, VecDeque},
fmt::Debug,
marker::PhantomData,
sync::Arc,
Expand All @@ -35,14 +35,16 @@ use sc_network_common::{
};
use sc_network_gossip::GossipEngine;

use sp_arithmetic::traits::{AtLeast32Bit, Saturating};
use sp_api::{BlockId, BlockT, HeaderT, ProvideRuntimeApi};
use sp_arithmetic::traits::AtLeast32Bit;
use sp_blockchain::Backend as BlockchainBackend;
use sp_consensus::SyncOracle;
use sp_mmr_primitives::MmrApi;
use sp_runtime::{
generic::OpaqueDigestItemId,
traits::{Block, NumberFor},
traits::{Block, Header, NumberFor, Zero},
SaturatedConversion,
traits::{Block, NumberFor, CheckedConversion, ConstU32},
BoundedBTreeMap, SaturatedConversion,
};

Expand All @@ -51,7 +53,7 @@ use beefy_primitives::{
BeefyApi, Commitment, ConsensusLog, MmrRootHash, Payload, PayloadProvider, SignedCommitment,
ValidatorSet, VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID,
};
use sp_runtime::traits::{CheckedConversion, ConstU32};
use sc_utils::notification::NotificationReceiver;

use crate::{
communication::{
Expand Down Expand Up @@ -338,6 +340,8 @@ pub(crate) struct BeefyWorker<B: Block, BE, P, R, N> {
BeefyVersionedFinalityProof<B>,
ConstU32<MAX_BUFFERED_JUSTIFICATIONS>,
>,
/// Persisted voter state.
persisted_state: PersistedState<B>,
/// Chooses which incoming votes to accept and which votes to generate.
voting_oracle: VoterOracle<B>,
}
Expand Down Expand Up @@ -385,11 +389,9 @@ where
on_demand_justifications,
links,
metrics,
best_grandpa_block_header: last_finalized_header,
best_beefy_block: None,
pending_votes: BoundedBTreeMap::new(),
pending_justifications: BoundedBTreeMap::new(),
voting_oracle: VoterOracle::new(min_block_delta),
persisted_state,
}
}

Expand Down Expand Up @@ -1538,7 +1540,10 @@ pub(crate) mod tests {
let keys = &[Keyring::Alice, Keyring::Bob];
let validator_set = ValidatorSet::new(make_beefy_ids(keys), 0).unwrap();
let mut net = BeefyTestNet::new(1);
let mut worker = create_beefy_worker(&net.peer(0), &keys[0], 1);
let mut worker = create_beefy_worker(&net.peer(0), &keys[0], 1, validator_set.clone());
// remove default session, will manually add custom one.
worker.persisted_state.voting_oracle.sessions.clear();

fn new_vote(
block_number: NumberFor<Block>,
) -> VoteMessage<NumberFor<Block>, AuthorityId, Signature> {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.