paritytech / subxt

Interact with Substrate based nodes in Rust or WebAssembly
Other
391 stars 236 forks source link

Light Client: Iteration on map storage will never stop. #1525

Closed david9991 closed 2 months ago

david9991 commented 2 months ago

The storage devices in my testnet has only one entry, but the iteration will never stop while querying via the light client. Dependences:

subxt = { version = "0.35.2", features = ["unstable-light-client", "unstable-reconnecting-rpc-client"] }
subxt-signer = { version = "0.35.2", features = ["subxt"] }
subxt-lightclient = "0.35.2"
Screenshot 2024-04-12 at 15 18 34
jsdw commented 2 months ago

Thanks for your report! Oh that is strange; def something we'll need to dig into!

Would you happen to have some concrete steps to reproduce this? Does it happen when iterating over any storage query or just a specific one? Does it still happen when you're not using the reconnecting RPC client?

david9991 commented 2 months ago

@jsdw You can reproduce it using this project: https://github.com/david9991/lightclient-lssue And it is still happening while using jsonrpsee instead of unstable-reconnecting-rpc-client.

lexnv commented 2 months ago

IIRC, we have encountered something similar with the legacy backend.

Could you change the backend to use the unstable one (rpc-v2 unstable methods), as suggested here? 🙏 https://github.com/paritytech/subxt/issues/1453#issuecomment-2011922808

jsdw commented 2 months ago

@david9991 Thank you for your reproduciton; that was very helpful!

The problem is that the Smoldot storage API we use returns the start_key given whereas the Substrate one does not. As a workaround, I created a small fix in #1534 which will ignore such a dupe key if returned. This makes your reproduction work as expected :)