Skip to content
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

HIP-1056: Block Streams #1056

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a9a980
Initial upload of the block stream HIP
rbair23 Oct 1, 2024
f56a4f5
Update with HIP #
rbair23 Oct 1, 2024
51d17a1
Merge f56a4f588c66cb85c3a76a36d743526a799925b0 into da405eec611610992…
rbair23 Oct 1, 2024
33d5768
Assigning HIP 1056 and renaming file to hip-1056.md
actions-user Oct 1, 2024
a5cff30
Added round header item image and addressed comments
Nana-EC Oct 15, 2024
dc22fd1
Add updated block stream merkle svg and rejected ideas
Nana-EC Oct 17, 2024
2b44d4e
More updates and added open Issues
Nana-EC Oct 25, 2024
1cd4d6f
Pushed comunity wording fix suggestions. Thanks Kelly, Michael T, Der…
Nana-EC Oct 25, 2024
e7d07d1
Fixed proto indents
Nana-EC Oct 31, 2024
bddecaf
Addressed comments up to 11/17/24. Thanks jsync-swirlds, poulok, stev…
Nana-EC Nov 17, 2024
b979ffd
Fixed image paths, added proof types and started a table with options
Nana-EC Nov 17, 2024
8b1f83d
Added side car and signature sto diagram and added proof scenarios
Nana-EC Nov 17, 2024
a73475c
Fix table contents
Nana-EC Nov 17, 2024
470b928
Cleaned up platform related proto
Nana-EC Nov 17, 2024
6c76dce
Cleaned up and address some comments
Nana-EC Nov 26, 2024
e72e10a
Fix background images
Nana-EC Nov 26, 2024
e79b9a4
Add protofuf asset files
Nana-EC Nov 26, 2024
79719fc
Minor changes and removed block service
Nana-EC Dec 2, 2024
49722aa
Removed block file concept and updated open issues
Nana-EC Dec 2, 2024
ecdf2ef
Fix HSCS transaction outputs
Nana-EC Dec 2, 2024
b878ace
Push fixed HSC proto
Nana-EC Dec 2, 2024
e34a186
More fixes and improvemnts in text and proto
Nana-EC Dec 2, 2024
0c4c239
Added a good chunk or proto indentation
Nana-EC Dec 3, 2024
a01b57f
Update sidecar references and Open Issues
Nana-EC Dec 3, 2024
03784ce
Added clarification regarding consistency of singleton and queue stat…
Nana-EC Dec 3, 2024
63bd540
Removed ContractStateChange as it's contents are covered by StateChan…
Nana-EC Dec 3, 2024
ec00e89
Megamap reference added to open issues
Nana-EC Dec 3, 2024
fd643cc
Moved automatic_token_associations and token_transfer_lists out of Tr…
Nana-EC Dec 3, 2024
231a137
Updated sentence on platform state changes
Nana-EC Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions HIP/hip-1056.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ additional block and state APIs that benefit the Hedera community (e.g., state p
"downstream service" that can consume block streams.

TSS signatures refer to a single, aggregated TSS-BLS signature that verifies a block has been signed by a threshold of
Hedera consensus weight. Each block will include TSS signatures, offering verifiable assurance that the block was
Hedera consensus stake weight. Each block will include TSS signatures, offering verifiable assurance that the block was
produced by a configured threshold of the network stake weight.

Subsequent HIPs, to be introduced at a later date, will provide details on Block Nodes and TSS Signatures.
Expand Down Expand Up @@ -188,7 +188,7 @@ transaction execution. These are hashed separately into two different *block str
we can separate out a subset of historical blocks with just their input items, or just output items. That subset block stream could then be used
for transaction replay or transaction execution verification, for example.

![Block Stream Merkle Tree](../assets/hip-blocks/block-stream-merkle.png)
![Block Stream Merkle Tree](../assets/hip-blocks/block-stream-merkle.svg)

Consensus nodes have a `state merkle tree`, which is a merkle tree containing the current state of the consensus node.
The block stream has a separate `block stream merkle tree` which is a merkle tree of all the items in the block stream
Expand Down Expand Up @@ -246,7 +246,7 @@ full complexity of the merkle state tree.
can authenticate transactional data without the cost and complexity of downloading multiple signature files for
verification.
3. As a verifier for a network, I want a single, self-contained stream of data with aggregated signature signed by a
threshold weight of nodes, so that I can cost-effectively confirm that the stream represents the consensus output of
threshold of stake weights, so that I can cost-effectively confirm that the stream represents the consensus output of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really decide what terms we are going to use. Some places use stake weights and others simply use weight. Either is fine as long as it is used consistently. Inconsistent use will contribute to confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to stake weight

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i forgot that I said "either is fine" in this comment. I posted another comment above saying that "stake weight" is confusing. I've always thought this, but know it's a commonly used term so I must have been feeling particularly lenient the day i made this original comment. Happy to discuss offline. I don't want to cause uncecessary churn.

the network.
4. As a downstream developer, I want a low latency feed that provides the state changes associated with transaction(s)
within a block, so that I can interact with state changes with the smallest possible delay.
Expand Down Expand Up @@ -1068,7 +1068,7 @@ message SingletonUpdateChange {
* A change to the platform state singleton.
*/
com.hedera.hapi.platform.state.PlatformState platform_state_value = 12;

/**
* A change to the roster state singleton.
*/
Expand Down Expand Up @@ -1579,7 +1579,7 @@ message MerkleSiblingHash {

The following diagram illustrates what the 4 sub trees contain and how blocks are chained.

![Block Stream Merkle](../assets/hip-blocks/block-stream-merkle.png)
![Block Stream Merkle](../assets/hip-blocks/block-stream-merkle.svg)

The input and output item merkle trees are balanced base 2 size binary trees. The leaves across the bottom are the items in the order they occur in the block. If the total number of input or output items contained in the block is less than a power of 2 then the empty leaves are assumed to be `null` (zero length bytes). The nature of the merkle tree creation logic allows for the consensus node or block validator to calculate the input and output tree merkle hashes as items are received in a streaming way.

Expand Down Expand Up @@ -1730,11 +1730,38 @@ clients consuming a block stream.
## Rejected Ideas

### Re-writing pre block stream transaction body protobufs
The previous record streams protobuf contained deprecated fields and messages that could be better grouped for efficiency and consistency.
With a new data stream there was a consideration to rewrite the previous format.
Unfortunately, the TransactionBody message itself cannot be re-written due to signing verification implications on backwards compatability.
This is because mirror node and other products need to be able to parse historical transaction bytes utilizing older formats and verify them.
However, the transaction wrappers in the old formats could still be optimized. This may be explored in the future.
The previous record streams protobuf contained deprecated fields and messages that could be better grouped for efficiency
and consistency. With a new data stream there was a consideration to rewrite the previous format.
Unfortunately, the TransactionBody message itself cannot be re-written due to signing verification implications on backwards
compatability. This is because mirror node and other products need to be able to parse historical transaction bytes utilizing
older formats and verify them. However, the transaction wrappers in the old formats could still be optimized. This may be
explored in the future.

### Ensuring all events across upgrade boundaries are captured
The block streams design ensures that all events are captured and that blocks are signed. However, how does one denote the last
block before upgrade if the act of signing a block `n` produces new events that must be recorded in block `n+1`?
One consideration was to create a marker after which a future block may be ignored in terms of signing requirements. Though this
could work it would result in Blocks that are unsigned even if they are ignored. This also makes stream consideration by clients
a bit more complex as they would have to be aware of and handle this marker case.
The final solution was to capture events created by signing Block `n` in the Pre Consensus Event Stream (PCES) across the upgrade
boundary for insertion into a future Block `n+1` after upgrade.

#### Impact of large entities when externalizing individual entity state.
The Block Stream plans to ensure visibilty of all modified entities by externalizing the full entity state in the stream.
This is to solve the issue of partial data in record streams where a client may miss the externalization of state data and would
therefore possess a partial state for entities with few easy options to retrieve the missing data.
By externalizing the full entity state in tehe block stream a client can get the complete entity details on any update and won't have
jsync-swirlds marked this conversation as resolved.
Show resolved Hide resolved
to employ upsert logic. An emergent feature when externalizing the full entity state of modified entities is that entities who's
properties are modified multiple times would be externalized in the stream multiple times.
jsync-swirlds marked this conversation as resolved.
Show resolved Hide resolved
These accounts may have multiple keys and other potentially large list properties (e.g. approvals) that may result in a large block size.
To manage this an idea inspired from video iframe approach (when the image changes the whole entity is sent, if not only diffs
are sent) was considered. In this case every entity could have a last updated counter that is updated on entity changes, if the
value is over a certain threshold then the whole entity is externalized, if not only deltas would be externalized. This would optimize
how far back a client would have to go to retrieve state info. However, this approach would require the counter to be stored in state
for every entity which has undesired impacts on state size.
Another inspired approach is that on the first observation of an entity in a block would cause the full entity to be extenralized,
after that only the delta changes are externalized for the remainder of the block.
In this way any consumer of a block would have the complete state by applying the diffs onto the initial state.
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved

## Copyright/license

Expand Down
Binary file removed assets/hip-blocks/block-stream-merkle.png
Binary file not shown.
4 changes: 4 additions & 0 deletions assets/hip-blocks/block-stream-merkle.svg
poulok marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading