docs: add docs on state vars docs re packing in structs#20747
Open
nventuro wants to merge 2 commits intomerge-train/fairiesfrom
Open
docs: add docs on state vars docs re packing in structs#20747nventuro wants to merge 2 commits intomerge-train/fairiesfrom
nventuro wants to merge 2 commits intomerge-train/fairiesfrom
Conversation
Move each trait (Empty, FromField, Hash, Packable, ToField) into its own file under traits/, with private submodules and pub re-exports. Move the bounded_vec_serialization test to the serde crate where it belongs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
benesjan
approved these changes
Feb 21, 2026
Comment on lines
+64
to
+65
| //! therefore | ||
| //! a single read. |
Contributor
There was a problem hiding this comment.
Suggested change
| //! therefore | |
| //! a single read. | |
| //! therefore a single read. |
broken formatting
| //! [`PublicImmutable`](crate::state_vars::PublicImmutable) and | ||
| //! [`DelayedPublicMutable`](crate::state_vars::DelayedPublicMutable)) benefit from packing multiple values in the same | ||
| //! `struct` even if there is no need for tight packing (e.g. if all values are `Field`s), since they often work by | ||
| //! reading the _hash_ of the entire value. Many values in the same `struct` will result in a single hash, and |
Contributor
There was a problem hiding this comment.
Think people would be curious to learn why this optimization only works in private so would link here to the WithThash struct where I assume it's already explained.
| @@ -0,0 +1,175 @@ | |||
| // Trait: is_empty | |||
| // | |||
| // The general is_empty trait checks if a data type is is empty, | |||
Contributor
There was a problem hiding this comment.
Suggested change
| // The general is_empty trait checks if a data type is is empty, | |
| // The general is_empty trait checks if a data type is empty, |
I am aware it's unrelated to the PR but I couldn't help. These old docs are pretty ugly
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I added docs to
state_varstelling people to consider putting values in the same struct for cost reductions, and added lots of docs toPackableexplaining what it does, benefits, when to derive and when to do it manually, along with an example (and tests for the example).I also reorganized
protocol-types/traitsa little bit by putting each trait into their ownmod, so that it's less messy. Themods are private and we re-export viapub::use, so from the outside everything looks the same.For some reason the docsite does not build a page for
protocol::traitsand we instead get links toprotocol_types. I'll need to ask @asterite about this.