-
Notifications
You must be signed in to change notification settings - Fork 31
pqdevnet0: container specs #5
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
36fa692
feat: 1st draft pqdevnet0
unnawut 3ce36d9
docs: improve descriptions
unnawut 0c0b13f
docs: annotate divergences from 3SF-mini.py
unnawut b39afbd
fix: deps order
unnawut ddfd5fb
refactor: move from remerkleable to ethereum_types and py-ssz
unnawut 703f63a
fix: add docs and import order
unnawut f77a05b
fix: move pqdevnet to client and out of subspecs folder
unnawut 24767f0
fix: blank lines
unnawut ef95e42
refactor: root and slot pairs become checkpoints
unnawut 4c89d14
fix: use Union for optionals
unnawut bc1b305
fix: unused import
unnawut b239dd6
fix: remove no longer used remerkleable
unnawut e722767
docs: consolidted comments
unnawut 5dc1795
fix: remove Union optional
unnawut ac41ad4
docs: add change comment
unnawut 1465223
fix: remove dataclass
unnawut 1f8b78f
fix: add tests for all containers
unnawut e6392a7
fix: import ordering
unnawut bfcdca8
fix: ruff format
unnawut 33603bc
fix: mypy
unnawut 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 hidden or 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 hidden or 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 @@ | ||
| """Specification for pqdevnet-0""" |
This file contains hidden or 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,27 @@ | ||
| """ | ||
| A `Block` is a single link in the Lean Consensus chain. Each `Block` contains | ||
| associated metadata like the slot number, parent block hash and votes. | ||
| Together, these blocks form a cryptographically secure journal recording the | ||
| history of all state transitions that have happened since the genesis of the | ||
| chain. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass | ||
| from remerkleable.basic import uint64 | ||
| from remerkleable.byte_arrays import Bytes32 | ||
| from remerkleable.complex import List | ||
| from pydantic import BaseModel, ConfigDict | ||
|
|
||
| from preset import VALIDATOR_REGISTRY_LIMIT | ||
| from vote import Vote | ||
|
|
||
| @dataclass | ||
| class Block(BaseModel): | ||
| model_config = ConfigDict(arbitrary_types_allowed=True) | ||
|
|
||
| slot: uint64 | ||
unnawut marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| parent: Bytes32 | ||
unnawut marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| votes: List[Vote, VALIDATOR_REGISTRY_LIMIT] | ||
| # Diverged from 3SF-mini.py: Removed Optional from `state_root` | ||
| state_root: Bytes32 | ||
This file contains hidden or 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,26 @@ | ||
| """ | ||
| The `preset` module contains the parameters that are used to configure the | ||
| Lean Consensus chain. | ||
| """ | ||
|
|
||
| from remerkleable.basic import uint64 | ||
|
|
||
| # Time parameters | ||
| # --------------------------------------------------------------- | ||
|
|
||
| # 4 seconds | ||
| SLOT_DURATION_MS = 4000 | ||
|
|
||
| # Basis points (out of 10000) | ||
| PROPOSER_REORG_CUTOFF_BPS: 2500 | ||
| VOTE_DUE_BPS: 5000 | ||
| FAST_CONFIRM_DUE_BPS: 7500 | ||
| VIEW_FREEZE_CUTOFF_BPS: 7500 | ||
|
|
||
| # Misc | ||
| # --------------------------------------------------------------- | ||
|
|
||
| # 2^18, enough for 2^18 / (60 / 4) / 60 / 24 = 12.1 days | ||
| MAX_HISTORICAL_BLOCK_HASHES: uint64 = 262144 | ||
|
|
||
| VALIDATOR_REGISTRY_LIMIT: uint64 = 4096 |
This file contains hidden or 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,40 @@ | ||
| """ | ||
| A `State` is a collection of metadata that describes the current state of the | ||
| Lean Consensus chain. It contains information about the latest justified and | ||
| finalized blocks, as well as the historical block hashes and justified slots. | ||
|
|
||
| It is used to verify the integrity of the chain and to ensure that the chain is | ||
| progressing correctly. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass | ||
| from remerkleable.basic import uint64 | ||
| from remerkleable.bitfields import Bitlist | ||
| from remerkleable.byte_arrays import Bytes32 | ||
| from remerkleable.complex import List | ||
| from pydantic import BaseModel, ConfigDict | ||
|
|
||
| from preset import MAX_HISTORICAL_BLOCK_HASHES, VALIDATOR_REGISTRY_LIMIT | ||
|
|
||
| @dataclass | ||
| class State(BaseModel): | ||
| model_config = ConfigDict(arbitrary_types_allowed=True) | ||
|
|
||
| # Diverged from 3SF-mini.py: | ||
| # - Removed `config: Config` from the state | ||
| # - Using uint64 instead of native int for all fields | ||
| # - Using Bytes32 instead of native str for all fields | ||
|
|
||
| latest_justified_hash: Bytes32 | ||
| latest_justified_slot: uint64 | ||
|
|
||
| latest_finalized_hash: Bytes32 | ||
| latest_finalized_slot: uint64 | ||
|
|
||
| historical_block_hashes: List[Bytes32, MAX_HISTORICAL_BLOCK_HASHES] | ||
| justified_slots: List[bool, MAX_HISTORICAL_BLOCK_HASHES] | ||
|
|
||
| # Diverged from 3SF-mini.py: | ||
| # - Flattened `justifications: Dict[str, List[bool]]` for SSZ compatibility | ||
| justifications_roots: List[Bytes32, MAX_HISTORICAL_BLOCK_HASHES] | ||
| justifications_validators: Bitlist[MAX_HISTORICAL_BLOCK_HASHES * VALIDATOR_REGISTRY_LIMIT] |
This file contains hidden or 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,27 @@ | ||
| """ | ||
| A `Vote` is a single vote for a block in the Lean Consensus chain. Each `Vote` | ||
| contains information about the validator that voted, the slot of the block they | ||
| voted for, and the block hash they voted for. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass | ||
| from remerkleable.basic import uint64 | ||
| from remerkleable.byte_arrays import Bytes32 | ||
| from pydantic import BaseModel, ConfigDict | ||
|
|
||
| @dataclass | ||
| class Vote(BaseModel): | ||
| model_config = ConfigDict(arbitrary_types_allowed=True) | ||
|
|
||
| # Diverged from 3SF-mini.py: | ||
| # - Using `uint64` instead of native `int` for all fields | ||
| # - Using `Bytes32` instead of native `str` for all fields | ||
|
|
||
| validator_id: uint64 | ||
| slot: uint64 | ||
| head: Bytes32 | ||
| head_slot: uint64 | ||
| target: Bytes32 | ||
| target_slot: uint64 | ||
| source: Bytes32 | ||
| source_slot: uint64 |
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.
Uh oh!
There was an error while loading. Please reload this page.