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

Restoring Sandbox Host Functions for Node Synchronization in Full Mode #478

Draft
wants to merge 17 commits into
base: feat/polkadot-stable2409
Choose a base branch
from

Conversation

Aideepakchaudhary
Copy link
Contributor

@Aideepakchaudhary Aideepakchaudhary commented Nov 19, 2024

Description

This PR restores the sandbox host functions that were removed in Polkadot version v0.9.35 to address the node synchronization issue in full mode.

Changes Introduced in this PR:

  1. Reintroduction of Sandbox Host Functions
    Added new files to reinstate the functionality of sandbox host functions:
    • env : This contains the definition of a sandbox environment.
    • freeing_bump: The file freeing_bump.rs implements a freeing-bump allocator which manages heap memory as a
      continuous linear space.
    • sandbox_interface: It implements the several traits for FunctionExecutor like Sandbox trait implementation.
    • sandbox_util: It implements the sandboxing support for the runtime.
    • wasmi_backend: It contains the wasmi specific impls for sandbox.
    • utils: It contains the utilities used by all other files.
  2. Integration with Node Logic
    Sandbox functions are now called directly from node/client/src/lib.rs to ensure seamless integration.

Notes:

Dependency on an Older Version of wasmi
The implementation currently uses version 0.13 of the wasmi library. This decision was made because the recent updates to wasmi involved a complete reimplementation, which resulted in the removal of several functions and types required for sandbox functionality.

Issue with Host Function Calls
When attempting to call the host function implementation here, the call (self.sandbox()) traverses through the sp-runtime_interface and attempts to access the sandbox function in the wasm_interface module. However, this function has been removed from Polkadot SDK, leading to the current challenge.

Types of Changes

Please select the branch type you are merging and fill in the relevant template.

  • Hotfix
  • Release
  • Fix or Feature

Fix or Feature

Types of Changes

  • Tech Debt (Code improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Dependency upgrade (A change in substrate or any 3rd party crate version)

Migrations and Hooks

  • This change requires a runtime migration.
  • Modifies on_initialize
  • Modifies on_finalize

Checklist for Fix or Feature

  • Change has been tested locally.
  • Change adds / updates tests if applicable.
  • Changelog doc updated.
  • spec_version has been incremented.
  • network-relayer's events have been updated according to the blockchain events if applicable.
  • All CI checks have been passed successfully

Checklist for Hotfix

  • Change has been deployed to Testnet.
  • Change has been tested in Testnet.
  • Changelog has been updated.
  • Crate version has been updated.
  • spec_version has been incremented.
  • Transaction version has been updated if required.
  • Pull Request to dev has been created.
  • Pull Request to staging has been created.
  • network-relayer's events have been updated according to the blockchain events if applicable.
  • All CI checks have been passed successfully

Checklist for Release

  • Change has been deployed to Devnet.
  • Change has been tested in Devnet.
  • Change has been deployed to Qanet.
  • Change has been tested in Qanet.
  • Change has been deployed to Testnet.
  • Change has been tested in Testnet.
  • Changelog has been updated.
  • Crate version has been updated.
  • Spec version has been updated.
  • Transaction version has been updated if required.
  • All CI checks have been passed successfully

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.

1 participant