Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic fork versions and signature domains #738

Merged
merged 7 commits into from
Mar 12, 2019
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ Code snippets appearing in `this style` are to be interpreted as Python code.

| Name | Value |
| - | - |
| `DOMAIN_BEACON_BLOCK` | `0` |
| `DOMAIN_RANDAO` | `1` |
| `DOMAIN_ATTESTATION` | `2` |
| `DOMAIN_DEPOSIT` | `3` |
| `DOMAIN_VOLUNTARY_EXIT` | `4` |
| `DOMAIN_TRANSFER` | `5` |
| `DOMAIN_BEACON_BLOCK` | `int_to_bytes4(0)` |
| `DOMAIN_RANDAO` | `int_to_bytes4(1)` |
| `DOMAIN_ATTESTATION` | `int_to_bytes4(2)` |
| `DOMAIN_DEPOSIT` | `int_to_bytes4(3)` |
| `DOMAIN_VOLUNTARY_EXIT` | `int_to_bytes4(4)` |
| `DOMAIN_TRANSFER` | `int_to_bytes4(5)` |

## Data structures

Expand All @@ -288,9 +288,9 @@ The types are defined topologically to aid in facilitating an executable version
```python
{
# Previous fork version
'previous_version': 'uint64',
'previous_version': 'bytes4',
# Current fork version
'current_version': 'uint64',
'current_version': 'bytes4',
# Fork epoch number
'epoch': 'uint64',
}
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def get_total_balance(state: BeaconState, validators: List[ValidatorIndex]) -> G

```python
def get_fork_version(fork: Fork,
epoch: Epoch) -> int:
epoch: Epoch) -> bytes4:
JustinDrake marked this conversation as resolved.
Show resolved Hide resolved
"""
Return the fork version of the given ``epoch``.
"""
Expand All @@ -1122,12 +1122,11 @@ def get_fork_version(fork: Fork,
```python
def get_domain(fork: Fork,
epoch: Epoch,
domain_type: int) -> int:
domain_type: bytes4) -> int:
JustinDrake marked this conversation as resolved.
Show resolved Hide resolved
"""
Get the domain number that represents the fork meta and signature domain.
"""
fork_version = get_fork_version(fork, epoch)
return fork_version * 2**32 + domain_type
return bytes_to_int(get_fork_version(fork, epoch) + domain_type))
```

### `get_bitfield_bit`
Expand Down