-
Notifications
You must be signed in to change notification settings - Fork 998
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
Revamp 1_shard-data-chains.md #1383
Conversation
WIP! * Significant simplifications * A few bug fixes * Lots of cleanups and reorganising (making it consistent with `0_beacon-chain.md`) * Likely a few bugs introduced
1) Make `ShardBlock` and `ShardState` flat containers (as opposed to plain containers) 2) Make Gwei deltas `int64` (as opposed `uint64`) 3) Make `older_committee_deltas` a `Vector` (as opposed to `List`) 4) Apply size fee on block body only (as opposed to block header and body) 5) Enshrine minimum "extra" block body fee for proposers (reusing `PROPOSER_REWARD_QUOTIENT`) 6) Fix bugs reported by @terencechain and @hwwhww 👍
Co-Authored-By: terence tsao <terence@prysmaticlabs.com>
specs/core/1_shard-data-chains.md
Outdated
|
||
```python | ||
class ShardBlockCore(Container): | ||
class ShardBlock(FlatContainer): |
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.
This is actually a (big) problem with this approach. With a flat container, you no longer have this nice property that an object with an entire subtree substituted with its root necessarily has the same hash tree root as the original object, so you can't have shard blocks and shard block headers in the same way. Not sure how to get around this within the FlatContainer model.
This is arguably one reason why not doing flat containers and instead taking Danny's suggestion and having "embedded vectors (and containers)" would be better. Basically, the idea would be that if you have a container as follows:
class Foo(Container):
bar: uint64
baz: Embedded[Vector[uint64, 4]]
bav: Bytes32
It would be treated identically to:
class Foo(Container):
bar: uint64
baz_0: uint64
baz_1: uint64
baz_2: uint64
baz_3: uint64
bav: Bytes32
This way you avoid introducing a separate type of container and instead have flattening as a feature that you can use or not use for specific elements at will.
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.
Was just about to question if we indeed get this property anymore. The embedded looks like a reasonable approach
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.
So are we going to replace FlatContainer with Embedded here? I guess the attestations
and signature
would need to be part of a 2-item Embedded container where the items are themselves Embedded to get flatness while gaining the ability to use the standard signature root method?
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.
This is awesome! super pleased with the parallels to the structure in phase 0. It makes it really easy to reason about and check for correctness.
Great work :)
I have a number of comments. I'm not 100% done reviewing, but don't want to leave you hanging as I'll be afk for much of the rest of the day. Trying to finish my review up tonight
specs/core/1_shard-data-chains.md
Outdated
|
||
```python | ||
class ShardBlockCore(Container): | ||
class ShardBlock(FlatContainer): |
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.
Was just about to question if we indeed get this property anymore. The embedded looks like a reasonable approach
body_root: Hash | ||
block_size_sum: uint64 | ||
aggregation_bits: Bitvector[2 * MAX_PERIOD_COMMITTEE_SIZE] | ||
attestations: BLSSignature |
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.
Any reasons we not using attestation_signatures
? I find attestations
a bit miss-leading
if validate_state_root: | ||
assert block.state_root == hash_tree_root(shard_state) | ||
# Return post-state | ||
return shard_state | ||
``` | ||
|
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.
### Slot processing |
Shard chain CI cleanup
Shard chain sanity test
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.
great work! still things to be done and some potential changes to discuss with crosslinking, but this is good enough to get into dev for now
TODO:
PR dependencies:
compute_proposer_index
from Improve beacon proposer selection logic #1371Renamings:
Substantive changes:
FlatContainer
for shard blocks and stateVector
s instead ofList
s in shard state to be friendly to flatteningShardCheckpoint
s (as opposed toparent_root
s)SHARD_HEADER_SIZE
(simpler and partially cachable Merkleisation)get_shard_proposer_index
(also make it consistent with phase 0—see Improve beacon proposer selection logic #1371)receipt_root
(instead useolder_committee_rewards
and compute indices on the beacon chain)Gwei
everywhere (and reuseget_base_reward
from phase 0)_deltas
List[byte, SHARD_BLOCK_SIZE_LIMIT - SHARD_HEADER_SIZE]
(as opposed toBytes[SHARD_BLOCK_SIZE_LIMIT - SHARD_HEADER_SIZE]
)2 *
inrange(len(persistent_committee), 2 * MAX_PERSISTENT_COMMITTEE_SIZE)
get_shard_committee
MAX_BLOCK_SIZE_PRICE
less conservative (32 ETH as opposed to 1 ETH)—fees are split across the shard committee anywayshard
check inprocess_shard_block_header
beacon_chain_root
check inprocess_shard_block_header
len(data.body)
tolen(data.body) + SHARD_HEADER_SIZE
inprocess_shard_block
(as forblock_size_sum
)process_shard_block_size_fee
when computingMAX_BLOCK_SIZE_PRICE
(should have been// SLOTS_PER_EPOCH
as opposed to* SLOTS_PER_EPOCH
)block.parent_root == Bytes32()
to bypass parent root checkMisc cosmetic changes:
1_beacon-chain-misc.md
—see Starting on phase 1 misc beacon changes #1323)MIN_BLOCK_SIZE_PRICE
parameterPHASE_1_FORK_SLOT
,CROSSLINK_LOOKBACK
,PLACEHOLDER
parametersSHARD_SLOTS_PER_BEACON_SLOT
in favour ofSHARD_SLOTS_PER_EPOCH
raise Exception
which is not used in phase 0shard_block_transition
into three functions (header, attestations, block size fee)BeaconState
parameter, thenShardState
, thenShard
)state
everywhere forBeaconState
, andshard_state
forShardState
)compute_slot_of_shard_slot