-
Notifications
You must be signed in to change notification settings - Fork 19
Frequent occurence of "error code -32005: rate limited" #20
Description
When testing limit order feature using foundry and BaseSimulatorTest, it frequently encounters
vm.rpc: "eth_call": Max retries exceeded server returned an error response: error code -32005: rate limited.
The core reason is, in CoreExecution.executePerpLimitOrder(), it calls:
PrecompileLib.markPx()PrecompileLib.normalizedMarkPx()PrecompileLib.perpAssetInfo()
which call perpAssetInfo() without internal caching, rather each calling json rpc every time.
Many functions in PrecompileLib call perpAssetInfo() directly or indirectly.
1 call wouldn't be a problem but if you write a test suite of 20-30 cases that open limit orders in one run, it's highly likely that you'd encounter with rate limited error.
I believe it'll be more practical if PrecompileLib supports caching for more functions.
These are primitive functions that are not cached but believed to be(at least cached in one block):
PrecompileLib.perpAssetInfo()PrecompileLib.spotInfo()PrecompileLib.tokenInfo()