Home > web3.0 > body text

A deep dive into OpenRank's Eigentrust algorithm: How to build a social computing layer?

WBOY
Release: 2024-06-24 13:33:20
Original
509 people have browsed it

Original title: "OpenRank: Powering Apps with Contextual and Personalized Graph Feeds"

Editor's Note:

In this article, the author takes an in-depth look at OpenRank's Eigentrust algorithm, which is currently used by Metamask Snaps, Degen tips and A new technology used by Supercast. OpenRank, as a computing layer, can run multiple reputation graph algorithms. The first one introduced is the eigentrust algorithm. The authors share why you need community-built graphs, key concepts of the algorithm, how it works, and how to create your own graphs. In addition, the author previews upcoming Bytexexplorers tasks and encourages readers to subscribe to get the latest updates.

Most of today’s cryptocurrency frontends consist of simple leaderboards with top coins sorted by trading volume, liquidity, minting, points, votes, etc. If we want to get into a consumer-grade cryptocurrency experience that can surpass today's Web2 giants, we need more than leaderboards in our apps.

OpenRank is one of the cornerstones that helps us achieve this and is already used by Metamask Snaps, Degen Tips and Supercast. OpenRank is a computational layer that can run a number of reputation graph algorithms, the first of which is the eigentrust algorithm.

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

The importance of community-built graphs, and why you need them

Key concepts of the algorithm and how it works

To learn how to create your own graph, refer to a graph I made in a Python notebook

Let’s get started!

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

When building algorithms and recommendation flows in cryptocurrency, you will quickly face some data problems:

· Transactions contain many layers of operations

· Relationships between addresses can become infinitely complex with multiple transactions

· The address itself contains partial identities, each of which is relevant in different contexts

All three points above are evolving at an exponential rate, let’s call these growing elements “context”.

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

You also don’t want your backend or data engineering team to handle these problems, after all they have a product to build. The days of apps having users and user data structures are over, you no longer just have a simple link, user ID, like/reply/share and post ID, but you can have redemptions, splits, drops, swaps, Staking, delegation, voting, minting and more. There are new "operations" appearing almost every day, as well as new chains, new types of wallets, new types of identities, and so on.

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 have been in Dune’s wizard community for many years and have witnessed the power of the community. Powerful, beyond the capabilities of small teams. I've also seen almost every small crypto team go from "Yeah, we can do this on our own with a node and an RDS database" to "We need to leverage community-built data tools like The Graph and Dune." For me, creating a combination of queries and graphs tuned for a specific type of recommendation flow and community is a similar problem. We need to start collecting and testing graphs that can provide recommendation flow on every application, from Farcaster clients to block explorers.

The concept of a recommendation flow is mimetic and will be eliminated. Users become curators of content

In the cryptocurrency space, users not only want to bring their social graphs to different applications, but also the context hidden in these graphs. If I'm actively following the /degen community on Farcaster, I'd like to be recommended on Zora, Roam.xyz or OnceUpon for that community's activities, and I'd like to be able to switch that recommendation to the context of another community I'm a member of, e.g. artblocks collector. The future will be one where users discover and choose their own feeds, rather than being limited to a certain 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 world, you could imagine using it to proxy high-quality governance principals or identify trustworthy smart contracts.

Here’s the formula for Eigentrust:

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

There are two key inputs: pre-trusted nodes and the local trust graph. "P" is your pre-trust and "S" is your local trust.

· Localtrust: This is your measurement of the interaction between two nodes, when node "i" passes some value to node "j". This could be token transfers, attestations, vote replies/likes, etc.

· Pretrust: This is your choice of "seed" for 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 typically have a power-law distribution, so higher pre-trust weights help normalize the distribution of final ranking values.

If these mathematical formulas are not easy to understand, it can be compared to a social graph like Twitter, where influence such as followers, likes, replies, etc. are usually concentrated in a small number of people, resulting in power law dynamics. By setting up 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.

What does this have to do with selecting any context and creating any recommendation flow?

Suppose you want to sort 10,000 grant proposals in a recommendation stream. You can value-rank all voters and proposers based on a set of voting interactions (local trust) and a set of trusted voters of your own choosing (pre-trust). You can select your pre-confidence voters by selecting the top 10 voters to whom you have delegated votes 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-trusted nodes.

With this, you can now weigh real-time governance proposals using this ranked value list for a more personalized recommendation flow!

This is probably still too abstract, so I’ll explain it with concrete code examples in the next section. Keep in mind that OpenRank handles the computation and storage of these Eigentrust graphs and recommends that you can use the output recommendation stream. All you need to do is decide on pre-trust 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 the user wallet of Farcaster/base (Farcaster is a Twitter-like application). The output is just a list of ids and values, in my diagram each id is associated with a Farcaster user id (fid).

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

<em><span style="font-size: 14px;">数据来源</span></em>
Copy after login
Copy after login
Copy after login

After creating the ranking graph, we generated this referral flow based on their main contract interactions last week:

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

<span style="font-size: 14px;">数据来源</span>
Copy after login

You can view the dashboard to see other referral flows created from this graph, e.g. NFT minting, DEX token trading and Farcaster channel activity.

Code Implementation

Now that you see the goal, let’s talk about how I created this ranking chart.

All the code for this example can be found in the hex.tech notebook, or you can use 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 for our "pre-trust node". This query outputs the top users in the channel based on interactions received (likes, retweets, replies), my formula is (likes + 3 retweets + 10 replies). We will take the first 100 ids from this query as our trust nodes.

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

<em><span style="font-size: 14px;">数据来源</span></em>
Copy after login
Copy after login
Copy after login

The second query is used to track on-chain interactions between nodes, using the link address of the user in the /base channel. Because the subscription flow will recommend on-chain actions, I want to make sure to choose an interaction graph based on the amount of on-chain interactions. Using the USD value transferred between nodes is a good general proxy - I've tracked stablecoin and ETH transfers on Optimism, Base and the Ethereum mainnet.

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

<em><span style="font-size: 14px;">数据来源</span></em>
Copy after login
Copy after login
Copy after login

Analyze the input graph and test the output Eigentrust graph

Now that we have the pre-trusted nodes and the local trust graph, let’s look at some summary statistics. 65,755 users in the /base channel have transferred tokens to others in the channel, and 19% of the graph (i.e. connected nodes) can be traversed from our pre-trusted nodes. This percentage may vary depending on how Sybil the graph's local trust data is. Token transfers can be high signals, but they can also be brush trades, so it’s not surprising that the majority of the graph is unconnected.

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

After confirming that the size of the input data and connections 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 OpenRank SDK as the scikit-learn of cryptograph models.

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

Do you still remember the constant "c" in the previous formula? Let's do a grid search on different c values ​​(I'll call it alpha) and different pre-trust seed sizes to see which one gives us the most log-normal trust score and the highest coverage:

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

There are a lot of tradeoffs here and there is no one best value to choose from. High regularization and coverage is a good choice if you want strong diversity in recommendations, but for high-stakes governance votes you might actually want a higher concentration of trust. Use your intuition here.

From here, we can insert values ​​into the subscription query linked at the beginning of Dune's dashboard to get a flow of contract interactions for trusted users in the /base channel. This subjective recommendation output helps us better connect the previous common metrics with our expected intuition about the quality of the recommendation output.

深入探讨 OpenRank 的 Eigentrust 算法:如何构建社交计算层?

Done! You can use this Dune API to power any of your apps right away.

Learn to build your own OpenRank Eigentrust graph

Are you ready to do it yourself? You can fork my notebook and try it yourself, all the links needed are below:

· OpenRank Docs

· Python SDK repo

· Python Notebook

· Dune feed dashboard

I will be running a Bytexplorers mission within the next month , we will compete to create the best subscription flow graph for top crypto applications.

The above is the detailed content of A deep dive into OpenRank's Eigentrust algorithm: How to build a social computing layer?. For more information, please follow other related articles on the PHP Chinese website!

source:chaincatcher.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!