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: symbol string size #95

Open
wants to merge 6 commits into
base: v3
Choose a base branch
from
Open

fix: symbol string size #95

wants to merge 6 commits into from

Conversation

ethzoomer
Copy link
Contributor

@ethzoomer ethzoomer commented Nov 18, 2024

Closes #94

@ethzoomer
Copy link
Contributor Author

Currently on this branch, a v2 pool containing a token with too large of a symbol returns "-NA-" for the pool symbol which is probably not ideal. Need to understand how to slice the response of the raw_call without making abi_decode() revert

return abi_decode(response, String[100])
# String size cannot be larger than max_outsize - 64 bytes
if len(response) > 0 and len(response) <= 128:
return abi_decode(response, String[128])
Copy link
Collaborator

Choose a reason for hiding this comment

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

My understanding is that this should also be a String[192] if we're doing the max_outsize=192, no?

Copy link
Contributor Author

@ethzoomer ethzoomer Nov 18, 2024

Choose a reason for hiding this comment

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

The compiler only allows the string size to be a maximum of max_outsize - 64. But unfortunately there are cases where the raw_call spits out a response that is too large to fit into a string the size of max_outsize - 64

@ethzoomer ethzoomer requested a review from stas November 20, 2024 17:50
@stas
Copy link
Collaborator

stas commented Dec 5, 2024

@ethzoomer do you have a contract we can use to test this? I've simplified the conversion to be based on bytes btw, but would love to add a test before this is merged.

@ethzoomer
Copy link
Contributor Author

@stas Ty good idea, this token was the one with the large symbol: 0x045D841ba37E180bC9b9D4da718E14b9ED7925d6. It can be fetched using LpSugar.tokens(1, 995)

@stas
Copy link
Collaborator

stas commented Dec 6, 2024

This should be up for review now.

Vyper doesn't let us have dynamic string size initialization. Because of this, we can't really use abi_decode() on an arbitrary size bytes array.

To avoid that, we basically ignore any bytes array larger than 96, meaning 10 chars. Larger token symbols will display as -???-.

@stas
Copy link
Collaborator

stas commented Dec 6, 2024

Reported the limitations upstream
vyperlang/vyper#4391

@ethzoomer
Copy link
Contributor Author

@stas Verified here with tokens working, thank you!

all(1, 995) fails, I believe because symbol: staticcall pool.symbol(), needs to be a _safe_symbol() call. The 10 character limit may be too small for v2 pool symbols, do you have a preference for how to adjust this?

@stas
Copy link
Collaborator

stas commented Dec 13, 2024

all(1, 995) fails, I believe because symbol: staticcall pool.symbol(), needs to be a _safe_symbol() call.

good call o adding a test for the pool... I forgot the symbol 💩 will carry over there too!

The 10 character limit may be too small for v2 pool symbols, do you have a preference for how to adjust this?

I'll update the symbols to 30 chars

Ty ty for reviewing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

execution reverted
2 participants