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

Optimize Wrapper ABI #1

Open
dOrgJelli opened this issue Aug 15, 2022 · 2 comments
Open

Optimize Wrapper ABI #1

dOrgJelli opened this issue Aug 15, 2022 · 2 comments
Assignees
Milestone

Comments

@dOrgJelli
Copy link
Member

dOrgJelli commented Aug 15, 2022

Currently, the WRAP ABI structure has a lot of redundant data. This is because the nested redundant data is useful when generating code, but is unneeded elsewhere.

We should optimize the ABI structure to ensure that it serializes to as small of a size as possible.

Example Optimization

Optimized:

{
  name: "uArrayArray",
  required: true,
  kind: 34,
  array: {
    type: "[[UInt]]",
    required: true,
    kind: 18,
    array: {
      type: "[UInt]",
      kind: 18,
      scalar: {
        type: "UInt",
        kind: 4
      }
    }
  }
}

Original:

{
  type: "[[UInt]]",
  name: "uArrayArray",
  required: true,
  kind: 34,
  array: {
    type: "[[UInt]]",
    name: "uArrayArray",
    required: true,
    kind: 18,
    array: {
      type: "[UInt]",
      name: "uArrayArray",
      kind: 18,
      scalar: {
        type: "UInt",
        name: "uArrayArray",
        kind: 4
      },
      item: {
        type: "UInt",
        name: "uArrayArray",
        kind: 4
      }
    },
    item: {
      type: "[UInt]",
      name: "uArrayArray",
      kind: 18,
      scalar: {
        type: "UInt",
        name: "uArrayArray",
        kind: 4
      },
      item: {
        type: "UInt",
        name: "uArrayArray",
        kind: 4
      }
    }
  }
}

NOTE: we can add back this redundant data using transformations, that way our codegen string templates do not need to be changed.

@krisbitney
Copy link

I think this is really important! The wrap.info file can get really big right now.

Uniswap v3 example:
wrap.info -> 171kb
wrap.wasm -> 799kb

@dOrgJelli dOrgJelli added this to the wrap-0.2 milestone Jan 10, 2023
@dOrgJelli dOrgJelli transferred this issue from polywrap/wrap-cli Jan 10, 2023
@dOrgJelli
Copy link
Member Author

Work is being done here: https://github.com/polywrap/wrap/tree/abi-0.2

@dOrgJelli dOrgJelli self-assigned this Jan 10, 2023
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

No branches or pull requests

3 participants