Cointime

Download App
iOS & Android

Building Helios: Fully trustless access to Ethereum

Cointime Official

One of the main reasons we use blockchains is trustlessness. This property promises to allow us self-sovereign access to our wealth and data. For the most part, blockchains like Ethereum have delivered on this promise — our assets are truly ours. 

However, there are concessions we’ve made for the sake of convenience. One such area is in our use of centralized RPC (remote procedure call) servers. Users typically access Ethereum through centralized providers like Alchemy. These companies run high-performance nodes on cloud servers so that others can easily access chain data. When a wallet queries its token balances or checks whether a pending transaction has been included in a block, it almost always does so through one of these centralized providers. 

The trouble with the existing system is that users need to trust the providers, and there is no way to verify the correctness of their queries.

Enter Helios, a Rust-based Ethereum light client we developed that provides fully trustless access to Ethereum. Helios — which uses Ethereum’s light client protocol, made possible by the recent switch to proof of stake — converts data from an untrusted centralized RPC provider into a verifiably safe, local RPC. Helios works together with centralized RPCs to make it possible to verify their authenticity without running a full node. 

The tradeoff between portability and decentralization is a common pain point, but our client – which we’ve made available to the public to build on and more – syncs in around two seconds, requires no storage, and allows users to access secure chain data from any device (including mobile phones and browser extensions). But what are the potential pitfalls of relying on centralized infrastructure? We cover how they might play out in this post, walk through our design decisions, and also outline a few ideas for others to contribute to the codebase.

the pitfalls of centralized infrastructure: theoretical creatures in ethereum’s “dark forest”

A (theoretical) creature lurks in the dark forest. This one doesn’t hunt for its prey in the Ethereum mempool, but instead sets its traps by mimicking centralized infrastructure that we’ve come to rely on. The users who get caught in this trap don’t make any mistakes: They visit their favorite decentralized exchange, set a reasonable slippage tolerance, and buy and sell tokens as usual… They do everything right, but still fall victim to a new kind of sandwich attack, a trap meticulously set at the very entrance to Ethereum’s dark forest: RPC providers.

Before we elaborate, let’s look at how trades work on decentralized exchanges. When users send a swap transaction, they provide several parameters to the smart contract — which tokens to swap, the swap amount, and most importantly, the minimum number of tokens a user must receive for the transaction to go through. This last parameter specifies that the swap must satisfy a “minimum output,” or revert. This is often known as “slippage tolerance,” as it effectively sets the maximum price change that can occur between when the transaction is sent to the mempool and when it is included in a block. If this parameter is set too low, the user accepts the possibility of receiving fewer tokens. This situation can also lead to a sandwich attack, where an attacker effectively sandwiches the bid between two malicious swaps. The swaps drive up the spot price and forces the user’s trade to execute at a less favorable price. The attacker then sells immediately to collect a small profit.

So long as this minimum output parameter is set near the fair value, you are safe from sandwich attacks. But what if your RPC provider doesn’t provide an accurate price quote from the decentralized exchange smart contract? A user can then be tricked into signing a swap transaction with a lower minimum output parameter, and, to make matters worse, sends the transaction straight to the malicious RPC provider. Instead of broadcasting this transaction to the public mempool, where dozens of bots compete to perform the sandwich attack, the provider can withhold it and send the attack transaction bundle directly to Flashbots, securing the profits for themselves.

The root cause of this attack is trusting somebody else to fetch the state of the blockchain. Experienced users have traditionally solved this problem by running their own Ethereum nodes — a time and resource-intensive endeavor that, at the very least, requires a constantly-online machine, hundreds of gigabytes of storage, and around a day to sync from scratch. This process is certainly easier than it used to be; groups like Ethereum on ARM have worked tirelessly to make it possible to run nodes on low-cost hardware (such as a Raspberry Pi with an external hard drive strapped to it). But even with these relatively minimal requirements, running a node is still difficult for most users, particularly for those using mobile devices.

It’s important to note that centralized RPC provider attacks, although entirely plausible, are generally simple phishing attacks — and the one we describe has yet to happen. Even though the track records of larger providers like Alchemy give us little reason to doubt them, it’s worth doing some further research before adding unfamiliar RPC providers to your wallet.

introducing helios: fully trustless access to ethereum

By introducing its light client protocol (made possible by the recent switch to Proof of Stake), Ethereum opened exciting new possibilities for quickly interacting with the blockchain and verifying RPC endpoints with minimal hardware requirements. In the month’s since The Merge, we’ve seen a new crop of light clients emerge independently of each other (LodestarNimbus, and the JavaScript-based Kevlar) that have taken different approaches in service of the same goal: efficient and trustless access, without using a full node.

Our solution, Helios, is an Ethereum light client that syncs in around two seconds, requires no storage, and provides fully trustless access to Ethereum. Like all Ethereum clients, Helios consists of an execution layer and a consensus layer. Unlike most other clients, Helios tightly couples both layers so that users only need to install and run a single piece of software. (Erigon is moving in this direction as well, by adding a consensus layer light client built directly into their archive node). 

So how does it work? The Helios consensus layer uses a previously known beacon chain blockhash and a connection to an untrusted RPC to verifiably sync to the current block. The Helios execution layer uses these authenticated beacon chain blocks in tandem with an untrusted execution layer RPC to prove arbitrary information about the chain state such as account balances, contract storage, transaction receipts, and smart contract call results. These components work together to serve users a fully trustless RPC, without the need to run a full node.

…At the consensus layer

The consensus layer light client conforms to the beacon chain light client specification, and makes use of the beacon chain’s sync committees (introduced ahead of the Merge in the Altair hard fork). The sync committee is a randomly selected subset of 512 validators that serve for ~27-hour periods. 

When a validator is on a sync committee, they sign every beacon chain block header that they see. If more than two-thirds of the committee signs a given block header, it is highly likely that that block is in the canonical beacon chain. If Helios knows the makeup of the current sync committee, it can confidently track the head of the chain by asking an untrusted RPC for the most recent sync committee signature. 

Thanks to BLS signature aggregation, only a single check is required to validate the new header. If the signature is valid and has been signed by more than two-thirds of the committee, it’s safe to assume the block was included in the chain (of course it can be reorg’d out of the chain, but tracking block finality can provide stricter guarantees).

There’s an obvious missing piece in this strategy, though: how to find the current sync committee. This starts with acquiring a root of trust called the weak subjectivity checkpoint. Don’t let the name intimidate you — it just means an old blockhash that we can guarantee was included in the chain at some point in the past. There is some interesting math behind exactly how old the checkpoint can be; worst-case analysis suggests around two weeks, while more practical estimates suggest many months. 

If the checkpoint is too old, there are theoretical attacks that can trick nodes into following the wrong chain. Acquiring a weak subjectivity checkpoint is out of band for the protocol. Our approach with Helios provides an initial checkpoint hardcoded into the codebase (which can easily be overridden); it then saves the most recent finalized blockhash locally to use as the checkpoint in the future, whenever the node is synced. 

Conveniently, beacon chain blocks can be hashed to produce a unique beacon blockhash. This means it’s easy to ask a node for a full beacon block, and then prove the block contents are valid by hashing it and comparing to a known blockhash. Helios uses this property to fetch and prove certain fields inside the weak subjectivity checkpoint block, including two very important fields: the current sync committee, and the next sync committee. Critically, this mechanism allows light clients to fast forward through the blockchain’s history.

Now that we have a weak subjectivity checkpoint, we can fetch and verify the current and next sync committees. If the current chain head is within the same sync committee period as the checkpoint, then we immediately start verifying new blocks with the signed sync committee headers. If our checkpoint is several sync committees behind, we can:

  1. Use the next sync committee after our checkpoint to fetch and verify a block that originates one sync committee in the future.
  2. Use this new block to fetch the new next sync committee.
  3. If still behind, return to step 1.

Each iteration of this process allows us to fast forward through 27 hours of the chain’s history, start with any blockhash in the past, and sync to the current blockhash.

…At the execution layer

The goal of the execution layer light client is to take beacon block headers that are verified by the consensus layer, and use them along with an untrusted execution layer RPC to provide verified execution layer data. This data can then be accessed via an RPC server that is locally hosted by Helios.

Here’s a simple example of fetching an account’s balance, starting with a quick primer on how state is stored in Ethereum. Each account contains a couple fields, such as the contract code hash, nonce, storage hash, and balance. These accounts are stored in a large, modified Merkle-Patricia tree called the state tree. If we know the root of the state tree, we can validate merkle proofs to prove the existence (or exclusion) of any account within the tree. These proofs are effectively impossible to forge.

Helios has an authenticated state root from the consensus layer. Using this root and merkle proof requests to the untrusted execution layer RPC, Helios can locally verify all data stored on Ethereum.

We apply different techniques to verify all sorts of data used by the execution layer; used together, these allow us to authenticate all data retrieved from the untrusted RPC. While an untrusted RPC can deny access to data, it can no longer serve us incorrect results.

using helios in the wild

The tradeoff between portability and decentralization is a common pain point — but since Helios is so lightweight, users can access secure chain data from any device (including mobile phones and browser extensions). The ability to run Helios anywhere makes it possible for more people to access trustless Ethereum data, regardless of their hardware. This means users can use Helios as their RPC provider in MetaMask, and trustlessly access dapps without any other changes. 

Further, Rust’s support for WebAssembly makes it easily possible for app developers to embed Helios inside Javascript applications (like wallets and dapps). These integrations would make Ethereum safer, and reduce our need to trust centralized infrastructure.

We can’t wait to see what the community comes up with. But in the meantime, there are lots of ways to contribute to Helios — if you’re not interested in contributing to the codebase, you can also build software that integrates Helios to take advantage of its benefits. These are just a few of the ideas we’re excited about:

  • Support fetching light client data directly from the P2P network rather than via RPC
  • Implement some of the missing RPC methods
  • Build a version of Helios that compiles to WebAssembly
  • Integrate Helios directly into wallet software
  • Build a web dashboard to view your token balances that fetches data from Helios embedded into the website with WebAssembly
  • Implement the engine API so that Helios’ consensus layer can be connected to an existing execution layer full node
Comments

All Comments

Recommended for you

  • Lumoz supports Op Stack + ZK Fraud Proof, Initiating a New Paradigm in L2 Architecture

    After completing a total of tens of millions of dollars in financing, the modular computing layer Lumoz continues to make strides in the Layer 2 (L2) space. This week, Lumoz announced that its Modular Compute Layer will support the Op Stack + ZK Fraud Proof Layer 2 architecture, initiating a new paradigm in L2 architecture.

  • Scammers use Google to promote fake Whales Market website to steal cryptocurrency

    According to a report from BleepingComputer, threat actors have discovered a method where scammers use Google's platform to promote phishing websites impersonating Whales Market in order to steal cryptocurrency. These fraudulent websites are placed as sponsored links (i.e. advertisements) at the top of Google search result pages, and despite the domain address displayed on the search result page appearing to be real, users will be redirected to the fake website upon clicking.

  • Bitcoin Halving Happens This Week: HTX Liquid Restaking with New Momentum Fuels Your Crypto Growth

    The highly anticipated Bitcoin halving event is expected to arrive on April 20, 2024. As the block reward falls from 6.25 to 3.125, the cryptocurrency market will undergo a significant shift. Investors worldwide are seeking new ways to maximize their returns in this dynamic landscape.

  • Cyvers: Hedgey suffered the same vulnerability on Arbitrum and lost about $42.8 million

    Cyvers Alerts on X platform stated that the system detected that the financial derivative agreement Hedgey Finance executed the same vulnerability on the ARB chain and gained approximately 42.8 million US dollars in profit.

  • Tether issues 1 billion USDT on Ethereum (authorized but not yet issued)

    Whale Alert has monitored Tether Treasury's addition of 1 billion USDT on Ethereum. Tether CEO Paolo Ardoino stated that this 1 billion USDT is a supplement to Ethereum inventory. This is an authorized but unissued transaction, which means that this issuance will be used for the next issuance request and cross-chain exchange inventory.

  • CertiK: Hedgey vulnerability was exploited and $1.9 million was stolen

    CertiK Alert posted on social media that it has detected that the on-chain token infrastructure protocol Hedgey has been exploited and stolen approximately 1.9 million US dollars.The attacker abused the createLockedCampaign function in flash loans to obtain approval for the use of tokens on the victim's contract. The USDC, NOBL, and MASA tokens in the victim's contract have been depleted.

  • Binance executives' bail application postponed again, still in custody

    The bail hearing for Binance executive Tigran Gambaryan has been postponed again by a Nigerian court, and he remains detained at the Kuje Correctional Center. The hearing is now scheduled for April 22, with the EFCC requesting time to respond to new arguments from the defense. Gambaryan's lawyer criticized the prosecution for failing to respond promptly. Binance has been accused of concealing the source of its income, while Gambaryan is accused of money laundering. In addition, he has also filed a lawsuit against the government for violating his human rights.

  • BTC breaks through $64,000

    The market shows BTC breaking through $64,000, now reporting at $64,012.44, with an intraday increase of 4.95%. The market fluctuates greatly, so please be prepared for risk control.

  • SEC accuses Justin Sun of frequent trips to the U.S. to sell tokens

    The US SEC has amended its lawsuit against Tron founder Sun Yuchen, stating that his frequent travel to multiple locations in the US allows the court to have corresponding jurisdiction. The SEC accuses Sun Yuchen and his company of selling unregistered securities through Tron and BitTorrent (BTT) tokens and engaging in manipulative money laundering transactions. The SEC claims that Sun Yuchen spent more than 380 days in the US from 2017 to 2019, with travel destinations including New York, Boston, and San Francisco. Sun Yuchen argues that the token sales were conducted entirely overseas, avoiding the US market, and therefore the SEC has no jurisdiction over him and the Tron Foundation, which is headquartered in Singapore. (Cointelegraph)

  • Cyvers Alerts: Multiple phishing transactions detected this morning

    Cyvers Alerts reported on X platform that multiple phishing transactions were discovered by the system this morning. The victims have approved the external owned accounts (EOA) of the phishers. We strongly recommend revoking the relevant approvals.