Yarkin/test antelope support - #1
Draft
yarkinwho wants to merge 20 commits into
Draft
Conversation
The Antelope backend was scaffolded by reusing the Polkadot and Soroban backends, and inherited code that is wrong or wasteful for Antelope. This cleans up that inheritance: it makes storage-heavy contracts dramatically smaller and fixes an invalid-IR crash at -O none/-O less. Changes (all in the Antelope backend): * Outline storage read-modify-write into shared helpers. Each scalar storage access used to inline the full slot-find + row read/update-or- insert sequence (~200 instructions) at every site. Emit it once as internal `__antelope_store_slot` / `__antelope_load_slot` and call them; structs benefit automatically via the recursive scalar path. * Outline mapping-slot hashing. Every `m[k]` subscript inlined a keccak preimage build + sha3 call, chained per nesting level. Route the fixed-size-key case through one shared `__map_slot(prev, key, key_len)` helper (the preimage bytes are identical, so slot hashes are unchanged). * Stop generating the inherited Polkadot dispatch CFGs for Antelope. Antelope's entry point is the hand-written `apply`, which dispatches actions by name; it never used these selector-based dispatchers. They were emitted as dead functions whose Polkadot-specific terminators (ReturnCode / the ReturnData success path) the Antelope emit doesn't lower, leaving basic blocks unterminated — invalid IR that crashed the backend at -O none/-O less (masked at -O default only because global_dce drops dead functions). Also implement the previously-empty `return_code` hook defensively so it always emits a terminator. * De-export the bundled Soroban allocator. The allocator comes from the Soroban stdlib, where each function is `wasm-export-name`'d because the Stellar host calls the guest allocator by name. The Antelope host only calls `apply`, so those exports are useless here and, being export roots, blocked wasm-opt from DCE-ing the unused ones. Strip the export attribute for Antelope (apply is exported via linkage, so it is unaffected). Impact on the example contracts (release + wasm-opt -Oz + strip): FlagGame 24,061 -> 8,157 bytes (-66%) FlagJudge 28,329 -> 10,318 bytes (-64%) Exports reduced to just `memory` + `apply`. Verified: all opt levels (none/less/default/aggressive) compile, and the 28 Antelope wasmi-VM tests pass (store/load/overwrite/nested-mapping round-trips), confirming slot hashes and storage semantics are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ay params, and abi_extensions
Fixes five bugs in the Antelope target found while deploying ai-oracle to a
local nodeos, plus adds action-name collision detection.
Action names (C1/C2):
- Lowercase function names before filtering instead of dropping uppercase
bytes, so `putHash` becomes action `puthash`, not `putash`. Idiomatic
camelCase now maps predictably.
- Restrict the digit class to the eosio::name charset `1`-`5` (`0`,`6`-`9`
were being silently dropped, causing `cleos set abi` to reject the name).
- Unify both sites behind a single `abi::antelope::normalize_action_name`
so the emitter dispatch switch and the ABI can no longer disagree.
- Reject public function names that don't fit the charset / 12-char limit
at compile time (was silent mangling); pure case changes stay allowed.
- Add a contract-level pass rejecting two public functions that map to the
same action name — catches case-folding (`putHash`/`puthash`) and
overloads (`foo(uint64)`/`foo(string)`), which the per-function check
cannot see.
Struct-returning getters (C3):
- The multi-return serialization path called `memcpy` (never declared)
instead of `__memcpy`, panicking the compiler on `mapping(=>struct)
public` getters. Use the declared `__memcpy`.
Action parameters (C4):
- Unsupported parameter types (dynamic arrays, structs, …) now emit a clean
compile-time error instead of panicking the emitter.
ABI extensions (C5):
- Serialize `abi_extensions` entries as fc tuples `[type, dataHex]` rather
than objects `{type, data}`, matching `vector<pair<uint16, bytes>>` so
`cleos set abi` accepts the raw ABI (no reshape step needed).
Adds unit tests for action-name normalization and the tuple wire form.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A largely working build.