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
c2b20fe5
Commit
c2b20fe5
authored
6 years ago
by
asynchronous rob
Committed by
Gav Wood
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix block body fetch for availability pruning (#539)
parent
a330f2e0
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/polkadot/consensus/src/service.rs
+14
-8
14 additions, 8 deletions
substrate/polkadot/consensus/src/service.rs
with
14 additions
and
8 deletions
substrate/polkadot/consensus/src/service.rs
+
14
−
8
View file @
c2b20fe5
...
...
@@ -103,7 +103,8 @@ fn prune_unneeded_availability<C>(client: Arc<C>, extrinsic_store: ExtrinsicStor
use
polkadot_runtime
::
CheckedBlock
;
enum
NotifyError
{
NoBody
(::
client
::
error
::
Error
),
NoBody
,
BodyFetch
(::
client
::
error
::
Error
),
UnexpectedFormat
,
ExtrinsicsWrong
,
}
...
...
@@ -111,29 +112,34 @@ fn prune_unneeded_availability<C>(client: Arc<C>, extrinsic_store: ExtrinsicStor
impl
NotifyError
{
fn
log
(
&
self
,
hash
:
&
::
polkadot_primitives
::
Hash
)
{
match
*
self
{
NotifyError
::
NoBody
(
ref
err
)
=>
warn!
(
"Failed to fetch block body for imported block {:?}: {:?}"
,
hash
,
err
),
NotifyError
::
NoBody
=>
warn!
(
"No block body for imported block {:?}"
,
hash
),
NotifyError
::
BodyFetch
(
ref
err
)
=>
warn!
(
"Failed to fetch block body for imported block {:?}: {:?}"
,
hash
,
err
),
NotifyError
::
UnexpectedFormat
=>
warn!
(
"Consensus outdated: Block {:?} has unexpected body format"
,
hash
),
NotifyError
::
ExtrinsicsWrong
=>
warn!
(
"Consensus outdated:
Failed to fetch block body for imported block
{:?}"
,
hash
),
NotifyError
::
ExtrinsicsWrong
=>
warn!
(
"Consensus outdated:
Extrinsics cannot be decoded for
{:?}"
,
hash
),
}
}
}
client
.import_notification_stream
()
.for_each
(
move
|
notification
|
{
let
checked_block
=
client
.block_body
(
&
BlockId
::
hash
(
notification
.hash
))
.map_err
(
NotifyError
::
NoBody
)
.map
(|
b
|
::
polkadot_runtime
::
Block
::
decode
(
&
mut
b
.encode
()
.as_slice
()))
let
hash
=
notification
.hash
;
let
parent_hash
=
notification
.header.parent_hash
;
let
checked_block
=
client
.block_body
(
&
BlockId
::
hash
(
hash
))
.map_err
(
NotifyError
::
BodyFetch
)
.and_then
(|
maybe_body
|
maybe_body
.ok_or
(
NotifyError
::
NoBody
))
.map
(|
extrinsics
|
Block
{
header
:
notification
.header
,
extrinsics
})
.map
(|
b
:
Block
|
::
polkadot_runtime
::
Block
::
decode
(
&
mut
b
.encode
()
.as_slice
()))
.and_then
(|
maybe_block
|
maybe_block
.ok_or
(
NotifyError
::
UnexpectedFormat
))
.and_then
(|
block
|
CheckedBlock
::
new
(
block
)
.map_err
(|
_
|
NotifyError
::
ExtrinsicsWrong
));
match
checked_block
{
Ok
(
block
)
=>
{
let
candidate_hashes
=
block
.parachain_heads
()
.iter
()
.map
(|
c
|
c
.hash
())
.collect
();
if
let
Err
(
e
)
=
extrinsic_store
.candidates_finalized
(
notification
.header.
parent_hash
,
candidate_hashes
)
{
if
let
Err
(
e
)
=
extrinsic_store
.candidates_finalized
(
parent_hash
,
candidate_hashes
)
{
warn!
(
target
:
"consensus"
,
"Failed to prune unneeded available data: {:?}"
,
e
);
}
}
Err
(
e
)
=>
e
.log
(
&
notification
.
hash
)
Err
(
e
)
=>
e
.log
(
&
hash
)
}
Ok
(())
...
...
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