Case Study: RAILGUN leveraging SQD Trace Data to enable Privacy Pools
Fact Sheet/ Profile
Quick description of Railgun: Railgun is a fully on-chain privacy infrastructure for EVM. It enables private use of public DeFi without any limitations on liquidity and security. When using the Railgun wallet, anyone can interact privately and securely with existing DeFi apps.
Chains served: Ethereum, BNB Chain, Polygon, Arbitrum.
Make or break features: Scalability and feature completeness across multiple chains.
Using SQD for: fast access to public blockchain data, alternative to RPC calls
Benefits of using SQD: reduced balance scanning times, feature completeness across multiple chains, fantastic response time
Only possible with SQD: Call tracing, which enables Railgun deployment on chains.
How Railgun is leveraging SQD for its privacy-enabling infrastructure
Railgun provides a privacy layer, shielding users' transactions and enabling them to maintain anonymity while interacting with smart contracts and DeFi apps. This approach addresses the inherent transparency of blockchains, masking details of asset transfers while also retaining the option to “unshield” a transaction if a user wishes to do so.
Use cases range from individuals simply wanting to maintain their privacy to corporate usage where companies want to comply with data protection and privacy laws.
While Railgun serves an important, unmet need in the current Web3 ecosystem, its privacy tech also poses challenges in developing an easy-to-use suite of tools for retail users. As Railgun contributors put it, “Building privacy tools is tough,” and building a protocol that does not leak any financial information is complex.
Since Railgun is built on top of existing blockchain infra it requires efficient data servicing to facilitate user privacy. Privacy is important, yet it also needs to be balanced with user experience. Prior to using SQD, Railgun relied heavily on Quicksync and used direct RPC calls as a fallback option to access blockchain data. Further improving on this, Railgun moved to scan balances with Subgraphs instead, which improved the time a little.
Privacy pools (otherwise known as private proofs of innocence) is the Railgun user compliance tool that privately proves funds entering the system are clean of bad activity. However, as Railgun privacy pools is multi-chain, just serving Ethereum wasn’t enough and it lacked a tool to go multi-chain with. With SQD, Railgun contributors found a solution that allows the deployment of privacy pools on all chains Railgun is deployed on, while also having the option to expand even further across chains without the need to migrate to a new indexing solution.
Call Tracing
Call traces capture information such as the input, output, and gas details of any nested smart contract and transaction in the EVM. For example, when using call tracing, a developer can access the input data and parameters provided when a function is called or see details of a transaction, including those that are not on-chain.
For Railgun, accessing such data is crucial for privacy pools to function quickly and cross-chains.
“As far as RAILGUN is concerned, call tracing is for the Privacy Pool/Proof of Innocence Mechanism. Without call tracing on Polygon, PPOI can't be deployed for that chain.”
In this deployment, call tracing enables the detection of other smart contract calls to ensure that, even if a user submits their proof of innocence outside of the railgun smart contract, the indexer can still extract and process the data.
In other words, it would be impossible for the Railgun flagship user compliance tool to go multi-chain without SQD. Now, the intention is to continue this with future network integrations.
SQDis currently the only decentralized solution offering call tracing on EVM chains. An example of what’s possible with this feature can be found here: indexing all Ethereum NFT transfers.
Migrating from the Graph to SQD
According to RAILGUN contributors, privacy pools require “...accurate and fast blockchain data, that currently only SQD can serve.“
Contributors’ impetus for switching to SQD from their previous solution (Subgraphs) was precisely that: ”The Graph seemingly full stop just won't support call tracing on Polygon... They made it seem like it was "too hard" or even impossible.”
The reason it’s nearly impossible for a solution like The Graph to offer call tracing at scale is that call traces are not information usually stored by RPC nodes. Instead, the information is served on demand and requires nodes to replay the entire transaction - a compute-heavy process that is expensive.
Additional Speed Boosts
In addition to the context that RAILGUN can get, thanks to SQD’s support for traces, contributors were highly impressed by the significant reduction in the time it takes to scan balances. “A boost in overall balance scanning times was also a nice bonus.” This opens up opportunities for faster iterations and, indeed, for entirely new and more advanced product feature developments.
Working together
Railgun contributors described working with Subsquid Labs members as a fantastic experience describing them as:
“Friendly and responsive and even worked closely with RAILGUN contributors to optimize queries for efficiency and assisted in setup across the whole process.”