compute_domain for consistency with get_domain

This commit is contained in:
Justin Drake 2019-07-01 00:35:09 +01:00
parent 41897e779a
commit aeba6ee8fb
3 changed files with 8 additions and 8 deletions

View File

@ -72,7 +72,7 @@
- [`compute_epoch_of_slot`](#compute_epoch_of_slot) - [`compute_epoch_of_slot`](#compute_epoch_of_slot)
- [`compute_start_slot_of_epoch`](#compute_start_slot_of_epoch) - [`compute_start_slot_of_epoch`](#compute_start_slot_of_epoch)
- [`compute_activation_exit_epoch`](#compute_activation_exit_epoch) - [`compute_activation_exit_epoch`](#compute_activation_exit_epoch)
- [`compute_bls_domain`](#compute_bls_domain) - [`compute_domain`](#compute_domain)
- [Beacon state accessors](#beacon-state-accessors) - [Beacon state accessors](#beacon-state-accessors)
- [`get_current_epoch`](#get_current_epoch) - [`get_current_epoch`](#get_current_epoch)
- [`get_previous_epoch`](#get_previous_epoch) - [`get_previous_epoch`](#get_previous_epoch)
@ -771,10 +771,10 @@ def compute_activation_exit_epoch(epoch: Epoch) -> Epoch:
return Epoch(epoch + 1 + ACTIVATION_EXIT_DELAY) return Epoch(epoch + 1 + ACTIVATION_EXIT_DELAY)
``` ```
#### `compute_bls_domain` #### `compute_domain`
```python ```python
def compute_bls_domain(domain_type: uint64, fork_version: bytes=b'\x00' * 4) -> int: def compute_domain(domain_type: uint64, fork_version: bytes=b'\x00' * 4) -> int:
""" """
Return the BLS domain for the ``domain_type`` and ``fork_version``. Return the BLS domain for the ``domain_type`` and ``fork_version``.
""" """
@ -1010,7 +1010,7 @@ def get_domain(state: BeaconState, domain_type: uint64, message_epoch: Epoch=Non
""" """
epoch = get_current_epoch(state) if message_epoch is None else message_epoch epoch = get_current_epoch(state) if message_epoch is None else message_epoch
fork_version = state.fork.previous_version if epoch < state.fork.epoch else state.fork.current_version fork_version = state.fork.previous_version if epoch < state.fork.epoch else state.fork.current_version
return compute_bls_domain(domain_type, fork_version) return compute_domain(domain_type, fork_version)
``` ```
#### `get_indexed_attestation` #### `get_indexed_attestation`
@ -1685,8 +1685,8 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
if pubkey not in validator_pubkeys: if pubkey not in validator_pubkeys:
# Verify the deposit signature (proof of possession) for new validators. # Verify the deposit signature (proof of possession) for new validators.
# Note: The deposit contract does not check signatures. # Note: The deposit contract does not check signatures.
# Note: Deposits are valid across forks, thus the deposit domain is retrieved directly from `compute_bls_domain` # Note: Deposits are valid across forks, thus the deposit domain is retrieved directly from `compute_domain`
domain = compute_bls_domain(DOMAIN_DEPOSIT) domain = compute_domain(DOMAIN_DEPOSIT)
if not bls_verify(pubkey, signing_root(deposit.data), deposit.data.signature, domain): if not bls_verify(pubkey, signing_root(deposit.data), deposit.data.signature, domain):
return return

View File

@ -99,7 +99,7 @@ To submit a deposit:
- Pack the validator's [initialization parameters](#initialization) into `deposit_data`, a [`DepositData`](../core/0_beacon-chain.md#depositdata) SSZ object. - Pack the validator's [initialization parameters](#initialization) into `deposit_data`, a [`DepositData`](../core/0_beacon-chain.md#depositdata) SSZ object.
- Let `amount` be the amount in Gwei to be deposited by the validator where `MIN_DEPOSIT_AMOUNT <= amount <= MAX_EFFECTIVE_BALANCE`. - Let `amount` be the amount in Gwei to be deposited by the validator where `MIN_DEPOSIT_AMOUNT <= amount <= MAX_EFFECTIVE_BALANCE`.
- Set `deposit_data.amount = amount`. - Set `deposit_data.amount = amount`.
- Let `signature` be the result of `bls_sign` of the `signing_root(deposit_data)` with `domain=compute_bls_domain(DOMAIN_DEPOSIT)`. (Deposits are valid regardless of fork version, `compute_bls_domain` will default to zeroes there). - Let `signature` be the result of `bls_sign` of the `signing_root(deposit_data)` with `domain=compute_domain(DOMAIN_DEPOSIT)`. (Deposits are valid regardless of fork version, `compute_domain` will default to zeroes there).
- Send a transaction on the Ethereum 1.0 chain to `DEPOSIT_CONTRACT_ADDRESS` executing `def deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96])` along with a deposit of `amount` Gwei. - Send a transaction on the Ethereum 1.0 chain to `DEPOSIT_CONTRACT_ADDRESS` executing `def deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96])` along with a deposit of `amount` Gwei.
*Note*: Deposits made for the same `pubkey` are treated as for the same validator. A singular `Validator` will be added to `state.validators` with each additional deposit amount added to the validator's balance. A validator can only be activated when total deposits for the validator pubkey meet or exceed `MAX_EFFECTIVE_BALANCE`. *Note*: Deposits made for the same `pubkey` are treated as for the same validator. A singular `Validator` will be added to `state.validators` with each additional deposit amount added to the validator's balance. A validator can only be activated when total deposits for the validator pubkey meet or exceed `MAX_EFFECTIVE_BALANCE`.

View File

@ -19,7 +19,7 @@ def build_deposit_data(spec, pubkey, privkey, amount, withdrawal_credentials, st
def sign_deposit_data(spec, deposit_data, privkey, state=None): def sign_deposit_data(spec, deposit_data, privkey, state=None):
if state is None: if state is None:
# Genesis # Genesis
domain = spec.compute_bls_domain(spec.DOMAIN_DEPOSIT) domain = spec.compute_domain(spec.DOMAIN_DEPOSIT)
else: else:
domain = spec.get_domain( domain = spec.get_domain(
state, state,