-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EIP-7805 (FOCIL) specs #4003
Open
terencechain
wants to merge
45
commits into
ethereum:dev
Choose a base branch
from
terencechain:focil-consensus
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
3a16a0e
Add focil containers
terencechain fa27c8f
Add process inclusion list aggregate
terencechain 3c86963
Add inclusion list gossip conditions
terencechain 8a1e940
Add execution api
terencechain 833be94
Add validator spec
terencechain a2b68a7
Review feedback
terencechain fb4a3c3
Update forkchoice
terencechain c7a056b
Update based on latest discussion. No more IL aggregate
terencechain f84556c
Update fork-choice.md
terencechain 2787b0d
Update per https://ethresear.ch/t/focil-cl-el-workflow/20526
terencechain 0b09f96
Address feedback
terencechain 6056b69
Clarify forkchoice and p2p
terencechain a8aec7c
Remove local
terencechain cbe6129
suggested changes
fradamt 0efcf13
Merge pull request #5 from fradamt/focil-patch
terencechain f151c7c
replace parent_root with il_committee_root
fradamt b181655
add timing logic (deaadlines) to IL processing
fradamt 0681f8c
missing :
fradamt 2861684
Merge pull request #6 from fradamt/focil-patch
terencechain e678deb
Use eip7805
terencechain e9fdfc6
@jtraglia's suggestions
terencechain 6ce0077
Update new inclusion list comments
terencechain be471b8
P2p spec feedbacks
terencechain c443db0
Add get attester head
terencechain c8b6296
Fix typo and make CI happy
hwwhww 7fa44f4
fix byte limit check
fradamt 84acfbb
ensure valid committee with <16 validators
nerolation 702b9e5
Merge pull request #7 from nerolation/patch-1
terencechain 561aed7
Merge branch 'dev' into focil-consensus
jtraglia c762a33
Add eip7805 to list of executable specs
jtraglia 20b0c50
Fix simple linter warnings
jtraglia aca38ea
Fix some more linter issues
jtraglia 1c6761a
Add execution_requests_list to notify_new_payload
jtraglia d63042e
Fix things regarding engine API
jtraglia 86c86d0
Update eth2spec before linting
jtraglia 7d8e6fb
Expand acronym in DOMAIN_IL_COMMITTEE and IL_COMMITTEE_SIZE
jtraglia 19b50a6
Rename il_transactions to inclusion_list_transactions
jtraglia f25efbf
Change engine API param type to Sequence[Transaction]
jtraglia 5a37c91
Fix various nits
jtraglia c411d45
Replace "since" with "up to"
jtraglia dcd31d6
Pull in electra's changes to verify_and_notify_new_payload
jtraglia 3652904
Change inclusion_list_transactions to a Sequence
jtraglia 2781459
Make some improvements to fork-choice doc
jtraglia 7a2cb7a
Make time params work with minimal
jtraglia 91054e6
Fix networking toc
jtraglia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from .base import BaseSpecBuilder | ||
from ..constants import EIP7805 | ||
|
||
|
||
class EIP7805SpecBuilder(BaseSpecBuilder): | ||
fork: str = EIP7805 | ||
|
||
|
||
@classmethod | ||
def execution_engine_cls(cls) -> str: | ||
return """ | ||
class NoopExecutionEngine(ExecutionEngine): | ||
|
||
def notify_new_payload(self: ExecutionEngine, | ||
execution_payload: ExecutionPayload, | ||
parent_beacon_block_root: Root, | ||
execution_requests_list: Sequence[bytes], | ||
inclusion_list_transactions: | ||
List[Transaction, MAX_TRANSACTIONS_PER_INCLUSION_LIST]) -> 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, | ||
execution_requests_list: Sequence[bytes], | ||
inclusion_list_transactions: | ||
List[Transaction, MAX_TRANSACTIONS_PER_INCLUSION_LIST]) -> 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 | ||
|
||
|
||
EXECUTION_ENGINE = NoopExecutionEngine()""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
# EIP-7805 -- The Beacon Chain | ||
|
||
## Table of contents | ||
|
||
<!-- TOC --> | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Introduction](#introduction) | ||
- [Preset](#preset) | ||
- [Domain types](#domain-types) | ||
- [Inclusion List Committee](#inclusion-list-committee) | ||
- [Execution](#execution) | ||
- [Containers](#containers) | ||
- [New containers](#new-containers) | ||
- [`InclusionList`](#inclusionlist) | ||
- [`SignedInclusionList`](#signedinclusionlist) | ||
- [Predicates](#predicates) | ||
- [New `is_valid_inclusion_list_signature`](#new-is_valid_inclusion_list_signature) | ||
- [Beacon State accessors](#beacon-state-accessors) | ||
- [New `get_inclusion_list_committee`](#new-get_inclusion_list_committee) | ||
- [Beacon chain state transition function](#beacon-chain-state-transition-function) | ||
- [Execution engine](#execution-engine) | ||
- [Request data](#request-data) | ||
- [Modified `NewPayloadRequest`](#modified-newpayloadrequest) | ||
- [Engine APIs](#engine-apis) | ||
- [Modified `is_valid_block_hash`](#modified-is_valid_block_hash) | ||
- [Modified `notify_new_payload`](#modified-notify_new_payload) | ||
- [Modified `verify_and_notify_new_payload`](#modified-verify_and_notify_new_payload) | ||
- [Modified `process_execution_payload`](#modified-process_execution_payload) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- /TOC --> | ||
|
||
## Introduction | ||
|
||
This is the beacon chain specification to add EIP-7805 / fork-choice enforced, committee-based inclusion list (FOCIL) mechanism to allow forced transaction inclusion. Refers to the following posts: | ||
- [Fork-Choice enforced Inclusion Lists (FOCIL): A simple committee-based inclusion list proposal](https://ethresear.ch/t/fork-choice-enforced-inclusion-lists-focil-a-simple-committee-based-inclusion-list-proposal/19870/1) | ||
- [FOCIL CL & EL workflow](https://ethresear.ch/t/focil-cl-el-workflow/20526) | ||
*Note:* This specification is built upon [Electra](../../electra/beacon_chain.md) and is under active development. | ||
|
||
## Preset | ||
|
||
### Domain types | ||
|
||
| Name | Value | | ||
| - | - | | ||
| `DOMAIN_INCLUSION_LIST_COMMITTEE` | `DomainType('0x0C000000')` | | ||
|
||
### Inclusion List Committee | ||
|
||
| Name | Value | | ||
| - | - | | ||
| `INCLUSION_LIST_COMMITTEE_SIZE` | `uint64(2**4)` (=16) | | ||
|
||
### Execution | ||
|
||
| Name | Value | | ||
| - | - | | ||
| `MAX_TRANSACTIONS_PER_INCLUSION_LIST` | `uint64(1)` **TBD** | | ||
|
||
## Containers | ||
|
||
### New containers | ||
|
||
#### `InclusionList` | ||
|
||
```python | ||
class InclusionList(Container): | ||
slot: Slot | ||
validator_index: ValidatorIndex | ||
inclusion_list_committee_root: Root | ||
transactions: List[Transaction, MAX_TRANSACTIONS_PER_INCLUSION_LIST] | ||
``` | ||
|
||
#### `SignedInclusionList` | ||
|
||
```python | ||
class SignedInclusionList(Container): | ||
message: InclusionList | ||
signature: BLSSignature | ||
``` | ||
|
||
### Predicates | ||
|
||
#### New `is_valid_inclusion_list_signature` | ||
|
||
```python | ||
def is_valid_inclusion_list_signature( | ||
state: BeaconState, | ||
signed_inclusion_list: SignedInclusionList) -> bool: | ||
""" | ||
Check if ``signed_inclusion_list`` has a valid signature. | ||
""" | ||
message = signed_inclusion_list.message | ||
index = message.validator_index | ||
pubkey = state.validators[index].pubkey | ||
domain = get_domain(state, DOMAIN_INCLUSION_LIST_COMMITTEE, compute_epoch_at_slot(message.slot)) | ||
signing_root = compute_signing_root(message, domain) | ||
return bls.Verify(pubkey, signing_root, signed_inclusion_list.signature) | ||
``` | ||
|
||
### Beacon State accessors | ||
|
||
#### New `get_inclusion_list_committee` | ||
|
||
```python | ||
def get_inclusion_list_committee(state: BeaconState, | ||
slot: Slot) -> Vector[ValidatorIndex, INCLUSION_LIST_COMMITTEE_SIZE]: | ||
epoch = compute_epoch_at_slot(slot) | ||
seed = get_seed(state, epoch, DOMAIN_INCLUSION_LIST_COMMITTEE) | ||
indices = get_active_validator_indices(state, epoch) | ||
start = (slot % SLOTS_PER_EPOCH) * INCLUSION_LIST_COMMITTEE_SIZE | ||
end = start + INCLUSION_LIST_COMMITTEE_SIZE | ||
return [ | ||
indices[compute_shuffled_index(uint64(i % len(indices)), uint64(len(indices)), seed)] | ||
for i in range(start, end) | ||
] | ||
``` | ||
|
||
## Beacon chain state transition function | ||
|
||
### Execution engine | ||
|
||
#### Request data | ||
|
||
##### Modified `NewPayloadRequest` | ||
|
||
```python | ||
@dataclass | ||
class NewPayloadRequest(object): | ||
execution_payload: ExecutionPayload | ||
versioned_hashes: Sequence[VersionedHash] | ||
parent_beacon_block_root: Root | ||
execution_requests: ExecutionRequests | ||
inclusion_list_transactions: Sequence[Transaction] # [New in EIP-7805] | ||
``` | ||
|
||
#### Engine APIs | ||
|
||
##### Modified `is_valid_block_hash` | ||
|
||
*Note*: The function `is_valid_block_hash` is modified to include the additional `inclusion_list_transactions`. | ||
|
||
```python | ||
def is_valid_block_hash(self: ExecutionEngine, | ||
execution_payload: ExecutionPayload, | ||
parent_beacon_block_root: Root, | ||
execution_requests_list: Sequence[bytes], | ||
inclusion_list_transactions: Sequence[Transaction]) -> bool: | ||
""" | ||
Return ``True`` if and only if ``execution_payload.block_hash`` is computed correctly. | ||
""" | ||
... | ||
``` | ||
|
||
##### Modified `notify_new_payload` | ||
|
||
*Note*: The function `notify_new_payload` is modified to include the additional `inclusion_list_transactions`. | ||
|
||
```python | ||
def notify_new_payload(self: ExecutionEngine, | ||
execution_payload: ExecutionPayload, | ||
parent_beacon_block_root: Root, | ||
execution_requests_list: Sequence[bytes], | ||
inclusion_list_transactions: Sequence[Transaction]) -> bool: | ||
""" | ||
Return ``True`` if and only if ``execution_payload`` and ``execution_requests_list`` | ||
are valid with respect to ``self.execution_state``. | ||
""" | ||
# TODO: move this outside of notify_new_payload. | ||
# If execution client returns block does not satisfy inclusion list transactions, cache the block | ||
# store.unsatisfied_inclusion_list_blocks.add(execution_payload.block_root) | ||
... | ||
``` | ||
|
||
##### Modified `verify_and_notify_new_payload` | ||
|
||
*Note*: The function `verify_and_notify_new_payload` is modified to pass the additional parameter | ||
`inclusion_list_transactions` when calling `notify_new_payload` in EIP-7805. | ||
|
||
```python | ||
def verify_and_notify_new_payload(self: ExecutionEngine, | ||
new_payload_request: NewPayloadRequest) -> bool: | ||
""" | ||
Return ``True`` if and only if ``new_payload_request`` is valid with respect to ``self.execution_state``. | ||
""" | ||
execution_payload = new_payload_request.execution_payload | ||
parent_beacon_block_root = new_payload_request.parent_beacon_block_root | ||
execution_requests_list = get_execution_requests_list(new_payload_request.execution_requests) | ||
inclusion_list_transactions = new_payload_request.inclusion_list_transactions # [New in EIP-7805] | ||
|
||
if b'' in execution_payload.transactions: | ||
return False | ||
|
||
if not self.is_valid_block_hash( | ||
execution_payload, | ||
parent_beacon_block_root, | ||
execution_requests_list): | ||
return False | ||
|
||
if not self.is_valid_versioned_hashes(new_payload_request): | ||
return False | ||
|
||
# [Modified in EIP-7805] | ||
if not self.notify_new_payload( | ||
execution_payload, | ||
parent_beacon_block_root, | ||
execution_requests_list, | ||
inclusion_list_transactions): | ||
return False | ||
|
||
return True | ||
``` | ||
|
||
##### Modified `process_execution_payload` | ||
|
||
```python | ||
def process_execution_payload(state: BeaconState, body: BeaconBlockBody, execution_engine: ExecutionEngine) -> None: | ||
payload = body.execution_payload | ||
|
||
# Verify consistency of the parent hash with respect to the previous execution payload header | ||
assert payload.parent_hash == state.latest_execution_payload_header.block_hash | ||
# Verify prev_randao | ||
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state)) | ||
# Verify timestamp | ||
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot) | ||
# Verify commitments are under limit | ||
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK_ELECTRA | ||
# Verify the execution payload is valid | ||
versioned_hashes = [kzg_commitment_to_versioned_hash(commitment) for commitment in body.blob_kzg_commitments] | ||
# Verify inclusion list transactions | ||
inclusion_list_transactions: Sequence[Transaction] = [] # TODO: where do we get this? | ||
assert len(inclusion_list_transactions) <= MAX_TRANSACTIONS_PER_INCLUSION_LIST | ||
# Verify the payload with the execution engine | ||
assert execution_engine.verify_and_notify_new_payload( | ||
NewPayloadRequest( | ||
execution_payload=payload, | ||
versioned_hashes=versioned_hashes, | ||
parent_beacon_block_root=state.latest_block_header.parent_root, | ||
execution_requests=body.execution_requests, | ||
inclusion_list_transactions=inclusion_list_transactions, | ||
) | ||
) | ||
# Cache execution payload header | ||
state.latest_execution_payload_header = ExecutionPayloadHeader( | ||
parent_hash=payload.parent_hash, | ||
fee_recipient=payload.fee_recipient, | ||
state_root=payload.state_root, | ||
receipts_root=payload.receipts_root, | ||
logs_bloom=payload.logs_bloom, | ||
prev_randao=payload.prev_randao, | ||
block_number=payload.block_number, | ||
gas_limit=payload.gas_limit, | ||
gas_used=payload.gas_used, | ||
timestamp=payload.timestamp, | ||
extra_data=payload.extra_data, | ||
base_fee_per_gas=payload.base_fee_per_gas, | ||
block_hash=payload.block_hash, | ||
transactions_root=hash_tree_root(payload.transactions), | ||
withdrawals_root=hash_tree_root(payload.withdrawals), | ||
blob_gas_used=payload.blob_gas_used, | ||
excess_blob_gas=payload.excess_blob_gas, | ||
) | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we introduce a
SignedInclusionList
container instead of just adding the signature field directly ontoInclusionList
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the beacon node initially retrieves the IL transactions from the execution client wouldn't it create the (unsigned)
InclusionList
and pass it through the beacon-api to the validator client to sign over it? only after that the validator client would submit theSignedInclusionList
to be broadcast