LukeYoungblood.eth ๐Ÿ›ก๏ธ Profile picture
Apr 27, 2024 โ€ข 25 tweets โ€ข 9 min read โ€ข Read on X
Web3 data is broken...

I didn't quite realize how badly until just recently, but we hit some hard scaling challenges at @MoonwellDeFi as we crossed 40,000 wallets on @Base. ๐ŸŒœ๐Ÿ”ต๐ŸŒ›

In the last 3 months, our community on Base has quadrupled. This is a great problem to have... ๐Ÿงต Image
Before our launch on Base last year, we designed a new data architecture that enabled us to show beautiful market and portfolio graphs in our app. Using GraphQL, we were able to capture daily snapshots of your positions, and show your portfolio history over time.
This worked beautifully, and was well received by our community, but we knew it was a somewhat inefficient way to do this. As we recently reached over 40,000 wallets, it was now taking several hours per day to index all of this onchain data and generate these daily snapshots.
For context, it takes almost a month now for us to index our GraphQL data from the beginning of our protocol launch in 2022. We planned on refactoring our data architecture this summer so we could scale to the millions of wallets that will come onchain. ๐ŸŒœ๐ŸŒž๐ŸŒ›
This is not unique to us. @Uniswap's subgraph takes a month to sync as well, and they only have to index swap and LP events. Imagine being a data engineer at Uniswap or Moonwell and having to wait a month to test a new feature... ๐Ÿ˜…

I woke up April 18th to this ominous message: Image
We use both @Goldskyio and @AlchemyPlatform for subgraph hosting. They are some of the best web3 hosts in the space, and our subgraph had failed on both, with this ominous message in the logs.

We had hit an unknown limit or bug in The Graph node itself: github.com/graphprotocol/โ€ฆ

Image
Image
One of the core maintainers of The Graph node was very interested in fixing our problem, however, when I asked our friends at @Goldsky how soon we might get a fix, they indicated The Graph doesn't typically cut a release for months... We struggled to come up with a workaround. This is the CTO of Goldsky, Paymahn Moghadasian, relaying our issue and how we hit this limit indexing about 30,000 wallets.
Coincidentally, @x0s0l and I had already been researching an alternative backend, @ponder_sh, as an eventual replacement for The Graph. One of the challenges we were aiming to solve was multi-chain support. We support 5 networks now, and have 2 subgraphs on each. Image
One of the challenges with having so many subgraphs is that our app needs to pull data from all of them, so we're running identical queries across 10 different backend APIs at once instead of just one. And making a change to add a new column of data requires super long reindexing Image
With @ponder_sh we could index all of the networks we support in parallel from a single indexer, and we could query data on all the networks with a single API endpoint. We could also index on our laptops locally, which was too slow using the open source node from The Graph. Image
Here we were a week ago, with a subgraph that crashed due to a previously unknown scalability limit, with no fix in sight. We had two options:
- Refactor our subgraph to make it more efficient by only snapshotting N accounts per event
- Migrate to @ponder_sh, a refactor in itself
We decided to try @ponder_sh. There were two major factors leading to our decision:
1) With some early testing we determined we could capture the daily snapshots in ~5 minutes per day instead of ~3 hours, and we could index all our data in just a few hours, vs. ~30 days
2) Even if we could work around the issue in The Graph, hitting this limit at only ~30,000 wallets indicated that it would be extremely unlikely that we could ever scale to 100,000, much less the millions of users that will soon be using @Base as @Coinbase onboards retail users.
The only challenge with @ponder_sh is hosting: you're kind of on your own, and we prefer to use cloud services. We found this really awesome service called @Railway that makes hosting super easy. I used to work at @AWScloud and this is 100x easier. Here's how I setup our backend: Image
First, I setup a staging environment, so we could test upgrades and improvements, as well as west and east coast production environments, so you could access our data in the region closest to you, as measured by latency. Image
For a robust @ponder_sh environment suitable for production you'll want something like this:
- A Postgres database
- An indexer deployment: this system indexes all the data from each network's RPCs
- A serve-only deployment: this contains 2 or more replica ponder serve containers Image
The east coast region looks exactly the same. This gives you more resilience in case one of the regions is having a bad day, and also enables you to make changes to one at a time to perform zero downtime upgrades.

I recommend pointing each region at a different branch in Github. Image
To pull it all together and provide a more reliable and performant service, we front it with a @Cloudflare load balancer. Cloudflare can do "traffic steering," which enables it to send traffic to the closest region by latency, and it performs health checks from 8 regions globally Image
With a Cloudflare load balancer and traffic steering in place, now we have a consistent URL for Moonwell data:

Anyone can query Moonwell's open data using a very familiar interface: GraphQL. This is also what the app uses to render those beautiful graphs. ponder.moonwell.fi
Image
We still have a lot more optimization to do in order to prepare to scale to the millions of new wallets that will be created during onchain Summer. While we've overcome the current scaling challenge, I'm sure we'll encounter more and need to optimize our data backend further. Image
@base Going forward, I'm confident that @ponder_sh can meet our current and future data needs. In this multi-chain world we're in now, where there are dozens of networks, the single API per network model for The Graph just doesn't seem to scale, and indexing speed is a pain point.
I want to thank @typedarray and the @ponder_sh team for their help and being super responsive in Telegram. They are really shipping improvements fast. Ponder is still very new and a little rough around the edges, but it's rapidly becoming a data powerhouse.
I also think Ponder might be the future of web3 data, and if so, I'm sure the fine people at @Goldsky and @AlchemyPlatform will start offering higher level hosting services for Ponder so that you don't have to build your own infra like we did.
What's next? We still need to migrate our governance subgraphs over to the new data backend, and there are a number of ancillary services that need to be updated, things like Discord bots, etc. We're staying Based and Optimistic, in this new world of multi-chain web3 data! ๐ŸŒœ๐Ÿค”๐ŸŒ›
I hope you've found this thread about our Based data journey helpful.

Follow @MoonwellDeFi and me, @LukeYoungblood for more.

Like/Repost the quote below if you can:

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with LukeYoungblood.eth ๐Ÿ›ก๏ธ

LukeYoungblood.eth ๐Ÿ›ก๏ธ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @LukeYoungblood

May 26
Most financial tools feel overwhelming. They're designed for people who already speak the language of finance. @Mamo_agent takes a different path. It's built for the rest of us - for people who want to grow their money without making it their full-time job. Story time...๐Ÿงต
๐ŸŒœ๐ŸŒฑ๐ŸŒ› Image
In summer 2020 when the world locked down for Covid, I began exploring smarter ways to grow money, not through chasing trends, but calm, steady systems that compound over time. My friends at @Coinbase took notice. Some suggested I start a fund, but I had a different vision... Image
As generative AI revolutionized the world in 2023, I was working on decentralized apps at @MoonwellDeFi, and began thinking about agents with a wallet, and how we might automate the systems for passive wealth creation I had developed in the last few years. The tech wasn't ready. Image
Read 16 tweets
Dec 24, 2024
Last night, a vault on @Optimism named "Moonhacker" had a vulnerability that was exploited and I'd like to explain what happened.

First, let me be clear: All funds on @MoonwellDeFi are safe and there are no vulnerabilities in the Moonwell protocol. ๐Ÿงต
The @CyversAlerts team has already deleted the post above that had incorrect information. Here's what really happened:

The Moonhacker vault deployer and the actual Moonhacker are unknown to our team. The vault appears to have been developed to execute a leveraged USDC strategy.
Many individual whales and funds deploy vaults like this that integrate with Moonwell core markets and vaults. The typical strategy is to supply USDC, then borrow USDC, then supply more, in order to farm WELL and OP liquidity incentives.
Read 19 tweets
Jun 20, 2022
The last several weeks have been challenging for crypto, web3 and DeFi, but even in the darkest of times, green shoots of life emerge.

๐ŸŒฑ One new blossoming ecosystem is @MoonbeamNetwork - an EVM compatible parachain on @Polkadot.

Let's explore! ๐Ÿงต (not financial advice)
@MoonbeamNetwork @Polkadot What makes @Polkadot unique? Parachains and shared security. Parachains are distinct L1 networks that can support any use case. Proof of stake validators on the L0 relay chain provide shared security to all parachains and can pass messages between them.
@MoonbeamNetwork @Polkadot In case it isn't obvious, this gives @MoonbeamNetwork and other parachains superpowers:

๐Ÿ’Œ Send messages and communicate between apps
๐Ÿ’ธ Teleport tokens and NFTs between parachains
๐Ÿฆ Mint digital assets that can be used on all parachains
๐Ÿšซ Reduce or eliminate bridge risk
Read 24 tweets
Dec 22, 2021
I keep getting asked what web3 is. ๐Ÿงต
I can send money to my family overseas without paying over 10% in fees and getting cheated by criminally convicted @WesternUnion. What's more, no corporation can deplatform me or censor the transfers of value to my family. consumer.ftc.gov/blog/2020/09/1โ€ฆ
I can contribute directly to open source projects without any 3rd-party, charity or not, taking a cut of my donation. In addition, a matching pool will probably enhance my contribution. gitcoin.co
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(