[Feature] Mixed tuple-based and dynamic multicall
- Vorherrschende Sprache
- Rust
- Sterne
- 1.3k
- Forks
- 668
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 29
Beschreibung
### 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_
Beitragsleitfaden
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rust
- Bereich
- blockchain
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100