Skip to content

Conversation

@shrenujb
Copy link
Contributor

@shrenujb shrenujb commented Oct 27, 2025

Changelist

Blocktimes were reduced from 1s to ~0.6s which decreased the short term order block window
Increase the ShortBlockWindow to 40 to account for the decreased blocktime.

Also double the mempool size to allow for more orders to live in mempool and change TTL to correspond with shortBlockWindow.

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • Chores
    • Increased short-term order validity window (longer acceptance window for placing and cancelling orders).
    • Adjusted replay‑validation and rate‑limit thresholds to match the new short‑term window.
    • Increased transaction pool capacity and extended how long pending transactions are retained.
    • Updated end‑to‑end and rate‑limit tests to reflect the new timing and thresholds.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Walkthrough

Short-block timing and related test GTB values were increased: ShortBlockWindow changed from 20 → 40, multiple e2e and rate-limit tests' GoodTilBlock (GTB) values updated from 27 → 47, and Tendermint mempool TTL/size config values were increased.

Changes

Cohort / File(s) Change Summary
CLOB Constants
protocol/x/clob/types/constants.go
ShortBlockWindow changed from 2040.
E2E Tests (GTB updates)
protocol/x/clob/e2e/app_test.go
Renamed variables and updated embedded GoodTilBlock literals: ..._GTB27..._GTB47 (PlaceOrder, CancelOrder, BatchCancel).
Rate-limit Tests (GTB updates)
protocol/x/clob/e2e/rate_limit_test.go
GTB references updated from 2747 in replay-guarding tests.
Tendermint Mempool Config
protocol/cmd/dydxprotocold/cmd/config.go
cfg.Mempool.Size 50000100000; cfg.Mempool.TTLNumBlocks 2040.

Sequence Diagram(s)

(No sequence diagram included: changes are numeric constants/config updates without new control-flow paths.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Check consistency where ShortBlockWindow is referenced elsewhere (validation, comparisons against GTB).
  • Verify tests relying on specific block offsets or replay protections still assert expected behavior.
  • Confirm Tendermint mempool TTL/size increases have intended operational impact and no hardcoded assumptions elsewhere.

Suggested reviewers

  • jonfung-dydx
  • teddyding

Poem

🐰
I hopped through constants, nibbling at time,
From twenty to forty the short-block does climb.
Tests stretched their legs, GTBs follow the tune,
Mempool grows wider beneath the same moon.
Carrots for CI, a soft, happy rune.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title states an increase to 30, but the changeset actually increases ShortBlockWindow to 40, creating a significant mismatch between the stated and actual change. Update the title to 'Increase ShortBlockWindow to 40 due to decreased blocktimes' to accurately reflect the actual implementation in the code.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description includes a Changelist and Author/Reviewer Checklist, but the Test Plan section is empty with only a placeholder comment.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sbansal/increase-shortblockwindow

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93684c1 and f2d70dc.

📒 Files selected for processing (3)
  • protocol/x/clob/e2e/app_test.go (3 hunks)
  • protocol/x/clob/e2e/rate_limit_test.go (3 hunks)
  • protocol/x/clob/types/constants.go (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-04-15T16:58:46.335Z
Learnt from: anmolagrawal345
Repo: dydxprotocol/v4-chain PR: 2780
File: protocol/x/clob/keeper/twap_order_state_test.go:191-209
Timestamp: 2025-04-15T16:58:46.335Z
Learning: For TWAP orders, message validation in message_place_order.go handles edge cases with comprehensive checks for parameters like durations and intervals, making it unnecessary to test invalid parameters in twap_order_state_test.go which only receives pre-validated inputs.

Applied to files:

  • protocol/x/clob/e2e/app_test.go
  • protocol/x/clob/e2e/rate_limit_test.go
📚 Learning: 2024-11-15T16:17:29.092Z
Learnt from: hwray
Repo: dydxprotocol/v4-chain PR: 2551
File: protocol/x/clob/types/expected_keepers.go:86-90
Timestamp: 2024-11-15T16:17:29.092Z
Learning: The function `GetCrossInsuranceFundBalance` in `protocol/x/clob/types/expected_keepers.go` already existed and was just moved in this PR; changes to its error handling may be out of scope.

Applied to files:

  • protocol/x/clob/e2e/app_test.go
📚 Learning: 2025-04-15T16:57:55.413Z
Learnt from: anmolagrawal345
Repo: dydxprotocol/v4-chain PR: 2780
File: protocol/x/clob/keeper/twap_order_state.go:0-0
Timestamp: 2025-04-15T16:57:55.413Z
Learning: TWAP order parameter validation (for interval, duration, and price tolerance) is handled in the message_place_order.go file through the ValidateBasic method, which ensures parameters are within acceptable ranges and that duration is a multiple of interval.

Applied to files:

  • protocol/x/clob/e2e/app_test.go
🧬 Code graph analysis (2)
protocol/x/clob/e2e/app_test.go (4)
protocol/x/clob/types/message_place_order.go (1)
  • NewMsgPlaceOrder (33-37)
protocol/testutil/app/order.go (1)
  • MustScaleOrder (68-120)
protocol/x/clob/types/message_cancel_order.go (1)
  • NewMsgCancelOrderShortTerm (19-25)
protocol/x/clob/types/message_batch_cancel.go (1)
  • NewMsgBatchCancel (13-23)
protocol/x/clob/e2e/rate_limit_test.go (1)
protocol/x/clob/e2e/app_test.go (3)
  • PlaceOrder_Alice_Num0_Id0_Clob0_Buy5_Price10_GTB47 (81-90)
  • CancelOrder_Alice_Num0_Id0_Clob0_GTB47 (178-185)
  • BatchCancel_Alice_Num0_Clob0_1_2_3_GTB47 (278-287)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-auxo-lambda / (auxo) Build and Push Lambda
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-bazooka-lambda / (bazooka) Build and Push Lambda
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-roundtable / (roundtable) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-vulcan / (vulcan) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-socks / (socks) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-comlink / (comlink) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-ender / (ender) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-ender / (ender) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-bazooka-lambda / (bazooka) Build and Push Lambda
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-roundtable / (roundtable) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-auxo-lambda / (auxo) Build and Push Lambda
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-vulcan / (vulcan) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-comlink / (comlink) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-socks / (socks) Build and Push
  • GitHub Check: build-and-push-mainnet
  • GitHub Check: benchmark
  • GitHub Check: check-sample-pregenesis-up-to-date
  • GitHub Check: golangci-lint
  • GitHub Check: test-coverage-upload
  • GitHub Check: build
  • GitHub Check: liveness-test
  • GitHub Check: unit-end-to-end-and-integration
  • GitHub Check: build-and-push-testnet
  • GitHub Check: test-race
  • GitHub Check: container-tests
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Summary
🔇 Additional comments (4)
protocol/x/clob/e2e/rate_limit_test.go (1)

709-709: Test updates are mathematically consistent with the new ShortBlockWindow.

The GTB value updates from 27 to 47 correctly reflect the increased window (27 = 20 + 7; 47 = 40 + 7). These values test replay attack protection by exceeding the validation window. The changes are correct assuming ShortBlockWindow = 40 is the intended value.

Also applies to: 723-723, 737-737

protocol/x/clob/e2e/app_test.go (3)

81-90: Test fixture correctly updated to reflect new ShortBlockWindow.

The PlaceOrder_Alice_Num0_Id0_Clob0_Buy5_Price10_GTB47 fixture (renamed from GTB27) with GoodTilBlock: 47 is correctly updated to test values beyond the new validation window. The changes are consistent with the increased ShortBlockWindow.


178-185: Test fixture correctly updated.

The CancelOrder_Alice_Num0_Id0_Clob0_GTB47 fixture properly reflects the new GTB value of 47 for testing boundary conditions.


278-287: Test fixture correctly updated.

The BatchCancel_Alice_Num0_Clob0_1_2_3_GTB47 fixture properly reflects the new GTB value of 47 for testing batch cancel scenarios beyond the validation window.

@Kefancao Kefancao merged commit adf3ad4 into main Nov 25, 2025
38 checks passed
@Kefancao Kefancao deleted the sbansal/increase-shortblockwindow branch November 25, 2025 19:49
@Kefancao
Copy link
Contributor

@mergify backport release/protocol/v9.5.x

@mergify
Copy link
Contributor

mergify bot commented Nov 25, 2025

backport release/protocol/v9.5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 25, 2025
Signed-off-by: Shrenuj Bansal <[email protected]>
Co-authored-by: Kefan Cao <[email protected]>
(cherry picked from commit adf3ad4)
Kefancao added a commit that referenced this pull request Nov 25, 2025
…3226) (#3262)

Signed-off-by: Shrenuj Bansal <[email protected]>
Co-authored-by: shrenujb <[email protected]>
Co-authored-by: Kefan Cao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants