Skip to content

Frequent occurence of "error code -32005: rate limited" #20

@levx-me

Description

@levx-me

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:

  1. PrecompileLib.markPx()
  2. PrecompileLib.normalizedMarkPx()
  3. 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):

  1. PrecompileLib.perpAssetInfo()
  2. PrecompileLib.spotInfo()
  3. PrecompileLib.tokenInfo()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions