Repository navigation
Conversation
…-scoped
A blockHandler with `filter: { kind: call }` declared in a template never
fired under static filters. Static filters deliberately drop the addresses of
created data sources, and the template contributes only trigger_every_block
through EthereumBlockFilter::from_mapping, so the Start/End triggers a data
source created from that template receives never match a Call handler. Nothing
was logged, and the subgraph kept indexing while its entities and PoI drifted
from a node running in default mode.
Report the condition on the template trait and let the runner fall back to the
full filter, which rebuilds on data source creation and therefore does include
the created address. Chains without an equivalent construct keep the default,
so their behaviour does not change.
Subgraphs that already indexed in static filters with such a template have a
PoI computed from the missing handlers; they need to be rewound to before the
block where static filters took effect.
Signed-off-by: Liang Xu <24490353+lx3133584@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6750
Problem
With static filters on —
EXPERIMENTAL_STATIC_FILTERS=true, or automatically oncea subgraph exceeds
GRAPH_STATIC_FILTERS_THRESHOLD— ablockHandlerwithfilter: { kind: call }declared in a template never fired for the datasources created from that template. In default mode it fired normally.
Nothing was logged. The subgraph stayed healthy and kept indexing, while its
entities and PoI diverged from a node running in default mode. A subgraph that
crosses the threshold would stop seeing these handlers from the restart at which
it switched.
Two things have to line up for this:
extend_with_template, and the block stream is not restarted when a datasource is created, so the created address never enters the filter.
EthereumBlockFilter::from_mappingruns for the template. It setstrigger_every_blockfor any block handler and leavescontract_addressesempty, so the data source created from it receives
Start/Endtriggers,which a
Callhandler cannot match.from_data_sourcesdoes handle this correctly for a data source that alreadyhas an address — that path is why default mode works.
Fix
The runner decides whether to use static filters before it builds either
filter, so the condition is recorded on the template itself:
DataSourceTemplate::has_address_scoped_block_handler. Ethereum answers it fromthe mapping it already had a helper for; the trait default is
false, so chainswithout an equivalent construct are unaffected.
When a template reports it,
is_static_filters_enabledreturnsfalseand thesubgraph keeps the full filter, which is rebuilt on data source creation and
therefore includes the created address. The reason is logged once, at info, so an
operator can tell why the optimization is not in effect for that subgraph.
The alternative — an "any address" mode for the block call filter, mirroring
wildcard_signaturesfor call handlers — keeps the optimization but asks fortraces on every block for these subgraphs. That is the second option in the
issue and is left for a follow-up; correctness first.
Testing
Added
chain/ethereum/src/data_source.rsunit tests covering the predicate therunner reads:
Call-filtered block handler reportstrueNone,OnceandPollinghandlers reportfalsefalseCall-filtered handler among others still reportstrueThe last three keep the test honest about the direction of the check: an
implementation that answered
trueunconditionally would pass the first casealone.
The four failures above are the IPFS tests (
link_resolver::ipfs::tests,polling_monitor::ipfs_service::test), which need network access this machinedoes not have. They fail identically on unmodified
master, so they areunrelated to this change.
cargo fmt --all -- --checkandcargo clippy -p graph -p graph-core -p graph-chain-ethereum --all-targetsare clean.Deployment note
Subgraphs that already indexed with such a template under static filters have a
PoI computed without these handlers. After this change they need to be rewound to
before the block at which static filters took effect, otherwise the new
(complete) indexing starts from an inconsistent base.