Skip to content

fix: exclude reverted cctx from rate limiter#2256

Merged
ws4charlie merged 7 commits intodevelopfrom
fix-rate-limiter-reverted-inbound-cctx
May 24, 2024
Merged

fix: exclude reverted cctx from rate limiter#2256
ws4charlie merged 7 commits intodevelopfrom
fix-rate-limiter-reverted-inbound-cctx

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
@github-actions
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 and removed nosec labels May 23, 2024
@codecov
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
Contributor

@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
Member

@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
Contributor

lumtis commented May 24, 2024

We need to generate the files again.

@ws4charlie ws4charlie merged commit 7e27b5f into develop May 24, 2024
@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

nosec zetaclient Issues related to ZetaClient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants