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

bug: Serialize value in decimal format #1910

Closed
sunce86 opened this issue Oct 2, 2023 · 0 comments · Fixed by #1913
Closed

bug: Serialize value in decimal format #1910

sunce86 opened this issue Oct 2, 2023 · 0 comments · Fixed by #1913
Assignees
Labels
bug Something isn't working

Comments

@sunce86
Copy link
Contributor

sunce86 commented Oct 2, 2023

Problem

Change InteractionData::Value field to be serialized in a decimal format. Currently is serialized in hexadecimal format:
https://github.com/cowprotocol/services/blob/main/crates/shared/src/http_solver/model.rs#L162

Slack discussion: https://cowservices.slack.com/archives/C0375NV72SC/p1696164285488129

Impact

Some solvers expressed this value as decimal by mistake and got their solutions rejected.

Expected behaviour

Should be serialized in decimal format.

@sunce86 sunce86 added the bug Something isn't working label Oct 2, 2023
@fleupold fleupold self-assigned this Oct 3, 2023
fleupold added a commit that referenced this issue Oct 12, 2023
# Description
We were made aware that the interaction's value field is parsed using
the default U256 string parser (which assumes fields to be in base16
represenation). This was an oversight on our end and is being fixed in
this PR by interpreting the value as
- base16 string if prefixed by 0x
- base10 string otherwise

We also use the new type on most other "amount" fields in the solver
API.

Assuming that no solvers are currently using the value field with non
prefixed hex strings, this change should be backwards compatible. It
makes previous `u256_dec` deserialized values more permissive (allowing
to parse them from prefixed hex strings as well) while keeping their
serialisation behavior.

# Changes
- Implemented u256_hex_or_decimal deserialization (serialization same as
u256_dec)
- Use the new type for most value fields on the solver response

## How to test
Added a unit test for the serialization

## Related Issues

Fixes #1910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants