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

Contract Spec: Experiment with custom sections and if we can store something like XDR in them. See if it is then also easy to extract that section, and strip that section, after compile. #116

Closed
leighmcculloch opened this issue Jun 3, 2022 · 1 comment
Assignees

Comments

@leighmcculloch
Copy link
Member

No description provided.

@leighmcculloch leighmcculloch mentioned this issue Jun 3, 2022
12 tasks
@leighmcculloch leighmcculloch self-assigned this Jun 6, 2022
@leighmcculloch leighmcculloch changed the title Experiment with custom sections and if we can store something like XDR in them. See if it is then also easy to extract that section, and strip that section, after compile. Contract API: Experiment with custom sections and if we can store something like XDR in them. See if it is then also easy to extract that section, and strip that section, after compile. Jun 6, 2022
@leighmcculloch leighmcculloch changed the title Contract API: Experiment with custom sections and if we can store something like XDR in them. See if it is then also easy to extract that section, and strip that section, after compile. Contract Spec: Experiment with custom sections and if we can store something like XDR in them. See if it is then also easy to extract that section, and strip that section, after compile. Jun 7, 2022
@leighmcculloch
Copy link
Member Author

leighmcculloch commented Jun 7, 2022

I experimented with custom sections and it looks really promising. There is good support for custom WASM sections in Rust, browsers, wasmi, wasm-opt, and other tools.

The are simple to implement:

#[cfg(target_family = "wasm")]
#[link_section = "scv1"]
pub static SCV1: [u8; 10] = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1];

Ref: #123

I was able to confirm that the bytes could be extracted with the wasm-custom-section tool:

❯ wasm-custom-section target/wasm32-unknown-unknown/release/example_add_i64.wasm show scv1
Section `scv1` (10 bytes):
Length: 10 (0xa) bytes
0000:   01 02 03 04  05 05 04 03  02 01                      ..........

And I was able to confirm that:

  • wasm-opt ignores the section and doesn't strip it, so developers are unlikely to accidentally strip their contract specs.
  • wasmi is able to run contracts containing a custom section.
  • parity_wasm is able to extract custom sections, and strip them. See Export custom sections from Vm rs-soroban-env#103.

@leighmcculloch leighmcculloch added this to the v0 milestone Jun 18, 2022
@leighmcculloch leighmcculloch linked a pull request Jun 18, 2022 that will close this issue
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 a pull request may close this issue.

1 participant