vara-eth-demo: The Asynchronous Remote for Ethereum
Offloading heavy compute to a parallel WASM runtime without leaving the EVM.
- The repository transforms synchronous Ethereum transactions into an asynchronous request-reply model using a parallel WASM runtime.
- Mirror contracts provide a Solidity ABI that allows developers to interact with remote Rust programs as if they were local smart contracts.
- The Sails framework bridges the Gear Protocol's Actor model with Ethereum's object-oriented structure to automate cross-chain message formatting.
- A wrapped token system allows Ethereum contracts to fund remote execution without requiring developers to manually manage native Vara tokens.
The Callback Revolution
Ethereum is strictly synchronous. Every transaction executes sequentially, and if a contract calls another contract, the entire virtual machine waits for the result. This architectural choice makes composability simple but puts a hard ceiling on computational complexity. The vara-eth-demo repository introduces a fundamentally different approach. It leverages the Gear Protocol to offload heavy computation to a parallel WASM runtime, turning synchronous EVM calls into an asynchronous Request-Reply model.
Instead of waiting for a computation to finish, a smart contract on Ethereum dispatches a message and immediately receives a messageId. The actual result arrives later via a callback. It is a mental shift from atomic block-by-block execution to the event-driven microservice architecture common in modern web development.
Reflections in the Mirror
To make this asynchronous leap feel native to Ethereum developers, the repository employs a sophisticated Router and Mirror architecture. An IRouter contract acts as the central dispatch hub on Ethereum. When a developer wants to connect to a Rust program running on Vara, the Router deploys an IMirror proxy contract.
This proxy provides a Solidity ABI that perfectly mimics the remote Rust program. To the developer writing standard Foundry or Hardhat tests, the remote WASM binary looks and acts like a local Solidity contract, hiding the complexity of cross-chain message formatting and SCALE encoding.
function counterAdd(uint32 value) external {
// 1. Dispatch message to Vara, get ID immediately
bytes32 messageId = VARA_ETH_PROGRAM.counterAdd(value, true);
// 2. Store state waiting for callback
counterAddInputs[messageId] = value;
}
// 3. Callback triggered by the bridge
function replyOn_counterAdd(bytes32 messageId, uint32 reply)
external
onlyVaraEthProgram
{
emit CounterAddReply(messageId, reply);
}
Vara.eth is a high-performance application platform built directly into Ethereum's ecosystem, powered by the battle-tested Gear Protocol engine that runs Vara Network. Rather than creating another separate chain, Vara.eth extends Ethereum itself with high-speed computation and real-time responsiveness—without bridges, without fragmenting liquidity, and without compromising on security.
Sails: Rust for the EVM Mind
The backend logic running on Vara is written in Rust using the Sails framework. Sails acts as a translation layer between the Actor model of the Gear Protocol and the object-oriented expectations of a smart contract developer. It structures the Rust code into clear Services with dedicated methods, automatically generating the Interface Definition Language (IDL) needed to bridge the two networks.
A crucial detail in the Rust implementation is the dual event emission pattern. When the CounterService updates its state, it emits a standard Gear event for the Vara network and an emit_eth_event specifically formatted for the Ethereum bridge payload. This ensures that when the callback arrives back on Ethereum L1, the resulting logs are indistinguishable from a native Solidity execution.
Fueling the Cross-Chain Engine
Bridging compute requires bridging economics. To prevent Ethereum developers from needing to acquire native Vara tokens to pay for WASM execution, the demo utilizes an IWrappedVara contract. This allows the Ethereum Mirror contract to maintain an executableBalance, effectively paying for the remote parallel execution directly from the EVM side.
| Feature | Vara.eth (This Repo) | Standard L2 Rollups | Message Bridges (LayerZero) |
|---|---|---|---|
| Execution Model | Parallel (Actor Model) | Sequential (EVM) | Agnostic / Relayer Dependent |
| Primary Languages | Rust/WASM & Solidity | Solidity/Vyper | Agnostic |
| Compute Type | Asynchronous | Synchronous within L2 | Asynchronous |
| Developer Paradigm | Remote Callbacks | Local Deployment | Payload Routing |
By combining the Sails framework with the Router-Mirror pattern, the vara-eth-demo repository provides a practical blueprint. It shows how applications can keep their liquidity and user base on Ethereum while utilizing a separate, high-performance runtime for their most demanding computational tasks.