Skip to content
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
5 changes: 5 additions & 0 deletions .github/zombienet-tests/zombienet_polkadot_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,8 @@
test-filter: "functional::shared_core_idle_parachain::shared_core_idle_parachain_test"
runner-type: "default"
use-zombienet-sdk: true

- job-name: "zombienet-polkadot-collators-basic-reputation-persistence"
test-filter: "functional::collators_reputation_persistence"
runner-type: "default"
use-zombienet-sdk: true
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ fn build_polkadot_full_node(
invulnerable_ah_collators: HashSet::new(),
collator_protocol_hold_off: None,
experimental_collator_protocol: false,
collator_reputation_persist_interval: None,
};

let (relay_chain_full_node, paranode_req_receiver) = match config.network.network_backend {
Expand Down
7 changes: 7 additions & 0 deletions polkadot/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ pub struct RunCmd {
/// Enable experimental collator protocol. TESTING ONLY! Don't use on production
#[arg(long, hide = true, default_value = "false")]
pub experimental_collator_protocol: bool,

/// Collator reputation persistence interval in seconds.
/// If not specified, defaults to 600 seconds (10 minutes).
/// This should be used only with experimental_collator_protocol
/// and only on validators.
#[arg(long, requires = "experimental_collator_protocol", requires = "validator")]
pub collator_reputation_persist_interval: Option<u64>,
}

#[allow(missing_docs)]
Expand Down
4 changes: 4 additions & 0 deletions polkadot/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ where
invulnerable_ah_collators,
collator_protocol_hold_off,
experimental_collator_protocol,
collator_reputation_persist_interval: cli
.run
.collator_reputation_persist_interval
.map(std::time::Duration::from_secs),
},
)
.map(|full| full.task_manager)?;
Expand Down
3 changes: 3 additions & 0 deletions polkadot/node/network/collator-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ sp-core = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }

codec.workspace = true
fatality = { workspace = true }
polkadot-node-network-protocol = { workspace = true, default-features = true }
polkadot-node-primitives = { workspace = true, default-features = true }
polkadot-node-subsystem = { workspace = true, default-features = true }
polkadot-node-subsystem-util = { workspace = true, default-features = true }
polkadot-primitives = { workspace = true, default-features = true }
thiserror = { workspace = true }
tokio.workspace = true
tokio-util = { workspace = true }

[dev-dependencies]
assert_matches = { workspace = true }
kvdb-memorydb = { workspace = true }
rstest = { workspace = true }
sc-network-types = { workspace = true, default-features = true }
sp-tracing = { workspace = true }
Expand Down
15 changes: 10 additions & 5 deletions polkadot/node/network/collator-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use std::{
collections::HashSet,
sync::Arc,
time::{Duration, Instant},
};

Expand All @@ -31,16 +32,16 @@ use futures::{
FutureExt, TryFutureExt,
};

use polkadot_node_subsystem_util::reputation::ReputationAggregator;
use polkadot_node_subsystem_util::{database::Database, reputation::ReputationAggregator};
use sp_keystore::KeystorePtr;

use polkadot_node_network_protocol::{
request_response::{v2 as protocol_v2, IncomingRequestReceiver},
PeerId, UnifiedReputationChange as Rep,
};
use polkadot_primitives::CollatorPair;

use polkadot_node_subsystem::{errors::SubsystemError, overseer, DummySubsystem, SpawnedSubsystem};
use polkadot_primitives::CollatorPair;
pub use validator_side_experimental::ReputationConfig;

mod collator_side;
mod validator_side;
Expand Down Expand Up @@ -91,6 +92,10 @@ pub enum ProtocolSide {
keystore: KeystorePtr,
/// Prometheus metrics for validators.
metrics: validator_side_experimental::Metrics,
/// Database used for reputation house keeping.
db: Arc<dyn Database>,
/// Reputation configuration (column number).
reputation_config: validator_side_experimental::ReputationConfig,
},
/// Collators operate on a parachain.
Collator {
Expand Down Expand Up @@ -148,8 +153,8 @@ impl<Context> CollatorProtocolSubsystem {
.map_err(|e| SubsystemError::with_origin("collator-protocol", e))
.boxed()
},
ProtocolSide::ValidatorExperimental { keystore, metrics } => {
validator_side_experimental::run(ctx, keystore, metrics)
ProtocolSide::ValidatorExperimental { keystore, metrics, db, reputation_config } => {
validator_side_experimental::run(ctx, keystore, metrics, db, reputation_config)
.map_err(|e| SubsystemError::with_origin("collator-protocol", e))
.boxed()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use codec::{Decode, Encode};
use polkadot_node_network_protocol::{
peer_set::CollationVersion,
request_response::{outgoing::RequestError, v2 as request_v2},
Expand Down Expand Up @@ -84,7 +85,7 @@ pub const MAX_FETCH_DELAY: Duration = Duration::from_millis(300);
pub const MIN_FETCH_TIMER_DELAY: Duration = Duration::from_millis(150);

/// Reputation score type.
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy, Default)]
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy, Default, Encode, Decode)]
pub struct Score(u16);

impl Score {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use crate::LOG_TARGET;
use crate::{validator_side_experimental::peer_manager::PersistenceError, LOG_TARGET};
use fatality::Nested;
use polkadot_node_subsystem::{ChainApiError, SubsystemError};
use polkadot_node_subsystem_util::{backing_implicit_view, runtime};
Expand Down Expand Up @@ -44,6 +44,12 @@ pub enum Error {
#[fatal]
#[error("Receiving message from overseer failed: {0}")]
SubsystemReceive(#[source] SubsystemError),
#[fatal]
#[error("Failed to initialize reputation database: {0}")]
ReputationDbInit(PersistenceError),
#[fatal]
#[error("Failed to spawn background task: {0}")]
SpawnTask(String),
#[error("Unable to retrieve block number for {0:?} from implicit view")]
BlockNumberNotFoundInImplicitView(Hash),
#[fatal(forward)]
Expand Down
Loading
Loading