Domains are bytes

This commit is contained in:
Carl Beekhuizen 2019-12-17 12:20:34 +02:00
parent 502ee29537
commit 80eb721895
No known key found for this signature in database
GPG Key ID: 8F29E54F49E7AAB5
4 changed files with 9 additions and 11 deletions

View File

@ -169,7 +169,7 @@ def objects_to_spec(functions: Dict[str, str],
functions_spec = '\n\n'.join(functions.values()) functions_spec = '\n\n'.join(functions.values())
for k in list(constants.keys()): for k in list(constants.keys()):
if k.startswith('DOMAIN_'): if k.startswith('DOMAIN_'):
constants[k] = f"DomainType(({constants[k]}).to_bytes(length=4, byteorder='little'))" constants[k] = f"DomainType(bytes.fromhex('{constants[k]}'[2:]))"
if k == "BLS12_381_Q": if k == "BLS12_381_Q":
constants[k] += " # noqa: E501" constants[k] += " # noqa: E501"
constants_spec = '\n'.join(map(lambda x: '%s = %s' % (x, constants[x]), constants)) constants_spec = '\n'.join(map(lambda x: '%s = %s' % (x, constants[x]), constants))

View File

@ -249,15 +249,13 @@ The following values are (non-configurable) constants used throughout the specif
### Domain types ### Domain types
The following types are defined, mapping into `DomainType` (little endian):
| Name | Value | | Name | Value |
| - | - | | - | - |
| `DOMAIN_BEACON_PROPOSER` | `0` | | `DOMAIN_BEACON_PROPOSER` | `0x00000000` |
| `DOMAIN_BEACON_ATTESTER` | `1` | | `DOMAIN_BEACON_ATTESTER` | `0x01000000` |
| `DOMAIN_RANDAO` | `2` | | `DOMAIN_RANDAO` | `0x02000000` |
| `DOMAIN_DEPOSIT` | `3` | | `DOMAIN_DEPOSIT` | `0x03000000` |
| `DOMAIN_VOLUNTARY_EXIT` | `4` | | `DOMAIN_VOLUNTARY_EXIT` | `0x04000000` |
## Containers ## Containers

View File

@ -131,7 +131,7 @@ The following types are defined, mapping into `DomainType` (little endian):
| Name | Value | | Name | Value |
| - | - | | - | - |
| `DOMAIN_CUSTODY_BIT_CHALLENGE` | `6` | | `DOMAIN_CUSTODY_BIT_CHALLENGE` | `0x05000000` |
### TODO PLACEHOLDER ### TODO PLACEHOLDER

View File

@ -101,8 +101,8 @@ This document describes the shard transition function (data layer only) and the
| Name | Value | | Name | Value |
| - | - | | - | - |
| `DOMAIN_SHARD_PROPOSER` | `128` | | `DOMAIN_SHARD_PROPOSER` | `0x80000000` |
| `DOMAIN_SHARD_ATTESTER` | `129` | | `DOMAIN_SHARD_ATTESTER` | `0x81000000` |
## Containers ## Containers