-
Notifications
You must be signed in to change notification settings - Fork 86
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
IT: rewards to generic framework. Remove previous non-generic IT utilities #1805
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1805 +/- ##
==========================================
- Coverage 48.66% 48.65% -0.01%
==========================================
Files 167 167
Lines 13318 13318
==========================================
- Hits 6481 6480 -1
- Misses 6837 6838 +1 ☔ View full report in Codecov by Sentry. |
@gpmayorga, have you checked what we need to change to avoid showing a failure in the Maybe just return 0 after calling tarpaulin? |
crate::test_for_runtimes!(all, block_rewards_api); | ||
fn block_rewards_api<T: Runtime>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be really cool having this as a procedural macro:
#[test_for_runtimes(all)]
fn block_rewards_api() {
// ...
}
I think it should not be complicated, and we can leave this much more legible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be awesome!
pallet_collator_selection::Pallet::<T>::register_as_candidate( | ||
RawOrigin::Signed(collator.clone()).into(), | ||
) | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't call this in altair
and centrifuge
because I get a ValidatorNotRegistered
error.
@wischli, do you have any idea why this happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of pallet_collator_selection::Config
, Dev and Altair/Centrifuge differ in the ValidatorRegistration
trait implementor: Dev uses Sessions
whereas production uses the CollatorAllowlist
. Therefore, dev only requires session keys to be set for those addresses, which are registered. Production however requires the accounts to be whitelisted via the pallet_collator_allowlist
beforehand. This can done via the add
extrinsic of that pallet. This also requires the address to have their session key set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this answer @wischli, it helps me a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wischli, do you think we should align this for all runtimes? Why we are not using collator allowlist for dev?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally, it does not make sense to me to add an extra gate to collators for our dev runtime IMO. I suppose the only achievement for us would be that this test works for all runtimes?
I definitely dont want to block your proposal, just questioning the effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nono, it's not needed for the test; we can discriminate the behavior per runtime (at least it seems so by now). I asked because development
is our way of proving stuff that later will go to centrifuge
. So maybe it deserves that the demo also uses collator allowlist. Just a thought!
22c05e4
to
b3e0838
Compare
|
||
frame_system::Pallet::<T>::reset_events(); | ||
|
||
pallet_session::Pallet::<T>::rotate_session(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I've been playing with this and I've substituted pass_n(Period)
to rotate_session()
, which maps to the same behavior and allow us get rid of fast-runtime
feature in integration-test and simplify a bit the test.
If you have some thoughts against it @wischli , I can revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a perfect replacement and upgrade! Thanks a lot.
/* TODO: pending to fix. Why try_into() fails getting the reward_event::GroupRewarded? | ||
|
||
// The event exists in this list: | ||
dbg!(frame_system::Pallet::<T>::events()) | ||
|
||
// But not in in this list (that is the implementation of find_event()), | ||
// so try_into returns an Err for it. | ||
dbg!(frame_system::Pallet::<T>::events() | ||
.into_iter() | ||
.rev() | ||
.find_map(|record| record.event.try_into().ok()) | ||
.flatten()); | ||
|
||
// But later, if manually I create the event as follows: | ||
let e = T::RuntimeEventExt::from(pallet_rewards::Event::<T, BlockRewards>::GroupRewarded { | ||
group_id: 1, | ||
amount: 2, | ||
}); | ||
|
||
// And I call try_into(), it works. | ||
let re: pallet_rewards::Event<T, BlockRewards> = e.try_into().ok().unwrap(); | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
99% of developers can not fix this nor saying what's happening here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a solution at hand right now, would have to debug that myself. Can look into that next week, if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks William. My guess is that something weird is happening with the try_into
when events contain instances. But I've checked all the places where the instance is set, and we always set the correct one for that pallet. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for slimming this down and making it much more readable! I hope one of us is the 1% dev, which can solve the mystery. I can't dive into this for now, but next week I would have capacity.
@@ -43,6 +43,11 @@ use sp_runtime::{ | |||
}; | |||
use sp_std::marker::PhantomData; | |||
|
|||
pub mod instances { | |||
/// The rewards associated to block rewards | |||
pub type BlockRewards = pallet_rewards::Instance1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it, thanks!
pallet_collator_selection::Pallet::<T>::register_as_candidate( | ||
RawOrigin::Signed(collator.clone()).into(), | ||
) | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of pallet_collator_selection::Config
, Dev and Altair/Centrifuge differ in the ValidatorRegistration
trait implementor: Dev uses Sessions
whereas production uses the CollatorAllowlist
. Therefore, dev only requires session keys to be set for those addresses, which are registered. Production however requires the accounts to be whitelisted via the pallet_collator_allowlist
beforehand. This can done via the add
extrinsic of that pallet. This also requires the address to have their session key set.
/* TODO: pending to fix. Why try_into() fails getting the reward_event::GroupRewarded? | ||
|
||
// The event exists in this list: | ||
dbg!(frame_system::Pallet::<T>::events()) | ||
|
||
// But not in in this list (that is the implementation of find_event()), | ||
// so try_into returns an Err for it. | ||
dbg!(frame_system::Pallet::<T>::events() | ||
.into_iter() | ||
.rev() | ||
.find_map(|record| record.event.try_into().ok()) | ||
.flatten()); | ||
|
||
// But later, if manually I create the event as follows: | ||
let e = T::RuntimeEventExt::from(pallet_rewards::Event::<T, BlockRewards>::GroupRewarded { | ||
group_id: 1, | ||
amount: 2, | ||
}); | ||
|
||
// And I call try_into(), it works. | ||
let re: pallet_rewards::Event<T, BlockRewards> = e.try_into().ok().unwrap(); | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a solution at hand right now, would have to debug that myself. Can look into that next week, if desired.
/// | ||
/// Accounts: | ||
/// * Keyring::Admin | ||
/// * Keyring::Alice | ||
/// * Keyring::Bob | ||
/// * Keyring::Ferdie | ||
/// * Keyring::Charlie | ||
/// * Keyring::Dave | ||
/// * Keyring::Eve | ||
/// * Keyring::TrancheInvestor(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually liked the comment. Of course we dont need a line for every single tranche investor but do you think we could bring back something like Admin, ... Eve, TranchInvestor(1), ..., TrancheInvestor(50)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but I'm just curious, what add the comment that does not tell you the own implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. I often leverage rustdocs from hovering over. In this case, it is crystal clear so lets keep as is!
26db2ff
to
60c7b28
Compare
b3e0838
to
d478366
Compare
Ok, now it works for all runtimes. Thanks for the help @wischli. Could we consider this ready to be merged? and leave the 99% of developers can not fix this nor saying what's happening here issue as a tech-debt? |
WARNING: after merging this block rewards now will use |
Its definitely fine to reset on Dev. Do you want to open another PR for the cleanup and reset or do it in this one? The reset might require to execute the |
I would say to open a new PR. Too many things in this one.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blind approval after review of others.
Thanks both! |
I want to remove the |
I think it is because it attaches the staking currency to the group of the underlying |
Thanks William! I was wondering... if we want to avoid resetting the storage in the demo to not lose everything set. Could we instead modify the politic always to reset demo but have a script that later it populates with some sane state for Apps (by adding a bunch of transactions). Just thinking out loud. |
Let's discuss this at the offsite. If, Dev should be reset but Demo needs to be stable because of Axelar. I think repopulating state is quite intense as it requires multiple pools to be spawned etc. But given the current state of Demo, we might have to do a reset. It has never been planned to use that chain as our main testnet such that migrations have been ignored throughout numerous Subtrate and business logic updates. There are many many keys which cannot be decoded anymore.. |
Description
Fixes #1790
Changes and Descriptions
generic
version.Instance1
instead ofInstance2
in development runtime in order to align all runtimes. This can imply some reset on dev/demo.altair
andcentrifuge
runtimes.generic
tests withassert_events!
macro support #1804).fast-runtime
feature from IT (for now, it's not required).Blocks::JumpByNumber
to force the runtime to jump to a block in the future without passing by the previous blocks (can be used to speed up an integration-test)