Address a new portion of comments and fixes

This commit is contained in:
Mikhail Kalinin 2021-03-25 17:49:13 +06:00
parent 63ae9f2bdb
commit ee5ecf8e2b
3 changed files with 15 additions and 16 deletions

View File

@ -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`
@ -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
@ -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]
```
@ -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()
```

View File

@ -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
@ -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