Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
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
Remove inherents (moved to client code)
  • Loading branch information
davxy committed Aug 14, 2023
commit a6dfd28cbbced20ec507fd20f71ccd52ab76ff87
6 changes: 0 additions & 6 deletions primitives/consensus/sassafras/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,28 @@ publish = false
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = { version = "0.1.50", optional = true }
scale-codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.163", default-features = false, features = ["derive"], optional = true }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" }
sp-application-crypto = { version = "23.0.0", default-features = false, path = "../../application-crypto", features = ["bandersnatch-experimental"] }
sp-consensus-slots = { version = "0.10.0-dev", default-features = false, path = "../slots" }
sp-core = { version = "21.0.0", default-features = false, path = "../../core", features = ["bandersnatch-experimental"] }
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../inherents" }
sp-runtime = { version = "24.0.0", default-features = false, path = "../../runtime" }
sp-std = { version = "8.0.0", default-features = false, path = "../../std" }
sp-timestamp = { version = "4.0.0-dev", optional = true, path = "../../timestamp" }

[features]
default = ["std"]
std = [
"async-trait",
"scale-codec/std",
"scale-info/std",
"serde/std",
"sp-api/std",
"sp-application-crypto/std",
"sp-consensus-slots/std",
"sp-core/std",
"sp-inherents/std",
"sp-runtime/std",
"sp-std/std",
"sp-timestamp",
]

# Serde support without relying on std features.
Expand Down
2 changes: 1 addition & 1 deletion primitives/consensus/sassafras/src/digests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct NextEpochDescriptor {
pub authorities: Vec<AuthorityId>,
/// Epoch randomness.
pub randomness: Randomness,
/// Configurable parameters. If not present previous epoch parameters are used.
/// Mutable epoch parameters. If not present previous epoch parameters are used.
pub config: Option<EpochConfiguration>,
}

Expand Down
93 changes: 0 additions & 93 deletions primitives/consensus/sassafras/src/inherents.rs

This file was deleted.

1 change: 0 additions & 1 deletion primitives/consensus/sassafras/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub use sp_core::bandersnatch::{
use serde::{Deserialize, Serialize};

pub mod digests;
pub mod inherents;
pub mod ticket;

pub use ticket::{
Expand Down
20 changes: 8 additions & 12 deletions primitives/consensus/sassafras/src/ticket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,14 @@ pub fn ticket_id(vrf_input: &VrfInput, vrf_output: &VrfOutput) -> TicketId {
u128::from_le_bytes(bytes)
}

/// Computes the ticket-id maximum allowed value for a given epoch.
///
/// Only ticket identifiers below this threshold should be considered for
/// slot assignment.
///
/// The value is computed as `T = TicketId::MAX·(r·s)/(a·v)`, where:
/// - `r` = redundancy factor;
/// - `s` = number of slots in epoch;
/// - `a` = maximum number of tickets attempts per validator;
/// - `v` = number of validator in epoch.
///
/// If `a·v = 0` then we fallback to `T = 0`.
/// Computes the threshold for a given epoch as T = (x*s)/(a*v), where:
/// - x: redundancy factor;
/// - s: number of slots in epoch;
/// - a: max number of attempts;
/// - v: number of validator in epoch.
/// The parameters should be chosen such that T <= 1.
/// If `attempts * validators` is zero then we fallback to T = 0
// TODO-SASS-P3: this formula must be double-checked...
pub fn ticket_id_threshold(
redundancy: u32,
slots: u32,
Expand Down