-
Notifications
You must be signed in to change notification settings - Fork 692
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
Allow runtime-wide TryState
checks
#235
Comments
We don't really need to forward this into to: #frame_support::try_runtime_enabled! {
impl<#type_impl_gen>
#frame_support::traits::TryState<<T as #frame_system::Config>::BlockNumber>
for #pallet_ident<#type_use_gen> #where_clause
{
fn try_state(
n: <T as #frame_system::Config>::BlockNumber,
_s: #frame_support::traits::TryStateSelect
) -> Result<(), &'static str> {
#log_try_state
<
Self as #frame_support::traits::Hooks<
<T as #frame_system::Config>::BlockNumber
>
>::try_state(n)
}
}
} |
@bkchr I am not sure why you are against this. The main goal is to enable a try-state check that will look into multiple pallets. The only way to achieve this would be through doing it at the runtime (probably via |
I did not say that I'm against this. I just said that we don't need to move this to |
So we can already write and execute |
On further thought I don't this is sufficient. Most runtimes use the |
You mean we copy&paste the same try-state check into each runtime where we want to use it? |
Sensing some confusion while reading this. So, looking at the issue again afresh, we need to do exactly what we do with 'COnRuntimeUpgrade': Pass a new 'CTryState = ()' to executive, and run all checks on '(AllPallets, CTryState)' instead. Sounds right? |
Any update on this issue? I just stumbled across a similar need, and the only way around it that I found is feature-gating an additional type parameter on each pallet's |
@kianenigma @ggwpez I've been going over this issue and this code again, and I'm willing to put together a PR if we can agree on a design for the solution. As far as I can see, the same checks are repeated both in The easiest option would be to include a new generic that implements the |
So we could replace if checks.try_state() {
let _guard = frame_support::StorageNoopGuard::default();
<AllPalletsWithSystem as frame_support::traits::TryState<BlockNumberFor<System>>>::try_state(
frame_system::Pallet::<System>::block_number(),
frame_try_runtime::TryStateSelect::All,
)?;
} with if checks.try_state() {
let _guard = frame_support::StorageNoopGuard::default();
<(COnRuntimeUpgrade, AllPalletsWithSystem) as frame_support::traits::TryState<BlockNumberFor<System>>>::try_state(
frame_system::Pallet::<System>::block_number(),
frame_try_runtime::TryStateSelect::All,
)?;
} everywhere where relevant (this is taken from substrate v1.0, but it seems it still applies here and here as of today). |
This sounds reasonable to me, similar API as runtime upgrades. |
It would nevertheless be a breaking change since |
Yeah I wouldn't add it to the existing trait. Maybe a new one like |
have you tried this? |
@kianenigma that solution would work, for sure. I am wondering whether it's the best we can do here. If there's yet a new testing function, that would most likely mean a new generic to account for those? But if you guys think that's fine, I can go ahead and work up a little PR that adds the new feature. |
The nice thing about generics is that they can have defaults, so this is not a breaking change, as long as you add it to the end of the list. This is not pretty or elegant, but it is backwards compat, and near zero effort, I would do this. Longer term, I have shared some ideas around improving the development surface of executive with @gupnik or in other issues, but I am not sure if they are formalized or worth doing at this point. |
I agree with @kianenigma this approach is worth trying. It shouldn't be breaking, |
Yes, I agree this approach would not be breaking and relatively straightforward. I was just concerned it might not be the best, but I'm happy to hear there's discussion going on about improving DX on that side. I'll try to work a PR shortly, and would be great to get this backported to at least as back as 1.6. |
The matter is less trivial than I was expecting. The
Also, I was hoping for a solution where whatever type wants to implement I am wondering if declaring another trait that does not have the second argument, have a blanket impl of that trait for everything that implements the Cc @kianenigma since I see he was the one working on this feature last. Or alternatively require the new type to also implement |
Do we know what does it use |
@liamaharon yes, you can filter which pallets you want to run the tests for:
|
How about we add a new method Something like pub trait TryState<BlockNumber> {
/// Execute the state checks.
fn try_state(_: BlockNumber, _: Select) -> Result<(), TryRuntimeError>;
fn id() -> String
} When pallet implements it, it can use its name. This might be a bit tricky, let me know if u get stuck. |
This would be a breaking change, not sure if that's fine? I think we were trying to solve the issue in a way that does not introduce breaking changes. |
@liamaharon I am not sure that would be an ideal design. The trait already requires the implementor to perform some What's your opinion on that? |
Hm yes you are right. I missed that Your approach sounds good to try, let's see how it looks |
@liamaharon what approach are you referring to? Adding a new trait that has the |
Ok I have to pause work on this again right now, but I found that returning a String ID does not work either, as it would not be implementable by the |
Maybe it is not a breaking change if we provide an auto-implementation of
|
@kianenigma @liamaharon I opened a PR that fixes this: #4631. I did not find a way to make it work by adding an |
This PR updates litep2p to the latest release. - `KademliaEvent::PutRecordSucess` is renamed to fix word typo - `KademliaEvent::GetProvidersSuccess` and `KademliaEvent::IncomingProvider` are needed for bootnodes on DHT work and will be utilized later ### Added - kad: Providers part 8: unit, e2e, and `libp2p` conformance tests ([#258](paritytech/litep2p#258)) - kad: Providers part 7: better types and public API, public addresses & known providers ([#246](paritytech/litep2p#246)) - kad: Providers part 6: stop providing ([#245](paritytech/litep2p#245)) - kad: Providers part 5: `GET_PROVIDERS` query ([#236](paritytech/litep2p#236)) - kad: Providers part 4: refresh local providers ([#235](paritytech/litep2p#235)) - kad: Providers part 3: publish provider records (start providing) ([#234](paritytech/litep2p#234)) ### Changed - transport_service: Improve connection stability by downgrading connections on substream inactivity ([#260](paritytech/litep2p#260)) - transport: Abort canceled dial attempts for TCP, WebSocket and Quic ([#255](paritytech/litep2p#255)) - kad/executor: Add timeout for writting frames ([#277](paritytech/litep2p#277)) - kad: Avoid cloning the `KademliaMessage` and use reference for `RoutingTable::closest` ([#233](paritytech/litep2p#233)) - peer_state: Robust state machine transitions ([#251](paritytech/litep2p#251)) - address_store: Improve address tracking and add eviction algorithm ([#250](paritytech/litep2p#250)) - kad: Remove unused serde cfg ([#262](paritytech/litep2p#262)) - req-resp: Refactor to move functionality to dedicated methods ([#244](paritytech/litep2p#244)) - transport_service: Improve logs and move code from tokio::select macro ([#254](paritytech/litep2p#254)) ### Fixed - tcp/websocket/quic: Fix cancel memory leak ([#272](paritytech/litep2p#272)) - transport: Fix pending dials memory leak ([#271](paritytech/litep2p#271)) - ping: Fix memory leak of unremoved `pending_opens` ([#274](paritytech/litep2p#274)) - identify: Fix memory leak of unused `pending_opens` ([#273](paritytech/litep2p#273)) - kad: Fix not retrieving local records ([#221](paritytech/litep2p#221)) See release changelog for more details: https://github.com/paritytech/litep2p/releases/tag/v0.8.0 cc @paritytech/networking --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Dmitry Markin <[email protected]>
Currently the
TryState
can only be utilized on a per-pallet level by implementing thetry_state
hook.This limits the usage tor multi-pallet
try_state
functionality.Executive
could be extended to accept an optionalTryState
which will then be executed by the try-runtime CLI on a runtime-wide level.cc @kianenigma
The text was updated successfully, but these errors were encountered: