Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Sassafras Prototype 2.2 #12314

Merged
merged 27 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e4364e3
First experiments with Sassafras equivocations report
davxy Sep 12, 2022
b267418
Preparation for sassafras client tests
davxy Sep 20, 2022
1292e86
Cleanup and first working client test with multiple peers
davxy Sep 23, 2022
d0c8bc2
Merge branch 'davxy-sassafras-protocol' into davxy/sassafras-protocol…
davxy Sep 24, 2022
0a20351
Dummy commit
davxy Sep 24, 2022
326ac44
Conflicts resolution
davxy Sep 24, 2022
5b43f28
Test code refactory
davxy Sep 27, 2022
2dd6086
Better submit-tickets extrinsic tag
davxy Sep 27, 2022
829b90b
Refactory of client tests
davxy Oct 6, 2022
a2d66b6
Aux data revert implementation
davxy Oct 6, 2022
ca4b563
Handle skipped epochs on block-import
davxy Oct 7, 2022
e7be289
Skipped epoch test and fix
davxy Oct 11, 2022
7690a5c
Fix to epoch start slot computation
davxy Oct 14, 2022
6c20538
Minor tweaks
davxy Oct 17, 2022
2361064
Trivial comments refactory
davxy Oct 24, 2022
a26a31e
Do not alter original epoch changes node on epoch skip
davxy Oct 24, 2022
f3ebc2b
Insert tickets aux data after block import
davxy Oct 24, 2022
84bfdff
Tests environment refactory
davxy Oct 24, 2022
cfe639e
Use in-memory keystore for tests
davxy Oct 24, 2022
51e81a2
Push lock file
davxy Oct 24, 2022
04e92f6
Use test accounts keyring
davxy Oct 24, 2022
193134a
Test for secondary slots claims
davxy Oct 24, 2022
8bd8aed
Improved tests after epoch changes tree fix
davxy Oct 25, 2022
76c24bd
Tests for blocks verification
davxy Oct 29, 2022
950020b
Next epoch tickets incremental sort
davxy Oct 29, 2022
94e9ee8
Incremental sortition test
davxy Oct 29, 2022
d1a7edd
Set proper tickets tx longevity
davxy Oct 29, 2022
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: 8 additions & 0 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions bin/node-sassafras/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use sc_service::PartialComponents;

impl SubstrateCli for Cli {
fn impl_name() -> String {
"Substrate Node".into()
"Sassafras Node".into()
}

fn impl_version() -> String {
Expand All @@ -30,7 +30,7 @@ impl SubstrateCli for Cli {
}

fn copyright_start_year() -> i32 {
2017
2022
}

fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Expand Down Expand Up @@ -96,7 +96,8 @@ pub fn run() -> sc_cli::Result<()> {
runner.async_run(|config| {
let PartialComponents { client, task_manager, backend, .. } =
service::new_partial(&config)?;
let aux_revert = Box::new(|client, _, blocks| {
let aux_revert = Box::new(|client, backend, blocks| {
sc_consensus_sassafras::revert(backend, blocks)?;
sc_finality_grandpa::revert(client, blocks)?;
Ok(())
});
Expand Down
3 changes: 1 addition & 2 deletions bin/node-sassafras/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>

let slot_duration = sassafras_link.genesis_config().slot_duration();

let sassafras_params = sc_consensus_sassafras::SassafrasParams {
let sassafras_params = sc_consensus_sassafras::SassafrasWorkerParams {
client: client.clone(),
keystore: keystore_container.sync_keystore(),
select_chain,
Expand Down Expand Up @@ -303,7 +303,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };

let grandpa_config = sc_finality_grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
name: Some(name),
Expand Down
15 changes: 15 additions & 0 deletions bin/node-sassafras/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,21 @@ impl_runtime_apis! {
fn slot_ticket(slot: sp_consensus_sassafras::Slot) -> Option<sp_consensus_sassafras::Ticket> {
Sassafras::slot_ticket(slot)
}

fn generate_key_ownership_proof(
_slot: sp_consensus_sassafras::Slot,
_authority_id: sp_consensus_sassafras::AuthorityId,
) -> Option<sp_consensus_sassafras::OpaqueKeyOwnershipProof> {
None
}

fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: sp_consensus_sassafras::EquivocationProof<<Block as BlockT>::Header>,
_key_owner_proof: sp_consensus_sassafras::OpaqueKeyOwnershipProof,
) -> bool {
//let key_owner_proof = key_owner_proof.decode()?;
Sassafras::submit_unsigned_equivocation_report(equivocation_proof)
}
}

impl sp_session::SessionKeys<Block> for Runtime {
Expand Down
15 changes: 7 additions & 8 deletions client/consensus/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use sp_consensus_babe::{
inherents::InherentDataProvider, make_transcript, make_transcript_data, AllowedSlots,
AuthorityPair, Slot,
};
use sp_consensus_slots::SlotDuration;
use sp_core::crypto::Pair;
use sp_keystore::{vrf::make_transcript as transcript_from_data, SyncCryptoStore};
use sp_runtime::{
Expand Down Expand Up @@ -68,8 +67,6 @@ type Mutator = Arc<dyn Fn(&mut TestHeader, Stage) + Send + Sync>;
type BabeBlockImport =
PanickingBlockImport<crate::BabeBlockImport<TestBlock, TestClient, Arc<TestClient>>>;

const SLOT_DURATION_MS: u64 = 1000;

#[derive(Clone)]
struct DummyFactory {
client: Arc<TestClient>,
Expand Down Expand Up @@ -318,14 +315,15 @@ impl TestNetFactory for BabeTestNet {

let (_, longest_chain) = TestClientBuilder::new().build_with_longest_chain();

let slot_duration = data.link.config.slot_duration();
TestVerifier {
inner: BabeVerifier {
client: client.clone(),
select_chain: longest_chain,
create_inherent_data_providers: Box::new(|_, _| async {
create_inherent_data_providers: Box::new(move |_, _| async move {
let slot = InherentDataProvider::from_timestamp_and_slot_duration(
Timestamp::current(),
SlotDuration::from_millis(SLOT_DURATION_MS),
slot_duration,
);
Ok((slot,))
}),
Expand Down Expand Up @@ -425,17 +423,18 @@ fn run_one_test(mutator: impl Fn(&mut TestHeader, Stage) + Send + Sync + 'static
.for_each(|_| future::ready(())),
);

let slot_duration = data.link.config.slot_duration();
babe_futures.push(
start_babe(BabeParams {
block_import: data.block_import.lock().take().expect("import set up during init"),
select_chain,
client,
env: environ,
sync_oracle: DummyOracle,
create_inherent_data_providers: Box::new(|_, _| async {
create_inherent_data_providers: Box::new(move |_, _| async move {
let slot = InherentDataProvider::from_timestamp_and_slot_duration(
Timestamp::current(),
SlotDuration::from_millis(SLOT_DURATION_MS),
slot_duration,
);
Ok((slot,))
}),
Expand Down Expand Up @@ -1004,7 +1003,7 @@ fn obsolete_blocks_aux_data_cleanup() {
let data = peer.data.as_ref().expect("babe link set up during initialization");
let client = peer.client().as_client();

// Register the handler (as done by `babe_start`)
// Register the handler (as done by Babe's `block_import` method)
let client_clone = client.clone();
let on_finality = move |summary: &FinalityNotification<TestBlock>| {
aux_storage_cleanup(client_clone.as_ref(), summary)
Expand Down
10 changes: 5 additions & 5 deletions client/consensus/epochs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,6 @@ where
}
}

/// Return the inner fork tree.
pub fn tree(&self) -> &ForkTree<Hash, Number, PersistedEpochHeader<E>> {
&self.inner
}

/// Reset to a specified pair of epochs, as if they were announced at blocks `parent_hash` and
/// `hash`.
pub fn reset(&mut self, parent_hash: Hash, hash: Hash, number: Number, current: E, next: E) {
Expand Down Expand Up @@ -832,6 +827,11 @@ where
self.epochs.remove(&(h, n));
});
}

/// Return the inner fork tree (mostly useful for testing)
pub fn tree(&self) -> &ForkTree<Hash, Number, PersistedEpochHeader<E>> {
&self.inner
}
}

/// Type alias to produce the epoch-changes tree from a block type.
Expand Down
8 changes: 8 additions & 0 deletions client/consensus/sassafras/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ sp-core = { version = "6.0.0", path = "../../../primitives/core" }
sp-inherents = { version = "4.0.0-dev", path = "../../../primitives/inherents" }
sp-keystore = { version = "0.12.0", path = "../../../primitives/keystore" }
sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" }

[dev-dependencies]
sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
sc-keystore = { version = "4.0.0-dev", path = "../../keystore" }
sc-network-test = { version = "0.8.0", path = "../../network/test" }
sp-keyring = { version = "6.0.0", path = "../../../primitives/keyring" }
sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
Loading