This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
historical slashing w ocw w adhoc tree creation #6220
Merged
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b7d4a2a
draft
d2bb3b8
steps
7a4426c
chore: fmt
8eb7a4c
step by step
fe0682b
more details
c24b0a3
make test public
5aec81e
refactor: split into on and offchain
f1e9367
test stab
f29babe
tabs my friend
388970b
offchain overlay: split key into prefix and true key
1c41dfb
test: share state
3249272
fix & test
2600769
docs improv
5383907
address review comments
d6a78ca
cleanup test chore
3e5d00c
refactor, abbrev link text
dbbb282
chore: linewidth
2032b6a
fix prefix key split fallout
1bb092f
minor fallout
4abd969
minor changes
1fdc7c1
addresses review comments
1d271db
rename historical.rs -> historical/mod.rs
acb67fd
avoid shared::* wildcard import
359dec9
fix/compile: missing shared:: prefix
126f6ea
fix: add missing call to store_session_validator_set_to_offchain
7a7c0b2
fix/test: flow
87c1696
Merge remote-tracking branch 'origin/master' into bernhard/historical…
23cc9cf
fix/review: Apply suggestions from code review
drahnr 68ad304
fix/review: more review comment fixes
bf34c2c
fix/review: make ValidatorSet private
55f4271
fix/include: core -> sp_core
6c6c484
fix/review: fallout
7052484
fix/visbility: make them public API
6069f35
Merge remote-tracking branch 'origin/master' into bernhard/historical…
5231d06
fix/review: review changes fallout - again
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix & test
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,37 @@ | ||
|
|
||
| use codec::Encode; | ||
| use sp_runtime::traits::Convert; | ||
|
|
||
| use super::super::Trait as SessionTrait; | ||
| use super::super::{Module as SessionModule, SessionIndex}; | ||
| use super::Trait; | ||
| use super::Trait as HistoricalTrait; | ||
|
|
||
| use super::shared; | ||
|
|
||
| /// Store the validator set associated to the `session_index` to the off-chain database. | ||
| /// | ||
| /// **Must** be called from on-chain, i.e. `on_initialize(..)` or `on_finalization(..)`. | ||
drahnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub fn store_session_validator_set_to_offchain<T: Trait>(session_index: SessionIndex) { | ||
| let derived_key = shared::derive_key(shared::PREFIX, session_index); | ||
| pub fn store_session_validator_set_to_offchain<T: HistoricalTrait + SessionTrait>( | ||
| session_index: SessionIndex, | ||
| ) { | ||
| //let value = SessionModule::historical_root(session_index); | ||
drahnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let encoded_validator_list = <SessionModule<T>>::validators().encode(); | ||
| sp_io::offchain_index::set(derived_key.as_slice(), encoded_validator_list.as_slice()) | ||
| let encoded_validator_list = <SessionModule<T>>::validators() | ||
| .into_iter() | ||
| .filter_map(|validator_id: <T as SessionTrait>::ValidatorId| { | ||
| let full_identification = | ||
| <<T as HistoricalTrait>::FullIdentificationOf>::convert(validator_id.clone()); | ||
| full_identification.map(|full_identification| (validator_id, full_identification)) | ||
| }) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| encoded_validator_list.using_encoded(|encoded_validator_list| { | ||
| let derived_key = shared::derive_key(shared::PREFIX, session_index); | ||
| sp_io::offchain_index::set(derived_key.as_slice(), encoded_validator_list); | ||
| }); | ||
| } | ||
|
|
||
| /// Store the validator set associated to the _current_ session index to the off-chain database. | ||
| /// | ||
| /// **Must** be called from on-chain, i.e. `on_initialize(..)` or `on_finalization(..)`. | ||
| pub fn store_current_session_validator_set_to_offchain<T: Trait>() { | ||
| pub fn store_current_session_validator_set_to_offchain<T: HistoricalTrait + SessionTrait>() { | ||
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| store_session_validator_set_to_offchain::<T>(<SessionModule<T>>::current_index()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,7 @@ impl TestPersistentOffchainDB { | |
| /// Apply a set of off-chain changes directly to the test backend | ||
| pub fn apply_offchain_changes(&mut self, changes: &mut OffchainOverlayedChanges) { | ||
| let mut me = self.persistent.write(); | ||
| for ((prefix, key), value_operation) in changes.drain() { | ||
| for ((_prefix, key), value_operation) in changes.drain() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused about the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue here is that The whole point of this is to implement |
||
| match value_operation { | ||
| OffchainOverlayedChange::SetValue(val) => me.set(b"", key.as_slice(), val.as_slice()), | ||
| OffchainOverlayedChange::Remove => me.remove(b"", key.as_slice()), | ||
|
|
@@ -90,7 +90,7 @@ impl TestPersistentOffchainDB { | |
|
|
||
| impl OffchainStorage for TestPersistentOffchainDB { | ||
| fn set(&mut self, prefix: &[u8], key: &[u8], value: &[u8]) { | ||
| self.persistent.write().set(&b""[..], key, value); | ||
| self.persistent.write().set(prefix, key, value); | ||
| } | ||
|
|
||
| fn remove(&mut self, prefix: &[u8], key: &[u8]) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.