Skip to content

Commit

Permalink
Address a new portion of comments and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalinin committed Mar 25, 2021
1 parent 63ae9f2 commit ee5ecf8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
11 changes: 4 additions & 7 deletions specs/merge/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ order and append any additional fields to the end.

```python
class BeaconBlockBody(phase0.BeaconBlockBody):
application_payload: ApplicationPayload # [Added in Merge] application payload
application_payload: ApplicationPayload # [New in Merge] application payload
```

#### `BeaconState`
Expand All @@ -79,8 +79,8 @@ class BeaconBlockBody(phase0.BeaconBlockBody):
```python
class BeaconState(phase0.BeaconState):
# Application-layer
application_state_root: Bytes32 # [New in Merge]
application_block_hash: Bytes32 # [New in Merge]
application_state_root: Bytes32 # [New in Merge]
application_block_hash: Bytes32 # [New in Merge]
```

### New containers
Expand All @@ -96,7 +96,7 @@ class Transaction(Container):
gas_limit: uint64
recipient: Bytes20
value: uint256
input: List[Bytes1, MAX_BYTES_PER_TRANSACTION_PAYLOAD]
data: List[byte, MAX_BYTES_PER_TRANSACTION_PAYLOAD]
v: uint256
r: uint256
s: uint256
Expand All @@ -115,7 +115,6 @@ class ApplicationPayload(Container):
gas_used: uint64
receipt_root: Bytes32
logs_bloom: Vector[Bytes1, BYTES_PER_LOGS_BLOOM]
difficulty: uint64 # Temporary field, will be removed later on
transactions: List[Transaction, MAX_APPLICATION_TRANSACTIONS]
```

Expand Down Expand Up @@ -178,11 +177,9 @@ def process_application_payload(state: BeaconState, body: BeaconBlockBody) -> No

state.application_state_root = body.application_payload.state_root
state.application_block_hash = body.application_payload.block_hash

elif is_transition_block(state, body):
assert body.application_payload == ApplicationPayload(block_hash=body.application_payload.block_hash)
state.application_block_hash = body.application_payload.block_hash

else:
assert body.application_payload == ApplicationPayload()
```
6 changes: 4 additions & 2 deletions specs/merge/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Used by fork-choice handler, `on_block`.
```python
def is_valid_transition_block(block: PowBlock) -> boolean:
is_total_difficulty_reached = block.total_difficulty >= TRANSITION_TOTAL_DIFFICULTY
return block.is_processed and block.is_valid and is_total_difficulty_reached
return block.is_valid and is_total_difficulty_reached
```

### Updated fork-choice handlers
Expand All @@ -74,9 +74,11 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
# Check block is a descendant of the finalized block at the checkpoint finalized slot
assert get_ancestor(store, block.parent_root, finalized_slot) == store.finalized_checkpoint.root

# [New in Merge] Consider delaying the beacon block processing until PoW block is accepted by the application node
# [New in Merge]
if is_transition_block(pre_state, block.body):
pow_block = get_pow_block(block.body.application_payload.block_hash)
# Delay consideration of block until PoW block is processed by the PoW node
assert pow_block.is_processed
assert is_valid_transition_block(pow_block)

# Check the block is valid and compute the post-state
Expand Down
14 changes: 7 additions & 7 deletions specs/merge/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ The body of this function is implementation dependent.
```python
def get_application_payload(state: BeaconState) -> ApplicationPayload:
if not is_transition_completed(state):
pow_block = get_pow_chain_head()
if pow_block.total_difficulty < TRANSITION_TOTAL_DIFFICULTY:
# Pre-merge, empty payload
return ApplicationPayload()
else:
# Signify merge via last PoW block_hash and an otherwise empty payload
return ApplicationPayload(block_hash=pow_block.block_hash)
pow_block = get_pow_chain_head()
if pow_block.total_difficulty < TRANSITION_TOTAL_DIFFICULTY:
# Pre-merge, empty payload
return ApplicationPayload()
else:
# Signify merge via last PoW block_hash and an otherwise empty payload
return ApplicationPayload(block_hash=pow_block.block_hash)

# Post-merge, normal payload
application_parent_hash = state.application_block_hash
Expand Down

0 comments on commit ee5ecf8

Please sign in to comment.