Skip to content
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

Schema cache rework + background task tests setup #626

Merged

Conversation

tgmichel
Copy link
Contributor

@tgmichel tgmichel commented Apr 5, 2022

Using storage_changes_notification_stream for pallet-ethereum schema cache background task proved to be wrong.

The reason is storage change notifications are blindly emitted by substrate on import, without caring about blocks marked as best or re-org situations.

Proposal

This PR simplifies the background task to react to block import notifications instead, doing minimal work to guarantee the cache is up to date:

  • Add to cache when the imported block is best and includes a pallet-ethereum schema change.
  • When the imported block triggered a reorg, remove or add to cache using the retracted / enacted branches contained in the notification.

Tests

We don't test the background tasks. I added the ones that covers this cases, if it gets approved I will work on the tests for the remaining background tasks.

@tgmichel tgmichel requested a review from sorpaas as a code owner April 5, 2022 10:30
@tgmichel
Copy link
Contributor Author

@sorpaas could you review please?

@sorpaas sorpaas merged commit cb9f867 into polkadot-evm:master Apr 25, 2022
@tgmichel tgmichel mentioned this pull request May 6, 2022
@tgmichel tgmichel deleted the tgm-schema-cache-rework branch June 24, 2022 07:41
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
* Schema cache task rework using block import

* Use parent id

* Add test for background task

* fmt

* Update Cargo.lock

* Remove unused tokio

* Cleanup

* Add license

* Template runtime feature aura

* Handle reorgs and test

* Add `tempfile` dev-dependency

* Move `cache` mod + tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants