Universal Procedure Call (UPC)
Lyquid introduces Universal Procedure Call (UPC), a powerful built-in primitive that extends the capabilities of smart contracts by enabling seamless and composable off-chain communication across nodes and services. UPC combines the simplicity of local function calls with the power of multicast, fault-tolerant, distributed execution, making it a foundational building block for advanced decentralized applications.
What is UPC?
At its core, UPC allows a Lyquid to invoke off-chain logic across multiple nodes. Each invocation uses the same input, but nodes may execute the procedure using their own node-local state, making UPC useful not just for redundancy, but also for distributed computation and coordination.
Unlike traditional RPC systems, UPC is deeply integrated into Lyquid's programming model. It is expressed as a normal Lyquid function: no boilerplate, no special networking setup. Developers can write UPC handlers and initiate UPC calls from standard instance functions, which are fully compatible with Ethereum APIs. This means wallets can transparently benefit from decentralized request handling and fault-tolerant execution without any frontend changes.
Typical Styles
There are some typical execution and aggregation styles that one can easily express with UPC supports, depending on the application's needs:
| Mode / Pattern | Per-Node Behavior | Aggregation Strategy | Common Use Cases |
|---|---|---|---|
| 1. Share-based Aggregation | Each node returns a unique share or partial result | Aggregate shares into a final result (e.g., via threshold logic) | Oracle and Bridge serving, Threshold signatures, Verifiable Random Functions (VRF), Multi-Party Computation (MPC) |
| 2. Availability | All nodes execute with the same input, and expect the same output | Accept first valid response (e.g., hash match, on-chain verification) | High-performance decentralized storage, Resilient data transmission, Wallet serving |
| 3. Distributed Computation | Nodes return distinct partial results (state-dependent) | Custom, step-by-step logic | Decentralized orderbook matching, AI workload orchestration, Reputation scoring, Cloud-style service mesh coordination |
| 4. Simple RPC | One selected node executes the UPC handler | Return the result directly | Lightweight service calls, internal routing logic |
More Than Just Multicast
While multicast actor models have existed in distributed systems and game engines (e.g., Unreal Engine), UPC goes far beyond by making the coordination layer itself programmable and state-aware. What makes UPC fundamentally more powerful is how it is deeply integrated into Lyquid's execution and state model, not just bolted on as an extension.
Programmable Node Selection The decision of which nodes should execute a UPC handler is not hardcoded. It can be contract-defined, driven by:
- Network state, such as the virtual cluster topology, validator reputation scores, availability metrics.
- Instance state, such as node-specific heuristics or execution hints.
This allows UPC routing to adapt dynamically based on system context.
Programmable Aggregation Logic Similarly, how results are aggregated or validated is defined within the Lyquid itself:
- Quorum size and validation rules can come from network state (e.g., a global quorum threshold or validator set).
- Aggregation reducers (e.g., sum, median, majority) can be programmed explicitly, even using local inputs.
Ethereum-Compatible Entrypoints Because UPC logic is defined in instance functions, they can be invoked via standard eth_call interfaces with Ethereum ABI. This means:
- Wallets can make the initial call just like ordinary smart contract calls.
- Lyquid can internally further extend the execution of this single-point Ethereum RPC into UPC with a complex distributed flow.
- No SDK changes needed, just "smarter" contracts.
Off-Chain Composability
UPC procedures can call other UPCs, or be composed with other off-chain logic, just like ordinary function calls. This enables powerful coordination patterns such as:
- Self-recursive computation across node subsets
- Nested off-chain workflows with state-aware control logic
In essence, UPC makes your off-chain computation cloud-native, resilient, and composable.