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

refactor: SetCctxAndNonceToCctxAndInboundHashToCctx to accept tssPubkey as an argument #2748

Merged
merged 14 commits into from
Aug 28, 2024

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Aug 19, 2024

This pr refactors the SetCctxAndNonceToCctxAndInboundHashToCctx to accept a tssPubkey instead of trying to fetch it.
It does not modify any logic.
Closes #2719
https://github.com/zeta-chain/protocol-private/issues/72

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Enhanced handling of cross-chain transactions by incorporating TSS (Threshold Signature Scheme) public key support across multiple functions.
    • Improved context management for transaction processing, ensuring better security and traceability.
  • Bug Fixes

    • Added validation to prevent executing transactions without a valid TSS key.
  • Documentation

    • Updated changelog to reflect recent changes related to TSS integration.
  • Tests

    • Refined unit tests to include scenarios for TSS key validation and updated test cases to reflect changes in function signatures.

Copy link

gitguardian bot commented Aug 19, 2024

⚠️ GitGuardian has uncovered 3 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
13340122 Triggered Generic High Entropy Secret d6ea2df zetaclient/chains/solana/signer/signer_test.go View secret
13340122 Triggered Generic High Entropy Secret d6ea2df zetaclient/chains/solana/signer/signer_test.go View secret
13392123 Triggered Generic High Entropy Secret d6ea2df zetaclient/chains/solana/signer/signer_test.go View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Contributor

coderabbitai bot commented Aug 19, 2024

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

The changes enhance the cross-chain transaction handling by introducing a new parameter, tsspubkey, across multiple functions and tests. This refactor streamlines the processing of transactions while integrating a Threshold Signature Scheme (TSS) public key, improving security and traceability. Additionally, some mock setups and test cases have been adjusted or removed to better reflect the updated logic and focus on critical failure scenarios.

Changes

Files Change Summary
changelog.md Added entry for refactor of SetCctxAndNonceToCctxAndInboundHashToCctx, introducing tsspubkey.
testutil/keeper/crosschain.go Removed MockGetOutbound; streamlined testing strategy.
x/crosschain/genesis.go Updated InitGenesis function to include tssPubkey for processing cross-chain transactions.
x/crosschain/keeper/cctx.go Modified SetCctxAndNonceToCctxAndInboundHashToCctx to accept tssPubkey, enhancing efficiency.
x/crosschain/keeper/cctx_orchestrator_validate_inbound.go Updated ValidateInbound to use tssPubkey in SetCctxAndNonceToCctxAndInboundHashToCctx.
x/crosschain/keeper/cctx_orchestrator_validate_inbound_test.go No changes to public entities; test adjustments made.
x/crosschain/keeper/cctx_test.go Added tssPubkey to createNCctxWithStatus and createNCctx, updated relevant tests.
x/crosschain/keeper/grpc_query_inbound_hash_to_cctx_test.go Modified createInTxHashToCctxWithCctxs to accept tssPubkey.
x/crosschain/keeper/msg_server_migrate_erc20_custody_funds.go Updated MigrateERC20CustodyFunds to include tssPubkey.
x/crosschain/keeper/msg_server_migrate_tss_funds.go Updated initiateMigrateTSSFundsCCTX to pass tssPubkey to SetCctxAndNonceToCctxAndInboundHashToCctx.
x/crosschain/keeper/msg_server_update_erc20_custody_pause_status.go Added tssPubkey to UpdateERC20CustodyPauseStatus method.
x/crosschain/keeper/msg_server_vote_outbound_tx.go Enhanced VoteOutbound and related methods with tssPubkey, improved transaction handling.
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go Modified tests for VoteOutbound, added checks for TSS existence.
x/crosschain/keeper/msg_server_whitelist_erc20.go Updated WhitelistERC20 to pass tssPubkey to context settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant msgServer
    participant Keeper

    User->>msgServer: Initiate Cross-Chain Transaction
    msgServer->>Keeper: SetCctxAndNonceToCctxAndInboundHashToCctx(tssPubkey)
    Keeper-->>msgServer: Acknowledge
    msgServer-->>User: Transaction Successfully Processed
Loading

Assessment against linked issues

Objective Addressed Explanation
Unhandled error may result in incorrect query results for rate limiting and queries (#2719) It's unclear if additional error handling has been implemented with the new tsspubkey.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@kingpinXD kingpinXD changed the title refactor : SetCctxAndNonceToCctxAndInboundHashToCctx to accept tssPubkey as an argument refactor: SetCctxAndNonceToCctxAndInboundHashToCctx to accept tssPubkey as an argument Aug 19, 2024
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

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

Project coverage is 66.80%. Comparing base (580b360) to head (672a8c9).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
x/crosschain/genesis.go 20.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2748      +/-   ##
===========================================
- Coverage    66.83%   66.80%   -0.04%     
===========================================
  Files          368      368              
  Lines        20662    20661       -1     
===========================================
- Hits         13810    13803       -7     
- Misses        6219     6223       +4     
- Partials       633      635       +2     
Files with missing lines Coverage Δ
x/crosschain/keeper/cctx.go 94.11% <100.00%> (-0.33%) ⬇️
...chain/keeper/cctx_orchestrator_validate_inbound.go 92.00% <100.00%> (ø)
...n/keeper/msg_server_migrate_erc20_custody_funds.go 96.66% <100.00%> (ø)
.../crosschain/keeper/msg_server_migrate_tss_funds.go 87.83% <100.00%> (ø)
...er/msg_server_update_erc20_custody_pause_status.go 96.49% <100.00%> (ø)
x/crosschain/keeper/msg_server_vote_outbound_tx.go 90.10% <100.00%> (-2.20%) ⬇️
x/crosschain/keeper/msg_server_whitelist_erc20.go 69.72% <100.00%> (ø)
x/crosschain/genesis.go 85.10% <20.00%> (-8.23%) ⬇️

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 53883f5 and f543120.

Files selected for processing (14)
  • changelog.md (1 hunks)
  • testutil/keeper/crosschain.go (2 hunks)
  • x/crosschain/genesis.go (1 hunks)
  • x/crosschain/keeper/cctx.go (2 hunks)
  • x/crosschain/keeper/cctx_orchestrator_validate_inbound.go (1 hunks)
  • x/crosschain/keeper/cctx_orchestrator_validate_inbound_test.go (1 hunks)
  • x/crosschain/keeper/cctx_test.go (8 hunks)
  • x/crosschain/keeper/grpc_query_inbound_hash_to_cctx_test.go (3 hunks)
  • x/crosschain/keeper/msg_server_migrate_erc20_custody_funds.go (1 hunks)
  • x/crosschain/keeper/msg_server_migrate_tss_funds.go (1 hunks)
  • x/crosschain/keeper/msg_server_update_erc20_custody_pause_status.go (1 hunks)
  • x/crosschain/keeper/msg_server_vote_outbound_tx.go (6 hunks)
  • x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (19 hunks)
  • x/crosschain/keeper/msg_server_whitelist_erc20.go (1 hunks)
Additional context used
Path-based instructions (13)
x/crosschain/genesis.go (1)

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

x/crosschain/keeper/msg_server_update_erc20_custody_pause_status.go (1)

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

x/crosschain/keeper/msg_server_migrate_erc20_custody_funds.go (1)

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

x/crosschain/keeper/cctx_orchestrator_validate_inbound.go (1)

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

x/crosschain/keeper/cctx.go (1)

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

x/crosschain/keeper/msg_server_migrate_tss_funds.go (1)

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

x/crosschain/keeper/msg_server_whitelist_erc20.go (1)

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

x/crosschain/keeper/grpc_query_inbound_hash_to_cctx_test.go (1)

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

x/crosschain/keeper/cctx_test.go (1)

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

x/crosschain/keeper/msg_server_vote_outbound_tx.go (1)

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

testutil/keeper/crosschain.go (1)

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

x/crosschain/keeper/cctx_orchestrator_validate_inbound_test.go (1)

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

x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (1)

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

Learnings (2)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (1)
Learnt from: kingpinXD
PR: zeta-chain/node#2615
File: x/crosschain/keeper/msg_server_vote_outbound_tx_test.go:472-472
Timestamp: 2024-08-01T18:08:13.681Z
Learning: The `SaveFailedOutbound` function in `x/crosschain/keeper/msg_server_vote_outbound_tx.go` requires a string argument for the error message.
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (1)
Learnt from: kingpinXD
PR: zeta-chain/node#2615
File: x/crosschain/keeper/msg_server_vote_outbound_tx_test.go:472-472
Timestamp: 2024-08-01T18:08:13.681Z
Learning: The `SaveFailedOutbound` function in `x/crosschain/keeper/msg_server_vote_outbound_tx.go` requires a string argument for the error message.
GitHub Check: codecov/patch
x/crosschain/genesis.go

[warning] 48-50: x/crosschain/genesis.go#L48-L50
Added lines #L48 - L50 were not covered by tests

Additional comments not posted (21)
x/crosschain/genesis.go (1)

46-51: Ensure test coverage for new logic.

The addition of the tssPubkey parameter in the InitGenesis function enhances security and traceability. However, lines 48-50 are not covered by tests, as indicated by the code coverage tool. Consider adding tests to ensure the new logic is validated.

Tools
GitHub Check: codecov/patch

[warning] 48-50: x/crosschain/genesis.go#L48-L50
Added lines #L48 - L50 were not covered by tests

x/crosschain/keeper/msg_server_update_erc20_custody_pause_status.go (1)

84-84: Verify tssPubkey integration.

The integration of tss.TssPubkey into the SetCctxAndNonceToCctxAndInboundHashToCctx call aligns with the refactor's objectives. Ensure that this change is correctly reflected in all relevant parts of the system and that tests validate this integration.

Verification successful

Integration of tssPubkey is consistent and correctly implemented.

The tssPubkey is appropriately integrated into the SetCctxAndNonceToCctxAndInboundHashToCctx function across the codebase. This includes its usage in multiple files and the presence of test cases that validate this integration. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `tssPubkey` in the `UpdateERC20CustodyPauseStatus` function.

# Test: Check for references to `SetCctxAndNonceToCctxAndInboundHashToCctx` with `tssPubkey`.
rg --type go "SetCctxAndNonceToCctxAndInboundHashToCctx" --context 5

Length of output: 11593

x/crosschain/keeper/msg_server_migrate_erc20_custody_funds.go (1)

86-86: Verify tssPubkey integration.

The addition of tss.TssPubkey to the SetCctxAndNonceToCctxAndInboundHashToCctx call is consistent with the refactor's goals. Ensure that this integration is correctly implemented and tested across the system.

Verification successful

Integration of tssPubkey is consistent and well-tested.

The tss.TssPubkey parameter has been consistently integrated into the SetCctxAndNonceToCctxAndInboundHashToCctx function across the codebase. This change is reflected in both functional and test code, indicating thorough integration and coverage.

  • Files with updates:
    • x/crosschain/genesis.go
    • x/crosschain/keeper/msg_server_migrate_erc20_custody_funds.go
    • x/crosschain/keeper/msg_server_update_erc20_custody_pause_status.go
    • x/crosschain/keeper/msg_server_migrate_tss_funds.go
    • x/crosschain/keeper/msg_server_whitelist_erc20.go
    • x/crosschain/keeper/cctx_test.go

This suggests the integration is robust and should function as intended.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `tssPubkey` in the `MigrateERC20CustodyFunds` function.

# Test: Check for references to `SetCctxAndNonceToCctxAndInboundHashToCctx` with `tssPubkey`.
rg --type go "SetCctxAndNonceToCctxAndInboundHashToCctx" --context 5

Length of output: 11593

x/crosschain/keeper/cctx_orchestrator_validate_inbound.go (1)

54-54: Verify tssPubkey integration.

The integration of tss.TssPubkey into the SetCctxAndNonceToCctxAndInboundHashToCctx call aligns with the refactor's objectives. Ensure that this change is correctly reflected in all relevant parts of the system and that tests validate this integration.

Verification successful

Integration of tss.TssPubkey Verified

The integration of tss.TssPubkey into the SetCctxAndNonceToCctxAndInboundHashToCctx function is consistent across the codebase. This change aligns with the refactor's objectives and is reflected in various files, ensuring comprehensive coverage. The function's documentation supports this integration, confirming its correctness.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `tssPubkey` in the `ValidateInbound` function.

# Test: Check for references to `SetCctxAndNonceToCctxAndInboundHashToCctx` with `tssPubkey`.
rg --type go "SetCctxAndNonceToCctxAndInboundHashToCctx" --context 5

Length of output: 11593

x/crosschain/keeper/cctx.go (1)

Line range hint 19-32: Confirm correct usage of tssPubkey.

The addition of tssPubkey as a parameter in SetCctxAndNonceToCctxAndInboundHashToCctx simplifies the function. Ensure that the tssPubkey is correctly utilized throughout the function to maintain the intended functionality.

x/crosschain/keeper/msg_server_migrate_tss_funds.go (1)

131-131: Ensure correct usage of tssPubkey.

The addition of tssPubkey to the SetCctxAndNonceToCctxAndInboundHashToCctx function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

All function calls updated to match new signature

The function SetCctxAndNonceToCctxAndInboundHashToCctx has been consistently updated across the codebase to include the tssPubkey parameter. No discrepancies were found in the implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetCctxAndNonceToCctxAndInboundHashToCctx` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SetCctxAndNonceToCctxAndInboundHashToCctx'

Length of output: 6379

x/crosschain/keeper/msg_server_whitelist_erc20.go (1)

157-157: Ensure correct usage of tssPubkey.

The addition of tssPubkey to the SetCctxAndNonceToCctxAndInboundHashToCctx function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

All instances of SetCctxAndNonceToCctxAndInboundHashToCctx are updated correctly.

The function SetCctxAndNonceToCctxAndInboundHashToCctx has been consistently updated across the codebase to include the tssPubkey parameter. No discrepancies were found in its usage.

  • The function calls in x/crosschain/genesis.go, x/crosschain/keeper/grpc_query_inbound_hash_to_cctx_test.go, x/crosschain/keeper/msg_server_vote_outbound_tx.go, and other files correctly include tssPubkey.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetCctxAndNonceToCctxAndInboundHashToCctx` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SetCctxAndNonceToCctxAndInboundHashToCctx'

Length of output: 6379

x/crosschain/keeper/grpc_query_inbound_hash_to_cctx_test.go (2)

129-133: Ensure correct parameter order and usage.

The function createInTxHashToCctxWithCctxs now accepts tssPubkey as a parameter. Ensure that all calls to this function are updated to match the new signature and that the tssPubkey is used correctly within the function.

Verification successful

Function signature and usage are consistent.

The function createInTxHashToCctxWithCctxs has been updated to include tssPubkey as a parameter, and all calls to this function have been correctly updated to match the new signature. The tssPubkey is used appropriately within the function. No issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `createInTxHashToCctxWithCctxs` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'createInTxHashToCctxWithCctxs'

Length of output: 1202


143-143: Ensure correct usage of tssPubkey.

The addition of tssPubkey to the SetCctxAndNonceToCctxAndInboundHashToCctx function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

Consistent Usage of tssPubkey in Function Calls Verified

All instances of the function SetCctxAndNonceToCctxAndInboundHashToCctx in the codebase have been updated to include the tssPubkey parameter as intended. This ensures consistency with the refactor's objective. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetCctxAndNonceToCctxAndInboundHashToCctx` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SetCctxAndNonceToCctxAndInboundHashToCctx'

Length of output: 6379

x/crosschain/keeper/cctx_test.go (4)

27-27: Ensure correct parameter usage in createNCctxWithStatus.

The function createNCctxWithStatus now accepts tssPubkey as a parameter. Ensure that all calls to this function are updated to match the new signature and that the tssPubkey is used correctly within the function.

Verification successful

All calls to createNCctxWithStatus are correctly updated.

The function createNCctxWithStatus has been correctly updated to include the tssPubkey parameter across all its usages in the cctx_test.go file. No issues were found with the parameter usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `createNCctxWithStatus` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'createNCctxWithStatus'

Length of output: 2210


49-49: Ensure correct parameter usage in createNCctx.

The function createNCctx now accepts tssPubkey as a parameter. Ensure that all calls to this function are updated to match the new signature and that the tssPubkey is used correctly within the function.

Verification successful

Parameter usage in createNCctx is correct.

All calls to the createNCctx function have been updated to match the new signature, including the tssPubkey parameter. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `createNCctx` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'createNCctx'

Length of output: 4285


43-43: Ensure correct usage of tssPubkey.

The addition of tssPubkey to the SetCctxAndNonceToCctxAndInboundHashToCctx function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

All instances of SetCctxAndNonceToCctxAndInboundHashToCctx are correctly updated with tssPubkey.

The function SetCctxAndNonceToCctxAndInboundHashToCctx is consistently called with the tssPubkey parameter across the codebase, as per the refactor's objective. No further action is needed.

  • Verified in files such as genesis.go, msg_server_vote_outbound_tx.go, msg_server_whitelist_erc20.go, and others.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetCctxAndNonceToCctxAndInboundHashToCctx` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SetCctxAndNonceToCctxAndInboundHashToCctx'

Length of output: 6379


85-85: Ensure correct usage of tssPubkey.

The addition of tssPubkey to the SetCctxAndNonceToCctxAndInboundHashToCctx function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

All function calls to SetCctxAndNonceToCctxAndInboundHashToCctx are correctly updated.

The function SetCctxAndNonceToCctxAndInboundHashToCctx is consistently invoked with the tssPubkey argument across all relevant files, confirming the refactor's objective has been met. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetCctxAndNonceToCctxAndInboundHashToCctx` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SetCctxAndNonceToCctxAndInboundHashToCctx'

Length of output: 6379

x/crosschain/keeper/msg_server_vote_outbound_tx.go (4)

66-74: Ensure TSS existence check is robust.

The addition of a TSS existence check at the start of the VoteOutbound function is a good practice. Ensure that this check is performed consistently across all relevant functions to prevent errors related to missing TSS keys.


118-118: Ensure correct usage of tssPubkey in SaveFailedOutbound.

The addition of tssPubkey to the SaveFailedOutbound function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

Verification Successful: All SaveFailedOutbound Calls Match the New Signature

The function SaveFailedOutbound is consistently used with the updated signature across the codebase. No discrepancies were found in its invocation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SaveFailedOutbound` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SaveFailedOutbound'

Length of output: 3886


211-219: Ensure correct usage of tssPubkey in SaveOutbound.

The addition of tssPubkey to the SaveOutbound function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

All calls to SaveOutbound have been updated with tssPubkey. The function's new signature has been correctly implemented across the codebase, ensuring consistency with the refactor's objective. No further updates are necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SaveOutbound` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SaveOutbound'

Length of output: 7273


121-121: Ensure correct usage of tssPubkey in SaveSuccessfulOutbound.

The addition of tssPubkey to the SaveSuccessfulOutbound function call is consistent with the refactor's objective. Ensure that all invocations of this function across the codebase are updated to match the new signature.

Verification successful

Verification of SaveSuccessfulOutbound Usage Across Codebase

All instances of the SaveSuccessfulOutbound function in the codebase have been updated to use the new signature with the tssPubkey parameter. This includes the main implementation and test files. No discrepancies were found in the function's usage.

  • x/crosschain/keeper/msg_server_vote_outbound_tx.go
  • x/crosschain/keeper/msg_server_vote_outbound_tx_test.go

The function is consistently used with the new signature across the examined files.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SaveSuccessfulOutbound` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SaveSuccessfulOutbound'

Length of output: 5512

testutil/keeper/crosschain.go (1)

Line range hint 1-1: LGTM!

The removal of the MockGetOutbound function aligns with the updated testing strategy.

x/crosschain/keeper/cctx_orchestrator_validate_inbound_test.go (1)

Line range hint 1-1: Consider reintroducing tests for failure scenarios.

The removal of the test case for SetCctxAndNonceToCctxAndInboundHashToCctx failures reduces coverage of potential failure paths. It's important to ensure all critical scenarios are adequately tested.

x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (1)

176-212: LGTM! Ensure consistent testing of new parameters.

The addition of a test case for missing TSS keys enhances the robustness of the tests. Ensure that all new parameters, like tssPubkey, are consistently tested across relevant scenarios.

changelog.md (1)

21-21: LGTM!

The changelog entry accurately documents the refactor involving SetCctxAndNonceToCctxAndInboundHashToCctx.

changelog.md Outdated Show resolved Hide resolved
@kingpinXD kingpinXD enabled auto-merge August 28, 2024 16:08
@kingpinXD kingpinXD added this pull request to the merge queue Aug 28, 2024
Merged via the queue into develop with commit f5c2ee1 Aug 28, 2024
28 of 29 checks passed
@kingpinXD kingpinXD deleted the trailofbits-10-refactor-SaveCCTX branch August 28, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zetacore : Unhandled error may result in incorrect query results for rate limiting and queries
3 participants