Skip to content

Commit 18ad8a4

Browse files
committed
Fix get_effective_balance (ethereum/consensus-specs#297)
1 parent 69e8f3f commit 18ad8a4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

eth/beacon/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
)
88

99
from eth_utils import (
10+
denoms,
1011
to_tuple,
1112
ValidationError,
1213
)
@@ -375,7 +376,7 @@ def get_effective_balance(validator: 'ValidatorRecord', max_deposit: int) -> int
375376
"""
376377
Return the effective balance (also known as "balance at stake") for the ``validator``.
377378
"""
378-
return min(validator.balance, max_deposit)
379+
return min(validator.balance, max_deposit * denoms.gwei)
379380

380381

381382
def get_new_validator_registry_delta_chain_tip(current_validator_registry_delta_chain_tip: Hash32,

tests/beacon/test_helpers.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
from eth_utils import (
4+
denoms,
45
ValidationError,
56
)
67

@@ -609,14 +610,19 @@ def mock_get_shard_committees_at_slot(state,
609610
),
610611
[
611612
(
612-
1,
613+
1 * denoms.gwei,
613614
32,
614-
1,
615+
1 * denoms.gwei,
615616
),
616617
(
617-
33,
618+
32 * denoms.gwei,
618619
32,
620+
32 * denoms.gwei,
621+
),
622+
(
623+
33 * denoms.gwei,
619624
32,
625+
32 * denoms.gwei,
620626
)
621627
]
622628
)

0 commit comments

Comments
 (0)