alloy-rs / alloy-rs/alloy

[Feature] Mixed tuple-based and dynamic multicall

オープン
#4,054 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Rust
スター
1.3k
フォーク
668
平均マージ
2日 1時間
マージ済み PR(30日)
29

説明

### Component

provider, pubsub

### Describe the feature you would like

When you need to `eth_call` multiple functions returning different types for each item of a dynamic list, you currently need to perform one separate dynamic multicall for each function:
```rust
async fn separate_multicall(provider: impl Provider, erc20s: &[IERC20Instance]) {
let symbols = provider
.multicall()
.dynamic()
.extend(erc20s.into_iter().map(|e| e.symbol()))
.aggregate()
.await?;
let total_supplies = provider
.multicall()
.dynamic()
.extend(erc20s.into_iter().map(|e| e.totalSupply()))
.aggregate()
.await?;
}
```
It would be a massive performance improvement if that could be done in a single request by mixing the tuple-based and dynamic multicalls, like so:
```rust
async fn multicall_mix(provider: impl Provider, erc20s: &[IERC20Instance]) {
// Dynamic multicall nested inside tuple multicall
let (symbols, total_supplies) = provider
.multicall()
.add(
provider
.multicall()
.dynamic()
.extend(erc20s.into_iter().map(|e| e.symbol()))
.to_aggregate_request(),
)
.add(
provider
.multicall()
.dynamic()
.extend(erc20s.into_iter().map(|e| e.totalSupply()))
.to_aggregate_request(),
)
.aggregate()
.await?;

// Tuple multicall nested inside dynamic multicall
let results: Vec<(String, U256)> = provider
.multicall()
.dynamic()
.extend(erc20s.into_iter().map(|e| {
provider
.multicall()
.add(e.symbol())
.add(e.totalSupply())
.to_aggregate_request()
}))
.aggregate()
.await?;
}
```

### Additional context

_No response_

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start by tracing the provider.multicall(), dynamic(), extend(), aggregate(), and to_aggregate_request() entry points and the existing tuple and dynamic multicall implementations. Determine how nested aggregate requests are decoded, then verify both tuple-inside-dynamic and dynamic-inside-tuple examples produce the shown result shapes.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
blockchain
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。