Skip to content

[Bug] Missing trigger if there are both polling and once block handlers #6158

@pinglamb

Description

@pinglamb

Bug report

When the subgraph has both the kind: once and kind: polling block handlers, only one of them got triggered at the start block.

It is due to logic at https://github.com/graphprotocol/graph-node/blob/master/chain/ethereum/src/ethereum_adapter.rs#L1011 that exits early when any one of the polling_intervals matches.

It can be fixed by always matching all the polling_intervals so to have all the triggers:

        let matching_blocks = (from..=to)
            .filter_map(|block_number| {
                let mut triggers = Vec::new();

                filter
                    .polling_intervals
                    .iter()
                    .for_each(|(start_block, interval)| {
                        let has_once_trigger = (*interval == 0) && (block_number == *start_block);
                        let has_polling_trigger = block_number >= *start_block
                            && *interval > 0
                            && ((block_number - start_block) % *interval) == 0;

                        if has_once_trigger {
                            triggers.push(EthereumBlockTriggerType::Start);
                        }
                        if has_polling_trigger {
                            triggers.push(EthereumBlockTriggerType::End);
                        }
                    });

                if triggers.is_empty() {
                    None
                } else {
                    Some((block_number, triggers))
                }
            })
            .collect::<HashMap<_, _>>();

Relevant log output

IPFS hash

No response

Subgraph name or link to explorer

No response

Some information to help us out

  • Tick this box if this bug is caused by a regression found in the latest release.
  • Tick this box if this bug is specific to the hosted service.
  • I have searched the issue tracker to make sure this issue is not a duplicate.

OS information

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions