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

Bellatrix: random -> prev_randao #2835

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions specs/bellatrix/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class ExecutionPayload(Container):
state_root: Bytes32
receipts_root: Bytes32
logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]
random: Bytes32 # 'difficulty' in the yellow paper
prev_randao: Bytes32 # 'difficulty' in the yellow paper
block_number: uint64 # 'number' in the yellow paper
gas_limit: uint64
gas_used: uint64
Expand All @@ -193,7 +193,7 @@ class ExecutionPayloadHeader(Container):
state_root: Bytes32
receipts_root: Bytes32
logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]
random: Bytes32
prev_randao: Bytes32
block_number: uint64
gas_limit: uint64
gas_used: uint64
Expand Down Expand Up @@ -348,8 +348,8 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe
# Verify consistency of the parent hash with respect to the previous execution payload header
if is_merge_transition_complete(state):
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
# Verify random
assert payload.random == get_randao_mix(state, get_current_epoch(state))
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
# Verify the execution payload is valid
Expand All @@ -361,7 +361,7 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe
state_root=payload.state_root,
receipts_root=payload.receipts_root,
logs_bloom=payload.logs_bloom,
random=payload.random,
prev_randao=payload.prev_randao,
block_number=payload.block_number,
gas_limit=payload.gas_limit,
gas_used=payload.gas_used,
Expand Down
2 changes: 1 addition & 1 deletion specs/bellatrix/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Used to signal to initiate the payload build process via `notify_forkchoice_upda
@dataclass
class PayloadAttributes(object):
timestamp: uint64
random: Bytes32
prev_randao: Bytes32
suggested_fee_recipient: ExecutionAddress
```

Expand Down
2 changes: 1 addition & 1 deletion specs/bellatrix/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def prepare_execution_payload(state: BeaconState,
# Set the forkchoice head and initiate the payload build process
payload_attributes = PayloadAttributes(
timestamp=compute_timestamp_at_slot(state, state.slot),
random=get_randao_mix(state, get_current_epoch(state)),
prev_randao=get_randao_mix(state, get_current_epoch(state)),
suggested_fee_recipient=suggested_fee_recipient,
)
return execution_engine.notify_forkchoice_updated(parent_hash, finalized_block_hash, payload_attributes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_bad_random_first_payload(spec, state):

# execution payload
execution_payload = build_empty_execution_payload(spec, state)
execution_payload.random = b'\x42' * 32
execution_payload.prev_randao = b'\x42' * 32

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)

Expand All @@ -167,7 +167,7 @@ def test_bad_random_regular_payload(spec, state):

# execution payload
execution_payload = build_empty_execution_payload(spec, state)
execution_payload.random = b'\x04' * 32
execution_payload.prev_randao = b'\x04' * 32

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)

Expand All @@ -182,7 +182,7 @@ def test_bad_everything_regular_payload(spec, state):
# execution payload
execution_payload = build_empty_execution_payload(spec, state)
execution_payload.parent_hash = spec.Hash32()
execution_payload.random = spec.Bytes32()
execution_payload.prev_randao = spec.Bytes32()
execution_payload.timestamp = 0

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_prepare_execution_payload(spec, state):

# 1. Handle `is_merge_complete`
if is_merge_complete:
state.latest_execution_payload_header = spec.ExecutionPayloadHeader(random=b'\x12' * 32)
state.latest_execution_payload_header = spec.ExecutionPayloadHeader(prev_randao=b'\x12' * 32)
else:
state.latest_execution_payload_header = spec.ExecutionPayloadHeader()

Expand Down
4 changes: 2 additions & 2 deletions tests/core/pyspec/eth2spec/test/helpers/execution_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def build_empty_execution_payload(spec, state, randao_mix=None):
receipts_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?
block_number=latest.block_number + 1,
random=randao_mix,
prev_randao=randao_mix,
gas_limit=latest.gas_limit, # retain same limit
gas_used=0, # empty block, 0 gas
timestamp=timestamp,
Expand All @@ -38,7 +38,7 @@ def get_execution_payload_header(spec, execution_payload):
state_root=execution_payload.state_root,
receipts_root=execution_payload.receipts_root,
logs_bloom=execution_payload.logs_bloom,
random=execution_payload.random,
prev_randao=execution_payload.prev_randao,
block_number=execution_payload.block_number,
gas_limit=execution_payload.gas_limit,
gas_used=execution_payload.gas_used,
Expand Down
2 changes: 1 addition & 1 deletion tests/core/pyspec/eth2spec/test/helpers/genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_sample_genesis_execution_payload_header(spec,
state_root=b'\x20' * 32,
receipts_root=b'\x20' * 32,
logs_bloom=b'\x35' * spec.BYTES_PER_LOGS_BLOOM,
random=eth1_block_hash,
prev_randao=eth1_block_hash,
block_number=0,
gas_limit=30000000,
base_fee_per_gas=1000000000,
Expand Down