Skip to content
Merged
Changes from all commits
Commits
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
16 changes: 4 additions & 12 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,15 @@ func (b *Bootstrap) StartEventIngestion(ctx context.Context) error {

chainID := b.config.FlowNetworkID

// the event subscriber takes the first block to sync from the Access node, which is the block
// after the latest cadence block
nextCadenceHeight := latestCadenceHeight + 1
// Special case when using a local Emulator as Access Node. The Emulator
// always starts at block height 0, so if we try to subscribe at block
// height 1, we'll get an error, as it doesn't exist.
if latestCadenceHeight == config.EmulatorInitCadenceHeight {
nextCadenceHeight -= 1
}

// create event subscriber
// Create EVM event subscriber
// Event ingestion & tx replay is idempotent, so we use the
// `latestCadenceHeight` to be on the safe side.
subscriber := ingestion.NewRPCEventSubscriber(
b.logger,
b.client,
chainID,
b.keystore,
nextCadenceHeight,
latestCadenceHeight,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The latestCadenceHeight is read from storage, which is updated along with all the block data in an atomic batch updates, which means if latestCadenceHeight should always be the latest height that has its data indexed in the storage.

I think we should find the root cause for why nextCadenceHeight doesn't work. It would mean there is some non atomic updates committed after the height is updated, which probably got lost during restarts.

)

callTracerCollector, err := replayer.NewCallTracerCollector(
Expand Down