-
Notifications
You must be signed in to change notification settings - Fork 105
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
Init agents and channels with migration #1063
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1063 +/- ##
==========================================
- Coverage 81.31% 80.60% -0.72%
==========================================
Files 54 55 +1
Lines 2243 2269 +26
Branches 71 71
==========================================
+ Hits 1824 1829 +5
- Misses 402 423 +21
Partials 17 17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
#[pallet::genesis_build] | ||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> { | ||
fn build(&self) { | ||
let bridge_hub_agent_id = | ||
agent_id_of::<T>(&MultiLocation::here()).expect("infallible; qed"); | ||
// Agent for BridgeHub | ||
Agents::<T>::insert(bridge_hub_agent_id, ()); | ||
|
||
// Primary governance channel | ||
Channels::<T>::insert( | ||
PRIMARY_GOVERNANCE_CHANNEL, | ||
Channel { agent_id: bridge_hub_agent_id, para_id: self.para_id }, | ||
); | ||
|
||
// Secondary governance channel | ||
Channels::<T>::insert( | ||
SECONDARY_GOVERNANCE_CHANNEL, | ||
Channel { agent_id: bridge_hub_agent_id, para_id: self.para_id }, | ||
); | ||
|
||
// Asset Hub | ||
let asset_hub_location: MultiLocation = | ||
ParentThen(X1(Parachain(self.asset_hub_para_id.into()))).into(); | ||
let asset_hub_agent_id = | ||
agent_id_of::<T>(&asset_hub_location).expect("infallible; qed"); | ||
let asset_hub_channel_id: ChannelId = self.asset_hub_para_id.into(); | ||
Agents::<T>::insert(asset_hub_agent_id, ()); | ||
Channels::<T>::insert( | ||
asset_hub_channel_id, | ||
Channel { agent_id: asset_hub_agent_id, para_id: self.asset_hub_para_id }, | ||
); | ||
Pallet::<T>::initialize(self.para_id, self.asset_hub_para_id).expect("infallible; qed"); |
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.
Since the initialize call was introduced, maybe we can just totally remove the GenesisConfig?
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.
Removed the initialize call.
parachain/pallets/system/src/lib.rs
Outdated
#[pallet::weight((T::WeightInfo::force_initialize(), DispatchClass::Operational))] | ||
pub fn force_initialize( | ||
origin: OriginFor<T>, | ||
own_para_id: ParaId, |
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.
own_para_id
seems unnecessary which can be retrieved from 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.
Disagree, actually, the runtime is configured with the para_id using the genesis config for the ParachainInfo 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.
As per offline discussions, lets deliver this is as migration script, and remove the governance extrinsic.
We also need to initialize the storage for the runtime tests, for example in
To ensure that channels have been created before sending tokens back to Ethereum |
Polkadot-sdk: Snowfork/polkadot-sdk#70
Adds a migration script that will initialize the agents and channels if not initialized by the genesis build.
Adds a new extrinsic which can be used to force initialization.
Tested the extrinsic manually and via unit tests. Tested the migration by doing a manual runtime upgrade and by using the
try-runtime
tool from Parity.