paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.92k stars 707 forks source link

Ran out of free wasm instances, when using `runtime_api` #6436

Open seunlanlege opened 2 weeks ago

seunlanlege commented 2 weeks ago

Is there an existing issue?

Experiencing problems? Have you tried our Stack Exchange first?

Description of bug

In the Hyperbridge node, we provide an RPC for querying ISMP events which calls into the runtime using the runtime api.

https://github.com/polytope-labs/hyperbridge/blob/main/modules/ismp/pallets/rpc/src/lib.rs#L423

The problem is if this RPC gets called with a very large block range or perhaps too frequently, users start to observe the following error:

IMAGE 2024-11-11 10:51:39 AM

Which eventually causes the node to fall out of sync.

Steps to reproduce

No response

tmpolaczyk commented 2 weeks ago

I believe this is harmless, as a new instance will be allocated anyway. See here, maybe someone more familiar with the code can confirm.

https://github.com/paritytech/polkadot-sdk/blob/aff3a0796176ff3c0ee1b89c2f1d811a858f17a8/substrate/client/executor/src/wasm_runtime.rs#L143

Not sure why the warning exists, can it be removed?

seunlanlege commented 2 weeks ago

I believe this is harmless, as a new instance will be allocated anyway. See here, maybe someone more familiar with the code can confirm.

My question is why does it stall block syncing?

bkchr commented 2 weeks ago

Does it really stall or is it just extremely slow? Tell them to set --max-runtime-instances 32 and see if that helps.

bkchr commented 2 weeks ago

https://github.com/paritytech/substrate/issues/8846 generally this would prevent this by having some priority based cache for consensus related actions.

seunlanlege commented 2 weeks ago

Does it really stall or is it just extremely slow?

It actually stalls, from the attached image. Its syncing at 0.0bps, while serving a lot of rpc requests

bkchr commented 2 weeks ago

Can you please ask them to run with -lsync=trace and post the logs when it stalls?