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: update swap keys for possibly overlapped keys #1365

Merged
merged 6 commits into from
May 8, 2024

Conversation

jaeseung-bae
Copy link
Contributor

@jaeseung-bae jaeseung-bae commented May 8, 2024

Description

  • fix: update swap keys for possibly overlapped keys
    • They should be the same -> (hello, world) != (hell, oworld)

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@jaeseung-bae jaeseung-bae self-assigned this May 8, 2024
@jaeseung-bae jaeseung-bae added A: bug Something isn't working backport/v0.49.x labels May 8, 2024
@jaeseung-bae jaeseung-bae marked this pull request as ready for review May 8, 2024 14:00
Copy link

codecov bot commented May 8, 2024

Codecov Report

Attention: Patch coverage is 35.48387% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 69.53%. Comparing base (5e2cd7f) to head (0b9cc3c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1365      +/-   ##
==========================================
- Coverage   69.53%   69.53%   -0.01%     
==========================================
  Files         672      672              
  Lines       56111    56128      +17     
==========================================
+ Hits        39019    39027       +8     
- Misses      14827    14835       +8     
- Partials     2265     2266       +1     
Files Coverage Δ
x/fswap/keeper/keys.go 86.66% <84.61%> (-13.34%) ⬇️
x/fswap/types/fswap.go 5.00% <0.00%> (ø)
x/fswap/types/msgs.go 0.00% <0.00%> (ø)
x/fswap/keeper/grpc_query.go 6.97% <0.00%> (-1.60%) ⬇️

... and 1 file with indirect coverage changes

Copy link
Collaborator

@0Tech 0Tech left a comment

Choose a reason for hiding this comment

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

We should prohibit denoms longer than 255.

@jaeseung-bae
Copy link
Contributor Author

We should prohibit denoms longer than 255.

Can i have any reason for 255 limit?

@0Tech
Copy link
Collaborator

0Tech commented May 8, 2024

We should prohibit denoms longer than 255.

Can i have any reason for 255 limit?

It's because our newly introduced lengthPrefix() assumes it (converts length to byte).

@jaeseung-bae
Copy link
Contributor Author

We should prohibit denoms longer than 255.

Can i have any reason for 255 limit?

It's because our newly introduced lengthPrefix() assumes it (converts int to byte).

Thanks for letting me know.

I found regex for denom validation [a-zA-Z][a-zA-Z0-9/-]{2,127}.
function to get key will be called after validation logic, so it's okay without length limit.

zemyblue
zemyblue previously approved these changes May 8, 2024
@jaeseung-bae jaeseung-bae requested a review from 0Tech May 8, 2024 14:18
@jaeseung-bae
Copy link
Contributor Author

jaeseung-bae commented May 8, 2024

We should prohibit denoms longer than 255.

Can i have any reason for 255 limit?

It's because our newly introduced lengthPrefix() assumes it (converts int to byte).

Thanks for letting me know.

I found regex for denom validation [a-zA-Z][a-zA-Z0-9/-]{2,127}. function to get key will be called after validation logic, so it's okay without length limit.

I got another case to call without coin validation logic.
I've just made commit to fix it.

@jaeseung-bae jaeseung-bae force-pushed the fix/change-swap-key branch from e4def6a to 0b9cc3c Compare May 8, 2024 15:20
@jaeseung-bae jaeseung-bae merged commit e31eb43 into Finschia:main May 8, 2024
37 of 38 checks passed
@jaeseung-bae jaeseung-bae deleted the fix/change-swap-key branch May 8, 2024 15:51
mergify bot pushed a commit that referenced this pull request May 8, 2024
* fix: update swap keys for possibly overlapped keys

* chore: lint fix

* chore: update changelog

* chore: use address.LengthPrefix to check length

* Revert "chore: use address.LengthPrefix to check length"

This reverts commit b33165b.

* chore: add denom validation for string type denom

(cherry picked from commit e31eb43)
jaeseung-bae added a commit that referenced this pull request May 8, 2024
* fix: update swap keys for possibly overlapped keys

* chore: lint fix

* chore: update changelog

* chore: use address.LengthPrefix to check length

* Revert "chore: use address.LengthPrefix to check length"

This reverts commit b33165b.

* chore: add denom validation for string type denom

(cherry picked from commit e31eb43)

Co-authored-by: jaeseung-bae <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: bug Something isn't working backport/v0.49.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants