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

Refactor Runtime APIs Implementation and Update Import Paths #495

Merged
merged 5 commits into from
Mar 25, 2024

Conversation

asiniscalchi
Copy link
Member

@asiniscalchi asiniscalchi commented Mar 25, 2024

Type

enhancement


Description

  • Refactored the implementation of runtime APIs in laos_runtime from using macros to direct coding, enhancing readability and maintainability.
  • Updated import paths for RuntimeApi and dispatch method in node/src/service.rs to align with the new structure.
  • Made the apis module public in runtime/laos/src/lib.rs and updated the runtime versioning to use apis::PUBLIC_RUNTIME_API_VERSIONS.

Changes walkthrough

Relevant files
Enhancement
service.rs
Update Runtime API Import Paths and Dispatch Method           

node/src/service.rs

  • Import path for RuntimeApi updated to laos_runtime::apis::RuntimeApi.
  • Dispatch method now uses laos_runtime::apis::api::dispatch instead of
    laos_runtime::api::dispatch.
  • +2/-2     
    apis.rs
    Refactor Runtime APIs Implementation from Macro to Direct Coding

    runtime/laos/src/apis.rs

  • Removed macro-based implementation of runtime APIs.
  • Added direct implementation of runtime APIs with updated import paths
    and structures.
  • Introduced PUBLIC_RUNTIME_API_VERSIONS for exposing runtime API
    versions.
  • +399/-380
    lib.rs
    Expose APIs Module and Update Runtime Versioning                 

    runtime/laos/src/lib.rs

  • Made apis module public.
  • Updated VERSION to use apis::PUBLIC_RUNTIME_API_VERSIONS for API
    versions.
  • Removed the macro call impl_runtime_apis_plus!();.
  • +4/-16   

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @asiniscalchi
    Copy link
    Member Author

    /describe

    @github-actions github-actions bot changed the title Refactor/impl apis runtime is not macro Refactor Runtime APIs Implementation and Update Import Paths Mar 25, 2024
    Copy link

    PR Description updated to latest commit (aeb8188)

    ccubu
    ccubu previously approved these changes Mar 25, 2024
    @@ -122,7 +110,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
    authoring_version: 1,
    spec_version: 1201,
    impl_version: 0,
    apis: RUNTIME_API_VERSIONS,
    apis: apis::PUBLIC_RUNTIME_API_VERSIONS,
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    it might sound like too much, but do you think it is worth adding a test for the apis::PUBLIC_RUNTIME_API_VERSIONS value? so we ensure it doesn't change. If not why?

    Copy link
    Member Author

    @asiniscalchi asiniscalchi Mar 25, 2024

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    yes, not nice: it's forced by the fact that the macro defines RUNTIME_API_VERSIONS not public. I am trying to expose the problem to the polkadot-sdk guys. We'll see if they accept it.
    We can choose another name for sure... :D

    paritytech/polkadot-sdk#3817

    @magecnion magecnion merged commit 65b9c1a into main Mar 25, 2024
    8 checks passed
    @magecnion magecnion deleted the refactor/impl_apis_runtime_is_not_macro branch March 25, 2024 16:39
    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.

    3 participants