-
Notifications
You must be signed in to change notification settings - Fork 100
Add serde feature #331
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
Add serde feature #331
Conversation
Codecov ReportBase: 62.44% // Head: 62.23% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #331 +/- ##
==========================================
- Coverage 62.44% 62.23% -0.21%
==========================================
Files 124 124
Lines 14072 14134 +62
==========================================
+ Hits 8787 8797 +10
- Misses 5285 5337 +52
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I managed to fix the CI but there are a couple of things to consider ->
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo check --no-default-features
currently fails (I'll add the check to the CI). Seems like one of the fixes is to put the pub mod transfer
under the serde
feature (since it uses serde_json
).
Also I noticed today that ibc-proto-rs
depends on serde
(unsurprisingly), so we still implicitly depend on serde
even when the feature is off. However, this is a step in the right direction.
pub struct PrefixedDenom { | ||
/// A series of `{port-id}/{channel-id}`s for tracing the source of the token. | ||
#[serde(with = "serde_string")] | ||
#[cfg_attr(feature = "serde", serde(with = "serde_string"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the serde_string
module necessary? Also the serialization/deserialization is based on the Display
implementation, which seems brittle and easy to break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Coin::amount
is serialized as a decimal string so we use the display impl for easy serde. I think this is a popular pattern and there are crates that provide this functionality e.g. serde_with. Can you please expand on why you think this is brittle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it brittle because in general, Display
is for human-readable output; it's easy to forget that it's also used for serialization. If we change it for a different output, we just made a breaking serialization change, which is pretty bad. I find it unfortunate that it's a common pattern... We can leave it as is though
.github/workflows/rust.yml
Outdated
@@ -72,7 +72,7 @@ jobs: | |||
- uses: actions-rs/clippy-check@v1 | |||
with: | |||
token: ${{ secrets.GITHUB_TOKEN }} | |||
args: --no-default-features --features "clock" --all-targets # tests need the clock feature | |||
args: --no-default-features --features=clock,serde --all-targets # tests need the clock feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should change the CI like this; it should be possible to use the library as no_std, without wanting serde
. There are currently real errors to fix in the no_std
case (see previous review).
Should we add a cargo check --no-default-features
to the CI? Or is clippy
a superset of check
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a cargo check --no-default-features to the CI? Or is clippy a superset of check?
Good point! I think a clippy --all
should cover everything and therefore there is no need to run clippy with --no-default-features
- what we really need is just a check --no-default-features
. WDYT?
it should be possible to use the library as no_std, without wanting serde
The ICS20 impl relies on serde for correctness (to properly deal with PacketData
and Acknowledgement
) in the module callbacks such as on_recv_packet. Should we also feature-gate them? (Does it make sense to feature gate individual callbacks or should we simply feature gate the whole app itself?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that encoding to JSON is required by the spec ->
Note that both the FungibleTokenPacketData as well as FungibleTokenPacketAcknowledgement must be JSON-encoded (not Protobuf encoded) when they serialized into packet data. Also note that uint256 is string encoded when converted to JSON, but must be a valid decimal number of the form [0-9]+.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Philippe Laferrière <[email protected]> Signed-off-by: Shoaib Ahmed <[email protected]>
* Update issue templates and CONTRIBUTING.md * Reflect review input * few edits Co-authored-by: Philippe Laferriere <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge it if you agree with my latest changes
* Add serde feature * Fix clippy warnings * Feature gate serde imports * Fix for `ErasedSerialize` * Fix unused imports * Fix CI * cargo fmt * Add serde feature to no-std-check's ibc dep * Document ErasedSerialize re-export * Move TimeoutHeight serde into it's own module * Move ClientState serde tests into it's own module * Fix typo * Apply suggestions from code review Co-authored-by: Philippe Laferrière <[email protected]> Signed-off-by: Shoaib Ahmed <[email protected]> * Update issue templates and CONTRIBUTING.md (#345) * Update issue templates and CONTRIBUTING.md * Reflect review input * few edits Co-authored-by: Philippe Laferriere <[email protected]> * make transfer application serde-dependent Signed-off-by: Shoaib Ahmed <[email protected]> Co-authored-by: Davirain <[email protected]> Co-authored-by: Philippe Laferrière <[email protected]> Co-authored-by: Farhad Shabani <[email protected]>
* unclog release * bump version * Add serde feature (#331) * Add serde feature * Fix clippy warnings * Feature gate serde imports * Fix for `ErasedSerialize` * Fix unused imports * Fix CI * cargo fmt * Add serde feature to no-std-check's ibc dep * Document ErasedSerialize re-export * Move TimeoutHeight serde into it's own module * Move ClientState serde tests into it's own module * Fix typo * Apply suggestions from code review Co-authored-by: Philippe Laferrière <[email protected]> Signed-off-by: Shoaib Ahmed <[email protected]> * Update issue templates and CONTRIBUTING.md (#345) * Update issue templates and CONTRIBUTING.md * Reflect review input * few edits Co-authored-by: Philippe Laferriere <[email protected]> * make transfer application serde-dependent Signed-off-by: Shoaib Ahmed <[email protected]> Co-authored-by: Davirain <[email protected]> Co-authored-by: Philippe Laferrière <[email protected]> Co-authored-by: Farhad Shabani <[email protected]> * add serde changelog from #331 Signed-off-by: Shoaib Ahmed <[email protected]> Co-authored-by: Shoaib Ahmed <[email protected]> Co-authored-by: Davirain <[email protected]> Co-authored-by: Farhad Shabani <[email protected]>
* Add serde feature * Fix clippy warnings * Feature gate serde imports * Fix for `ErasedSerialize` * Fix unused imports * Fix CI * cargo fmt * Add serde feature to no-std-check's ibc dep * Document ErasedSerialize re-export * Move TimeoutHeight serde into it's own module * Move ClientState serde tests into it's own module * Fix typo * Apply suggestions from code review Co-authored-by: Philippe Laferrière <[email protected]> Signed-off-by: Shoaib Ahmed <[email protected]> * Update issue templates and CONTRIBUTING.md (#345) * Update issue templates and CONTRIBUTING.md * Reflect review input * few edits Co-authored-by: Philippe Laferriere <[email protected]> * make transfer application serde-dependent Signed-off-by: Shoaib Ahmed <[email protected]> Co-authored-by: Davirain <[email protected]> Co-authored-by: Philippe Laferrière <[email protected]> Co-authored-by: Farhad Shabani <[email protected]>
* unclog release * bump version * Add serde feature (#331) * Add serde feature * Fix clippy warnings * Feature gate serde imports * Fix for `ErasedSerialize` * Fix unused imports * Fix CI * cargo fmt * Add serde feature to no-std-check's ibc dep * Document ErasedSerialize re-export * Move TimeoutHeight serde into it's own module * Move ClientState serde tests into it's own module * Fix typo * Apply suggestions from code review Co-authored-by: Philippe Laferrière <[email protected]> Signed-off-by: Shoaib Ahmed <[email protected]> * Update issue templates and CONTRIBUTING.md (#345) * Update issue templates and CONTRIBUTING.md * Reflect review input * few edits Co-authored-by: Philippe Laferriere <[email protected]> * make transfer application serde-dependent Signed-off-by: Shoaib Ahmed <[email protected]> Co-authored-by: Davirain <[email protected]> Co-authored-by: Philippe Laferrière <[email protected]> Co-authored-by: Farhad Shabani <[email protected]> * add serde changelog from #331 Signed-off-by: Shoaib Ahmed <[email protected]> Co-authored-by: Shoaib Ahmed <[email protected]> Co-authored-by: Davirain <[email protected]> Co-authored-by: Farhad Shabani <[email protected]>
Closes: #293
Description
This PR builds on top of @DaviRain-Su's PR #301 - I was unable to push on their fork so opened this PR.
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.