-
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
Alternative crosslink data construction, take 1 #1278
Conversation
Properties: * Optimal data packing * Fixed depth * All data is encoded; makes fraud proofs not-too-difficult Weaknesses: * Uses SSZ serialization. * Positions of blocks dynamic, so accesses require an extra Merkle branch
) | ||
MAXLEN = ( | ||
BYTES_PER_SHARD_BLOCK_HEADER + BYTES_PER_SHARD_BLOCK_BODY | ||
) * SHARD_SLOTS_PER_EPOCH * MAX_EPOCHS_PER_CROSSLINK |
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.
SHARD_SLOTS_PER_EPOCH
is undefined. Should it be SHARD_SLOTS_PER_BEACON_SLOT
(#1276) * SLOTS_PER_EPOCH
?
@@ -76,7 +79,7 @@ The following types are defined, mapping into `DomainType` (little endian): | |||
|
|||
| Name | Value | | |||
| - | - | | |||
| `PLACEHOLDER` | `2**32` | | |||
| `PLACEHOLDER` | `2**3` | |
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 changed it to 2**3
for testing.
@@ -107,7 +110,7 @@ class ShardBlock(Container): | |||
shard: Shard | |||
beacon_chain_root: Bytes32 | |||
parent_root: Bytes32 | |||
data: ShardBlockBody | |||
body: ShardBlockBody |
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.
Also hotfix in #1298.
def compute_crosslink_data(blocks: Sequence[ShardBlock]) -> Bytes32: | ||
""" | ||
Flattens a series of blocks. Designed to be equivalent to SSZ serializing a list of | ||
flattened blocks with one empty block at the end as a termination marker. |
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.
Could you elaborate what do you mean by "one empty block at the end" here?
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.
Could you elaborate what's the main advantage of this one over just using SSZ serialize
like:
class CrosslinkingBlocks:
data: List[ShardBlock, SHARD_SLOTS_PER_EPOCH * MAX_EPOCHS_PER_CROSSLINK]
assert len(blocks) <= SHARD_SLOTS_PER_EPOCH * MAX_EPOCHS_PER_CROSSLINK
crosslinking_blocks = CrosslinkingBlocks(data=blocks)
return serialize(crosslinking_blocks)
?
|
||
```python | ||
def flatten_block(block: ShardBlock) -> Bytes: | ||
return zpad(serialize(get_shard_header(block)), BYTES_PER_SHARD_BLOCK_HEADER) + serialize(block.body) |
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 added serialize()
here, correct?
Co-Authored-By: Hsiao-Wei Wang <[email protected]>
positions = [4 * len(blocks)] | ||
bodies = [] | ||
for block in blocks: | ||
bodies.append(flatten_block(block)) |
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.
Doesn't flattening the block here reduce our ability to construct proofs about components of a block through the crosslink root? Still possible but not as clean due to flattening to bytes
I wouldn't see that as a weakness, if it is the right tool for the job, I think we should be able to bring it into consensus. |
agreed. |
Co-Authored-By: Hsiao-Wei Wang <[email protected]>
Closing -- superseded by #1294 |
Properties:
Weaknesses: