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
55e5e692
Commit
55e5e692
authored
6 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
Calculate spec block hash
parent
10d6dcc1
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
runtime/src/block.rs
+18
-1
18 additions, 1 deletion
runtime/src/block.rs
runtime/src/spec/mod.rs
+1
-1
1 addition, 1 deletion
runtime/src/spec/mod.rs
runtime/src/system.rs
+8
-1
8 additions, 1 deletion
runtime/src/system.rs
with
27 additions
and
3 deletions
runtime/src/block.rs
+
18
−
1
View file @
55e5e692
use
primitives
::
H256
;
use
runtime_primitives
;
use
header
::
Header
;
use
extrinsic
::
Extrinsic
;
use
spec
::
SpecHeader
;
pub
type
Block
=
runtime_primitives
::
generic
::
Block
<
Header
,
Extrinsic
>
;
pub
trait
BlockExt
{
fn
spec_hash
(
&
self
)
->
H256
;
}
impl
BlockExt
for
Block
{
fn
spec_hash
(
&
self
)
->
H256
{
let
extrinsic
=
&
self
.extrinsics
[
0
];
let
header
=
&
self
.header
;
let
spec_header
=
SpecHeader
{
parent_hash
:
header
.parent_hash
,
slot_number
:
extrinsic
.slot_number
,
randao_reveal
:
extrinsic
.randao_reveal
,
attestations
:
extrinsic
.attestations
.clone
(),
pow_chain_ref
:
extrinsic
.pow_chain_ref
,
active_state_root
:
header
.active_state_root
,
crystallized_state_root
:
header
.crystallized_state_root
,
};
spec_header
.spec_hash
()
}
}
This diff is collapsed.
Click to expand it.
runtime/src/spec/mod.rs
+
1
−
1
View file @
55e5e692
...
...
@@ -26,7 +26,7 @@ pub struct SpecHeader {
}
impl
SpecHeader
{
pub
fn
hash
(
&
self
)
->
H256
{
pub
fn
spec_
hash
(
&
self
)
->
H256
{
let
encoded
=
ssz
::
Encode
::
encode
(
self
);
let
mut
blake2
=
Blake2b
::
new_keyed
(
&
[],
64
);
blake2
.input
(
&
encoded
);
...
...
This diff is collapsed.
Click to expand it.
runtime/src/system.rs
+
8
−
1
View file @
55e5e692
...
...
@@ -33,7 +33,7 @@ pub fn execute_block(block: Block) {
let
attestations
=
&
extrinsic
.attestations
;
let
mut
active_state
=
Active
::
get
();
let
crystallized_state
=
Crystallized
::
get
();
let
mut
crystallized_state
=
Crystallized
::
get
();
validation
::
validate_block_pre_processing_conditions
();
active_state
.update_recent_block_hashes
(
parent_slot
,
slot
,
parent_hash
);
...
...
@@ -46,6 +46,13 @@ pub fn execute_block(block: Block) {
attestations
);
validation
::
process_cycle_transitions
::
<
BlockHashesBySlot
,
BlockVoteCache
>
(
slot
,
parent_hash
,
&
mut
crystallized_state
,
&
mut
active_state
);
ParentSlot
::
put
(
&
slot
);
// TODO: Update ParentHash
}
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