Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Better submit-tickets extrinsic tag
  • Loading branch information
davxy committed Sep 27, 2022
commit 2dd6086036874bb60ebc913d4d72c7041b7a635a
24 changes: 9 additions & 15 deletions frame/sassafras/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use sp_consensus_sassafras::{
AuthorityId, EquivocationProof, Randomness, SassafrasAuthorityWeight,
SassafrasEpochConfiguration, Slot, Ticket, SASSAFRAS_ENGINE_ID,
};
use sp_io::hashing;
use sp_runtime::{
generic::DigestItem,
traits::{One, Saturating},
Expand Down Expand Up @@ -408,7 +409,6 @@ pub mod pallet {
}

// Check tickets are below threshold

let next_auth = NextAuthorities::<T>::get();
let epoch_config = EpochConfig::<T>::get();
let threshold = sp_consensus_sassafras::compute_threshold(
Expand All @@ -417,27 +417,21 @@ pub mod pallet {
epoch_config.attempts_number,
next_auth.len() as u32,
);

// TODO-SASS-P2: if we move this in the `submit_tickets` call then we can
// can drop only the invalid tickets.
// In this way we don't penalize validators that submit tickets together
// with faulty validators.
if !tickets
.iter()
.all(|ticket| sp_consensus_sassafras::check_threshold(ticket, threshold))
{
return InvalidTransaction::Custom(0).into()
}

let tickets_tag = tickets.using_encoded(|bytes| hashing::blake2_256(bytes));
// TODO-SASS-P2: this should be set such that it is discarded after the first half
let tickets_longevity = 3_u64;

ValidTransaction::with_tag_prefix("Sassafras")
// We assign the maximum priority for any equivocation report.
.priority(TransactionPriority::max_value())
// TODO-SASS-P2: if possible use a more efficient way to distinquish
// duplicates...
.and_provides(tickets)
// TODO-SASS-P2: this should be set such that it is discarded after the
// first half
.longevity(3_u64)
.and_provides(tickets_tag)
.longevity(tickets_longevity)
.propagate(true)
.build()
} else {
Expand Down Expand Up @@ -572,7 +566,7 @@ impl<T: Config> Pallet<T> {
s.extend_from_slice(&next_epoch_index.to_le_bytes());
s.extend_from_slice(&accumulator);

let next_randomness = sp_io::hashing::blake2_256(&s);
let next_randomness = hashing::blake2_256(&s);
NextRandomness::<T>::put(&next_randomness);

next_randomness
Expand Down Expand Up @@ -601,7 +595,7 @@ impl<T: Config> Pallet<T> {
fn deposit_randomness(randomness: &Randomness) {
let mut s = RandomnessAccumulator::<T>::get().to_vec();
s.extend_from_slice(randomness);
let accumulator = sp_io::hashing::blake2_256(&s);
let accumulator = hashing::blake2_256(&s);
RandomnessAccumulator::<T>::put(accumulator);
}

Expand Down