Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shasper
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository 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
shasper
Commits
75fa8e56
Commit
75fa8e56
authored
6 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
Fix execute block and state root
parent
5a208e7a
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
runtime/src/lib.rs
+20
-10
20 additions, 10 deletions
runtime/src/lib.rs
with
20 additions
and
10 deletions
runtime/src/lib.rs
+
20
−
10
View file @
75fa8e56
...
...
@@ -34,10 +34,11 @@ mod genesis;
mod
storage
;
use
rstd
::
prelude
::
*
;
use
primitives
::{
H256
,
ValidatorId
,
Hash
,
OpaqueMetadata
};
use
primitives
::{
H256
,
ValidatorId
,
OpaqueMetadata
};
use
client
::
block_builder
::
api
::
runtime_decl_for_BlockBuilder
::
BlockBuilder
;
use
runtime_primitives
::{
ApplyResult
,
transaction_validity
::
TransactionValidity
,
traits
::{
Header
as
HeaderT
,
Block
as
BlockT
,
GetNodeBlockType
,
GetRuntimeBlockType
,
BlakeTwo256
,
Hash
as
HashT
},
traits
::{
Block
as
BlockT
,
GetNodeBlockType
,
GetRuntimeBlockType
,
BlakeTwo256
,
Hash
as
HashT
},
BasicInherentData
,
CheckInherentError
,
ApplyOutcome
,
};
use
client
::{
...
...
@@ -101,8 +102,14 @@ impl_runtime_apis! {
<
storage
::
Authorities
>
::
items
()
}
fn
execute_block
(
_block
:
Block
)
{
fn
execute_block
(
block
:
Block
)
{
let
(
header
,
extrinsics
)
=
block
.deconstruct
();
Runtime
::
initialise_block
(
header
);
extrinsics
.into_iter
()
.for_each
(|
e
|
{
Runtime
::
apply_extrinsic
(
e
)
.ok
()
.expect
(
"Extrinsic in block execution must be valid"
);
});
Runtime
::
finalise_block
();
}
fn
initialise_block
(
header
:
<
Block
as
BlockT
>
::
Header
)
{
...
...
@@ -137,13 +144,16 @@ impl_runtime_apis! {
fn
finalise_block
()
->
<
Block
as
BlockT
>
::
Header
{
<
storage
::
UncheckedExtrinsics
>
::
set_count
(
0
);
Header
::
new
(
<
storage
::
Number
>
::
take
(),
<
storage
::
ExtrinsicsRoot
>
::
take
(),
Hash
::
from
(
runtime_io
::
storage_root
()),
<
storage
::
ParentHash
>
::
take
(),
<
storage
::
Digest
>
::
take
()
)
let
number
=
<
storage
::
Number
>
::
take
();
let
extrinsics_root
=
<
storage
::
ExtrinsicsRoot
>
::
take
();
let
parent_hash
=
<
storage
::
ParentHash
>
::
take
();
let
digest
=
<
storage
::
Digest
>
::
take
();
let
state_root
=
BlakeTwo256
::
storage_root
();
Header
{
number
,
extrinsics_root
,
state_root
,
parent_hash
,
digest
}
}
fn
inherent_extrinsics
(
data
:
BasicInherentData
)
->
Vec
<<
Block
as
BlockT
>
::
Extrinsic
>
{
...
...
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