Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Mar 13, 2024
1 parent 7cb01ab commit 6dc2894
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
17 changes: 8 additions & 9 deletions pysetup/spec_builders/eip7547.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
class EIP7547SpecBuilder(BaseSpecBuilder):
fork: str = EIP7547

@classmethod
def sundry_functions(cls) -> str:
return '''
def retrieve_inclusion_list(slot: Slot, proposer_index: ValidatorIndex) -> InclusionList:
# pylint: disable=unused-argument
...
'''

@classmethod
def execution_engine_cls(cls) -> str:
Expand All @@ -21,29 +14,35 @@ def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root) -> bool:
return True
def notify_forkchoice_updated(self: ExecutionEngine,
head_block_hash: Hash32,
safe_block_hash: Hash32,
finalized_block_hash: Hash32,
payload_attributes: Optional[PayloadAttributes]) -> Optional[PayloadId]:
pass
def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse:
# pylint: disable=unused-argument
raise NotImplementedError("no default block production")
def is_valid_block_hash(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root) -> bool:
return True
def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
return True
def verify_and_notify_new_payload(self: ExecutionEngine,
new_payload_request: NewPayloadRequest) -> bool:
return True
def notify_new_inclusion_list(self: ExecutionEngine,
inclusion_list_request: NewInclusionListRequest) -> bool:
return True
def get_execution_inclusion_list(self: ExecutionEngine, parent_block_hash: Root) -> GetInclusionListResponse:
return GetInclusionListResponse()
EXECUTION_ENGINE = NoopExecutionEngine()"""

@classmethod
Expand Down
24 changes: 16 additions & 8 deletions specs/_features/eip7547/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [Execution](#execution)
- [Containers](#containers)
- [New Containers](#new-containers)
- [`SignedInclusionListSummary`](#signedinclusionlistsummary)
- [Execution engine](#execution-engine)
- [Request data](#request-data)
- [New `NewInclusionListRequest`](#new-newinclusionlistrequest)
Expand Down Expand Up @@ -56,6 +57,8 @@ This is the beacon chain specification to add an inclusion list mechanism to all

### New Containers

#### `SignedInclusionListSummary`

```python
class SignedInclusionListSummary(Container):
summary: List[ExecutionAddress, MAX_TRANSACTIONS_PER_INCLUSION_LIST]
Expand Down Expand Up @@ -87,7 +90,8 @@ def notify_new_inclusion_list(self: ExecutionEngine,
Return ``True`` if and only if the transactions in the inclusion list can be succesfully executed
starting from the execution state corresponding to the `parent_block_hash` in the inclusion list
summary. The execution engine also checks that the total gas limit is less or equal that
```MAX_GAS_PER_INCLUSION_LIST``, and the transactions in the list of transactions correspond to the signed summary
``MAX_GAS_PER_INCLUSION_LIST``, and the transactions in the list of transactions correspond to
the signed summary.
"""
...
```
Expand Down Expand Up @@ -117,7 +121,7 @@ class ExecutionPayload(Container):
withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
blob_gas_used: uint64
excess_blob_gas: uint64
previous_inclusion_list_summary: SignedInclusionListSummary # [New in EIP7547]
previous_inclusion_list_summary: SignedInclusionListSummary # [New in EIP7547]
```

#### `ExecutionPayloadHeader`
Expand All @@ -143,7 +147,7 @@ class ExecutionPayloadHeader(Container):
withdrawals_root: Root
blob_gas_used: uint64
excess_blob_gas: uint64
previous_inclusion_list_summary_root: Root # [New in EIP7547]
previous_inclusion_list_summary_root: Root # [New in EIP7547]
```

#### `BeaconState`
Expand Down Expand Up @@ -192,7 +196,7 @@ class BeaconState(Container):
# Deep history valid from Capella onwards
historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]
# Needed for inclusion list validation
previous_proposer_index: ValidatorIndex # [New in EIP7547]
previous_proposer_index: ValidatorIndex # [New in EIP7547]
```

### Block processing
Expand All @@ -210,7 +214,7 @@ def process_block_header(state: BeaconState, block: BeaconBlock) -> None:
# Verify that the parent matches
assert block.parent_root == hash_tree_root(state.latest_block_header)
# Set previous proposer index before overwriting latest block header
state.previous_proposer_index = state.latest_block_header.proposer_index # [New in EIP7547]
state.previous_proposer_index = state.latest_block_header.proposer_index # [New in EIP7547]
# Cache current block as the new latest block
state.latest_block_header = BeaconBlockHeader(
slot=block.slot,
Expand Down Expand Up @@ -274,13 +278,17 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
withdrawals_root=hash_tree_root(payload.withdrawals),
blob_gas_used=payload.blob_gas_used,
excess_blob_gas=payload.excess_blob_gas,
previous_inclusion_list_summary_root=hash_tree_root(payload.previous_inclusion_list_summary) # [New in EIP7547]
previous_inclusion_list_summary_root=hash_tree_root(payload.previous_inclusion_list_summary) # [New in EIP7547]
)
```

```python
def verify_inclusion_list_summary_signature(state: BeaconState, inclusion_list_summary: SignedInclusionListSummary) -> bool:
signing_root = compute_signing_root(inclusion_list_summary.message, get_domain(state, DOMAIN_INCLUSION_LIST_SUMMARY))
def verify_inclusion_list_summary_signature(state: BeaconState,
inclusion_list_summary: SignedInclusionListSummary) -> bool:
signing_root = compute_signing_root(
inclusion_list_summary.message,
get_domain(state, DOMAIN_INCLUSION_LIST_SUMMARY),
)
previous_proposer = state.validators[state.previous_proposer_index]
return bls.Verify(previous_proposer.pubkey, signing_root, inclusion_list_summary.signature)
```
11 changes: 7 additions & 4 deletions specs/_features/eip7547/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ This is the modification of the fork choice accompanying EIP-7547.
*[New in EIP-7547]*

```python
def verify_inclusion_list(state: BeaconState, block: BeaconBlock, inclusion_list: SignedInclusionList, execution_engine: ExecutionEngine) -> bool:
def verify_inclusion_list(state: BeaconState, block: BeaconBlock, inclusion_list: SignedInclusionList,
execution_engine: ExecutionEngine) -> bool:
"""
returns true if the inclusion list is valid.
"""
Expand All @@ -38,9 +39,10 @@ def verify_inclusion_list(state: BeaconState, block: BeaconBlock, inclusion_list

# Check that the inclusion list is valid
return execution_engine.notify_new_inclusion_list(NewInclusionListRequest(
inclusion_list=inclusion_list.transactions,
summary=inclusion_list.signed_summary.message.summary,
parent_block_hash = state.latest_execution_payload_header.block_hash))
inclusion_list=inclusion_list.transactions,
summary=inclusion_list.signed_summary.message.summary,
parent_block_hash=state.latest_execution_payload_header.block_hash,
))
```

## Updated fork-choice handlers
Expand Down Expand Up @@ -77,6 +79,7 @@ def on_block(store: Store, signed_block_and_inclusion_list: SignedBeaconBlockAnd
assert store.finalized_checkpoint.root == finalized_checkpoint_block

# [New in EIP-7547] Check if the inclusion list is valid.
state = pre_state.copy()
assert verify_inclusion_list(state, block, signed_inclusion_list.signed_summary, block.parent_root)

# Check the block is valid and compute the post-state
Expand Down

0 comments on commit 6dc2894

Please sign in to comment.