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

tron: add hot blocks support #345

Open
wants to merge 7 commits into
base: support-hot-blocks
Choose a base branch
from
Open

tron: add hot blocks support #345

wants to merge 7 commits into from

Conversation

belopash
Copy link
Contributor

No description provided.

}

async getFinalizedHeight(): Promise<number> {
let height = await this.getHeight()
return height - this.finalityConfirmation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should never be negative.


let self = this

let from = requests[0].range.from - 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we start from zero?

top: [],
},
{
process: async (update) => { queue.push(update) },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just realised, that src.getBlockStream() interface for hot blocks requires handling data consistency errors on a processor side as well.

For example, consider the case, when storage request was made to a block that is already gone.

Currently we don't handle this in the SDK, but prev callback based interface for hot blocks had ability to do that.

@@ -79,6 +79,10 @@ export class TronGateway {
})) {
let req = getRequestAt(requests, batch.blocks[0].header.number)

// FIXME: needs to be done during batch ingestion
let finalizedHeight = await this.getFinalizedHeight()
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no need for this. Simply take the last block in the batch as finalized.

Copy link
Contributor Author

@belopash belopash Oct 1, 2024

Choose a reason for hiding this comment

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

Ah, now I understand what you mean in this comment, but this is some odd behavior. Finalized head should never decrease
If you write stream data directly to a message queue, you won't expect a such trap

!!opts.supportHotBlocks || opts.stopOnHead
)) {
// FIXME: needs to be done during batch ingestion
let finalizedHeight = await this.getFinalizedHeight()
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no need for this. Simply take the last block in the batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants