mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 17:35:03 -05:00
Rename randao->random, other fixes as per review
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user