-
Couldn't load subscription status.
- Fork 162
Update script #3049
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
base: main
Are you sure you want to change the base?
Update script #3049
Conversation
WalkthroughAdds 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
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)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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.
📒 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.
Changelist
[Describe or list the changes made in this PR]
Test Plan
[Describe how this PR was tested (if applicable)]
Author/Reviewer Checklist
state-breakinglabel.indexer-postgres-breakinglabel.PrepareProposalorProcessProposal, manually add the labelproposal-breaking.feature:[feature-name].backport/[branch-name].refactor,chore,bug.Summary by CodeRabbit