Skip to content

Conversation

@jusbar23
Copy link
Contributor

@jusbar23 jusbar23 commented Aug 19, 2025

Changelist

[Describe or list the changes made in this PR]

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

  • New Features
    • Environment-aware configuration automatically selects the correct validators and proposer per network.
    • Voting participants are determined dynamically based on the target chain.
    • Testnet proposals can be marked as expedited for faster processing.
  • Chores
    • Reduced hardcoded settings in the submission flow, minimizing manual setup and potential misconfiguration across environments.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Adds environment-specific validator lists and a helper to select validators and submitter based on chain_id, updates proposer/voter selection to be dynamic, and sets an expedited flag for testnet proposals in the rev share script.

Changes

Cohort / File(s) Summary of Changes
Revshare script updates
protocol/scripts/revshare/add_order_router_rev_share.py
Added staging/testnet validator lists; introduced get_validators_and_submitter(chain_id); switched proposer and voter selection to use helper; set expedited flag when chain_id == "dydx-testnet-4".

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Script as Revshare Script
    participant Env as get_validators_and_submitter()
    participant Gov as Governance Module
    participant Vals as Validators

    User->>Script: Run add_order_router_rev_share (chain_id)
    Script->>Env: Resolve (validators, submitter)
    Env-->>Script: Return env-specific values
    Note over Script: If chain_id == dydx-testnet-4<br/>set expedited = true

    Script->>Gov: Submit proposal (submitter, expedited?)
    Gov-->>Script: Proposal ID
    Script->>Vals: Vote with selected validators
    Vals-->>Gov: Votes submitted
    Gov-->>User: Proposal finalized (per normal flow)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Kefancao
  • shrenujb

Poem

A rabbit taps keys with a twitch of delight,
Picks validators by chain in the night.
“Expedite!” for testnet’s swift, bright flair,
Proposer not hardcoded—fresh spring air.
Votes hop along—thump, thump—in line,
Rev share proposed, all working fine. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update_script

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 0

🧹 Nitpick comments (4)
protocol/scripts/revshare/add_order_router_rev_share.py (4)

31-42: Make chain selection explicit (no silent fallback), add types, and de-duplicate the chain-id literal.

Right now, any unknown chain_id quietly falls back to the staging config, which is risky (e.g., passing mainnet would attempt to use staging keys). Also, the "dydx-testnet-4" literal is duplicated elsewhere.

Consider:

  • Explicitly handling known chain IDs and raising on unknown ones.
  • Adding a return type for clarity.
  • Extracting "dydx-testnet-4" into a constant to avoid typos and keep checks consistent.
  • Verify that the earlier testnet_chain/staging_chain constants are correct — both are currently "dydxprotocol-testnet", which may be intentional but looks suspicious alongside "dydx-testnet-4".

Apply this diff to tighten the helper:

-def get_validators_and_submitter(chain_id):
-    """Get the appropriate validators and proposal submitter based on chain ID."""
-    if chain_id == "dydx-testnet-4":
-        return testnet_validators, "dydx-1"
-    else:
-        # Default to staging configuration for dydxprotocol-testnet and other chains
-        return staging_validators, "alice"
+def get_validators_and_submitter(chain_id: str) -> tuple[list[str], str]:
+    """Return (validators, submitter) for a supported chain_id. Raise on unknown chains."""
+    if chain_id == "dydx-testnet-4":
+        return testnet_validators, "dydx-1"
+    if chain_id == staging_chain:
+        return staging_validators, "alice"
+    raise ValueError(f"Unsupported chain_id: {chain_id}")

If you want to de-duplicate the string literal, add a constant near the other chain config and use it here and below:

# near other chain constants
DYDX_TESTNET_4 = "dydx-testnet-4"

127-131: Always clean up the temp file on errors.

Since the temp file is created with delete=False, failures between creation and the success path leave orphaned files. Wrap the submit/vote workflow in a try/finally that removes tmp_file_path if it exists.

Example structure to add around this block:

tmp_file_path = None
try:
    with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as tmp_file:
        # build JSON...
        json.dump(order_router_rev_share_msg, tmp_file, indent=2)
        tmp_file_path = tmp_file.name

    # run submit-proposal, voting, etc.
    # on success, you can still remove tmp_file_path early
finally:
    if tmp_file_path and os.path.exists(tmp_file_path):
        try:
            os.remove(tmp_file_path)
        except OSError:
            pass

140-140: Avoid recomputing validators/submitter; compute once and reuse.

You call get_validators_and_submitter twice. Compute once before building the submit command and reuse, which also centralizes any error handling if chain_id is unexpected.

Apply this diff to the submit-proposal flag:

-                f"--from={get_validators_and_submitter(args.chain_id)[1]}",
+                f"--from={submitter}",

And add this once after parsing args (outside this hunk):

voters, submitter = get_validators_and_submitter(args.chain_id)

156-158: Remove redundant call to get_validators_and_submitter.

Reuse the precomputed voters to avoid double work and ensure consistency.

Apply this diff:

-            # Get appropriate validators for this environment
-            voters, _ = get_validators_and_submitter(args.chain_id)
             proposal_id = get_proposal_id(args.node, args.chain_id)
             for voter in voters:
                 vote_for(args.node, args.chain_id, proposal_id, voter)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 31f8947 and 6286008.

📒 Files selected for processing (1)
  • protocol/scripts/revshare/add_order_router_rev_share.py (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: hwray
PR: dydxprotocol/v4-chain#2597
File: indexer/services/ender/src/scripts/handlers/dydx_update_perpetual_v1_handler.sql:16-20
Timestamp: 2024-11-22T18:12:04.606Z
Learning: Avoid suggesting changes to deprecated functions such as `dydx_update_perpetual_v1_handler` in `indexer/services/ender/src/scripts/handlers/dydx_update_perpetual_v1_handler.sql` if they are unchanged in the PR.
⏰ 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). (17)
  • GitHub Check: test-sim-multi-seed-short
  • GitHub Check: test-sim-import-export
  • GitHub Check: test-sim-nondeterminism
  • GitHub Check: test-sim-after-import
  • GitHub Check: test-coverage-upload
  • GitHub Check: unit-end-to-end-and-integration
  • GitHub Check: test-race
  • GitHub Check: liveness-test
  • GitHub Check: golangci-lint
  • GitHub Check: benchmark
  • GitHub Check: container-tests
  • GitHub Check: (Public Testnet) 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-auxo-lambda / (auxo) Build and Push Lambda
  • GitHub Check: build-and-push-mainnet
  • GitHub Check: build-and-push-testnet
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (1)
protocol/scripts/revshare/add_order_router_rev_share.py (1)

127-131: Expedited proposals: confirm schema support and deposit threshold for dydx-testnet-4.

Two checks to avoid runtime failures:

  • Ensure the gov submit-proposal JSON on this chain actually supports the top-level "expedited" flag; otherwise, the tx will be rejected with an unknown field error.
  • Expedited proposals typically require a higher min deposit than standard proposals. Verify that "deposit" meets the expedited threshold on dydx-testnet-4, or the tx will fail.

If you adopt a chain-id constant (see earlier comment), also use it here to avoid string drift.

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.

1 participant