USDC Yield With Cover Built InQuicknode Earn now runs USDC yield with cover for protocol risk built in, underwritten by OpenCover. Six covered vaults on Base.
発表を見るWeb3プロバイダーの冗長性の重要性
In a time when we are trying to build unstoppable apps, we must understand the importance of Web3 providers and redundancy of Web3 providers.

2021年1月27日 — 読了時間7分

Web3 providers, also known as Node providers, are essentially blockchain data keepers. These projects run networks of hundreds of blockchain nodes, and are tasked with providing applications with the latest and historical blockchain data.
The Web3 provider is an essential part of a blockchain-powered application. It is what wallets and interfaces/gateways like TrustWallet, MetaMask, and MyCrypto use to "talk" (read/write) to blockchain networks.
Every time you see or ask for a token balance in MetaMask, MetaMask has to first query the blockchain for this data. It does this through the Web3 provider (usually through a library like web3js, ethersjs, ethereum.rb, web3py, etc...).
The Web3 provider then queries the blockchain node(s), and returns the value/data to the app for it to display to the end-user.
Imagine thousands of users asking for their tokens' balance at the same time – that's a lot of requests! This is why companies like Quicknode exist, to be able to quickly and efficiently provide this data, so apps can function even at scale.
This function extends beyond just token balances on Bitcoin, Ethereum, or Solana – smart-contract states on Ethereum are updated almost every 13 seconds (average ETH MainNet block time). Apps relying on smart-contract events must receive updates in real-time. For this apps can subscribe to or poll for events using a Web3 provider.
さて、ノードはピア・ツー・ピア(P2P)ソフトウェアにおいて興味深い要素です。ノードは、台帳の同期された最新コピーを維持し、コンセンサスに参加し、ブロックを検証し、ライトクライアントに対応し、ピアとの接続を維持する役割を担っています。ノードにはさまざまな種類(例:eth1、eth2)があり、それぞれにメリットと課題があります。
単一のノードを運用することさえ容易ではありませんが、大規模でグローバルに負荷分散されたクラスターの運用となると、なおさらです。
- 堅牢なインフラを構築するには数ヶ月を要する
- 障害が発生すると壊滅的な影響を及ぼし、復旧に数週間を要する場合がある
- ノードでは平均して5日に1回の割合で問題が発生する:
- CPU使用率の急上昇、メモリリーク、ディスクの問題
- ピアリングの不整合、データベースの破損
- トランザクションのブロードキャストに関する問題
- 頻繁に発生するバグやリグレッション
- 「安定版リリース」の6回に1回は互換性を損なう変更が含まれているWithout a Web3 provider, there is no data for the application to work with; no data from the blockchain to manipulate or display.
Web3 providers abstract the node infrastructure layer, so developers, teams and businesses can focus on their core app. Platforms like Quicknode also have tools & features which accelerate development and help users build the best version of their app.
Web3プロバイダーがいかに不可欠であるかがわかったところで、次は冗長性とフェイルオーバーの重要性について見ていきましょう。
When you build your app with a single Web3 provider, you have a central point of failure. We want to decentralize data and applications, but most apps are running with 1 provider, and mostly a single provider. On November 11, we learned what happens when that single provider has an outage.
Infuraの功績は称えるべきでしょう。同社のサービスと努力がなければ、Ethereum 、アプリ開発、開発者の活動は、決して現在の水準には達しなかったでしょう。同社はEthereum 5~10%Ethereum 運用していると推定されており、そのネットワークが1日で処理するトラフィック量は、他のすべてのノードが1か月で処理する量よりも多いと言われています。
とはいえ、ノードのバージョン管理上の見落としにより、約7時間にわたるサービス停止が発生しました。
この障害により、バイナンスやビサムなどの仮想通貨取引所も、ETHおよびERC-20トークンの出金を停止せざるを得なくなりました。人気のEthereum 「MetaMask」も、Infuraをデフォルトのサービスプロバイダーとして利用しているため、利用に支障をきたしています。
この件により、多くのWeb3アプリケーションが機能停止に陥りました。このことから、私たちは何を学べるでしょうか?
There are other Web3 provider options out there! One of them is Quicknode.com and it is a drop-in replacement for Infura. Users also get an endpoint which they can plug into their code, cURL, or compose with a tool like Etherflow – to get the data they or their app needs.
Why is Web3 provider redundancy important? To make dApps better, build-in Web3 provider redundancy from the beginning. This way if your primary provider has an outage, whether it's internal (ie. something broke), or an issue with hosting (eg. cloud provider outage), or global network-related (eg. fiber cut, network outage), it can be mitigated by having a backup/failover provider.
メインのプロバイダーが応答しなくなると、バックアップのプロバイダーが引き継ぎます。これにより、アプリのダウンタイムは最小限、あるいはゼロに抑えられます。コスト削減のため、複数のプロバイダーを利用することも検討してみてください。これは一般的な慣行のように聞こえますが、実際にはそれほど一般的ではありません!
Web3プロバイダーの冗長性の重要性が理解できたところで、これを実際にどのように実践すればよいのでしょうか?
さて、unisignals.aiやfilter.sitg.app を運営し、現在はQuicknode 私たちの友人イゴールは、サービス停止が自身のアプリに与える影響を身をもって体験しました。彼はすぐに複数のプロバイダーを導入したため、彼のアプリは以前よりはるかに堅牢になり、Web3 プロバイダーの問題に対する耐性も高まりました。
彼がそれを成し遂げた方法は次のとおりです:
At unisignals.ai, we search for valuable insight from Ethereum transactions. We scan and parse pending and confirmed transactions, then enhance with on-chain and off-chain data.
開発の過程で学んだことをいくつかご紹介します。
無料のRPCノードを使えば、さまざまなことができます。リストはこちらをご覧ください:https://ethereumnodes.com/
Infura を利用する場合は、アプリを us-east-1 AWS リージョンでホストするのが理にかなっています。Infura の API エンドポイントは同じ AWS データセンター内にあるため、非常に低いレイテンシが期待できます。
1つのプロバイダーだけに頼らないでください。冗長性を確保しましょう:
特に無料のプロバイダーを利用する場合は、プロバイダー間で負荷を分散させる
if some endpoint returns many errors or slow, disable it and check it later
制限時間のあるRPCリクエスト。1つのCPUプロセス(例:Node.js)内で着信トランザクションを処理する場合、ハングしたPromiseによってアプリがクラッシュする可能性があるため、それらを速やかに解決する必要があります。
異なるプロバイダー間で分散され、結果を取得可能で、時間制限のあるRPC操作の実装例については、こちらをご覧ください:
https://github.com/kigorw/eth-utils/blob/main/eth.ts#L67
および使い方:https://github.com/kigorw/eth-utils/blob/main/eth.ts#L149
頻繁に必要となる定数値(例えば、シンボルやERC20トークンの供給量など)をキャッシュしておけば、RPCクエリの回数を減らすことができます。
また、リアルタイム処理を行う場合は、複数のプロバイダーに同時に加入するのも理にかなっています:
取引領収書
保留中の取引
受信したトランザクションを記憶し、重複をスキップする。
上記の内容の使用例については、こちらをご覧ください:https://github.com/kigorw/eth-utils/blob/main/index.ts
リアルタイム処理においては、処理済みのブロックを追跡しておくことも理にかなっています。サーバーが再起動した場合、見逃したブロックに含まれるトランザクションを後から処理することができるからです。
If you send time-sensitive transactions (for example, swap on a DEX at a certain block), have a separate list of RPC APIs that will not be rate-limited and send the same transaction (same nonce) to several providers simultaneously. You may also try to defend yourself against front-running by using private transactions of https://taichi.network/
イゴールからの素晴らしいアドバイス!
This is just one way to implement Web3 provider redundancy into your blockchain application.
素晴らしいのは、Quicknode を使えば、堅牢で信頼性の高いバックアップサービスを無料で導入できることです(プレミアムプランはわずか49ドルから)。これはまさに最高の保険策です!
もし、すでにアプリに一定のユーザー基盤があり、リクエスト数も一定数ある場合は、Quicknodeの「Build」または「Scale」プランのご利用をご検討ください!
Quicknodeを選ぶ理由
Quicknode makes running a Blockchain node easy so developers can focus on all the wonderful dApps they’re building, instead of worrying about DevOps/NodeOps, uptime, scaling, security, etc...
Quicknode saves valuable time getting to-market while taking away the headache of node maintenance and synchronization. It’s a valuable tool in every dApp developer’s arsenal that was created by developers for developers. Visit Quicknode’s Guides section for more information.
プロジェクトについてサポートが必要だったり、ご質問がある場合は、こちらのフォーム、Twitter(Quicknode)、またはDiscordからご連絡ください!
2017年に設立されたQuicknode は、開発者 および企業向けに、機関投資家レベルのブロックチェーン インフラストラクチャを提供しています。99.99%の稼働率と、80以上のチェーンに対応したサポート を備え、チーム は妥協のないオンチェーン アプリケーションの構築とスケーリングを実現します。
最新のエンジニアリングに関する知見、製品の最新情報、Web3のニュースを、メールボックスに直接お届けします。
SOC 2 タイプ II 認証取得・ISO 27001