Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions Cargo.lock

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

9 changes: 6 additions & 3 deletions bin/node/executor/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,18 @@ fn block_weight_capacity_report() {
let mut xts = (0..num_transfers)
.map(|i| CheckedExtrinsic {
signed: Some((charlie(), signed_extra(nonce + i as Index, 0))),
function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 0)),
function: Call::Balances(pallet_balances::Call::transfer {
dest: bob().into(),
value: 0,
}),
})
.collect::<Vec<CheckedExtrinsic>>();

xts.insert(
0,
CheckedExtrinsic {
signed: None,
function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)),
function: Call::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }),
},
);

Expand Down Expand Up @@ -319,7 +322,7 @@ fn block_length_capacity_report() {
vec![
CheckedExtrinsic {
signed: None,
function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)),
function: Call::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }),
},
CheckedExtrinsic {
signed: Some((charlie(), signed_extra(nonce, 0))),
Expand Down
4 changes: 2 additions & 2 deletions client/consensus/babe/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
);

check_secondary_plain_header::<B>(pre_hash, secondary, sig, &epoch)?;
}
},
PreDigest::SecondaryVRF(secondary)
if epoch.config.allowed_slots.is_secondary_vrf_slots_allowed() =>
{
Expand All @@ -125,7 +125,7 @@ where
);

check_secondary_vrf_header::<B>(pre_hash, secondary, sig, &epoch)?;
}
},
_ => return Err(babe_err(Error::SecondarySlotAssignmentsDisabled)),
}

Expand Down
4 changes: 2 additions & 2 deletions client/network/src/protocol/notifications/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ impl Notifications {
timer: delay_id,
timer_deadline: *backoff,
};
}
},

// Disabled => Enabled
PeerState::Disabled { mut connections, backoff_until } => {
Expand Down Expand Up @@ -2085,7 +2085,7 @@ impl NetworkBehaviour for Notifications {
.boxed(),
);
}
}
},

// We intentionally never remove elements from `delays`, and it may
// thus contain obsolete entries. This is a normal situation.
Expand Down
2 changes: 1 addition & 1 deletion client/network/src/protocol/sync/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<B: BlockT> BlockCollection<B> {
{
*downloading -= 1;
false
}
},
Some(&mut BlockRangeState::Downloading { .. }) => true,
_ => false,
};
Expand Down
2 changes: 1 addition & 1 deletion client/network/src/service/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ fn fallback_name_working() {
{
assert_eq!(negotiated_fallback, Some(PROTOCOL_NAME));
break
}
},
_ => {},
};
}
Expand Down
4 changes: 2 additions & 2 deletions client/network/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ impl<B: BlockT + 'static, H: ExHashT> TransactionsHandler<B, H> {
},
);
debug_assert!(_was_in.is_none());
}
},
Event::NotificationStreamClosed { remote, protocol }
if protocol == self.protocol_name =>
{
let _peer = self.peers.remove(&remote);
debug_assert!(_peer.is_some());
}
},

Event::NotificationsReceived { remote, messages } => {
for (protocol, message) in messages {
Expand Down
2 changes: 1 addition & 1 deletion frame/election-provider-multi-phase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ pub mod pallet {
Self::on_initialize_open_unsigned(enabled, now);
T::WeightInfo::on_initialize_open_unsigned()
}
}
},
_ => T::WeightInfo::on_initialize_nothing(),
}
}
Expand Down
16 changes: 9 additions & 7 deletions frame/sudo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub mod pallet {
ensure!(sender == Self::key(), Error::<T>::RequireSudo);

let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into());
Self::deposit_event(Event::Sudid(res.map(|_| ()).map_err(|e| e.error)));
Self::deposit_event(Event::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) });
// Sudo user does not pay a fee.
Ok(Pays::No.into())
}
Expand All @@ -176,7 +176,7 @@ pub mod pallet {
ensure!(sender == Self::key(), Error::<T>::RequireSudo);

let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into());
Self::deposit_event(Event::Sudid(res.map(|_| ()).map_err(|e| e.error)));
Self::deposit_event(Event::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) });
// Sudo user does not pay a fee.
Ok(Pays::No.into())
}
Expand All @@ -201,7 +201,7 @@ pub mod pallet {
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
let new = T::Lookup::lookup(new)?;

Self::deposit_event(Event::KeyChanged(Self::key()));
Self::deposit_event(Event::KeyChanged { new_sudoer: Self::key() });
<Key<T>>::put(new);
// Sudo user does not pay a fee.
Ok(Pays::No.into())
Expand Down Expand Up @@ -241,7 +241,9 @@ pub mod pallet {

let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Signed(who).into());

Self::deposit_event(Event::SudoAsDone(res.map(|_| ()).map_err(|e| e.error)));
Self::deposit_event(Event::SudoAsDone {
sudo_result: res.map(|_| ()).map_err(|e| e.error),
});
// Sudo user does not pay a fee.
Ok(Pays::No.into())
}
Expand All @@ -251,11 +253,11 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A sudo just took place. \[result\]
Sudid(DispatchResult),
Sudid { sudo_result: DispatchResult },
/// The \[sudoer\] just switched identity; the old key is supplied.
KeyChanged(T::AccountId),
KeyChanged { new_sudoer: T::AccountId },
/// A sudo just took place. \[result\]
SudoAsDone(DispatchResult),
SudoAsDone { sudo_result: DispatchResult },
}

#[pallet::error]
Expand Down
8 changes: 4 additions & 4 deletions frame/sudo/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub mod logger {
// Ensure that the `origin` is `Root`.
ensure_root(origin)?;
<I32Log<T>>::append(i);
Self::deposit_event(Event::AppendI32(i, weight));
Self::deposit_event(Event::AppendI32 { value: i, weight });
Ok(().into())
}

Expand All @@ -72,16 +72,16 @@ pub mod logger {
let sender = ensure_signed(origin)?;
<I32Log<T>>::append(i);
<AccountLog<T>>::append(sender.clone());
Self::deposit_event(Event::AppendI32AndAccount(sender, i, weight));
Self::deposit_event(Event::AppendI32AndAccount { sender, value: i, weight });
Ok(().into())
}
}

#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
AppendI32(i32, Weight),
AppendI32AndAccount(T::AccountId, i32, Weight),
AppendI32 { value: i32, weight: Weight },
AppendI32AndAccount { sender: T::AccountId, value: i32, weight: Weight },
}

#[pallet::storage]
Expand Down
10 changes: 5 additions & 5 deletions frame/sudo/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn sudo_emits_events_correctly() {
// Should emit event to indicate success when called with the root `key` and `call` is `Ok`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 }));
assert_ok!(Sudo::sudo(Origin::signed(1), call));
System::assert_has_event(TestEvent::Sudo(Event::Sudid(Ok(()))));
System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) }));
})
}

Expand Down Expand Up @@ -96,7 +96,7 @@ fn sudo_unchecked_weight_emits_events_correctly() {
// Should emit event to indicate success when called with the root `key` and `call` is `Ok`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 }));
assert_ok!(Sudo::sudo_unchecked_weight(Origin::signed(1), call, 1_000));
System::assert_has_event(TestEvent::Sudo(Event::Sudid(Ok(()))));
System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) }));
})
}

Expand All @@ -123,10 +123,10 @@ fn set_key_emits_events_correctly() {

// A root `key` can change the root `key`.
assert_ok!(Sudo::set_key(Origin::signed(1), 2));
System::assert_has_event(TestEvent::Sudo(Event::KeyChanged(1)));
System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { new_sudoer: 1 }));
// Double check.
assert_ok!(Sudo::set_key(Origin::signed(2), 4));
System::assert_has_event(TestEvent::Sudo(Event::KeyChanged(2)));
System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { new_sudoer: 2 }));
});
}

Expand Down Expand Up @@ -161,6 +161,6 @@ fn sudo_as_emits_events_correctly() {
// A non-privileged function will work when passed to `sudo_as` with the root `key`.
let call = Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 }));
assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call));
System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone(Ok(()))));
System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone { sudo_result: Ok(()) }));
});
}
4 changes: 2 additions & 2 deletions frame/support/procedural/src/pallet/parse/pallet_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ impl PalletStructDef {
if generate_storage_info.is_none() =>
{
generate_storage_info = Some(span);
}
},
PalletStructAttr::StorageVersion { storage_version, .. }
if storage_version_found.is_none() =>
{
storage_version_found = Some(storage_version);
}
},
attr => {
let msg = "Unexpected duplicated attribute";
return Err(syn::Error::new(attr.span(), msg))
Expand Down
36 changes: 20 additions & 16 deletions frame/tips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new tip suggestion has been opened. \[tip_hash\]
NewTip(T::Hash),
/// A tip suggestion has reached threshold and is closing. \[tip_hash\]
TipClosing(T::Hash),
/// A tip suggestion has been closed. \[tip_hash, who, payout\]
TipClosed(T::Hash, T::AccountId, BalanceOf<T>),
/// A tip suggestion has been retracted. \[tip_hash\]
TipRetracted(T::Hash),
/// A tip suggestion has been slashed. \[tip_hash, finder, deposit\]
TipSlashed(T::Hash, T::AccountId, BalanceOf<T>),
/// A new tip suggestion has been opened.
NewTip { tip_hash: T::Hash },
/// A tip suggestion has reached threshold and is closing.
TipClosing { tip_hash: T::Hash },
/// A tip suggestion has been closed.
TipClosed { tip_hash: T::Hash, who: T::AccountId, payout: BalanceOf<T> },
/// A tip suggestion has been retracted.
TipRetracted { tip_hash: T::Hash },
/// A tip suggestion has been slashed.
TipSlashed { tip_hash: T::Hash, finder: T::AccountId, deposit: BalanceOf<T> },
}

/// Old name generated by `decl_event`.
Expand Down Expand Up @@ -265,7 +265,7 @@ pub mod pallet {
finders_fee: true,
};
Tips::<T>::insert(&hash, tip);
Self::deposit_event(Event::NewTip(hash));
Self::deposit_event(Event::NewTip { tip_hash: hash });
Ok(())
}

Expand Down Expand Up @@ -300,7 +300,7 @@ pub mod pallet {
let err_amount = T::Currency::unreserve(&who, tip.deposit);
debug_assert!(err_amount.is_zero());
}
Self::deposit_event(Event::TipRetracted(hash));
Self::deposit_event(Event::TipRetracted { tip_hash: hash });
Ok(())
}

Expand Down Expand Up @@ -340,7 +340,7 @@ pub mod pallet {
let hash = T::Hashing::hash_of(&(&reason_hash, &who));

Reasons::<T>::insert(&reason_hash, &reason);
Self::deposit_event(Event::NewTip(hash.clone()));
Self::deposit_event(Event::NewTip { tip_hash: hash.clone() });
let tips = vec![(tipper.clone(), tip_value)];
let tip = OpenTip {
reason: reason_hash,
Expand Down Expand Up @@ -390,7 +390,7 @@ pub mod pallet {

let mut tip = Tips::<T>::get(hash).ok_or(Error::<T>::UnknownTip)?;
if Self::insert_tip_and_check_closing(&mut tip, tipper, tip_value) {
Self::deposit_event(Event::TipClosing(hash.clone()));
Self::deposit_event(Event::TipClosing { tip_hash: hash.clone() });
}
Tips::<T>::insert(&hash, tip);
Ok(())
Expand Down Expand Up @@ -449,7 +449,11 @@ pub mod pallet {
T::OnSlash::on_unbalanced(imbalance);
}
Reasons::<T>::remove(&tip.reason);
Self::deposit_event(Event::TipSlashed(hash, tip.finder, tip.deposit));
Self::deposit_event(Event::TipSlashed {
tip_hash: hash,
finder: tip.finder,
deposit: tip.deposit,
});
Ok(())
}
}
Expand Down Expand Up @@ -544,7 +548,7 @@ impl<T: Config> Pallet<T> {
// same as above: best-effort only.
let res = T::Currency::transfer(&treasury, &tip.who, payout, KeepAlive);
debug_assert!(res.is_ok());
Self::deposit_event(Event::TipClosed(hash, tip.who, payout));
Self::deposit_event(Event::TipClosed { tip_hash: hash, who: tip.who, payout });
}

pub fn migrate_retract_tip_for_tip_new(module: &[u8], item: &[u8]) {
Expand Down
10 changes: 5 additions & 5 deletions frame/tips/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ fn close_tip_works() {

let h = tip_hash();

assert_eq!(last_event(), TipEvent::NewTip(h));
assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h });

assert_ok!(Tips::tip(Origin::signed(11), h.clone(), 10));

assert_noop!(Tips::close_tip(Origin::signed(0), h.into()), Error::<Test>::StillOpen);

assert_ok!(Tips::tip(Origin::signed(12), h.clone(), 10));

assert_eq!(last_event(), TipEvent::TipClosing(h));
assert_eq!(last_event(), TipEvent::TipClosing { tip_hash: h });

assert_noop!(Tips::close_tip(Origin::signed(0), h.into()), Error::<Test>::Premature);

Expand All @@ -284,7 +284,7 @@ fn close_tip_works() {
assert_ok!(Tips::close_tip(Origin::signed(0), h.into()));
assert_eq!(Balances::free_balance(3), 10);

assert_eq!(last_event(), TipEvent::TipClosed(h, 3, 10));
assert_eq!(last_event(), TipEvent::TipClosed { tip_hash: h, who: 3, payout: 10 });

assert_noop!(Tips::close_tip(Origin::signed(100), h.into()), Error::<Test>::UnknownTip);
});
Expand All @@ -306,14 +306,14 @@ fn slash_tip_works() {
assert_eq!(Balances::free_balance(0), 88);

let h = tip_hash();
assert_eq!(last_event(), TipEvent::NewTip(h));
assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h });

// can't remove from any origin
assert_noop!(Tips::slash_tip(Origin::signed(0), h.clone()), BadOrigin);

// can remove from root.
assert_ok!(Tips::slash_tip(Origin::root(), h.clone()));
assert_eq!(last_event(), TipEvent::TipSlashed(h, 0, 12));
assert_eq!(last_event(), TipEvent::TipSlashed { tip_hash: h, finder: 0, deposit: 12 });

// tipper slashed
assert_eq!(Balances::reserved_balance(0), 0);
Expand Down
3 changes: 2 additions & 1 deletion utils/frame/remote-externalities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jsonrpsee-ws-client = { version = "0.3.1", default-features = false, features =
jsonrpsee-proc-macros = "0.3.1"

env_logger = "0.9"
frame-support = { path = "../../../frame/support", optional = true }
log = "0.4.11"
codec = { package = "parity-scale-codec", version = "2.0.0" }
serde_json = "1.0"
Expand All @@ -34,4 +35,4 @@ tokio = { version = "1.10", features = ["macros", "rt-multi-thread"] }
pallet-elections-phragmen = { path = "../../../frame/elections-phragmen", version = "5.0.0-dev" }

[features]
remote-test = []
remote-test = ["frame-support"]