In-depth exploration of OpenRank's Eigentrust algorithm: How to build the social computing layer?

BlockBeats
2024-06-24 12:43:42
Collection
The Eigentrust algorithm is similar to PageRank, as it ranks nodes in a graph network. The difference is that it focuses on capturing complex peer-to-peer relationships as a distribution of trust.

Original Title: “OpenRank: Powering Apps with Contextual and Personalized Graph Feeds”

Author: Andrew Hong

Compiled by: Ladyfinger, BlockBeats

Editor's Note:

In this article, the author delves into OpenRank's Eigentrust algorithm, a new technology currently used by Metamask Snaps, Degen Tips, and Supercast. OpenRank serves as a computational layer capable of running various reputation graph algorithms, with the eigentrust algorithm being the first introduced. The author shares why community-built graphs are necessary, the key concepts of the algorithm, how it works, and how to create your own graph. Additionally, the author previews an upcoming Bytexplorers task, encouraging readers to subscribe for updates.

Today's cryptocurrency frontends mostly feature simple leaderboards ranking top tokens by trading volume, liquidity, minting, points, voting, etc. If we want to enter a consumer-grade cryptocurrency experience that can surpass today's Web2 giants, our applications need more than just leaderboards.

OpenRank is one of the cornerstones to help us achieve this goal and has been utilized by Metamask Snaps, Degen Tips, and Supercast. OpenRank is a computational layer that can run many reputation graph algorithms, with the first being the eigentrust algorithm.

In this article, I will introduce you to OpenRank's eigentrust algorithm and discuss the following topics:

  • The importance of community-built graphs and why you need them
  • The key concepts of the algorithm and how it works
  • How to create your own graph, referencing one I created in a Python notebook

Let’s get started!

Why Build Recommendation Graphs with the Community Instead of Relying Solely on Your Own Machine Learning Team?

When building algorithms and recommendation streams in cryptocurrency, you will quickly face some data challenges:

  • Transactions involve many layers of operations
  • Relationships between addresses can become infinitely complex through multiple transactions
  • Addresses themselves contain partial identities, each relevant in different contexts

All three of these points are evolving at an exponential rate, so let’s refer to these growing elements as "context."

Your Small ML Team Can't Keep Up with These Endless Innovations

You also don’t want your backend or data engineering team to handle these issues, after all, they have products to build. The era of applications having a simple link, user ID, likes/replies/shares, and post ID is over; you can now have swaps, splits, drops, exchanges, staking, delegating, voting, minting, and more. New "operations" emerge almost daily, along with new chains, new types of wallets, new types of identities, and so on.

I Believe the Cryptocurrency Industry Will Develop a Graph Data Science Community Based on the OpenRank Protocol and Products in the Coming Year

I have been part of the Dune wizard community for years, witnessing the immense power of community surpassing the capabilities of small teams. I have also seen almost every small crypto team transition from "Yes, we can do this independently with one node and an RDS database" to "We need to leverage community-built data tools like The Graph and Dune." For me, creating queries and chart combinations tailored to specific types of recommendation streams and community adjustments is a similar issue. We need to start collecting and testing charts that can provide recommendation streams across every application, from Farcaster clients to block explorers.

The Concept of a Recommendation Stream is Obsolete; Users Become Curators of Content

In the cryptocurrency space, users not only want to bring their social graphs to different applications but also want to carry the context hidden within those graphs. If I am actively following the /degen community on Farcaster, I want to be recommended activities from that community on Zora, Roam.xyz, or OnceUpon, and I want to be able to switch that recommendation to the context of another community I participate in, such as artblocks collectors. The future will be an era where users discover and choose their own feeds, rather than being limited to a group or channel feature on a single platform.

How Does OpenRank's Eigentrust Algorithm Work?

The Eigentrust algorithm is similar to PageRank, ranking nodes in a graph network. The difference is that it focuses on capturing complex peer-to-peer relationships as a distribution of trust. It was originally built to assign trust scores in file-sharing networks. In the cryptocurrency space, you can imagine using it to proxy high-quality governance delegates or identify trustworthy smart contracts.

Here is the formula for Eigentrust:

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

There are two key inputs above: pretrust nodes and local trust graphs. "P" is your pretrust, and "S" is your local trust.

  • Local Trust (localtrust): This is your measurement of interaction between two nodes when node "i" conveys some value to node "j." This could be token transfers, proofs, voting replies/likes, etc.

  • Pretrust (pretrust): This is your "seed" selection of nodes in the network that should be more trustworthy.

  • "c": This constant (between 0 and 1) is the weight of the trust value between the overall local trust graph and the pretrust seeds. Interaction graphs typically have a power-law distribution, so a higher pretrust weight helps normalize the distribution of the final ranking values.

If these mathematical formulas are hard to grasp, you can think of them as social graphs like Twitter, where influence from followers, likes, replies, etc., is usually concentrated among a few individuals, leading to power-law dynamics. By setting a group of influential individuals and choosing a constant "c" value of 0.5 or higher, the people these trusted individuals interact with will inherit half the value of that influence. This is how to balance and distribute trust scores more evenly across the network.

How Does This Relate to Choosing Any Context and Creating Any Recommendation Stream?

Suppose you want to rank 10,000 funding proposals in a recommendation stream. Based on a set of voting interactions (local trust) and a set of trusted voters you choose (pretrust), you can rank all voters and proposers by value. You can select your pretrust voters by choosing the top 10 voters you delegate votes to across multiple DAOs. Eigentrust will run based on these two inputs and give you a larger list of voters ranked in the graph based on the trust inherited from the pretrust nodes.

This way, you can now use this ranked value list to weigh real-time governance proposals for a more personalized recommendation stream!

This may still be too abstract, so I will illustrate it with specific code examples in the next section. Remember, OpenRank handles the computation and storage of these Eigentrust graphs and recommends the output recommendation streams you can use. All you need to do is decide on the pretrust and local trust inputs.

How to Build an Eigentrust Graph Using OpenRank?

Final Goal

In this example, I want to provide a subscription stream of recommended contracts based on users' wallets from Farcaster/base (Farcaster is a Twitter-like application). The output is simply a list containing IDs and values, where each ID in my graph is associated with a Farcaster user ID (fid).

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

https://dune.com/ilemi/openrank

After creating the ranking graph, we generated this recommendation stream based on their main contract interactions from last week:

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

https://dune.com/ilemi/openrank

You can view the dashboard to see other recommendation streams created from this graph, such as NFT minting, DEX token trading, and Farcaster channel activities.

Code Implementation

Now that you’ve seen the goal, let’s talk about how I created this ranking graph.

All the code for this example can be found in the hex.tech notebook, and if you prefer to run it locally, you can use the jupyter notebook.

First, I created two queries for our pretrust and local trust:

The first query is our "pretrust nodes." This query outputs the top users in the /base channel based on received interactions (likes, shares, replies), with my formula being (likes + 3 shares + 10 replies). We will take the top 100 IDs from this query as our trust nodes.

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

https://dune.com/queries/3756241

The second query is used to track on-chain interactions between nodes, using the linked addresses of users in the /base channel. Since the subscription stream will recommend on-chain operations, I want to ensure that the interaction graph is based on the volume of on-chain interactions. Using the dollar value of transfers between nodes is a good general proxy—I tracked stablecoin and ETH transfers on Optimism, Base, and Ethereum mainnet.

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

https://dune.com/queries/3756692

Analyze the Input Graph and Test the Output Eigentrust Graph

Now that we have the pretrust nodes and local trust graph, let’s look at some summary statistics. There are 65,755 users in the /base channel who transferred tokens to others in that channel, and we can traverse 19% of the graph from our pretrust nodes (i.e., connected nodes). This percentage may vary based on the degree of Sybil in the local trust data of the graph. Token transfers may be high signal, but they can also be subject to wash trading, so it’s not surprising that much of the graph is unconnected.

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

After confirming that the size and connectivity of the input data are reasonable, we can run and save our Eigentrust graph. I saved my graph as ID "basetransfer50"—you can see below that it only takes 10 lines of code to train the graph. You can think of the OpenRank SDK as the scikit-learn for crypto graph models.

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

Remember the constant "c" from the earlier formula? Let’s perform a grid search over different c values (which I call alpha) and different pretrust seed sizes to see which gives us the most log-normal trust scores and highest coverage:

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

There are many trade-offs here, and there is no single best value to choose. If you want recommendations to have strong diversity, high regularization and coverage is a good choice, but for high-stakes governance votes, you may actually want higher concentration of trust. Your intuition can guide you here.

From here, we can insert the values into the subscription query linked at the start of the Dune dashboard to get the contract interaction stream of trusted users in the /base channel. This subjective recommendation output helps us better connect previous general metrics with our expected intuition about the quality of recommendation outputs.

In-depth Exploration of OpenRank's Eigentrust Algorithm: How to Build a Social Computing Layer?

Done! You can immediately use this Dune API to power any of your applications.

Learn to Build Your Own OpenRank Eigentrust Graph

Are you ready to get hands-on? You can fork my notebook and try it yourself, with all the necessary links below:

I will be launching a Bytexplorers task within the next month, where we will compete to create the best subscription stream charts for top crypto applications.

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
ChainCatcher Building the Web3 world with innovators