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 11 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.27%. Comparing base (7be3d87) to head (4c5317b).
Report is 120 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9716      +/-   ##
============================================
- Coverage     92.32%   92.27%   -0.06%     
- Complexity     7413     7770     +357     
============================================
  Files           911      951      +40     
  Lines         31050    32457    +1407     
  Branches       3978     4114     +136     
============================================
+ Hits          28667    29949    +1282     
- Misses         1450     1544      +94     
- Partials        933      964      +31     

☔ 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
Copy link

sonarcloud bot commented Nov 25, 2024

```

### 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.


## 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.


### 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.

```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.

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();

```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?

```

### 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.

| 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.

| 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.

| 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.

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