Change transition_td to terminal_td in the merge spec
This commit is contained in:
parent
fff03a96d1
commit
5a84224d1a
|
@ -73,7 +73,7 @@ def finalize_block(self: ExecutionEngine, block_hash: Hash32) -> bool:
|
||||||
```python
|
```python
|
||||||
@dataclass
|
@dataclass
|
||||||
class TransitionStore(object):
|
class TransitionStore(object):
|
||||||
transition_total_difficulty: uint256
|
terminal_total_difficulty: uint256
|
||||||
```
|
```
|
||||||
|
|
||||||
### `PowBlock`
|
### `PowBlock`
|
||||||
|
@ -101,8 +101,8 @@ Used by fork-choice handler, `on_block`.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def is_valid_terminal_pow_block(transition_store: TransitionStore, block: PowBlock, parent: PowBlock) -> bool:
|
def is_valid_terminal_pow_block(transition_store: TransitionStore, block: PowBlock, parent: PowBlock) -> bool:
|
||||||
is_total_difficulty_reached = block.total_difficulty >= transition_store.transition_total_difficulty
|
is_total_difficulty_reached = block.total_difficulty >= transition_store.terminal_total_difficulty
|
||||||
is_parent_total_difficulty_valid = parent.total_difficulty < transition_store.transition_total_difficulty
|
is_parent_total_difficulty_valid = parent.total_difficulty < transition_store.terminal_total_difficulty
|
||||||
return block.is_valid and is_total_difficulty_reached and is_parent_total_difficulty_valid
|
return block.is_valid and is_total_difficulty_reached and is_parent_total_difficulty_valid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) ==
|
||||||
Transition store initialization occurs after the state has been modified by corresponding `upgrade_to_merge` function.
|
Transition store initialization occurs after the state has been modified by corresponding `upgrade_to_merge` function.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def compute_transition_total_difficulty(anchor_pow_block: PowBlock) -> uint256:
|
def compute_terminal_total_difficulty(anchor_pow_block: PowBlock) -> uint256:
|
||||||
seconds_per_voting_period = EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH * SECONDS_PER_SLOT
|
seconds_per_voting_period = EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH * SECONDS_PER_SLOT
|
||||||
pow_blocks_per_voting_period = seconds_per_voting_period // SECONDS_PER_ETH1_BLOCK
|
pow_blocks_per_voting_period = seconds_per_voting_period // SECONDS_PER_ETH1_BLOCK
|
||||||
pow_blocks_to_merge = TARGET_SECONDS_TO_MERGE // SECONDS_PER_ETH1_BLOCK
|
pow_blocks_to_merge = TARGET_SECONDS_TO_MERGE // SECONDS_PER_ETH1_BLOCK
|
||||||
|
@ -119,8 +119,8 @@ def compute_transition_total_difficulty(anchor_pow_block: PowBlock) -> uint256:
|
||||||
|
|
||||||
|
|
||||||
def get_transition_store(anchor_pow_block: PowBlock) -> TransitionStore:
|
def get_transition_store(anchor_pow_block: PowBlock) -> TransitionStore:
|
||||||
transition_total_difficulty = compute_transition_total_difficulty(anchor_pow_block)
|
terminal_total_difficulty = compute_terminal_total_difficulty(anchor_pow_block)
|
||||||
return TransitionStore(transition_total_difficulty=transition_total_difficulty)
|
return TransitionStore(terminal_total_difficulty=terminal_total_difficulty)
|
||||||
|
|
||||||
|
|
||||||
def initialize_transition_store(state: BeaconState) -> TransitionStore:
|
def initialize_transition_store(state: BeaconState) -> TransitionStore:
|
||||||
|
|
|
@ -95,7 +95,7 @@ def get_execution_payload(state: BeaconState,
|
||||||
execution_engine: ExecutionEngine,
|
execution_engine: ExecutionEngine,
|
||||||
pow_chain: Sequence[PowBlock]) -> ExecutionPayload:
|
pow_chain: Sequence[PowBlock]) -> ExecutionPayload:
|
||||||
if not is_merge_complete(state):
|
if not is_merge_complete(state):
|
||||||
terminal_pow_block = get_pow_block_at_total_difficulty(transition_store.transition_total_difficulty, pow_chain)
|
terminal_pow_block = get_pow_block_at_total_difficulty(transition_store.terminal_total_difficulty, pow_chain)
|
||||||
if terminal_pow_block is None:
|
if terminal_pow_block is None:
|
||||||
# Pre-merge, empty payload
|
# Pre-merge, empty payload
|
||||||
return ExecutionPayload()
|
return ExecutionPayload()
|
||||||
|
|
Loading…
Reference in New Issue