Skip to content

Commit 8487575

Browse files
committed
Clean up
1 parent 24b0749 commit 8487575

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

eth/beacon/block_committees_info.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
'BlockCommitteesInfo',
1313
(
1414
('proposer_index', int),
15-
('proposer_index_in_committee', int),
16-
('proposer_shard_id', int),
15+
('proposer_shard', int),
1716
('proposer_committee_size', int),
1817
('shards_committees', Tuple['ShardCommittee'])
1918
)

eth/beacon/helpers.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@
4343

4444

4545
if TYPE_CHECKING:
46-
from eth.beacon.types.active_states import ActiveState # noqa: F401
4746
from eth.beacon.types.attestation_records import AttestationRecord # noqa: F401
4847
from eth.beacon.types.blocks import BaseBeaconBlock # noqa: F401
49-
from eth.beacon.types.crystallized_states import CrystallizedState # noqa: F401
5048
from eth.beacon.types.states import BeaconState # noqa: F401
5149
from eth.beacon.types.validator_records import ValidatorRecord # noqa: F401
5250

@@ -309,7 +307,6 @@ def get_block_committees_info(parent_block: 'BaseBeaconBlock',
309307
epoch_length,
310308
)
311309
"""
312-
FIXME
313310
Return the block committees and proposer info with BlockCommitteesInfo pack.
314311
"""
315312
# `proposer_index_in_committee` th attester in `shard_committee`
@@ -330,13 +327,11 @@ def get_block_committees_info(parent_block: 'BaseBeaconBlock',
330327
proposer_committee_size
331328
)
332329

333-
# The index in CrystallizedState.validators
334330
proposer_index = shard_committee.committee[proposer_index_in_committee]
335331

336332
return BlockCommitteesInfo(
337333
proposer_index=proposer_index,
338-
proposer_index_in_committee=proposer_index_in_committee,
339-
proposer_shard_id=shard_committee.shard_id,
334+
proposer_shard=shard_committee.shard,
340335
proposer_committee_size=proposer_committee_size,
341336
shards_committees=shards_committees,
342337
)

tests/beacon/test_helpers.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -376,61 +376,65 @@ def test_get_new_shuffling_handles_shard_wrap(genesis_validators,
376376
#
377377
# Get proposer postition
378378
#
379-
@pytest.mark.xfail(reason="Need to be fixed")
380379
@pytest.mark.parametrize(
381380
(
382-
'committee,parent_block_number,result_proposer_index_in_committee'
381+
'num_validators,committee,parent_block_number,result_proposer_index'
383382
),
384383
[
385-
([0, 1, 2, 3], 0, 0),
386-
([0, 1, 2, 3], 2, 2),
387-
([0, 1, 2, 3], 11, 3),
388-
([], 1, ValueError()),
384+
(100, [4, 5, 6, 7], 0, 4),
385+
(100, [4, 5, 6, 7], 2, 6),
386+
(100, [4, 5, 6, 7], 11, 7),
387+
(100, [], 1, ValueError()),
389388
],
390389
)
391390
def test_get_block_committees_info(monkeypatch,
392-
genesis_block,
393-
genesis_crystallized_state,
391+
sample_block,
392+
sample_state,
393+
num_validators,
394394
committee,
395395
parent_block_number,
396-
result_proposer_index_in_committee,
396+
result_proposer_index,
397397
epoch_length):
398398
from eth.beacon import helpers
399399

400-
def mock_get_shard_committees_at_slot(parent_block,
401-
crystallized_state,
400+
def mock_get_shard_committees_at_slot(state,
401+
slot,
402402
epoch_length):
403-
return [
404-
ShardCommittee(shard_id=1, committee=committee),
405-
]
403+
return (
404+
ShardCommittee(
405+
shard=1,
406+
committee=committee,
407+
total_validator_count=num_validators,
408+
),
409+
)
406410

407411
monkeypatch.setattr(
408412
helpers,
409-
'_get_shard_committees_at_slot',
413+
'get_shard_committees_at_slot',
410414
mock_get_shard_committees_at_slot
411415
)
412416

413-
parent_block = genesis_block
414-
parent_block = genesis_block.copy(
417+
parent_block = sample_block
418+
parent_block = sample_block.copy(
415419
slot=parent_block_number,
416420
)
417421

418-
if isinstance(result_proposer_index_in_committee, Exception):
422+
if isinstance(result_proposer_index, Exception):
419423
with pytest.raises(ValueError):
420424
get_block_committees_info(
421425
parent_block,
422-
genesis_crystallized_state,
426+
sample_state,
423427
epoch_length,
424428
)
425429
else:
426430
block_committees_info = get_block_committees_info(
427431
parent_block,
428-
genesis_crystallized_state,
432+
sample_state,
429433
epoch_length,
430434
)
431435
assert (
432-
block_committees_info.proposer_index_in_committee ==
433-
result_proposer_index_in_committee
436+
block_committees_info.proposer_index ==
437+
result_proposer_index
434438
)
435439

436440

0 commit comments

Comments
 (0)