原标题:《OpenRank: Powering Apps with Contextual and Personalized Graph Feeds》

Author: Andrew Hong

Compiled by: 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. OpenRank, as a computational layer, is capable of running 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 of 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 helps us achieve this 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 will introduce you to OpenRank’s eigentrust algorithm and discuss the following:

The Importance of Community Building Graphs, and Why You Need Them

Key concepts of the algorithm and how it works

To learn how to create your own plots, follow this one I made in a Python notebook

let's start!

Why build the recommendation graph with the community instead of relying solely on your own machine learning team?

When building algorithms and recommendation flows in crypto, you quickly face a few data problems:

Transactions consist of many levels of operations

The relationship between addresses can become infinitely complex through multiple transactions

The address itself contains parts of the identity, and each identity is relevant in different contexts

All three of the above points are evolving at an exponential rate. Let’s call this growing element “context”.

Your small ML team can’t keep up with these never-ending ideas

You also don’t want your backend or data engineering team to deal with these issues, after all, they have products to build. The days of applications owning users and user data structures are over. Instead of just having a simple link, user ID, likes/replies/shares, and post IDs, you can redeem, split, drop, exchange, stake, delegate, vote, mint, and more. New “operations” appear almost every day, along with new chains, new types of wallets, new types of identities, and more.

I believe that in the next year, the cryptocurrency industry will develop a graph data science community based on the OpenRank protocol and products.

I’ve been in the Dune wizard community for years and have seen the power of the community grow beyond what a small team can do. I’ve 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 community-tuned 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.

The concept of a recommendation stream is skeuomorphic and will be eliminated. Users will become curators of content.

In the crypto space, users not only want to bring their social graphs with them to different applications, they want to bring the context behind those graphs with them. 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, like 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.

How does OpenRank’s Eigentrust algorithm work?

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 could 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 an interaction between two nodes, when node “i” delivers some value to node “j”. This could be a token transfer, a proof, a vote reply/upvote, etc.

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 pre-trust seed. Interaction graphs usually have a power-law distribution, so a higher pre-trust weight helps normalize the distribution of the final ranking value.

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 a power-law dynamic. By setting a set of influential individuals and choosing a constant “c” value of 0.5 or higher, in effect, the people these trusted individuals interact with will inherit half the value of that influence. This is how you balance and distribute trust scores more evenly across the network.

How does this relate to choosing any context and creating any recommendation flow?

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 choose your pre-trust voters by selecting 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 pre-trust nodes.

With that, you can now use this ranked list of values ​​to weigh real-time governance proposals for a more personalized recommendation stream!

This may still be too abstract, so I will walk 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 as output. All you need to do is decide on the pre-trusted and locally trusted inputs.

How to build an Eigentrust graph using OpenRank?

Final goal

In this example, I want to provide a subscription stream of recommendation contracts based on the user's wallet in 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 Sources

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

Data Sources

You can check out the dashboard to see other recommended flows created from this graph, such as NFT minting, DEX token trading, and Farcaster channel activity.

Code

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, 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-trusted nodes". 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 trusted nodes.

Data Sources

The second query is for tracking on-chain interactions between nodes, using the linked addresses of users in the /base channel. Since subscribing to the stream will recommend on-chain actions, I want to make sure to select 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 Sources

Analyze the input graph and test the output Eigentrust graph

Now that we have our pre-trusted nodes and 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 (i.e. connected nodes) can be traversed 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 trades, so it’s not surprising that a large portion of the graph is unconnected.

After confirming that the size and connectivity of the input data is 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. You can 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-trusted 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 might 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 start of Dune’s dashboard to get the contract interaction stream for trusted users in the /base channel. This subjective recommendation output helps us better connect the previous generic metrics with our expected intuition about the quality of the recommendation output.

That’s it! 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 try it yourself? You can fork my notebook and try it yourself, all the links you need are here:

·OpenRank Docs

·Python SDK repo

·Python Notebook

·Dune feed dashboard

I will be running a Bytexplorers mission within the next month where we will compete to create the best subscription flow charts for top crypto apps.