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

fix: exclude reverted cctx from rate limiter #2256

Merged
merged 7 commits into from
May 24, 2024

Conversation

ws4charlie
Copy link
Contributor

Description

Athens3 saw a sharp increase in Current Withdraw Rate metrics right after the rate limiter conversion rates of eth/erc20/btc kicked in. The reason was found after some debugging effort. There were many reverted cctxs (for instance https://zetachain-testnet-api.itrocket.net/zeta-chain/crosschain/cctx/11155111/135) happened in Sepolia testnet. Reverted cctxs contain inbound_tx_observed_external_height that indicates an external chain's height (not ZetaChain height). When compared with ZetaChain height, these reverted cctxs were falsely included in the rate limiter window and count to the total withdrawn value.

A quick fix can be excluding these type of cctxs by checking SenderChainId to make sure it is a true withdrawal from ZetaChain.

image
image

Closes:

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

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

Checklist:

  • I have added unit tests that prove my fix feature works

@ws4charlie ws4charlie added the zetaclient Issues related to ZetaClient label May 23, 2024
Copy link

!!!WARNING!!!
nosec detected in the following files: x/crosschain/keeper/grpc_query_cctx_rate_limit.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 May 23, 2024
@ws4charlie ws4charlie added bug Something isn't working and removed nosec labels May 23, 2024
Copy link

codecov bot commented May 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.81%. Comparing base (1a2c964) to head (d3268ef).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2256      +/-   ##
===========================================
+ Coverage    68.80%   68.81%   +0.01%     
===========================================
  Files          261      261              
  Lines        16250    16257       +7     
===========================================
+ Hits         11180    11187       +7     
  Misses        4589     4589              
  Partials       481      481              
Files Coverage Δ
x/crosschain/keeper/grpc_query_cctx_rate_limit.go 95.53% <100.00%> (+0.14%) ⬆️

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Reverted cctxs contain inbound_tx_observed_external_height that indicates an external chain's height (not ZetaChain height)

inbound_tx_observed_external_height should never contains the height of ZetaChain per its name. If it is the case, there are refactoring to do on this side

@github-actions github-actions bot added the nosec label May 24, 2024
Copy link
Contributor

@skosito skosito left a comment

Choose a reason for hiding this comment

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

looks good, just small comments about naming

@lumtis
Copy link
Member

lumtis commented May 24, 2024

We need to generate the files again.

@ws4charlie ws4charlie merged commit 7e27b5f into develop May 24, 2024
21 checks passed
@ws4charlie ws4charlie deleted the fix-rate-limiter-reverted-inbound-cctx branch May 24, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nosec zetaclient Issues related to ZetaClient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants