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

feat(observer): implement MsgUpdateOperationalChainParams #3538

Merged
merged 16 commits into from
Feb 18, 2025

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Feb 17, 2025

Description

Closes #3521

Add MsgUpdateOperationalChainParams

Set MsgUpdateChainParams to admin (it's currently not in the migration script, my thinking is that we already plan to migrate it manually as we're setting up the operational group?) [EDIT: actually necessary for making the upgrade test work anyway]

Summary by CodeRabbit

  • New Features

    • Enhanced chain parameter configuration with advanced confirmation and operational settings.
    • Introduced a new tracking command and the ability to remove inbound trackers for streamlined management.
  • Bug Fixes

    • Resolved issues with transaction scheduling and operational updates for improved reliability.
  • Documentation

    • Updated API and user guides to reflect new operational update capabilities.
  • Tests

    • Expanded test coverage to validate the enhanced chain parameter functionalities.

Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This pull request introduces extensive modifications to enhance chain parameter management. It adds a new field, ConfirmationParams, and a ConfirmationMode enum across key messages. A new message, MsgUpdateOperationalChainParams, is implemented along with its RPC endpoint and corresponding unit/E2E tests. The changes also include refactoring of validation logic, authorization adjustments (switching policy names), and updates to documentation and OpenAPI specifications, ensuring robust error handling and test coverage throughout the system.

Changes

File(s) Change Summary
changelog.md Updated changelog with new features: added ConfirmationParams, ConfirmationMode, MsgRemoveInboundTracker, MsgUpdateOperationalChainParams, and command track-cctx; noted refactors and test enhancements.
docs/.../openapi.swagger.yaml, docs/.../messages.md Introduced new OpenAPI object and documentation for MsgUpdateOperationalChainParams.
cmd/zetae2e/local/local.go, e2e/e2etests/*.go, e2e/runner/*.go Added new E2E test case TestUpdateOperationalChainParams and updated policy usage from OperationalPolicyName to AdminPolicyName.
proto/.../tx.proto Added RPC method UpdateOperationalChainParams along with new request/response message types.
x/authority/migrations/v3/*, x/authority/types/authorization_list*.go Updated migration logic and authorization lists to include new message authorizations and reassign policy mappings.
x/observer/keeper/*.go, x/observer/simulation/operation_update_chain_params.go Added new keeper method UpdateOperationalChainParams with corresponding tests; improved inline error handling in simulations.
x/observer/types/* Refactored chain parameters validation: introduced ConfirmationParams.Validate(), removed old validations, registered new message types, and updated tests.
zetaclient/context/app.go, zetaclient/orchestrator/contextupdater.go Modified chain parameter validation calls to use the new Validate() method on the ChainParams struct.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant M as MsgServer
    participant A as AuthorityKeeper
    participant CP as ChainParamsStore

    C->>M: UpdateOperationalChainParams(msg)
    M->>A: CheckAuthorization(msg.creator)
    A-->>M: Authorization result
    alt Authorized
        M->>CP: Retrieve chain parameters (by chainID)
        alt Chain parameters found
            M->>CP: Update parameters with new values
            CP-->>M: Success
            M-->>C: Return success response
        else Not Found
            M-->>C: Return error (ChainParamsNotFound)
        end
    else Not Authorized
        M-->>C: Return error (Unauthorized)
    end
Loading

Possibly related PRs

Suggested labels

zetacore, UPGRADE_TESTS, ADMIN_TESTS

Suggested reviewers

  • skosito
  • kingpinXD
  • fbac
  • ws4charlie
  • gartnera

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. (Beta)
  • @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.

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.

@lumtis lumtis changed the title Feat/operational chain params feat(observer): implement MsgUpdateOperationalChainParams Feb 17, 2025
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 97.10145% with 4 lines in your changes missing coverage. Please review.

Project coverage is 64.61%. Comparing base (370b1d5) to head (abc2c9c).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
x/observer/types/chain_params.go 98.11% 0 Missing and 1 partial ⚠️
x/observer/types/message_update_chain_params.go 75.00% 0 Missing and 1 partial ⚠️
zetaclient/context/app.go 0.00% 0 Missing and 1 partial ⚠️
zetaclient/orchestrator/contextupdater.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3538      +/-   ##
===========================================
+ Coverage    64.54%   64.61%   +0.07%     
===========================================
  Files          456      458       +2     
  Lines        31747    31825      +78     
===========================================
+ Hits         20490    20565      +75     
- Misses       10353    10355       +2     
- Partials       904      905       +1     
Files with missing lines Coverage Δ
x/authority/migrations/v3/migrate.go 100.00% <100.00%> (ø)
x/authority/types/authorization_list.go 100.00% <ø> (ø)
...eper/msg_server_update_operational_chain_params.go 100.00% <100.00%> (ø)
...r/types/message_update_operational_chain_params.go 100.00% <100.00%> (ø)
x/observer/types/chain_params.go 94.87% <98.11%> (-0.06%) ⬇️
x/observer/types/message_update_chain_params.go 89.65% <75.00%> (-10.35%) ⬇️
zetaclient/context/app.go 72.66% <0.00%> (ø)
zetaclient/orchestrator/contextupdater.go 59.72% <0.00%> (ø)

@lumtis lumtis marked this pull request as ready for review February 17, 2025 14:24
@lumtis lumtis requested a review from a team as a code owner February 17, 2025 14:24
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: 4

🧹 Nitpick comments (17)
x/observer/keeper/msg_server_update_operational_chain_params.go (2)

13-15: Clarify the comment regarding sensitive values.

Currently, the link between “MsgUpdateChainParams” and the areas considered “sensitive” is somewhat vague. Consider succinctly reinforcing that sensitive fields (e.g., gateway contract) are purposefully excluded from this operational update to preserve stricter access control.


27-28: Correct or rephrase the inline documentation.

The comment “// can't only update existing params” appears to contain a grammatical slip. If the intent is to convey that only existing parameters may be updated (not created), then consider clarifying it for readability, e.g. “// Can only update existing params, not create them.”

x/observer/types/message_update_chain_params.go (1)

51-51: Confirm that ChainParams.Validate() covers all newly introduced fields.

Where newly added fields (e.g., ConfirmationParams) exist, ensure they are thoroughly validated. Extending test coverage to corner cases (e.g., negative values or zero thresholds) is recommended.

x/authority/migrations/v3/migrate.go (2)

30-33: Double-check admin coverage for chain parameter edits.

The message /zetachain.zetacore.observer.MsgUpdateChainParams is assigned PolicyType_groupAdmin. Validate that administrators truly require broader privileges than operational groups for these specific chain parameter edits, ensuring no overlap or confusion with operational updates.


44-46: Keep the authorization list sorted or structured if expansions continue.

As the number of authorized messages grows, consider a consistent organizational pattern or mechanical means (e.g., enumerating them in ascending order by message URL) to improve maintainability and clarity in future migrations.

x/observer/types/message_update_operational_chain_params.go (1)

58-81: Enhance validation in ValidateBasic().

The validation should include checks for empty ticker strings and reasonable bounds for schedule parameters.

 func (msg *MsgUpdateOperationalChainParams) ValidateBasic() error {
 	_, err := sdk.AccAddressFromBech32(msg.Creator)
 	if err != nil {
 		return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
 	}

 	if msg.ChainId < 0 {
 		return cosmoserrors.Wrap(sdkerrors.ErrInvalidChainID, "chain id cannot be negative")
 	}

+	if msg.GasPriceTicker == "" || msg.InboundTicker == "" || msg.OutboundTicker == "" {
+		return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, "ticker values cannot be empty")
+	}

 	if msg.OutboundScheduleInterval < 0 {
 		return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, "outbound schedule interval cannot be negative")
 	}

 	if msg.OutboundScheduleLookahead < 0 {
 		return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, "outbound schedule lookahead cannot be negative")
 	}

+	// Add reasonable upper bounds for schedule parameters
+	if msg.OutboundScheduleInterval > 86400 { // 24 hours in seconds
+		return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, "outbound schedule interval too large")
+	}

+	if msg.OutboundScheduleLookahead > 3600 { // 1 hour in seconds
+		return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, "outbound schedule lookahead too large")
+	}

 	if err := msg.ConfirmationParams.Validate(); err != nil {
 		return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
 	}

 	return nil
 }
x/observer/types/message_update_operational_chain_params_test.go (1)

14-150: Consider adding edge cases to ValidateBasic tests.

While the test coverage is good, consider adding these edge cases:

  • Zero values for tickers (GasPriceTicker, InboundTicker, etc.)
  • Maximum possible values for confirmation counts
  • Relative validation between fast and safe confirmation counts
x/observer/keeper/msg_server_update_operational_chain_params_test.go (2)

24-39: Reduce test data duplication by extracting common setup.

The message setup is duplicated across multiple test cases. Consider extracting this into a helper function to improve maintainability.

+func createTestMsg(admin string) *types.MsgUpdateOperationalChainParams {
+    return &types.MsgUpdateOperationalChainParams{
+        Creator:                   admin,
+        ChainId:                   1,
+        GasPriceTicker:            1,
+        InboundTicker:             1,
+        OutboundTicker:            1,
+        WatchUtxoTicker:           1,
+        OutboundScheduleInterval:  1,
+        OutboundScheduleLookahead: 1,
+        ConfirmationParams: types.ConfirmationParams{
+            FastInboundCount:  1,
+            FastOutboundCount: 1,
+            SafeInboundCount:  1,
+            SafeOutboundCount: 1,
+        },
+    }
+}

Also applies to: 58-73, 92-107, 132-147


135-146: Document magic numbers in test assertions.

The test uses magic numbers (1000-1009) for parameter values in the successful update test case. Consider using named constants with descriptive names to improve test readability.

+const (
+    testGasPriceTicker            = 1000
+    testInboundTicker             = 1001
+    testOutboundTicker            = 1002
+    testWatchUtxoTicker           = 1003
+    testOutboundScheduleInterval  = 1004
+    testOutboundScheduleLookahead = 1005
+    testFastInboundCount         = 1006
+    testFastOutboundCount        = 1007
+    testSafeInboundCount         = 1008
+    testSafeOutboundCount        = 1009
+)

Also applies to: 196-217

e2e/e2etests/test_migrate_chain_support.go (2)

39-196: Consider breaking down the large test function into smaller, focused test cases.

The TestMigrateChainSupport function is quite long and handles multiple test scenarios. Consider breaking it down into smaller sub-tests using t.Run() for better maintainability and clarity.

Example structure:

func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
    t.Run("setup_initial_state", func(t *testing.T) {
        // Initial setup code
    })
    
    t.Run("deploy_and_configure_new_chain", func(t *testing.T) {
        // New chain setup
    })
    
    t.Run("verify_chain_migration", func(t *testing.T) {
        // Migration verification
    })
}

41-42: Document magic numbers used in test setup.

The test uses magic numbers for ZETA amounts. Consider using named constants with clear documentation of their purpose.

+// TestZetaAmount represents 20B Zeta tokens used for testing
+const TestZetaAmount = 20_000_000_000
+
-zetaAmount := big.NewInt(1e18)
-zetaAmount = zetaAmount.Mul(zetaAmount, big.NewInt(20_000_000_000))
+zetaAmount := big.NewInt(1e18)
+zetaAmount = zetaAmount.Mul(zetaAmount, big.NewInt(TestZetaAmount))
e2e/runner/setup_zevm.go (2)

296-299: Address TODO comment regarding protocol contracts.

The TODO comment indicates a need to update all protocol contracts. This should be tracked and addressed.

Would you like me to create an issue to track this enhancement? The issue would cover:

  1. Updating all protocol contracts in chain params
  2. Including the ZETA connector
  3. Implementing proper validation for all contract addresses

300-332: Enhance error handling in UpdateProtocolContractsInChainParams.

The function uses require.NoError but could benefit from more descriptive error handling and validation.

 func (r *E2ERunner) UpdateProtocolContractsInChainParams() {
     res, err := r.ObserverClient.GetChainParams(r.Ctx, &observertypes.QueryGetChainParamsRequest{})
-    require.NoError(r, err)
+    if err != nil {
+        r.Logger.Error("failed to get chain params: %v", err)
+        return err
+    }

     evmChainID, err := r.EVMClient.ChainID(r.Ctx)
-    require.NoError(r, err)
+    if err != nil {
+        r.Logger.Error("failed to get EVM chain ID: %v", err)
+        return err
+    }
x/observer/types/chain_params_test.go (2)

15-81: Enhance test table descriptions and coverage.

The test table for TestConfirmationParams_Validate could benefit from more descriptive test cases and additional edge cases.

Add test cases for:

{
    name: "invalid when FastInboundCount equals SafeInboundCount",
    cp: types.ConfirmationParams{
        SafeInboundCount:  2,
        FastInboundCount:  2,
        SafeOutboundCount: 1,
        FastOutboundCount: 1,
    },
    isErr: true,
},
{
    name: "invalid when FastOutboundCount equals SafeOutboundCount",
    cp: types.ConfirmationParams{
        SafeInboundCount:  1,
        FastInboundCount:  1,
        SafeOutboundCount: 2,
        FastOutboundCount: 2,
    },
    isErr: true,
}

459-478: Consider using a more efficient deep copy method.

The copyParams function could be optimized for better performance when handling large parameter sets.

 func copyParams(src *types.ChainParams) *types.ChainParams {
     if src == nil {
         return nil
     }
-    cp := *src
+    // Use a more efficient copy method for large structs
+    cp := &types.ChainParams{
+        ChainId:                     src.ChainId,
+        ConfirmationCount:           src.ConfirmationCount,
+        GasPriceTicker:              src.GasPriceTicker,
+        // ... other fields
+    }
     if src.ConfirmationParams == nil {
-        return &cp
+        return cp
     }
     // ... rest of the function
 }
x/observer/types/chain_params.go (1)

20-35: Enhance error messages in validation.

The validation logic is correct but could benefit from more descriptive error messages that include the actual values.

Apply this diff to improve error messages:

func (cp ConfirmationParams) Validate() error {
  if cp.SafeInboundCount == 0 {
-    return errors.New("SafeInboundCount must be greater than 0")
+    return errors.New("SafeInboundCount must be greater than 0, got 0")
  }
  if cp.FastInboundCount > cp.SafeInboundCount {
-    return errors.New("FastInboundCount must be less than or equal to SafeInboundCount")
+    return errors.Errorf("FastInboundCount (%d) must be less than or equal to SafeInboundCount (%d)", cp.FastInboundCount, cp.SafeInboundCount)
  }
  if cp.SafeOutboundCount == 0 {
-    return errors.New("SafeOutboundCount must be greater than 0")
+    return errors.New("SafeOutboundCount must be greater than 0, got 0")
  }
  if cp.FastOutboundCount > cp.SafeOutboundCount {
-    return errors.New("FastOutboundCount must be less than or equal to SafeOutboundCount")
+    return errors.Errorf("FastOutboundCount (%d) must be less than or equal to SafeOutboundCount (%d)", cp.FastOutboundCount, cp.SafeOutboundCount)
  }
  return nil
}
docs/openapi/openapi.swagger.yaml (1)

59941-59942: Enhance Schema Documentation for observerMsgUpdateOperationalChainParamsResponse

The new response object is defined solely with "type: object", which meets the minimal specification; however, adding a description field, and if applicable, enumerating its expected properties, would improve clarity and usability in the API documentation. This enhancement will provide better context for API consumers and maintain production-grade documentation.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d601689 and 9568a38.

⛔ Files ignored due to path filters (2)
  • typescript/zetachain/zetacore/observer/tx_pb.d.ts is excluded by !**/*_pb.d.ts
  • x/observer/types/tx.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
📒 Files selected for processing (28)
  • changelog.md (1 hunks)
  • cmd/zetae2e/local/local.go (1 hunks)
  • docs/openapi/openapi.swagger.yaml (1 hunks)
  • docs/spec/observer/messages.md (1 hunks)
  • e2e/e2etests/e2etests.go (2 hunks)
  • e2e/e2etests/test_migrate_chain_support.go (2 hunks)
  • e2e/e2etests/test_update_operational_chain_params.go (1 hunks)
  • e2e/runner/legacy_setup_evm.go (1 hunks)
  • e2e/runner/setup_solana.go (1 hunks)
  • e2e/runner/setup_ton.go (1 hunks)
  • e2e/runner/setup_zevm.go (1 hunks)
  • proto/zetachain/zetacore/observer/tx.proto (3 hunks)
  • x/authority/migrations/v3/migrate.go (2 hunks)
  • x/authority/migrations/v3/migrate_test.go (1 hunks)
  • x/authority/types/authorization_list.go (2 hunks)
  • x/authority/types/authorization_list_test.go (2 hunks)
  • x/observer/keeper/msg_server_update_chain_params_test.go (1 hunks)
  • x/observer/keeper/msg_server_update_operational_chain_params.go (1 hunks)
  • x/observer/keeper/msg_server_update_operational_chain_params_test.go (1 hunks)
  • x/observer/simulation/operation_update_chain_params.go (2 hunks)
  • x/observer/types/chain_params.go (4 hunks)
  • x/observer/types/chain_params_test.go (6 hunks)
  • x/observer/types/codec.go (2 hunks)
  • x/observer/types/message_update_chain_params.go (1 hunks)
  • x/observer/types/message_update_operational_chain_params.go (1 hunks)
  • x/observer/types/message_update_operational_chain_params_test.go (1 hunks)
  • zetaclient/context/app.go (1 hunks)
  • zetaclient/orchestrator/contextupdater.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • x/observer/keeper/msg_server_update_chain_params_test.go
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.go`: Review the Go code, point out issues relative to ...

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • e2e/runner/setup_solana.go
  • e2e/runner/setup_zevm.go
  • x/observer/types/codec.go
  • cmd/zetae2e/local/local.go
  • x/authority/migrations/v3/migrate.go
  • x/authority/migrations/v3/migrate_test.go
  • zetaclient/context/app.go
  • e2e/runner/setup_ton.go
  • x/observer/types/message_update_chain_params.go
  • x/authority/types/authorization_list.go
  • e2e/e2etests/test_migrate_chain_support.go
  • e2e/runner/legacy_setup_evm.go
  • zetaclient/orchestrator/contextupdater.go
  • x/observer/simulation/operation_update_chain_params.go
  • x/authority/types/authorization_list_test.go
  • x/observer/types/chain_params_test.go
  • x/observer/keeper/msg_server_update_operational_chain_params.go
  • e2e/e2etests/test_update_operational_chain_params.go
  • x/observer/keeper/msg_server_update_operational_chain_params_test.go
  • x/observer/types/message_update_operational_chain_params_test.go
  • x/observer/types/chain_params.go
  • x/observer/types/message_update_operational_chain_params.go
  • e2e/e2etests/e2etests.go
`**/*.proto`: Review the Protobuf definitions, point out iss...

**/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.

  • proto/zetachain/zetacore/observer/tx.proto
🔇 Additional comments (23)
x/observer/keeper/msg_server_update_operational_chain_params.go (2)

33-48: Verify that partial updates will not cause unintended overrides.

Each assignment directly overwrites the existing parameter field. Confirm that the intended behavior is to overwrite rather than partially preserve original values. If partial updates are expected in the future, consider granular checks or deeper merge strategies to avoid accidental resets.


50-50: Ensure fallback behavior if multiple potential matches exist.

The code returns immediately once it finds a matching chain ID. If the possibility of duplicates in chainParamsList arises, this early return might skip subsequent conflicting entries. Confirm there are no scenarios where multiple chain configurations share the same ID.

x/observer/types/message_update_chain_params.go (1)

47-49: Validate that the chosen default behavior for nil ChainParams aligns with expectations.

Rejecting a nil ChainParams outright is typically correct, but confirm any existing usage patterns that might rely on a nil value to signify no change.

x/authority/migrations/v3/migrate.go (1)

26-29: Confirm policy alignment for operational chain updates.

The message /zetachain.zetacore.observer.MsgUpdateOperationalChainParams is assigned PolicyType_groupOperational. This grouping should align with the operational responsibilities. Verify that this operation does not require a higher-level admin oversight.

x/authority/migrations/v3/migrate_test.go (1)

20-21: LGTM! Test coverage for new message authorizations.

The test correctly removes authorizations for the new message types before migration, ensuring proper validation of the authorization list.

x/observer/types/codec.go (1)

24-24: LGTM! Proper registration of new message type.

The new message type is correctly registered in both codec and interface registry, following the established pattern.

Also applies to: 42-42

x/observer/simulation/operation_update_chain_params.go (1)

36-38: LGTM! Enhanced error handling syntax.

The refactored error handling using inline error declaration improves code readability while maintaining the same functionality.

Also applies to: 45-47

e2e/e2etests/test_update_operational_chain_params.go (1)

11-92: LGTM! Well-structured test with comprehensive verification.

The test follows good practices:

  • Proper error handling with require assertions
  • Thorough verification of all updated parameters
  • Clear separation of setup, action, and verification phases
zetaclient/orchestrator/contextupdater.go (1)

82-82: LGTM! Improved encapsulation of validation logic.

The change from observertypes.ValidateChainParams(cp) to cp.Validate() better aligns with object-oriented principles by moving validation to the instance method.

e2e/runner/setup_ton.go (1)

121-121: LGTM! Appropriate policy update for chain parameters.

The change from OperationalPolicyName to AdminPolicyName aligns with the PR objectives to set MsgUpdateChainParams to admin policy.

x/observer/types/message_update_operational_chain_params_test.go (1)

152-210: LGTM! Well-structured test suite.

The test suite follows good practices:

  • Table-driven tests with clear test cases
  • Proper error assertions
  • Comprehensive coverage of message functionality
e2e/runner/legacy_setup_evm.go (1)

141-143: LGTM! Policy name updated correctly.

The change from OperationalPolicyName to AdminPolicyName aligns with the PR objectives to set MsgUpdateChainParams to admin.

x/authority/types/authorization_list.go (1)

23-23: LGTM! Authorization lists updated correctly.

The changes appropriately:

  1. Add MsgUpdateOperationalChainParams to operational policy
  2. Move MsgUpdateChainParams to admin policy

This maintains clear separation between admin and operational responsibilities.

Also applies to: 45-45

zetaclient/context/app.go (1)

215-215: LGTM! Improved validation encapsulation.

The change from ValidateChainParams(params) to params.Validate() improves encapsulation by moving validation logic to the struct method.

e2e/runner/setup_solana.go (1)

185-185: LGTM! Policy name updated correctly.

The change from OperationalPolicyName to AdminPolicyName for chain params update maintains proper separation between admin and operational tasks.

x/authority/types/authorization_list_test.go (1)

402-402: LGTM! Authorization policy correctly configured.

The addition of MsgUpdateOperationalChainParams to the operational policy list aligns with the intended functionality.

cmd/zetae2e/local/local.go (1)

343-343: LGTM! Test case correctly added.

The addition of TestUpdateOperationalChainParams to the admin test routine aligns with the PR objectives.

e2e/e2etests/e2etests.go (1)

942-948: LGTM! Test properly configured with version requirement.

The new test is correctly added with a minimum version requirement of "v28.0.0", ensuring compatibility with the new operational chain parameters functionality.

docs/spec/observer/messages.md (1)

176-194: New Message Definition for MsgUpdateOperationalChainParams is well documented.
The new section clearly explains that this message is meant for updating operational-related chain parameters without allowing modifications to sensitive values (e.g., the gateway contract). The field descriptions, including the inclusion of ConfirmationParams, match the PR objectives and enhance clarity in the documentation.

proto/zetachain/zetacore/observer/tx.proto (3)

12-12: New Import for Confirmation Params.
The added import "zetachain/zetacore/observer/confirmation_params.proto" correctly brings in the definitions required for the new confirmation_params field. Ensure that the imported file remains in sync with the expected schema for consistency across modules.


40-41: Addition of the UpdateOperationalChainParams RPC Method.
The new RPC method UpdateOperationalChainParams in the Msg service is appropriately defined. Its placement and syntax adhere to the conventions used in existing RPC definitions. Verify that the authorization and error handling in the implementation align with the operational policy requirements mentioned in the PR objectives.


75-89: New Message Types for Operational Chain Parameters.
The definitions for MsgUpdateOperationalChainParams and its corresponding response (MsgUpdateOperationalChainParamsResponse) are clear and well-structured. The message includes all necessary fields (creator, chain_id, various ticker fields, schedule intervals, and ConfirmationParams) with the proper field types and options (e.g., non-nullable for confirmation_params). This aligns well with the updated functional and security requirements.

changelog.md (1)

13-14: Changelog Entry for MsgUpdateOperationalChainParams is Accurate.
The new changelog entry for PR [3538] clearly states the purpose of implementing MsgUpdateOperationalChainParams for updating operational-related chain parameters with the operational policy. This entry is concise and consistent with both the documentation and the proto changes.

Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

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

Generally LGTM, but would be great to ensure that we drop as much old code as possible w/o performing a migration

Copy link

!!!WARNING!!!
nosec detected in the following files: e2e/e2etests/e2etests.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Feb 17, 2025
@lumtis lumtis added UPGRADE_TESTS Run make start-upgrade-tests ADMIN_TESTS Run make start-admin-tests labels Feb 17, 2025
@lumtis lumtis added this pull request to the merge queue Feb 18, 2025
Comment on lines +87 to +107
if cp.GasPriceTicker <= 0 || cp.GasPriceTicker > 300 {
return fmt.Errorf("GasPriceTicker %d out of range", cp.GasPriceTicker)
}
if params.InboundTicker <= 0 || params.InboundTicker > 300 {
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "InboundTicker %d out of range", params.InboundTicker)
if cp.InboundTicker <= 0 || cp.InboundTicker > 300 {
return fmt.Errorf("InboundTicker %d out of range", cp.InboundTicker)
}
if params.OutboundTicker <= 0 || params.OutboundTicker > 300 {
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "OutboundTicker %d out of range", params.OutboundTicker)
if cp.OutboundTicker <= 0 || cp.OutboundTicker > 300 {
return fmt.Errorf("OutboundTicker %d out of range", cp.OutboundTicker)
}
if params.OutboundScheduleInterval == 0 || params.OutboundScheduleInterval > 100 { // 600 secs
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
if cp.OutboundScheduleInterval == 0 || cp.OutboundScheduleInterval > 100 { // 600 secs
return fmt.Errorf(

"OutboundScheduleInterval %d out of range",
params.OutboundScheduleInterval,
cp.OutboundScheduleInterval,
)
}
if params.OutboundScheduleLookahead == 0 || params.OutboundScheduleLookahead > 500 { // 500 cctxs
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
if cp.OutboundScheduleLookahead == 0 || cp.OutboundScheduleLookahead > 500 { // 500 cctxs
return fmt.Errorf(

"OutboundScheduleLookahead %d out of range",
params.OutboundScheduleLookahead,
cp.OutboundScheduleLookahead,
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we can remove the upper limits for these values, they are set by a policy after all.
Removing might simply the validation logic.
Does not need to be done in this pr though ,

Merged via the queue into develop with commit c080298 Feb 18, 2025
45 checks passed
@lumtis lumtis deleted the feat/operational-chain-params branch February 18, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADMIN_TESTS Run make start-admin-tests breaking:cli breaking:proto nosec UPGRADE_TESTS Run make start-upgrade-tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate high risk params in chain_params from lower risk operational params
4 participants