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

Enable permissioned keys by default #2645

Merged
merged 4 commits into from
Dec 12, 2024
Merged

Enable permissioned keys by default #2645

merged 4 commits into from
Dec 12, 2024

Conversation

jayy04
Copy link
Contributor

@jayy04 jayy04 commented Dec 11, 2024

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

    • Smart account functionality is now active, enhancing account management capabilities.
    • Expanded configurations for liquidity tiers and trading pairs, improving trading options and mechanisms.
    • New parameters added for governance, including minimum deposit and updated voting periods.
  • Bug Fixes

    • Adjustments made to governance parameters, ensuring smoother governance processes.
  • Documentation

    • Updates to various configuration files to reflect the latest enhancements and operational requirements.
  • Tests

    • New checks added to validate smart account status post-upgrade, improving testing coverage.

@jayy04 jayy04 requested a review from a team as a code owner December 11, 2024 14:16
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes in this pull request primarily involve updates to configuration files related to the dydxaccountplus section, specifically activating the is_smart_account_active parameter. This adjustment is reflected across multiple files, including JSON configurations and Go scripts, indicating a shift in account management capabilities. Additionally, the upgrade process has been modified to incorporate this change, ensuring that the smart account feature is properly initialized and tested within the protocol.

Changes

File Path Change Summary
protocol/app/testdata/default_genesis_state.json Updated is_smart_account_active from false to true in dydxaccountplus section.
protocol/app/upgrades/v8.0/upgrade.go Added invocation of SetActiveState to set the account state to active during the upgrade process.
protocol/app/upgrades/v8.0/upgrade_container_test.go Introduced postUpgradeSmartAccountActiveCheck function to verify smart account status post-upgrade.
protocol/scripts/genesis/sample_pregenesis.json Updated is_smart_account_active from false to true; added new parameters in perpetuals, prices, ratelimit, revshare, and rewards sections.
protocol/testing/containertest/preupgrade_genesis.json Updated is_smart_account_active from false to true; added new parameters in gov and perpetuals sections.
protocol/testing/genesis.sh Added is_smart_account_active set to true and updated market parameters and liquidity tiers.
protocol/testutil/constants/genesis.go Updated is_smart_account_active from false to true in GenesisState.
protocol/x/accountplus/types/genesis.go Modified DefaultGenesis to initialize IsSmartAccountActive to true.
protocol/app/upgrades/v8.0/migrate_accountplus_test.go Updated test setup to reflect new genesis document conditions.

Possibly related PRs

  • feat: add x/marketmap module #1922: The changes in the main PR regarding the is_smart_account_active parameter in the default_genesis_state.json file may relate to the marketmap module, which could interact with account functionalities, although the connection is indirect.
  • OTE-558 Add scaffolding for module #1941: This PR introduces the AccountPlus module, which is directly related to the changes in the default_genesis_state.json file, specifically the is_smart_account_active parameter, as it pertains to account management.
  • [CT-1197] add query methods for smart account #2313: The addition of query methods for smart accounts in this PR is directly relevant to the changes in the main PR, as it focuses on the management and querying of account states, including the active status of smart accounts.
  • [CT-1268] fix genesis for account plus #2452: This PR addresses the genesis state for the accountplus module, which includes the is_smart_account_active parameter, making it directly related to the changes in the main PR.
  • Run account plus migration in v8 upgrade #2628: The migration of account states in the upgrade process is directly related to the changes in the main PR, as it involves the management of account states, including the is_smart_account_active parameter.
  • Add permissioned keys cli #2644: The introduction of CLI commands for the accountplus module is relevant as it may include functionalities that interact with the is_smart_account_active parameter, enhancing the management of smart accounts.

Suggested reviewers

  • teddyding
  • vincentwschau

🐰 In the realm of code, a change takes flight,
Smart accounts awaken, shining bright.
From false to true, a toggle so grand,
Enhancing our protocol, just as we planned.
With tests in place, and upgrades refined,
A leap for our future, in harmony aligned! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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

🧹 Outside diff range and nitpick comments (3)
protocol/x/accountplus/types/genesis.go (1)

Line range hint 13-15: Consider adding validation for IsSmartAccountActive.

The Validate function currently performs no validation. Consider adding validation to ensure IsSmartAccountActive is properly initialized.

func (gs GenesisState) Validate() error {
+	// Validate IsSmartAccountActive is properly initialized
+	if gs.Params.IsSmartAccountActive {
+		// Add any specific validation rules for when smart accounts are active
+	}
	return nil
}
protocol/app/upgrades/v8.0/migrate_accountplus_test.go (2)

28-37: Add documentation explaining the test setup rationale

The test setup explicitly sets IsSmartAccountActive to false, presumably to test the migration from disabled to enabled state. This setup intention should be documented for clarity.

Consider adding a comment like:

 func (s *UpgradeTestSuite) SetupTest() {
+    // Initialize with IsSmartAccountActive=false to test migration to enabled state
     s.tApp = testapp.NewTestAppBuilder(s.T()).WithGenesisDocFn(func() (genesis types.GenesisDoc) {

Line range hint 41-93: Consider adding assertions for smart account activation state

The test thoroughly verifies the storage migration but doesn't assert the final state of IsSmartAccountActive. Consider adding verification of the smart account activation state after migration.

Add assertions like:

 	}
+	// Verify smart account activation state after migration
+	params := s.tApp.App.AccountPlusKeeper.GetParams(ctx)
+	s.Require().True(params.IsSmartAccountActive, "Smart accounts should be active after migration")
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 39d5ce7 and 44b8a89.

📒 Files selected for processing (3)
  • protocol/app/upgrades/v8.0/migrate_accountplus_test.go (2 hunks)
  • protocol/testing/genesis.sh (1 hunks)
  • protocol/x/accountplus/types/genesis.go (1 hunks)
🔇 Additional comments (4)
protocol/x/accountplus/types/genesis.go (1)

5-9: LGTM! Verify the impact of enabling smart accounts by default.

The change correctly initializes GenesisState with IsSmartAccountActive set to true, which enables permissioned keys by default as intended.

✅ Verification successful

Based on the search results, I can now generate the final response:

Smart account activation by default is safe and well-integrated

The change to enable smart accounts by default (IsSmartAccountActive = true) is well-supported by the codebase:

  • The parameter is properly handled in the keeper layer with getter/setter methods
  • Circuit breaker and authentication flows properly respect this flag
  • Tests cover both active and inactive states
  • The feature can be toggled via governance if needed (MsgSetActiveState)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of enabling smart accounts by default.
# Test: Search for any references to IsSmartAccountActive to understand usage.
rg -A 5 "IsSmartAccountActive"

# Test: Search for any upgrade handlers that might need to handle this change.
ast-grep --pattern $'func CreateUpgradeHandler($_, $_) {
  $$$
}'

Length of output: 16645

protocol/testing/genesis.sh (1)

2155-2157: LGTM! Consistent with genesis.go changes.

The script correctly configures the accountplus module by setting is_smart_account_active to true in the genesis state, which aligns with the changes in genesis.go.

protocol/app/upgrades/v8.0/migrate_accountplus_test.go (2)

6-6: LGTM: Import addition is appropriate

The new import for CometBFT types is necessary for the genesis document manipulation in the test setup.


28-37: Verify test coverage for smart account activation

While this test covers the account state migration, we should verify that the activation of smart accounts is also tested.

✅ Verification successful

Let me check the content of these files to understand the test coverage better.


Let me check specifically for tests related to the v8.0 upgrade migration to ensure we have proper coverage.


Let me check the content of the upgrade file and all test files in the v8.0 directory to understand the migration and its test coverage completely.


Smart account activation is properly tested across the codebase

Looking at the code and test coverage:

  • The v8.0 upgrade explicitly sets smart accounts to active with accountplusKeeper.SetActiveState(sdkCtx, true) in the upgrade handler
  • The migration test properly sets up the initial state with IsSmartAccountActive = false
  • Comprehensive test coverage for smart account activation exists in:
    • protocol/x/accountplus/ante/circuit_breaker_test.go: Tests activation/deactivation behavior
    • protocol/x/accountplus/keeper/keeper_test.go: Tests keeper-level activation state
    • protocol/x/accountplus/genesis_test.go: Tests genesis state with active smart accounts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for tests covering the smart account activation
rg -l "IsSmartAccountActive.*true" --type go

Length of output: 222


Script:

#!/bin/bash
# Check the content of test files for smart account activation testing
rg "IsSmartAccountActive.*true" -B 2 -A 2 --type go

Length of output: 1675


Script:

#!/bin/bash
# Search for all test files related to v8.0 upgrade and smart account migration
rg -l "migrate.*account" protocol/app/upgrades/v8.0/

Length of output: 92


Script:

#!/bin/bash
# List all files in v8.0 directory and show their content
echo "=== Files in v8.0 directory ==="
ls protocol/app/upgrades/v8.0/

echo -e "\n=== Content of upgrade.go ==="
cat protocol/app/upgrades/v8.0/upgrade.go

echo -e "\n=== Content of migrate_accountplus_test.go ==="
cat protocol/app/upgrades/v8.0/migrate_accountplus_test.go

Length of output: 7074

@jayy04
Copy link
Contributor Author

jayy04 commented Dec 12, 2024

@Mergifyio backport release/protocol/v8.x

Copy link
Contributor

mergify bot commented Dec 12, 2024

backport release/protocol/v8.x

✅ Backports have been created

@jayy04 jayy04 merged commit 3d59131 into main Dec 12, 2024
22 checks passed
@jayy04 jayy04 deleted the jy/permissioned-key-enable branch December 12, 2024 16:15
mergify bot pushed a commit that referenced this pull request Dec 12, 2024
jayy04 added a commit that referenced this pull request Dec 12, 2024
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.

3 participants