Skip to content

Feat: stacks abi interface - #7905

Open
brice-stacks wants to merge 3 commits into
stacks-network:mainfrom
brice-stacks:feat/stacks-abi-interface
Open

brice-stacks wants to merge 3 commits into
stacks-network:mainfrom
brice-stacks:feat/stacks-abi-interface

Conversation

@brice-stacks

Copy link
Copy Markdown
Contributor

Adds to stacks-abi the parts of a deploy that need no Wasm parser: the abi.interface codec, the rules for a module's custom sections, and the reasons a deploy is rejected (chain ABI 3.4, 4.1, 11).

Closes #7876. Builds on the host-interface table of #7904 (issue #7877) and so should be reviewed after that one (currently just the last commit is new here).

What is in it

  • interface::Interface: the contents of the abi.interface section (ABI 4.1). decode accepts exactly the one encoding of an interface and reports the first field that is missing or invalid; encode writes it; hash is sha512/256 of the bytes. Interface::new builds one from lists and rejects a list that is not in strictly ascending order.
  • interface::ABI_VERSION: the version a module's interface and its import module name must both state (ABI 11). decode accepts any version, because a version mismatch is its own rejection reason: the deploy pipeline compares Interface::abi_version with this constant.
  • deploy::check_custom_sections: a module carries abi.interface and optionally abi.types and abi.provenance, each at most once, and no other custom section (ABI 3.4).
  • deploy::DeployRejection: the nine reasons a deploy is rejected, each with the string a receipt carries. It is defined with define_named_enum! of stacks-common, as ErrorClass is.

Tests

  • vectors/interfaces.txt: 75 vectors, covering every rejection rule of ABI 4.1 and 3.4, including which rule decides when more than one is broken. Every accepted interface encodes back to the same bytes.
  • The encoding and hash of a built interface, written out field by field, with the hash computed independently.
  • Uniqueness: generated interfaces decode from their encoding, and any mutation that still decodes is the encoding of what it decodes to.
  • Every rejection reason string is pinned.
  • The import module name is stacks-abi-v followed by ABI_VERSION.

The tests run natively and on wasm32-unknown-unknown through the existing stacks-abi CI steps.

Define the host interface of the chain ABI as one table: for each of the
66 host functions its group, parameters in the kinds of ABI 6.1, result,
status codes and charge formula. Deploy validation, linking, the fuel
schedule and the tools derive from it.

Tests check the Wasm types against ABI 6.1 and the rules every signature
and charge formula must keep.
Add the parts of a deploy that need no Wasm parser:

- The `abi.interface` section (ABI 4.1): encode, decode and validation,
  accepting exactly the one encoding of an interface, and its hash,
  `sha512/256` of the bytes.
- The rules for a module's custom sections (ABI 3.4).
- The reasons a deploy is rejected, each with the string a receipt
  carries.

Vectors cover every rejection rule of ABI 4.1 and 3.4.

This branch has not been deployed

No deployments
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.

[Clarity 8] ABI crate: abi.interface codec, custom-section rules, deploy rejection reasons

1 participant