-
Notifications
You must be signed in to change notification settings - Fork 12
Use serde without std if not needed #98
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| [toolchain] | ||
| channel = "1.81.0" | ||
| channel = "1.82.0" | ||
| components = ["rustfmt", "clippy"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
🧩 Analysis chain
No-std compatibility: serde now excludes std by default.
Adding
default-features = falseto serde prevents the standard library from being pulled into smart contract builds while preserving thederivefeature for macros. This aligns with the project's no-std support declaration and the existing pattern used for other dependencies (e.g., rlp, sha3, primitive-types).Verify that the
derivefeature alone is sufficient for all serde usage across the codebase. Specifically, confirm that no code relies on serde'sallocorstdfeatures. Run the following to identify potential gaps:🏁 Script executed:
Length of output: 1199
🏁 Script executed:
Length of output: 4470
🏁 Script executed:
Length of output: 1116
🏁 Script executed:
Length of output: 2579
Serde configuration introduces compilation failure: workspace dependency missing required "std" feature.
The root workspace now provides serde with only the
derivefeature, butevm/Cargo.tomlattempts to enableserde/stdwhen thestdfeature is activated (line in evm's feature definition). This creates an unsatisfiable dependency.Fix required:
Add
"std"to serde features in workspace Cargo.toml line 25:This maintains no-std compatibility for environments that don't use the
stdfeature while allowing standard library usage when needed.🤖 Prompt for AI Agents
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.
@aleksuss what do you think?
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.
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.
🧩 Analysis chain
🏁 Script executed:
Length of output: 1461
@aleksuss Thank you for confirming! I can see that
evm/Cargo.tomlline 38 does try to enableserde/stdwhen thestdfeature is active.However, I want to flag a potential concern with the suggested fix: adding
"std"to the workspace serde features list would enable std unconditionally, which would defeat the purpose of this PR (enabling serde usage without std in smart contracts).Could you verify if there's an actual compilation error with the current configuration? The pattern used here (workspace with
default-features = false, subcrate enabling features via feature flags) is the same pattern used successfully for other dependencies likesha3,rlp, andprimitive-types.If there is a compilation error, consider these alternatives:
Would you like me to help investigate further or test a different approach?
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 would pass the features in the member crates only. In the workspace
Cargo.tomlI would use: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.
Make sense. FYI: @vlad9486