Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the incoming comparison using set instead of vec #960

Merged
merged 2 commits into from
May 22, 2024
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
7 changes: 4 additions & 3 deletions pallets/thea/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use sp_runtime::{
transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction},
RuntimeAppPublic, SaturatedConversion,
};
use sp_std::collections::btree_set::BTreeSet;
use sp_std::prelude::*;
use thea_primitives::{
types::{Message, NetworkType, PayloadType},
Expand Down Expand Up @@ -102,7 +103,6 @@ pub mod pallet {
};
use frame_system::offchain::SendTransactionTypes;
use polkadex_primitives::Balance;
use sp_std::collections::btree_set::BTreeSet;
use thea_primitives::{
types::{IncomingMessage, Message, MisbehaviourReport, SignedMessage, THEA_HOLD_REASON},
TheaIncomingExecutor, TheaOutgoingExecutor,
Expand Down Expand Up @@ -770,7 +770,8 @@ impl<T: Config> Pallet<T> {
// that is, the incoming set is has different session keys from outgoing set.
// This last message should be signed by the outgoing set
// Similar to how Grandpa's session change works.
if incoming != queued {
let incoming_set = BTreeSet::from_iter(incoming.to_vec());
if incoming_set != BTreeSet::from_iter(queued.to_vec()) {
let uncompressed_keys: Vec<[u8; 20]> = vec![];
// TODO: Uncomment the following when parsing is fixed for ethereum keys.
// for public_key in queued.clone().into_iter() {
Expand Down Expand Up @@ -844,7 +845,7 @@ impl<T: Config> Pallet<T> {
}
<NextAuthorities<T>>::put(queued);
}
if incoming != outgoing {
if incoming_set != BTreeSet::from_iter(outgoing.to_vec()) {
// This will happen when new era starts, or end of the last epoch
<Authorities<T>>::insert(new_id, incoming);
<ValidatorSetId<T>>::put(new_id);
Expand Down
1 change: 1 addition & 0 deletions pallets/thea/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl<T: Config> Pallet<T> {
None => continue,
Some(msg) => msg,
};

let msg_hash = sp_io::hashing::sha2_256(message.encode().as_slice());
// Note: this is a double hash signing
let signature =
Expand Down
Loading