README: drop the free memory pointer alignment claim - #40
Merged
Merged
Conversation
Alignment of the free memory pointer is not a Solidity guarantee: under the legacy pipeline bytes.concat, string.concat and abi.encodePacked allocate at exact size and leave the pointer unaligned. Remove the three sentences that stated the allocator keeps it at a multiple of 32, and reword the hex"01"/hex"0100" example so the injectivity argument rests on the read length rather than on allocation rounding. The pattern hashes exactly `length` bytes and never reads past the data. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FvfmeRQKubdbFW1GL3kmib
|
Warning Review limit reachedNext included review available in 46 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FvfmeRQKubdbFW1GL3kmib
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.
Closes #38
README stated in three places that the allocator keeps the free memory pointer at a multiple of 32:
It is optimised so that the allocator always has the free memory pointer at a multiple of 32.Note that in the last case, the allocator will still move the free memory pointer to a multiple of 32 bytes even if that points past the end of the data structure.Even though the allocator retains a multiple of 0x20 on the free memory pointer, we MUST respect the true length ...Alignment of the free memory pointer is not a Solidity guarantee (issue Ruling, confirmed by the Solidity team). Under this repo's own build (solc 0.8.25, legacy pipeline)
bytes.concat,string.concatandabi.encodePackedallocate at exact byte size and leave the pointer unaligned; onlynew bytes(n)/new string(n)round up. Per the ruling the sentences are removed, not qualified per allocation form or pipeline. The issue names two sentences; the first bullet above is the title's claim verbatim ("always has the free memory pointer at a multiple of 32"), so all three go.The
hex"01"/hex"0100"example in "Hashing dynamic length byte strings" leaned on the removed premise ("they both have 0x20 bytes allocated to them"). It is reworded so the injectivity argument rests on the read length (rounding the length up to whole words would hash the same word for both when nothing has been written past them), and it now states what the pattern actually relies on: it hashes exactlylengthbytes and reads nothing past the data, so what the allocator does beyond it, including where it leaves the free memory pointer, is irrelevant. On the rewritten line, "whole-world lengths" is corrected to "whole-word lengths".test/MemoryLayout.t.sol:testBytesAllocationRoundsUpToWords,testBytesAllocationRoundsUpToWordsForAnyLengthandtestNewStringAllocatesLikeNewBytespinnew bytes(n)/new string(n)rounding, which stays true, and their NatSpec does not cite the removed README sentences; unchanged. No source or test files change.Also reworded two NatSpec lines in
test/MemoryLayout.t.solthat restated the removed claim: the contract doc no longer says the tests pin "claims README.md makes", and the rounding test saysnew bytes(n)allocates whole words rather than "the allocator roundsbytesup".QA
bytes.concat(hex"01", hex"02")moves the free memory pointer by 34,abi.encodePacked(uint8(7))by 33,new bytes(2)by 64, pointer mod 32 = 2 after the concat;--via-ir64/64/64/0) and the Solidity team's statement quoted in the issue's Ruling that free memory pointer alignment is not a guarantee. The legacy row is reproduced on this branch in the CI sol-shell (rainix dbcd9d3, solc 0.8.25): 34 / 33 / 64 / mod 32 = 2; memory literalshex"01"andhex"0100"each move the pointer by 64, so the old example's "0x20 bytes allocated" was true for literals only. The repro test is not committed: it would pin an implementation detail the compiler does not promise.new bytes(n)tests' NatSpec for citations of the removed text (none).🤖 Generated with Claude Code
https://claude.ai/code/session_01FvfmeRQKubdbFW1GL3kmib