xJonathanLEI / starknet-rs

Complete Starknet library in Rust™
https://starknet.rs
Apache License 2.0
282 stars 100 forks source link

JSON RPC batching #190

Closed fracek closed 2 months ago

fracek commented 2 years ago

JSON RPC supports batching multiple requests into one (batching). The performance gain is quite high, for example it takes around 80-100 ms to fetch a single block, but ~200ms to fetch 25 with batching.

xJonathanLEI commented 2 years ago

Intersting. I didn't know this before. Will implement soon. Thanks!

xJonathanLEI commented 2 years ago

That would mean we need to make the method calls return some intermedia representation of the requests though, pretty much like we did with Account::execute().

fracek commented 2 years ago

Yes, that's the best way to add batching.

Also notice a couple of things:

xJonathanLEI commented 2 years ago

Thanks for that! I guess a downside of such batching is you'd lose strong typing, unless you only allow batching the same request type.

fracek commented 2 years ago

The library would need a response enum that contains all type of response values. An alternative is to return the raw json values then let users deserialize them (all types support deserialization anyway).

xJonathanLEI commented 2 years ago

Yeah I mean then you have to do some kind of unwrap. Lemme have a think about how this can be best implemented. Will update this soon :)

xJonathanLEI commented 2 months ago

Superseded by #593.