fix(StdStorage): find string/bytes slots (dynamic ABI returns)#887
Open
Yonkoo11 wants to merge 1 commit into
Open
fix(StdStorage): find string/bytes slots (dynamic ABI returns)#887Yonkoo11 wants to merge 1 commit into
Yonkoo11 wants to merge 1 commit into
Conversation
find() compared only a single returndata word at depth. For string/bytes getters that word is the ABI offset (0x20), so mutating storage never looked like a hit and short strings failed with "Slot(s) not found". For single dynamic returns, compare the full returndata hash when probing slots, and skip the raw slot==return equality check (storage encoding is not the ABI word). Static multi-word returns still use the depth word so struct field isolation is unchanged. Fixes foundry-rs#345
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.
Summary
stdstore.find()failed on publicstring/bytesstate vars (short strings in particular):Slot(s) not found.Cause: mutation checks only compared one returndata word at
depth. For dynamic ABI returns that word is the offset (0x20), not the content, so writing storage never registered as a hit. The follow-upslot value == return wordcheck has the same mismatch (short-string packing is not the ABI word).Change
returndatalength ≥ 64 and word0 ==0x20)depthso sibling fields are not false hitsTests
test_StorageFindShortString— 31-char public string, expects slot 0 (bug(StdStorage): find() does not work for short strings #345)test_StorageFindLongString— find must not reverttest_StorageFindBytes— publicbytes, expects slot 0test/StdStorage.t.solsuite (incl. fuzz) green locallyNotes
Closes #345
Prepared with AI assistance; I reviewed and ran the tests above.