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
a77fdf44
Unverified
Commit
a77fdf44
authored
6 years ago
by
Wei Tang
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Define integer sqrt for reward quotient (#2)
parent
7173ef4d
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
runtime/src/utils.rs
+10
-11
10 additions, 11 deletions
runtime/src/utils.rs
runtime/src/validation.rs
+2
-1
2 additions, 1 deletion
runtime/src/validation.rs
with
12 additions
and
12 deletions
runtime/src/utils.rs
+
10
−
11
View file @
a77fdf44
...
...
@@ -14,19 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use
primitives
::
H256
;
use
runtime_primitives
::
traits
::{
DigestItem
as
DigestItemT
};
use
rstd
::
prelude
::
*
;
#[derive(Clone,
PartialEq,
Eq)]
#[cfg_attr(feature
=
"std"
,
derive(Debug,
Serialize,
Deserialize))]
pub
enum
Never
{
}
impl
DigestItemT
for
Never
{
type
Hash
=
H256
;
type
AuthorityId
=
Never
;
}
pub
fn
split
(
list
:
Vec
<
usize
>
,
n
:
usize
)
->
Vec
<
Vec
<
usize
>>
{
let
mut
ret
=
Vec
::
new
();
for
i
in
0
..
n
{
...
...
@@ -36,3 +25,13 @@ pub fn split(list: Vec<usize>, n: usize) -> Vec<Vec<usize>> {
}
ret
}
pub
fn
sqrt
(
n
:
u128
)
->
u128
{
let
mut
x
=
n
;
let
mut
y
=
(
x
+
1
)
/
2
;
while
y
<
x
{
x
=
y
;
y
=
(
x
+
n
/
x
)
/
2
;
}
x
}
This diff is collapsed.
Click to expand it.
runtime/src/validation.rs
+
2
−
1
View file @
a77fdf44
...
...
@@ -22,6 +22,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
,
MIN_DYNASTY_LENGTH
,
SHARD_COUNT
};
use
utils
::
sqrt
;
use
::
ShardId
;
pub
fn
validate_block_pre_processing_conditions
()
{
}
...
...
@@ -169,7 +170,7 @@ pub fn calculate_ffg_rewards<BlockHashesBySlot: StorageMap<u64, H256, Query=Opti
let
total_deposits
=
crystallized_state
.total_deposits
();
let
total_deposits_in_eth
=
total_deposits
/
WEI_PER_ETH
;
let
reward_quotient
=
BASE_REWARD_QUOTIENT
*
total_deposits_in_eth
/
2
;
let
reward_quotient
=
BASE_REWARD_QUOTIENT
*
sqrt
(
total_deposits_in_eth
)
;
let
quadratic_penalty_quotient
=
(
SQRT_E_DROP_TIME
/
SLOT_DURATION
)
.pow
(
2
);
let
last_state_recalc
=
crystallized_state
.last_state_recalc
;
...
...
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