mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-01 05:14:49 +00:00
Rename randao->random, other fixes as per review
This commit is contained in:
parent
cc20b80103
commit
6e86d8a696
2
setup.py
2
setup.py
@ -532,7 +532,7 @@ class NoopExecutionEngine(ExecutionEngine):
|
||||
def finalize_block(self, block_hash: Hash32) -> bool:
|
||||
return True
|
||||
|
||||
def assemble_block(self, block_hash: Hash32, timestamp: uint64, randao: Bytes32) -> ExecutionPayload:
|
||||
def assemble_block(self, block_hash: Hash32, timestamp: uint64, random: Bytes32) -> ExecutionPayload:
|
||||
raise NotImplementedError("no default block production")
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ class ExecutionPayload(Container):
|
||||
timestamp: uint64
|
||||
receipt_root: Bytes32
|
||||
logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]
|
||||
randao: Bytes32 # 'difficulty' in the yellow paper
|
||||
random: Bytes32 # 'difficulty' in the yellow paper
|
||||
transactions: List[OpaqueTransaction, MAX_EXECUTION_TRANSACTIONS]
|
||||
```
|
||||
|
||||
@ -127,7 +127,7 @@ class ExecutionPayloadHeader(Container):
|
||||
timestamp: uint64
|
||||
receipt_root: Bytes32
|
||||
logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]
|
||||
randao: Bytes32
|
||||
random: Bytes32
|
||||
transactions_root: Root
|
||||
```
|
||||
|
||||
@ -219,7 +219,7 @@ def process_execution_payload(state: BeaconState,
|
||||
if is_transition_completed(state):
|
||||
assert execution_payload.parent_hash == state.latest_execution_payload_header.block_hash
|
||||
assert execution_payload.number == state.latest_execution_payload_header.number + 1
|
||||
assert execution_payload.randao == randao_mix
|
||||
assert execution_payload.random == randao_mix
|
||||
|
||||
assert execution_payload.timestamp == compute_time_at_slot(state, state.slot)
|
||||
|
||||
@ -236,7 +236,7 @@ def process_execution_payload(state: BeaconState,
|
||||
timestamp=execution_payload.timestamp,
|
||||
receipt_root=execution_payload.receipt_root,
|
||||
logs_bloom=execution_payload.logs_bloom,
|
||||
randao=execution_payload.randao,
|
||||
random=execution_payload.random,
|
||||
transactions_root=hash_tree_root(execution_payload.transactions),
|
||||
)
|
||||
```
|
||||
@ -296,7 +296,7 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Bytes32,
|
||||
timestamp=eth1_timestamp,
|
||||
receipt_root=Bytes32(),
|
||||
logs_bloom=ByteVector[BYTES_PER_LOGS_BLOOM](),
|
||||
randao=randao_seed,
|
||||
random=randao_seed,
|
||||
transactions_root=Root(),
|
||||
)
|
||||
|
||||
|
@ -49,7 +49,7 @@ The body of this function is implementation dependent.
|
||||
The Consensus API may be used to implement this with an external execution engine.
|
||||
|
||||
```python
|
||||
def assemble_block(self: ExecutionEngine, block_hash: Hash32, timestamp: uint64, randao: Bytes32) -> ExecutionPayload:
|
||||
def assemble_block(self: ExecutionEngine, block_hash: Hash32, timestamp: uint64, random: Bytes32) -> ExecutionPayload:
|
||||
...
|
||||
```
|
||||
|
||||
@ -80,8 +80,8 @@ def produce_execution_payload(state: BeaconState,
|
||||
randao_reveal: BLSSignature,
|
||||
execution_engine: ExecutionEngine) -> ExecutionPayload:
|
||||
timestamp = compute_time_at_slot(state, state.slot)
|
||||
randao = compute_randao_mix(state, randao_reveal)
|
||||
return execution_engine.assemble_block(parent_hash, timestamp, randao)
|
||||
randao_mix = compute_randao_mix(state, randao_reveal)
|
||||
return execution_engine.assemble_block(parent_hash, timestamp, randao_mix)
|
||||
|
||||
|
||||
def get_execution_payload(state: BeaconState,
|
||||
|
@ -35,11 +35,6 @@ def apply_randao_reveal(spec, state, block, proposer_index=None):
|
||||
block.body.randao_reveal = bls.Sign(privkey, signing_root)
|
||||
|
||||
|
||||
def compute_randao_mix(spec, state, randao_reveal):
|
||||
epoch = spec.get_current_epoch(state)
|
||||
return spec.xor(spec.get_randao_mix(state, epoch), spec.hash(randao_reveal))
|
||||
|
||||
|
||||
# Fully ignore the function if BLS is off, beacon-proposer index calculation is slow.
|
||||
@only_with_bls()
|
||||
def apply_sig(spec, state, signed_block, proposer_index=None):
|
||||
@ -104,7 +99,7 @@ def build_empty_block(spec, state, slot=None):
|
||||
empty_block.body.sync_aggregate.sync_committee_signature = spec.G2_POINT_AT_INFINITY
|
||||
|
||||
if is_post_merge(spec):
|
||||
randao_mix = compute_randao_mix(spec, state, empty_block.body.randao_reveal)
|
||||
randao_mix = spec.compute_randao_mix(state, empty_block.body.randao_reveal)
|
||||
empty_block.body.execution_payload = build_empty_execution_payload(spec, state, randao_mix)
|
||||
|
||||
return empty_block
|
||||
|
@ -1,8 +1,8 @@
|
||||
def build_empty_execution_payload_with_randao(spec, state):
|
||||
def build_empty_execution_payload_with_zeroed_random(spec, state):
|
||||
return build_empty_execution_payload(spec, state, spec.Bytes32())
|
||||
|
||||
|
||||
def build_empty_execution_payload(spec, state, randao_mix):
|
||||
def build_empty_execution_payload(spec, state, random):
|
||||
"""
|
||||
Assuming a pre-state of the same slot, build a valid ExecutionPayload without any transactions.
|
||||
"""
|
||||
@ -21,7 +21,7 @@ def build_empty_execution_payload(spec, state, randao_mix):
|
||||
timestamp=timestamp,
|
||||
receipt_root=b"no receipts here" + b"\x00" * 16, # TODO: root of empty MPT may be better.
|
||||
logs_bloom=spec.ByteVector[spec.BYTES_PER_LOGS_BLOOM](), # TODO: zeroed logs bloom for empty logs ok?
|
||||
randao=randao_mix,
|
||||
random=random,
|
||||
transactions=empty_txs,
|
||||
)
|
||||
# TODO: real RLP + block hash logic would be nice, requires RLP and keccak256 dependency however.
|
||||
@ -42,7 +42,7 @@ def get_execution_payload_header(spec, execution_payload):
|
||||
timestamp=execution_payload.timestamp,
|
||||
receipt_root=execution_payload.receipt_root,
|
||||
logs_bloom=execution_payload.logs_bloom,
|
||||
randao=execution_payload.randao,
|
||||
random=execution_payload.random,
|
||||
transactions_root=spec.hash_tree_root(execution_payload.transactions)
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from eth2spec.test.helpers.execution_payload import (
|
||||
build_empty_execution_payload_with_randao,
|
||||
build_empty_execution_payload_with_zeroed_random,
|
||||
get_execution_payload_header,
|
||||
build_state_with_incomplete_transition,
|
||||
build_state_with_complete_transition,
|
||||
@ -56,7 +56,7 @@ def test_success_first_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload)
|
||||
|
||||
@ -69,7 +69,7 @@ def test_success_regular_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload)
|
||||
|
||||
@ -83,7 +83,7 @@ def test_success_first_payload_with_gap_slot(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload)
|
||||
|
||||
@ -97,7 +97,7 @@ def test_success_regular_payload_with_gap_slot(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload)
|
||||
|
||||
@ -112,7 +112,7 @@ def test_bad_execution_first_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False, execution_valid=False)
|
||||
|
||||
@ -127,7 +127,7 @@ def test_bad_execution_regular_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False, execution_valid=False)
|
||||
|
||||
@ -140,7 +140,7 @@ def test_bad_parent_hash_regular_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
execution_payload.parent_hash = spec.Hash32()
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
|
||||
@ -154,7 +154,7 @@ def test_bad_number_regular_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
execution_payload.number = execution_payload.number + 1
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
|
||||
@ -168,7 +168,7 @@ def test_bad_everything_regular_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
execution_payload.parent_hash = spec.Hash32()
|
||||
execution_payload.number = execution_payload.number + 1
|
||||
|
||||
@ -183,7 +183,7 @@ def test_bad_timestamp_first_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
execution_payload.timestamp = execution_payload.timestamp + 1
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
|
||||
@ -197,7 +197,7 @@ def test_bad_timestamp_regular_payload(spec, state):
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload_with_randao(spec, state)
|
||||
execution_payload = build_empty_execution_payload_with_zeroed_random(spec, state)
|
||||
execution_payload.timestamp = execution_payload.timestamp + 1
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user