Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throttle block consumption #156

Merged
merged 7 commits into from
Jul 22, 2024
Merged

Throttle block consumption #156

merged 7 commits into from
Jul 22, 2024

Conversation

anxolin
Copy link
Contributor

@anxolin anxolin commented Jul 19, 2024

Description

This PR adds a new optional config parameter to each network, allowing us to define some block throttling.

the setting is called processEveryNumBlocks :

  • Throttle block processing to only process blocks every N blocks. Set to 1 to process every block, 2 to process every other block, etc.

Also, note that even if we skip a block, it doesn't mean we don't have any work on it. We still need to check if there's new orders coming in. So what is actually skipped is only the programmatic order checks and posting orders.

Also, it persists all Prometheus metrics, so it should count as a "consumed block" for our consumption rate alerts, meaning we should see the block consumption rate progressing faster.

image

This is an example on how to use it: "processEveryNumBlocks": 40,
This would do polling and post orders once every 40 blocks. In arbitrum this should be every 8 seconds

{
  "networks": [
    {      
      "name": "arbitrum-one",
      "rpc": "wss://your-rpc/arbitrum",
      "deploymentBlock": 204704802,
      "processEveryNumBlocks": 40,
      "filterPolicy": {
        "defaultAction": "DROP",
        "handlers": {
          "0x44569Cbd4E10dd5e97293337964Eff32d58ed352": "ACCEPT",
          "0x519BA24e959E33b3B6220CA98bd353d8c2D89920": "ACCEPT",
          "0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5": "ACCEPT",
          "0xd3338f21c89745e46af56aeaf553cf96ba9bc66f": "ACCEPT",
          "0xE8212F30C28B4AAB467DF3725C14d6e89C2eB967": "ACCEPT",
          "0xB148F40fff05b5CE6B22752cf8E454B556f7a851": "ACCEPT"
        }
      },
      "watchdogTimeout": 120
    }
  ]
}

@anxolin anxolin changed the title Throttle Throttle block consumption Jul 19, 2024
src/types/types.d.ts Show resolved Hide resolved
@anxolin anxolin requested review from a team July 19, 2024 16:27
Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send it!

@@ -13,6 +13,10 @@ export interface Config {
rpc: string;
deploymentBlock: number;
watchdogTimeout?: number;
/**
* Throttle block processing to only process blocks every N blocks. Set to 1 to process every block, 2 to process every other block, etc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I feel this comment is a bit redundant (it's documented in the shema above and we don't have redundant docs for any of the other parameters)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is automatically generated from the JSON schema

@anxolin anxolin merged commit 90ecbf5 into main Jul 22, 2024
4 checks passed
@anxolin anxolin deleted the throttle branch July 22, 2024 09:22
@github-actions github-actions bot locked and limited conversation to collaborators Jul 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants