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
846834c9
Commit
846834c9
authored
6 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
Implement is_ready_for_dynasty_transition
parent
020368bd
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
runtime/src/consts.rs
+1
-0
1 addition, 0 deletions
runtime/src/consts.rs
runtime/src/validation.rs
+32
-1
32 additions, 1 deletion
runtime/src/validation.rs
with
33 additions
and
1 deletion
runtime/src/consts.rs
+
1
−
0
View file @
846834c9
...
...
@@ -5,3 +5,4 @@ pub const WEI_PER_ETH: u128 = 1000000000000000000;
pub
const
BASE_REWARD_QUOTIENT
:
u128
=
32768
;
pub
const
SQRT_E_DROP_TIME
:
u128
=
1048576
;
pub
const
SLOT_DURATION
:
u128
=
8
;
pub
const
MIN_DYNASTY_LENGTH
:
u64
=
256
;
This diff is collapsed.
Click to expand it.
runtime/src/validation.rs
+
32
−
1
View file @
846834c9
...
...
@@ -4,7 +4,7 @@ use rstd::collections::btree_map::BTreeMap;
use
state
::{
ActiveState
,
CrystallizedState
,
BlockVoteInfo
,
CrosslinkRecord
};
use
attestation
::
AttestationRecord
;
use
consts
::{
CYCLE_LENGTH
,
WEI_PER_ETH
,
BASE_REWARD_QUOTIENT
,
SQRT_E_DROP_TIME
,
SLOT_DURATION
};
use
consts
::{
CYCLE_LENGTH
,
WEI_PER_ETH
,
BASE_REWARD_QUOTIENT
,
SQRT_E_DROP_TIME
,
SLOT_DURATION
,
MIN_DYNASTY_LENGTH
};
use
::
ShardId
;
pub
fn
validate_block_pre_processing_conditions
()
{
}
...
...
@@ -298,3 +298,34 @@ pub fn initialize_new_cycle<BlockHashesBySlot: StorageMap<u64, H256, Query=Optio
crystallized_state
.justified_streak
=
justified_streak
;
crystallized_state
.last_finalized_slot
=
last_finalized_slot
;
}
pub
fn
is_ready_for_dynasty_transition
(
slot
:
u64
,
crystallized_state
:
&
CrystallizedState
)
->
bool
{
let
slots_since_last_dynasty_change
=
slot
-
crystallized_state
.dynasty_start
;
if
slots_since_last_dynasty_change
<
MIN_DYNASTY_LENGTH
{
return
false
;
}
if
crystallized_state
.last_finalized_slot
<=
crystallized_state
.dynasty_start
{
return
false
;
}
let
mut
required_shards
=
Vec
::
new
();
for
shards_and_committees_for_slot
in
&
crystallized_state
.shards_and_committees_for_slots
{
for
shard_and_committee
in
shards_and_committees_for_slot
{
required_shards
.push
(
shard_and_committee
.shard_id
);
}
}
for
(
shard_id
,
crosslink
)
in
crystallized_state
.crosslink_records
.iter
()
.enumerate
()
{
if
required_shards
.contains
(
&
(
shard_id
as
u16
))
{
if
crosslink
.slot
<=
crystallized_state
.dynasty_start
{
return
false
;
}
}
}
return
true
;
}
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