Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
483d8f6d
Unverified
Commit
483d8f6d
authored
May 13, 2021
by
Sergey Pepyakin
Committed by
GitHub
May 13, 2021
Browse files
Support opening HRMP channels in genesis (#3003)
parent
01882547
Pipeline
#137975
failed with stages
in 31 minutes and 33 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
node/service/src/chain_spec.rs
View file @
483d8f6d
...
...
@@ -880,6 +880,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
paras
:
vec!
[],
_phdata
:
Default
::
default
(),
},
parachains_hrmp
:
Default
::
default
(),
parachains_configuration
:
rococo_runtime
::
ParachainsConfigurationConfig
{
config
:
polkadot_runtime_parachains
::
configuration
::
HostConfiguration
{
validation_upgrade_frequency
:
1u32
,
...
...
@@ -1473,6 +1474,7 @@ pub fn rococo_testnet_genesis(
..
Default
::
default
()
},
},
parachains_hrmp
:
Default
::
default
(),
parachains_paras
:
rococo_runtime
::
ParasConfig
{
paras
:
vec!
[],
_phdata
:
Default
::
default
(),
...
...
runtime/parachains/src/hrmp.rs
View file @
483d8f6d
...
...
@@ -299,6 +299,51 @@ decl_storage! {
/// block number.
HrmpChannelDigests
:
map
hasher
(
twox_64_concat
)
ParaId
=>
Vec
<
(
T
::
BlockNumber
,
Vec
<
ParaId
>
)
>
;
}
add_extra_genesis
{
/// Preopen the given HRMP channels.
///
/// The values in the tuple corresponds to `(sender, recipient, max_capacity, max_message_size)`,
/// i.e. similar to `init_open_channel`. In fact, the initialization is performed as if
/// the `init_open_channel` and `accept_open_channel` were called with the respective parameters
/// and the session change take place.
///
/// As such, each channel initializer should satisfy the same constraints, namely:
///
/// 1. `max_capacity` and `max_message_size` should be within the limits set by the configuration module.
/// 2. `sender` and `recipient` must be valid paras.
config
(
preopen_hrmp_channels
):
Vec
<
(
ParaId
,
ParaId
,
u32
,
u32
)
>
;
build
(|
config
|
{
initialize_storage
::
<
T
>
(
&
config
.preopen_hrmp_channels
);
})
}
}
#[cfg(feature
=
"std"
)]
fn
initialize_storage
<
T
:
Config
>
(
preopen_hrmp_channels
:
&
[(
ParaId
,
ParaId
,
u32
,
u32
)])
{
let
host_config
=
configuration
::
Module
::
<
T
>
::
config
();
for
&
(
sender
,
recipient
,
max_capacity
,
max_message_size
)
in
preopen_hrmp_channels
{
if
let
Err
(
err
)
=
preopen_hrmp_channel
::
<
T
>
(
sender
,
recipient
,
max_capacity
,
max_message_size
)
{
panic!
(
"failed to initialize the genesis storage: {:?}"
,
err
);
}
}
<
Module
<
T
>>
::
process_hrmp_open_channel_requests
(
&
host_config
);
}
#[cfg(feature
=
"std"
)]
fn
preopen_hrmp_channel
<
T
:
Config
>
(
sender
:
ParaId
,
recipient
:
ParaId
,
max_capacity
:
u32
,
max_message_size
:
u32
)
->
DispatchResult
{
<
Module
<
T
>>
::
init_open_channel
(
sender
,
recipient
,
max_capacity
,
max_message_size
,
)
?
;
<
Module
<
T
>>
::
accept_open_channel
(
recipient
,
sender
)
?
;
Ok
(())
}
decl_error!
{
...
...
runtime/rococo/src/lib.rs
View file @
483d8f6d
...
...
@@ -218,7 +218,7 @@ construct_runtime! {
Initializer
:
parachains_initializer
::{
Pallet
,
Call
,
Storage
},
Dmp
:
parachains_dmp
::{
Pallet
,
Call
,
Storage
},
Ump
:
parachains_ump
::{
Pallet
,
Call
,
Storage
},
Hrmp
:
parachains_hrmp
::{
Pallet
,
Call
,
Storage
,
Event
},
Hrmp
:
parachains_hrmp
::{
Pallet
,
Call
,
Storage
,
Event
,
Config
},
SessionInfo
:
parachains_session_info
::{
Pallet
,
Call
,
Storage
},
// Parachain Onboarding Pallets
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment