Skip to content

Commit 1dc4dfa

Browse files
authored
Merge pull request #6 from wormhole-foundation/ilariae/relayer
Ilariae/relayer
2 parents 2ffce02 + 01db0fe commit 1dc4dfa

File tree

2 files changed

+118
-1
lines changed

2 files changed

+118
-1
lines changed

learn/infrastructure/.pages

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ nav:
33
- index.md
44
- 'VAAs': 'vaas.md'
55
- 'Guardians': 'guardians.md'
6-
- 'Spies': 'spy.md'
6+
- 'Spy': 'spy.md'
7+
- 'Relayers': 'relayer.md'

learn/infrastructure/relayer.md

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
title: Relayers
3+
description: Discover the role of relayers in the Wormhole network, including client-side, specialized, and standard types, for secure cross-chain communication.
4+
---
5+
6+
# Relayers
7+
8+
This documentation provides a comprehensive guide to relayers within the Wormhole network, describing their role, types, and benefits in facilitating cross-chain processes.
9+
10+
Relayers in the Wormhole context are processes that deliver [Verified Action Approvals (VAAs)](#){target=\_blank} to their destination, playing a crucial role in Wormhole's security model. They can't compromise security, only liveness, and act as delivery mechanisms for VAAs without the capacity to tamper with the outcome.
11+
12+
There are three primary types of relayers discussed:
13+
14+
- **Client-side relaying** - a cost-efficient, no-backend-infrastructure approach relying on user-facing front ends. It provides a simple solution, although it can complicate the user experience due to the manual steps involved
15+
- **Specialized relayers** - backend components that handle parts of the cross-chain process, offering a smoother user experience and allowing off-chain calculations to reduce gas costs. These relayers could operate through direct listening to the Guardian Network (Spy relaying) or by providing a REST endpoint to accept VAAs to be relayed (REST relaying)
16+
- **Standard relayers** - a decentralized relayer network that can deliver arbitrary VAAs, reducing the developer's need to develop, host, or maintain relayers. However, they require all calculations to be done on-chain and might be less gas-efficient
17+
18+
## Fundamentals
19+
20+
This section highlights the crucial principles underpinning the operation and handling of relayers within the Wormhole network.
21+
22+
Relayers are fundamentally untrusted entities within the network. This means that while they don't require your trust, they shouldn't be trusted implicitly. They function as delivery mechanisms, transporting VAAs from their source to their destination.
23+
24+
Key characteristics of VAAs include:
25+
26+
- Public emission from the Guardian Network
27+
- Authentication through signatures from the Guardian Network
28+
- Verifiability by any entity or any Wormhole Core Contract
29+
- As a result of these characteristics, anyone can pick up a VAA and deliver it anywhere, but no one can alter the VAA content without invalidating the signatures
30+
31+
When designing contracts, it's crucial to only trust information contained within your contract or a VAA. Relying on information from a relayer could expose you to untrusted input attacks.
32+
33+
Advanced strategies can involve relayers performing untrusted off-chain computation passed into the destination contract. These strategies can optimize gas costs but also create attack vectors if not used correctly.
34+
35+
In summary, the design of a relayer should ensure that there's a single, deterministic way to process messages in your protocol. In an optimally designed protocol, relayers should have a "correct" implementation, mirroring "crank turner" processes used elsewhere in blockchain.
36+
37+
## Client-Side Relaying
38+
39+
Client-side relaying relies on user-facing front ends, such as a webpage or a wallet, to complete the cross-chain process.
40+
41+
**Key Features**
42+
43+
- **Cost-efficiency** - users only pay the transaction fee for the second transaction, eliminating any additional costs
44+
- **No backend infrastructure** - the process is completely client-based, eliminating the need for a backend relaying infrastructure
45+
46+
**Implementation**
47+
48+
Users themselves carry out the three steps of the cross-chain process:
49+
50+
1. Perform an action on chain A
51+
2. Retrieve the resulting VAA from the Guardian Network
52+
3. Perform an action on chain B using the VAA
53+
54+
**Considerations**
55+
56+
!!! note
57+
Though simple, this type of relaying is generally not recommended if your aim is a highly polished user experience. It can, however, be useful for getting a Minimum Viable Product (MVP) up and running.
58+
59+
- Users must sign all required transactions with their own wallet
60+
- Users must have funds to pay the transaction fees on every chain involved
61+
- The user experience may be cumbersome due to the manual steps involved
62+
63+
## Specialized Relayers
64+
65+
Specialized relayers are purpose-built components within the Wormhole protocol, designed to relay messages for specific applications. They are capable of performing off-chain computations and can be customized to suit a variety of use cases.
66+
67+
**Key Features**
68+
69+
- **Optimization** - capable of performing untrusted off-chain computations which can optimize gas costs
70+
- **Customizability** - allows for specific strategies like batching, conditional delivery, multi-chain deliveries, and more
71+
- **Incentive structure** - developers have the freedom to design an incentive structure suitable for their application
72+
- **Enhanced UX** - the ability to retrieve a VAA from the Guardian Network and perform an action on the target chain using the VAA on behalf of the user can simplify the user experience
73+
74+
**Implementation**
75+
76+
!!! note
77+
To make the development of specialized relayers easier, a plugin relayer is available in the [main Wormhole repository](#){target=\_blank}. This sets up the basic infrastructure for relaying, allowing developers to focus on implementing the specific logic for their application.
78+
79+
There are two main methods of setting up a specialized relayer:
80+
81+
- **Spy relaying** - involves listening directly to the Guardian Network via a Spy
82+
- **REST relaying** - provides a REST endpoint to accept a VAA that should be relayed
83+
84+
**Considerations**
85+
86+
Remember, despite their name, specialized relayers still need to be considered untrusted. VAAs are public and can be submitted by anyone, so developers should not rely on off-chain relayers to perform any computation considered "trusted."
87+
88+
- Development work and hosting of relayers are required
89+
- The fee-modeling can become complex, as relayers are responsible for paying target chain fees
90+
- Relayers are responsible for liveness, adding dependency for the cross-chain application
91+
92+
## Standard Relayers
93+
94+
Standard relayers are a component of a decentralized network in the Wormhole protocol, facilitating the delivery of VAAs to recipient contracts compatible with the standard relayer API.
95+
96+
**Key Features**
97+
98+
- **Lower operational costs** - no need to develop, host, or maintain individual relayers
99+
- **Simplified integration** - because there is no need to run a relayer, integration is as simple as calling a function and implementing an interface
100+
101+
**Implementation**
102+
103+
The standard relayer integration involves two key steps:
104+
105+
- **Delivery request** - request delivery from the Wormhole Relay Ecosystem Contract
106+
- **Relay reception** - implement a [`receiveWormholeMessages`](#){target=\_blank} function within their contracts. This function is invoked upon successful relay of the VAA
107+
108+
**Considerations**
109+
110+
!!! note
111+
Developers should note that the choice of relayers depends their project's specific requirements and constraints. Standard relayers offer simplicity and convenience but limit customization and optimization opportunities compared to specialized relayers.
112+
113+
- All computations are performed on-chain
114+
- Potentially less gas-efficient compared to specialized relayers
115+
- Optimization features like conditional delivery, batching, off-chain calculations might be restricted
116+
- Support may not be available for all chains

0 commit comments

Comments
 (0)