-
Notifications
You must be signed in to change notification settings - Fork 996
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
Fix shard fork choice #1970
Fix shard fork choice #1970
Conversation
1. Add `ShardLatestMessage` dataclass 2. To make it compatible with phase 0 tests and APIs, add `Store.shard_stores: Dict[Shard, ShardStore]` 3. Update `get_forkchoice_store` and `update_latest_messages`
specs/phase1/shard-fork-choice.md
Outdated
@@ -145,9 +142,9 @@ def get_pending_shard_blocks(store: Store, shard_store: ShardStore) -> Sequence[ | |||
#### `on_shard_block` | |||
|
|||
```python | |||
def on_shard_block(store: Store, shard_store: ShardStore, signed_shard_block: SignedShardBlock) -> None: | |||
def on_shard_block(store: Store, shard: Shard, signed_shard_block: SignedShardBlock) -> None: |
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.
I wonder if we should delete assert shard_block.shard == shard
and simplify arguments to
def on_shard_block(store: Store, signed_shard_block: SignedShardBlock) -> None:
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.
agreed
We should just derive the shard
directly from the shard_block
and use the appropriate shard_store
from the store
The BLS-enabled tests require #1973. |
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.
agree with @terencechain. otherwise, PR looks good!
specs/phase1/shard-fork-choice.md
Outdated
@@ -145,9 +142,9 @@ def get_pending_shard_blocks(store: Store, shard_store: ShardStore) -> Sequence[ | |||
#### `on_shard_block` | |||
|
|||
```python | |||
def on_shard_block(store: Store, shard_store: ShardStore, signed_shard_block: SignedShardBlock) -> None: | |||
def on_shard_block(store: Store, shard: Shard, signed_shard_block: SignedShardBlock) -> None: |
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.
agreed
We should just derive the shard
directly from the shard_block
and use the appropriate shard_store
from the store
looks good other than merge conflict |
This is still marked draft. |
The test would not pass if BLS flag is enabled, so kinda depending on #1980 under the surface. |
#1980 merged |
Issue
The shard chain fork choice logic should be separate from different shards. (#1768 D.1)
How did I fix it
ShardLatestMessage
dataclass to store the latest message of per shard.latest_messages: Dict[ValidatorIndex, ShardLatestMessage]
field toShardStore
.Store
schema update.ShardStore
inon_attestation
but I also want to avoid overhaul the existing function APIs and test cases. This PR moveshard_stores: Dict[Shard, ShardStore]
to be one of the fields ofStore
.latest_message
to calculate the shard latest attesting balance.setup.py
: handle thedataclass
classes dependencies.