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 Add block streams design #9716

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

edwin-greene
Copy link
Contributor

Description:
Adds the design for phase one, support for block stream files.

Related issue(s):

Fixes #9573

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Edwin Greene <[email protected]>
@edwin-greene edwin-greene added enhancement Type: New feature design labels Nov 7, 2024
@edwin-greene edwin-greene self-assigned this Nov 7, 2024
@edwin-greene edwin-greene linked an issue Nov 7, 2024 that may be closed by this pull request
### Block protobuf to mirror node database mapping

#### Contract Create Transaction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More details on the missing entries still to come.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.26%. Comparing base (7be3d87) to head (b900501).
Report is 160 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9716      +/-   ##
============================================
- Coverage     92.32%   92.26%   -0.06%     
- Complexity     7413     7771     +358     
============================================
  Files           911      951      +40     
  Lines         31050    32472    +1422     
  Branches       3978     4118     +140     
============================================
+ Hits          28667    29961    +1294     
- Misses         1450     1546      +96     
- Partials        933      965      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Edwin Greene <[email protected]>
Signed-off-by: Edwin Greene <[email protected]>
Signed-off-by: Edwin Greene <[email protected]>
Signed-off-by: Edwin Greene <[email protected]>
Signed-off-by: Edwin Greene <[email protected]>
Signed-off-by: Edwin Greene <[email protected]>
@edwin-greene edwin-greene marked this pull request as ready for review November 22, 2024 21:33
@edwin-greene edwin-greene requested a review from a team as a code owner November 22, 2024 21:33
```

### Database

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently it is expected that there is a single round per block. The round has a round_number value that currently equals the block number. In the future multiple rounds could be included in a single block. I am not sure if we want to capture this somewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Rounds are sequential right? If so, can future proof by adding round_start, round_end columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I have added them.


## REST API

-Deprecate the REST API's State Proof Alpha. The record files and signature files will no longer be provided in the cloud buckets.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-Deprecate the REST API's State Proof Alpha. The record files and signature files will no longer be provided in the cloud buckets.
- Deprecate the REST API's State Proof Alpha. The record files and signature files will no longer be provided in the cloud buckets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


### Data Flow

![Data Flow](images/blockstream.png)
Copy link
Member

Choose a reason for hiding this comment

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

There's a StreamFileNotifier in between.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks I have added it

```java
package com.hedera.mirror.importer.downloader.block;

public class BlockStreamVerifier implements StreamFileNotifier, Closable {
Copy link
Member

Choose a reason for hiding this comment

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

The StreamFileNotifier is an existing component to batch and send stream files. The BlockStreamVerifier should leverage it, not implement it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, I have updated that part.

Comment on lines 112 to 113
public abstract class StreamPoller<StreamFile> {
public abstract void poll();
Copy link
Member

Choose a reason for hiding this comment

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

Should prefer interfaces

Suggested change
public abstract class StreamPoller<StreamFile> {
public abstract void poll();
public interface StreamPoller<StreamFile> {
void poll();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I have updated it to an interface.

```java
package com.hedera.mirror.common.domain.transaction;

public class BlockItem implements StreamItem {
Copy link
Member

Choose a reason for hiding this comment

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

I assume this won't do any parsing like RecordItem currently does and instead just contain the Transaction, results, output, and state changes? Maybe we can show those fields and make it a simple record?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It corresponds to the protobuf BlockItem. (Maybe it should be removed in favor of just using the protobuf class directly). The block item will only have an eventTransaction or a transactionOutput or one of the other types.

```

### Database

Copy link
Member

Choose a reason for hiding this comment

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

Rounds are sequential right? If so, can future proof by adding round_start, round_end columns.

```java
package com.hedera.mirror.importer.downloader.block;

public class BlockStreamVerifier implements StreamFileNotifier, Closable {
Copy link
Member

Choose a reason for hiding this comment

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

Closable is misspelled. But why is it needed? This should be a singleton bean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks I have removed that part, it will not be needed if StreamFileNotifier is used rather than implemented.

| name | Name of the blk file |
| node_id | |
| prev_hash | block_header.previous_block_hash |
| sidecar_count | Count of all transaction*output.\_transaction type*.sidecars in the blk file |
Copy link
Member

Choose a reason for hiding this comment

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

Should be zero. Sidecars should go away.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it I have updated it with a note.

| prev_hash | block_header.previous_block_hash |
| sidecar_count | Count of all transaction*output.\_transaction type*.sidecars in the blk file |
| size | byte size of the blk file |
| version | Record stream version - Perhaps a new version should be added to indicate "Translated from Block" |
Copy link
Member

Choose a reason for hiding this comment

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

Just assume it's 7.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good I have updated this to 7

| Database | Block Item |
| -------------- | ------------------------------------------------------ |
| entity.id | state_changes[i].state_change.map_update.value.topicId |
| entity.deleted | state_changes[i].state_change.map_update.value.deleted |
Copy link
Member

Choose a reason for hiding this comment

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

This value doesn't exist. This should be true i map_delete present or false for any other update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for spotting, I have updated it to map_delete/key/value

Signed-off-by: Edwin Greene <[email protected]>
Copy link

sonarcloud bot commented Dec 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design enhancement Type: New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HIP-1056: Design block stream support
2 participants