Original title: "OpenRank: Powering Apps with Contextual and Personalized Graph Feeds"
Original author: Andrew Hong
Original translation: Ladyfinger, BlockBeats
Editor's note:
In this article, the author takes a deep dive into OpenRank's Eigentrust algorithm, a new technology currently used by Metamask Snaps, Degen tips, and Supercast. As a computing layer, OpenRank is able to run multiple reputation graph algorithms, starting with the eigentrust algorithm. The author shares why community-built graphs are needed, the key concepts of the algorithm, how it works, and how to create your own graph. In addition, the author previews the upcoming Bytexplorers mission and encourages readers to subscribe to get the latest updates.
Most of today’s cryptocurrency frontends consist of simple leaderboards, top tokens by volume, liquidity, minting, points, voting, etc. If we want to move into consumer-grade cryptocurrency experiences that can outperform today’s Web2 giants, we need more than just leaderboards in our applications.
OpenRank is one of the building blocks that will help us get there, and is already used by Metamask Snaps, Degen Tips, and Supercast. OpenRank is a computational layer that can run many reputation graph algorithms, the first of which is the eigentrust algorithm.
In this post, I’ll introduce you to OpenRank’s EigenTrust algorithm and discuss:
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, see one I made in a Python notebook
Let’s get started!
When building algorithms and recommendation flows in crypto, you quickly face some data problems:
· Transactions contain many layers of operations
· Relationships between addresses can become infinitely complex through multiple transactions
· Addresses themselves contain parts of an identity, each of which is relevant in different contexts
All three of the above are evolving at an exponential rate, let’s call these ever-growing elements “context”.
You also don’t want your backend or data engineering team to deal with these problems, after all, they have products to build. The days of applications owning users and user data structures are over, you no longer just have a simple link, user ID, likes/replies/shares, and post IDs, but you can have redemptions, splits, drops, swaps, stakes, delegations, voting, minting, and more. New "operations" are appearing almost every day, along with new chains, new types of wallets, new types of identities, and more.
I have been in the Dune wizard community for many years and have witnessed the power of the community grow beyond the capabilities of a small team. I have also seen almost every small crypto team go from "yeah, we can do this independently with a node and RDS database" to "we need to leverage community built data tools like The Graph and Dune". To me, creating a combination of queries and graphs that are tuned for specific types of recommendation flows and communities is a similar problem. We need to start collecting and testing graphs that can provide recommendation flows on every application, from Farcaster clients to block explorers.
In crypto, users want to not only bring their social graphs with them to different applications, but also the context hidden in those graphs. If I actively follow the /degen community on Farcaster, I want to be recommended activity 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 about users discovering and selecting their own feeds, rather than being limited to a group or channel feature on a single platform.
The Eigentrust algorithm is similar to PageRank in that 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. It was originally built for assigning trust scores in file-sharing networks. In the cryptocurrency space, you can imagine using it to proxy high-quality governance principals or identify trustworthy smart contracts.
Here is the formula for Eigentrust:
There are two key inputs above: pre-trusted nodes and local trust graph. "P" is your pre-trust and "S" is your local trust.
· Local trust: This is your measurement of the interaction between two nodes, when node "i" passes some value to node "j". This could be a token transfer, proof, vote reply/like, etc.
· Pre-trust: 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 pre-trust seed. Interaction graphs often have a power-law distribution, so higher pre-trust weights help normalize the distribution of final ranking values.
If the math isn’t clear, an analogy is that in a social graph like Twitter, influence in terms of followers, likes, replies, etc. is often concentrated in a small number of people, leading to power-law dynamics. By setting a set of influential individuals and choosing the constant “c” value to be 0.5 or higher, in effect, the people these trusted individuals interact with will inherit half the value of that influence. This is how trust scores are more evenly balanced and distributed across the network.
Let’s say you want to rank 10,000 funding proposals in a recommendation stream. You can rank all voters and proposers for value based on a set of voting interactions (local trust) and a set of trusted voters of your own choosing (pre-trust). You can choose your pre-trust voters by selecting the top 10 voters you have delegated 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 pre-trust nodes.
With this, you can now use this ranked list of value to weigh real-time governance proposals for a more personalized recommendation stream!
This may still be too abstract, so I’ll walk you through it with concrete code examples in the next section. Remember that OpenRank handles the computation and storage of these Eigentrust graphs and recommends a recommendation stream that you can use the output. All you need to do is decide on the pre-trust and local trust inputs.
In this example, I want to provide a subscription stream of recommended contracts based on the user wallet of Farcaster/base (Farcaster is an application similar to Twitter). The output is just a list of ids and values, and in my graph, each id is associated with a Farcaster user id (fid).
Data source
After creating the ranking graph, we generated this recommendation flow based on their main contract interactions last week:
Data Source
You can check out the dashboard to see other referral flows created from this graph, such as NFT minting, DEX token trading, and Farcaster channel activity.
Now that you’ve seen the objective, let’s talk about how I created this ranking graph.
All the code for this example can be found in the hex.tech notebook, or in the jupyter notebook if you prefer to run it locally.
First, I created two queries for our pre-trust and local trust respectively:
The first query is our "pre-trust node". This query outputs the top users in the /base channel based on the interactions (likes, retweets, replies) received, my formula is (likes + 3 retweets + 10 replies). We will take the first 100 ids from this query as our trust nodes.
Data source
The second query is used to track on-chain interactions between nodes, using the linked addresses of users in the /base channel. Because subscribing to the stream will recommend on-chain actions, I want to make sure to choose an interaction graph based on the amount of on-chain interaction. Using the USD value transferred between nodes is a good general proxy - I tracked stablecoin and ETH transfers on Optimism, Base, and Ethereum mainnet.
Data Source
Now that we have our pre-trusted nodes and our local trust graph, let’s look at some summary statistics. There are 65,755 users in the /base channel who have transferred tokens to others in that channel, and 19% of the graph can be traversed (i.e. connected nodes) from our pre-trusted node. This percentage may vary depending on how Sybil-ish the graph’s local trust data is. Token transfers can be high signal, but they can also be wash trading, so it’s not surprising that much of the graph is unconnected.
After confirming that the size and connectivity of our input data are reasonable, we can run and save our Eigentrust graph. I saved my graph with the id “base_transfer_50” - you can see below that it only takes 10 lines of code to train the graph. Think of the OpenRank SDK as the scikit-learn of encrypted graph models.
Remember the constant “c” in the previous formula? Let’s grid search different values of c (which I’ll call alpha) and different pre-trust seed sizes to see which gives us the most log-normal trust scores and the highest coverage:
There are a lot of tradeoffs here, and there is no single best value to choose. If you want strong diversity in your recommendations, high regularization and coverage is a good choice, but for high-stakes governance votes, you may actually want a higher concentration of trust. Use your intuition here.
From here, we can plug the values into the subscription query linked at the beginning of Dune’s dashboard to get the contract interaction stream of trusted users in the /base channel. This subjective recommendation output helps us better connect the previous generic metrics to our expected intuition about the quality of recommendation output.
Got it! You can use this Dune API to power any of your applications right away.
Are you ready to make your own? You can fork my notebook and try it yourself, all the links you need are below: · OpenRank Docs
I’ll be running a Bytexplorers mission over the next month where we’ll be competing to create the best subscription stream chart for a top crypto app, be sure to subscribe to be notified when the mission starts!
Original link
欢迎加入律动 BlockBeats 官方社群:
Telegram 订阅群:https://t.me/theblockbeats
Telegram 交流群:https://t.me/BlockBeats_App
Twitter 官方账号:https://twitter.com/BlockBeatsAsia