Skip to content

Commit cb843cf

Browse files
committed
Always re-index from latestCadenceHeight + 1
1 parent 1963b71 commit cb843cf

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

bootstrap/bootstrap.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,23 @@ func (b *Bootstrap) StartEventIngestion(ctx context.Context) error {
143143

144144
chainID := b.config.FlowNetworkID
145145

146-
// Create EVM event subscriber
147-
// Event ingestion & tx replay is idempotent, so we use the
148-
// `latestCadenceHeight` to be on the safe side.
146+
// the event subscriber takes the first block to sync from the Access node,
147+
// which is the block after the latest cadence block
148+
nextCadenceHeight := latestCadenceHeight + 1
149+
// Special case when using a local Emulator as Access Node. The Emulator
150+
// always starts at block height 0, so if we try to subscribe at block
151+
// height 1, we'll get an error, as it doesn't exist.
152+
if latestCadenceHeight == config.EmulatorInitCadenceHeight {
153+
nextCadenceHeight -= 1
154+
}
155+
156+
// create EVM event subscriber
149157
subscriber := ingestion.NewRPCEventSubscriber(
150158
b.logger,
151159
b.client,
152160
chainID,
153161
b.keystore,
154-
latestCadenceHeight,
162+
nextCadenceHeight,
155163
)
156164

157165
callTracerCollector, err := replayer.NewCallTracerCollector(

0 commit comments

Comments
 (0)