Fix validator guide

1. Avoid negative computation in `is_candidate_block`
2. Fix `get_block_signature`: avoid extra casting; it's simpler to use BeaconBlock instead of
BeaconHeader
This commit is contained in:
Hsiao-Wei Wang 2020-04-23 13:23:31 +08:00
parent fde9b410f0
commit 4d980aec71
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 5 additions and 5 deletions

View File

@ -281,8 +281,8 @@ def voting_period_start_time(state: BeaconState) -> uint64:
```python
def is_candidate_block(block: Eth1Block, period_start: uint64) -> bool:
return (
block.timestamp <= period_start - SECONDS_PER_ETH1_BLOCK * ETH1_FOLLOW_DISTANCE
and block.timestamp >= period_start - SECONDS_PER_ETH1_BLOCK * ETH1_FOLLOW_DISTANCE * 2
block.timestamp + SECONDS_PER_ETH1_BLOCK * ETH1_FOLLOW_DISTANCE <= period_start
and block.timestamp + SECONDS_PER_ETH1_BLOCK * ETH1_FOLLOW_DISTANCE * 2 >= period_start
)
```
@ -350,9 +350,9 @@ def compute_new_state_root(state: BeaconState, block: BeaconBlock) -> Root:
`signed_block = SignedBeaconBlock(message=block, signature=block_signature)`, where `block_signature` is obtained from:
```python
def get_block_signature(state: BeaconState, header: BeaconBlockHeader, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(header.slot))
signing_root = compute_signing_root(header, domain)
def get_block_signature(state: BeaconState, block: BeaconBlock, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(block.slot))
signing_root = compute_signing_root(block, domain)
return bls.Sign(privkey, signing_root)
```