-
Notifications
You must be signed in to change notification settings - Fork 160
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
batch-processor: support hot blocks #344
Conversation
bad05f6
to
3af47a2
Compare
0d7bdcf
to
7b90ddd
Compare
7b90ddd
to
f3b112d
Compare
will fix other streams after review |
8b5cdd6
to
89c36b5
Compare
let state = await this.getDatabaseState() | ||
|
||
// remove all hot block to start from the finalized head | ||
state = {...state, top: []} |
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.
It is not polite to loose progress.
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.
It is not polite to loose progress.
Maybe, but it's just easier to do it in this way, rather than check all "top" blocks
let chainHeight = await this.chainHeight.get() | ||
private async processBatch(prevState: HotDatabaseState, finalizedHead: HashAndHeight, blocks: B[]): Promise<HotDatabaseState> { | ||
assert( | ||
prevState.height < finalizedHead.height || |
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.
Finalized head reported by the data source might lie below the previously finalized head at the start of processing.
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.
Finalized head reported by the data source might lie below the previously finalized head at the start of processing.
How is it possible? It should be considered as an error
|
||
let mappingStartTime = process.hrtime.bigint() | ||
let prevHead = maybeLast(prevState.top) || prevState | ||
let nextHead = maybeLast(nextState.top) || nextState |
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.
State tracking procedure above feels tricky, but most importantly it is not need (both for the current and future database interfaces).
let baseHead = getParent(blocks[0])
let nextHead = last(blocks)
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.
Processor doesn't know anything about parent blocks. Parant hash is not a part of the DataSource interface
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.
As I've already said, from the processor perpective it's better to have explicit "rollbacks" array in sream response
No description provided.