Add Rust ABI support for WASM subgraphs#6462
Draft
cargopete wants to merge 5 commits intographprotocol:masterfrom
Draft
Add Rust ABI support for WASM subgraphs#6462cargopete wants to merge 5 commits intographprotocol:masterfrom
cargopete wants to merge 5 commits intographprotocol:masterfrom
Conversation
- Add Ethereum ToRustBytes impl for Log/Call/Block triggers - Add NEAR ToRustBytes stub (unimplemented, Ethereum-only for now) - Propagate ToRustBytes trait bounds through instance_manager - Skip parity_wasm gas injection for Rust modules (can't parse bulk-memory opcodes) - Skip AS-specific exports (id_of_type, _start) for Rust modules - Add handle_trigger_rust and invoke_handler_rust calling convention - Add Rust host function wrappers in module/context.rs
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
Adds support for Rust-compiled WASM subgraphs as an alternative to AssemblyScript. This introduces a new
rust_abi/module parallel to the existingasc_abi/, with a clean ptr+len FFI protocol and TLV entity serialization.rust_abi/module (~1,450 LOC) —ToRustWasm/FromRustWasmtraits, TLV entity serialization, trigger serialization (RustLogTrigger/RustCallTrigger/RustBlockTrigger), and all host function linker wrappers (store, crypto, logging, data sources, IPFS, ethereum calls) with async + gas meteringis_rust_module()detects "graphite" namespace imports;MappingLanguageenum stored onValidModulebuild_linker()branches on language;handle_trigger_rust()uses Rust calling convention (allocate → write bytes → call handler(ptr, len) → reset_arena)parity_wasmgas injection for Rust modules (parity_wasm can't parse modern WASM features like bulk-memory); skips AS-specific exports (id_of_type,_start)ToRustBytesimpl for all 3 trigger types (Log, Call, Block)Live-tested
Deployed an ERC20 subgraph (compiled with Graphite SDK) to this fork, indexing real USDC Transfer events from Ethereum mainnet. Full pipeline verified: block ingestion → event scanning → Rust WASM handler → entity storage → correct GraphQL query results.
Architecture
Known gaps (not blocking review)
unimplemented!(Ethereum-only for now)Test plan