-
Notifications
You must be signed in to change notification settings - Fork 980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix offchain created from offchain #5051
Conversation
7ec4598
to
abf9f26
Compare
abf9f26
to
d457b3b
Compare
tests/tests/runner_tests.rs
Outdated
Ok(()) | ||
} | ||
|
||
async fn data_source_long_revert() -> anyhow::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge deal, but committing a failing test before the fix will make bisecting through this change harder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yhea I'll squash merge
let host = this.new_host(logger.cheap_clone(), ds, module_bytes)?; | ||
this.hosts.push(Arc::new(host)); | ||
let Some(host) = this.new_host(logger.cheap_clone(), ds)? else { continue }; | ||
this.hosts.push(host); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be cleaner as a if let Some(..)
so we can avoid the continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code changes in a further commit.
Some(host) | ||
}) | ||
// Check for duplicates and add the host. | ||
match is_onchain { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't a simple if
be clearer here?
.last() | ||
.and_then(|h| h.creation_block_number()) | ||
<= host.data_source().creation_block() | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am always a bit queasy with asserts since it's not that easy to spot panics in the logs; could we return an error here? That way, the subgraph will fail and the failure can tell use what exactly is wrong.
The hosts Vec expected the hosts to be pushed in ascending order of block number. Creating a file ds B within another file ds A violated that assumption, because B will have the same creation block as A. This is by design, so the cleanest way to fix this seemed to be separating the data structures for onchain and offchain hosts. Offchain data sources do not need to maintain insertion order, as their processing order ultimately does not impact determinism because they each have their own causality region. If in the future we introduce a feature that allows two different offchain data sources to have the same causality region, we maybe need to revisit this.
d457b3b
to
1cf8d66
Compare
This is blocking the update to the network subgraph, which now uses file data sources within file data sources.
This is more easily reviewed commit by commit. The first four commits are strictly refactors.