Fix ABI handling for dynamic cross-contract calls#36
Open
shawntabrizi wants to merge 2 commits into
Open
Conversation
Collaborator
|
The ABI handling has changed on the main branch, so I’m not sure it makes sense to keep fixing this branch, as it will probably never be merged into main. What I think is that we should move the functionality from this branch to main and start using it as soon as possible, so we don’t double the work. |
charlesHetterich
added a commit
that referenced
this pull request
Jun 10, 2026
* Make OrderedIndex stack-safe and O(log n) across all paths OrderedIndex insert/remove recursed per tree level, overflowing the 8 KiB default PolkaVM guest stack at B-tree height transitions. On-chain this manifested as a raw ContractTrapped (the panic handler needs stack too) at insert #36 for OrderedIndex<String, u32, 2>. Reproduced on Paseo Asset Hub: the same binary with a 128 KiB declared stack sails past the wall, and the iterative rewrite passes 300+ inserts at the unmodified 8 KiB default. - insert: single-pass preemptive-split descent; child_counts mirrors are incremented on the way down, removing back-propagation entirely - remove_by_nonce: read-only existence check, then a guaranteed-success CLRS single-pass destructive descent (borrow/merge on the way down); a remove miss now provably leaves the tree untouched - range: explicit cursor stack instead of recursion; the pagination offset is consumed positionally via subtree counts (O(log n + limit), measured 33 reads at offset 5000 vs thousands before) - const node-size envelope API (max_node_encoded_size / fits_storage_limit) so impossible (K, V, T) shapes fail at compile time instead of reverting with OrderedIndexNodeTooLarge on-chain - host-side storage shim (cfg target_arch, zero-cost on riscv) + 14-test property suite: 10k asc/desc/random inserts with full structural invariants, 20k mixed-op fuzz vs a reference model, 5k-duplicate tie scenarios with read-count assertions, height-transition regression On-chain storage layout (key derivation, node encoding) is byte-identical to the previous implementation; deployed trees remain readable/writable. * Declare 128 KiB min stack for all generated contracts polkavm-linker defaults guest stacks to 8 KiB (VM_MIN_PAGE_SIZE * 2), which deep call chains overflow as a raw VM trap with no revert message. Emit min_stack_size!(131072) from #[pvm::contract] for entry-point crates, matching resolc's production default. Contracts can still raise it further with their own min_stack_size! declaration (the linker takes the max).
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.
Summary
Testing