Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
d5b802ce
Commit
d5b802ce
authored
3 years ago
by
Bastian Köcher
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Check that we have set the validation data inherent (#451)
parent
07b3c44b
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cumulus/pallets/parachain-system/src/lib.rs
+28
-30
28 additions, 30 deletions
cumulus/pallets/parachain-system/src/lib.rs
with
28 additions
and
30 deletions
cumulus/pallets/parachain-system/src/lib.rs
+
28
−
30
View file @
d5b802ce
...
...
@@ -28,20 +28,19 @@
//! Users must ensure that they register this pallet as an inherent provider.
use
cumulus_primitives_core
::{
relay_chain
,
CollationInfo
,
AbridgedHostConfiguration
,
ChannelStatus
,
DmpMessageHandler
,
GetChannelInfo
,
InboundDownwardMessage
,
InboundHrmpMessage
,
MessageSendError
,
OnValidationData
,
relay_chain
,
AbridgedHostConfiguration
,
ChannelStatus
,
CollationInfo
,
DmpMessageHandler
,
GetChannelInfo
,
InboundDownwardMessage
,
InboundHrmpMessage
,
MessageSendError
,
OnValidationData
,
OutboundHrmpMessage
,
ParaId
,
PersistedValidationData
,
UpwardMessage
,
UpwardMessageSender
,
XcmpMessageHandler
,
XcmpMessageSource
,
};
use
cumulus_primitives_parachain_inherent
::
ParachainInherentData
;
use
frame_support
::{
ensure
,
dispatch
::{
DispatchError
,
DispatchResult
},
ensure
,
inherent
::{
InherentData
,
InherentIdentifier
,
ProvideInherent
},
storage
,
traits
::
Get
,
weights
::{
PostDispatchInfo
,
Weight
,
Pays
},
inherent
::{
InherentData
,
InherentIdentifier
,
ProvideInherent
},
weights
::{
Pays
,
PostDispatchInfo
,
Weight
},
};
use
frame_system
::{
ensure_none
,
ensure_root
};
use
polkadot_parachain
::
primitives
::
RelayChainBlockNumber
;
...
...
@@ -108,6 +107,11 @@ pub mod pallet {
fn
on_finalize
(
_
:
T
::
BlockNumber
)
{
<
DidSetValidationCode
<
T
>>
::
kill
();
assert!
(
<
ValidationData
<
T
>>
::
exists
(),
"set_validation_data inherent needs to be present in every block!"
);
let
host_config
=
match
Self
::
host_configuration
()
{
Some
(
ok
)
=>
ok
,
None
=>
{
...
...
@@ -118,18 +122,17 @@ pub mod pallet {
return
;
}
};
let
relevant_messaging_state
=
match
Self
::
relevant_messaging_state
()
{
Some
(
ok
)
=>
ok
,
None
=>
{
debug_assert!
(
false
,
"relevant messaging state is promised to be set until `on_finalize`;
\
let
relevant_messaging_state
=
match
Self
::
relevant_messaging_state
()
{
Some
(
ok
)
=>
ok
,
None
=>
{
debug_assert!
(
false
,
"relevant messaging state is promised to be set until `on_finalize`;
\
qed"
,
);
return
;
}
};
);
return
;
}
};
<
PendingUpwardMessages
<
T
>>
::
mutate
(|
up
|
{
let
(
count
,
size
)
=
relevant_messaging_state
.relay_dispatch_queue_size
;
...
...
@@ -181,10 +184,8 @@ pub mod pallet {
let
outbound_messages
=
T
::
OutboundXcmpMessageSource
::
take_outbound_messages
(
maximum_channels
)
.into_iter
()
.map
(|(
recipient
,
data
)|
OutboundHrmpMessage
{
recipient
,
data
,
})
.collect
::
<
Vec
<
_
>>
();
.map
(|(
recipient
,
data
)|
OutboundHrmpMessage
{
recipient
,
data
})
.collect
::
<
Vec
<
_
>>
();
HrmpOutboundMessages
::
<
T
>
::
put
(
outbound_messages
);
}
...
...
@@ -681,8 +682,8 @@ impl<T: Config> Pallet<T> {
let
mut
weight_used
=
0
;
if
dm_count
!=
0
{
Self
::
deposit_event
(
Event
::
DownwardMessagesReceived
(
dm_count
));
let
max_weight
=
<
ReservedDmpWeightOverride
<
T
>>
::
get
()
.unwrap_or_else
(
T
::
ReservedDmpWeight
::
get
);
let
max_weight
=
<
ReservedDmpWeightOverride
<
T
>>
::
get
()
.unwrap_or_else
(
T
::
ReservedDmpWeight
::
get
);
let
message_iter
=
downward_messages
.into_iter
()
...
...
@@ -728,11 +729,9 @@ impl<T: Config> Pallet<T> {
// A violation of the assertion below indicates that one of the messages submitted
// by the collator was sent from a sender that doesn't have a channel opened to
// this parachain, according to the relay-parent state.
assert!
(
ingress_channels
.binary_search_by_key
(
sender
,
|
&
(
s
,
_
)|
s
)
.is_ok
(),
);
assert!
(
ingress_channels
.binary_search_by_key
(
sender
,
|
&
(
s
,
_
)|
s
)
.is_ok
(),);
}
// Second, prepare horizontal messages for a more convenient processing:
...
...
@@ -863,8 +862,7 @@ impl<T: Config> Pallet<T> {
Error
::
<
T
>
::
OverlappingUpgrades
);
let
vfp
=
Self
::
validation_data
()
.ok_or
(
Error
::
<
T
>
::
ValidationDataNotAvailable
)
?
;
let
cfg
=
Self
::
host_configuration
()
.ok_or
(
Error
::
<
T
>
::
HostConfigurationNotAvailable
)
?
;
let
cfg
=
Self
::
host_configuration
()
.ok_or
(
Error
::
<
T
>
::
HostConfigurationNotAvailable
)
?
;
ensure!
(
validation_function
.len
()
<=
cfg
.max_code_size
as
usize
,
Error
::
<
T
>
::
TooBig
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment