Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

BEEFY gadget should recognize BeefyApi updates #129

Open
adoerr opened this issue Mar 27, 2021 · 2 comments
Open

BEEFY gadget should recognize BeefyApi updates #129

adoerr opened this issue Mar 27, 2021 · 2 comments
Labels
enhancement New feature or request M-gadget The client code of the gadget.

Comments

@adoerr
Copy link
Contributor

adoerr commented Mar 27, 2021

Currently, the BEEFY gadget is using a somewhat crude approach in order to detect the availability of an on-chain BEEFY pallet. One situation which would cause some mayhem, for example, is the removal of the BEEFY pallet as part of a runtime update.

The canonical approach followed by the BEEFY gadget should actually be to follow runtime updates and explicitly check for the availability of the BeefyApi. This would require basically two things:

  • catch and process frame_system::pallet::Event::CodeUpdated events
  • calling either sp_api::ProvideRuntimeApi::runtime_api()::has_api() or has_api_with() and verify that the new runtime provides the BeefyApi.
@adoerr adoerr added enhancement New feature or request M-gadget The client code of the gadget. labels Mar 27, 2021
@tomusdrw
Copy link
Contributor

tomusdrw commented Mar 29, 2021

catch and process frame_system::pallet::Event::CodeUpdated events

Events are not really reliable - we would need to be sure that we always receive all of them, and it's not going to be a case unless we plug ourselves into block import pipeline.

I think using has_api is the right way to to do it - we can simply do it before EVERY call to the BeefyApi - it's cheap enough.

@adoerr adoerr changed the title BEEFY gadget should recognize runtime updates BEEFY gadget should recognize BeefyApi updates Jul 2, 2021
@adoerr
Copy link
Contributor Author

adoerr commented Jul 2, 2021

Changed title of the issue, since we are actually interested in a version change of the BeefyApi.

Recently a function api_version() has been added to RuntimeVersion. This allows for the following approach:

  • Use the #[api_version(x)] attribute supported by the decl_runtime_apis! macro in order to version BeefyApi. Note, currently we are at version 1, since this is the default, if no explicit version is provided.
  • Use Client::runttime_version_at() to get the RuntimeVersion at a given block number and call api_version() in order to check the BeefyApi version.

@tomusdrw tomusdrw added this to the Some Day Maybe milestone Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request M-gadget The client code of the gadget.
Projects
No open projects
Status: Some Day Maybe
Development

No branches or pull requests

2 participants