Skip to content

Commit bfe6188

Browse files
committed
Improve length checks for EVM related events
1 parent 5e8f388 commit bfe6188

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

services/ingestion/block_tracking_subscriber.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ func (r *RPCBlockTrackingSubscriber) evmEventsForHeight(
233233
return flow.BlockEvents{}, err
234234
}
235235

236-
if len(evts) != 1 && len(evts[0].Events) != 1 {
236+
// We are requesting the `EVM.BlockExecuted` events for a single Flow block,
237+
// so we expect the length of `evts` to equal 1.
238+
// The `EVM.BlockExecuted` event should be present for every Flow block.
239+
if len(evts) != 1 || len(evts[0].Events) != 1 {
237240
return flow.BlockEvents{}, fmt.Errorf(
238241
"received unexpected number of EVM events for height: %d, got: %d, expected: 1",
239242
height,
@@ -262,7 +265,9 @@ func (r *RPCBlockTrackingSubscriber) evmEventsForHeight(
262265
return flow.BlockEvents{}, err
263266
}
264267

265-
if len(evts) != 1 && len(evts[0].Events) != 1 {
268+
// We are requesting the `EVM.TransactionExecuted` events for a single
269+
// Flow block, so we expect the length of `evts` to equal 1.
270+
if len(evts) != 1 {
266271
return flow.BlockEvents{}, fmt.Errorf(
267272
"received unexpected number of EVM events for height: %d, got: %d, expected: 1",
268273
height,

0 commit comments

Comments
 (0)