Address a new portion of comments and fixes
This commit is contained in:
parent
63ae9f2bdb
commit
ee5ecf8e2b
|
@ -69,7 +69,7 @@ order and append any additional fields to the end.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
class BeaconBlockBody(phase0.BeaconBlockBody):
|
class BeaconBlockBody(phase0.BeaconBlockBody):
|
||||||
application_payload: ApplicationPayload # [Added in Merge] application payload
|
application_payload: ApplicationPayload # [New in Merge] application payload
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `BeaconState`
|
#### `BeaconState`
|
||||||
|
@ -79,8 +79,8 @@ class BeaconBlockBody(phase0.BeaconBlockBody):
|
||||||
```python
|
```python
|
||||||
class BeaconState(phase0.BeaconState):
|
class BeaconState(phase0.BeaconState):
|
||||||
# Application-layer
|
# Application-layer
|
||||||
application_state_root: Bytes32 # [New in Merge]
|
application_state_root: Bytes32 # [New in Merge]
|
||||||
application_block_hash: Bytes32 # [New in Merge]
|
application_block_hash: Bytes32 # [New in Merge]
|
||||||
```
|
```
|
||||||
|
|
||||||
### New containers
|
### New containers
|
||||||
|
@ -96,7 +96,7 @@ class Transaction(Container):
|
||||||
gas_limit: uint64
|
gas_limit: uint64
|
||||||
recipient: Bytes20
|
recipient: Bytes20
|
||||||
value: uint256
|
value: uint256
|
||||||
input: List[Bytes1, MAX_BYTES_PER_TRANSACTION_PAYLOAD]
|
data: List[byte, MAX_BYTES_PER_TRANSACTION_PAYLOAD]
|
||||||
v: uint256
|
v: uint256
|
||||||
r: uint256
|
r: uint256
|
||||||
s: uint256
|
s: uint256
|
||||||
|
@ -115,7 +115,6 @@ class ApplicationPayload(Container):
|
||||||
gas_used: uint64
|
gas_used: uint64
|
||||||
receipt_root: Bytes32
|
receipt_root: Bytes32
|
||||||
logs_bloom: Vector[Bytes1, BYTES_PER_LOGS_BLOOM]
|
logs_bloom: Vector[Bytes1, BYTES_PER_LOGS_BLOOM]
|
||||||
difficulty: uint64 # Temporary field, will be removed later on
|
|
||||||
transactions: List[Transaction, MAX_APPLICATION_TRANSACTIONS]
|
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_state_root = body.application_payload.state_root
|
||||||
state.application_block_hash = body.application_payload.block_hash
|
state.application_block_hash = body.application_payload.block_hash
|
||||||
|
|
||||||
elif is_transition_block(state, body):
|
elif is_transition_block(state, body):
|
||||||
assert body.application_payload == ApplicationPayload(block_hash=body.application_payload.block_hash)
|
assert body.application_payload == ApplicationPayload(block_hash=body.application_payload.block_hash)
|
||||||
state.application_block_hash = body.application_payload.block_hash
|
state.application_block_hash = body.application_payload.block_hash
|
||||||
|
|
||||||
else:
|
else:
|
||||||
assert body.application_payload == ApplicationPayload()
|
assert body.application_payload == ApplicationPayload()
|
||||||
```
|
```
|
||||||
|
|
|
@ -49,7 +49,7 @@ Used by fork-choice handler, `on_block`.
|
||||||
```python
|
```python
|
||||||
def is_valid_transition_block(block: PowBlock) -> boolean:
|
def is_valid_transition_block(block: PowBlock) -> boolean:
|
||||||
is_total_difficulty_reached = block.total_difficulty >= TRANSITION_TOTAL_DIFFICULTY
|
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
|
### 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
|
# 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
|
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):
|
if is_transition_block(pre_state, block.body):
|
||||||
pow_block = get_pow_block(block.body.application_payload.block_hash)
|
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)
|
assert is_valid_transition_block(pow_block)
|
||||||
|
|
||||||
# Check the block is valid and compute the post-state
|
# Check the block is valid and compute the post-state
|
||||||
|
|
|
@ -56,13 +56,13 @@ The body of this function is implementation dependent.
|
||||||
```python
|
```python
|
||||||
def get_application_payload(state: BeaconState) -> ApplicationPayload:
|
def get_application_payload(state: BeaconState) -> ApplicationPayload:
|
||||||
if not is_transition_completed(state):
|
if not is_transition_completed(state):
|
||||||
pow_block = get_pow_chain_head()
|
pow_block = get_pow_chain_head()
|
||||||
if pow_block.total_difficulty < TRANSITION_TOTAL_DIFFICULTY:
|
if pow_block.total_difficulty < TRANSITION_TOTAL_DIFFICULTY:
|
||||||
# Pre-merge, empty payload
|
# Pre-merge, empty payload
|
||||||
return ApplicationPayload()
|
return ApplicationPayload()
|
||||||
else:
|
else:
|
||||||
# Signify merge via last PoW block_hash and an otherwise empty payload
|
# Signify merge via last PoW block_hash and an otherwise empty payload
|
||||||
return ApplicationPayload(block_hash=pow_block.block_hash)
|
return ApplicationPayload(block_hash=pow_block.block_hash)
|
||||||
|
|
||||||
# Post-merge, normal payload
|
# Post-merge, normal payload
|
||||||
application_parent_hash = state.application_block_hash
|
application_parent_hash = state.application_block_hash
|
||||||
|
|
Loading…
Reference in New Issue