You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Authorized origins can manage subscriptions: only authorized origins can call those dispatchables that interact with the idn manager directly to create/update/delete a subscription (create_subscription, kill_subscription, etc)
Authorized origins can deliver pulses: the consumer only receives pulses sent by authorized origins 3. [ ] Filter known subs: the consumer only receives pulses from known subscriptions
This is analog to how the contract lib/example already solves these, respectively:
Authorized origins can manage subscriptions: ensure_authorized
Authorized origins can deliver pulses: ensure_authorized_deliverer 3. Filter known subs: ensure_active_sub
Proposed solution
Authorized origins can manage subscriptions: Management dispatchables (create_subscription, kill_subscription, etc) to implement a custom EnsureOrigin instead of a fixed ensure_signed. Something similar to the current IdnOriginFilter should be implemented
Where AuthorizedDeliverers is a storage type.
Then instead of
ensure_signed(origin)?;
Do
T::OriginFilter::ensure_origin(origin)?;
On the Consumer runtime the implementation of this should do
let authorized = ensure_signed(origin)?;AuthorizedDeliverers::<T>::insert(authorized);
Authorized origins can deliver pulses: when a consume dispatchable is called (consume_pulse, consume_quote, consume_sub_info) we need to verify that the account associated with the origin is in the authorized list, then we need to update the IdnOriginFilter to take the AuthorizedDeliverers into account:
On the consumer runtime, the implementation should first extract the account id from the xcm location and verify it is in the authorized list. This could be done by updating the AllowSiblingOnly to something like AllowAuthorizedOnly.
3. Filter known subs: When calling create_subscription, do_create_subscription returns a subscription id, this id should be passed to a new config type AfterCreateHook which implements a new trait with a function handle_after_create_sub(sub_id). Also we need a new KnownSubscriptions storage item. On the consumer runtime, the implementation of this type should store the id in the KnownSubscription.
Then we should update the PulseConsumerImpl to check that the pulse comes from known subscriptions.
The aim of this is to make sure that:
create_subscription,kill_subscription, etc)3. [ ] Filter known subs: the consumer only receives pulses from known subscriptionsThis is analog to how the contract lib/example already solves these, respectively:
ensure_authorizedensure_authorized_deliverer3. Filter known subs:ensure_active_subProposed solution
create_subscription,kill_subscription, etc) to implement a customEnsureOrigininstead of a fixedensure_signed. Something similar to the currentIdnOriginFiltershould be implementedWhere
AuthorizedDeliverersis a storage type.Then instead of
Do
On the Consumer runtime the implementation of this should do
consume_pulse,consume_quote,consume_sub_info) we need to verify that the account associated with the origin is in the authorized list, then we need to update theIdnOriginFilterto take theAuthorizedDeliverersinto account:On the consumer runtime, the implementation should first extract the account id from the xcm location and verify it is in the authorized list. This could be done by updating the
AllowSiblingOnlyto something likeAllowAuthorizedOnly.3. Filter known subs: When callingcreate_subscription,do_create_subscriptionreturns a subscription id, this id should be passed to a new config typeAfterCreateHookwhich implements a new trait with a functionhandle_after_create_sub(sub_id). Also we need a newKnownSubscriptionsstorage item.On the consumer runtime, the implementation of this type should store the id in theKnownSubscription.Then we should update the
PulseConsumerImplto check that the pulse comes from known subscriptions.Important suggested solutions are a mix of code and pseudocode, and might have errors. They should be verified by the implementor