Skip to content
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

Fix keccak256(abi.encodePacked(addr, index)) => keccak256(abi.encode(… #786

Merged
merged 4 commits into from
Oct 19, 2024

Conversation

LingYe-WEB3
Copy link
Contributor

…addr, index))

What type of PR is this (这是什么类型的PR)

  • [✅ ] Typo(勘误)
  • BUG(程序错误)
  • Improvement(提升)
  • Feature(新特性)

Which issue(s) this PR fixes(Optional) (这个PR 修复了什么问题 (可选择))

  • resolve(修复) : #

What this PR does / why we need it (这个PR 做了什么/ 我们为什么需要这个PR)

在solidity的mapping计算插槽位置的计算方式错误,由abi.encodePacked更新为abi.encode

@XdpCs
Copy link
Collaborator

XdpCs commented Oct 18, 2024

@LingYe-WEB3 能提供你的参考资料吗?
最好是Solidity官方的文档

@XdpCs
Copy link
Collaborator

XdpCs commented Oct 18, 2024

The value corresponding to a mapping key k is located at keccak256(h(k) . p) where . is concatenation and h is a function that is applied to the key depending on its type:

  • for value types, h pads the value to 32 bytes in the same way as when storing the value in memory.
  • for strings and byte arrays, h(k) is just the unpadded data.

ref: https://docs.soliditylang.org/en/v0.8.28/internals/layout_in_storage.html

@XdpCs
Copy link
Collaborator

XdpCs commented Oct 18, 2024

The value corresponding to a mapping key k is located at keccak256(h(k) . p) where . is concatenation and h is a function that is applied to the key depending on its type:

  • for value types, h pads the value to 32 bytes in the same way as when storing the value in memory.
  • for strings and byte arrays, h(k) is just the unpadded data.

ref: https://docs.soliditylang.org/en/v0.8.28/internals/layout_in_storage.html

可能需要把这个重新整理一下 进入教程

@LingYe-WEB3
Copy link
Contributor Author

The value corresponding to a mapping key k is located at keccak256(h(k) . p) where . is concatenation and h is a function that is applied to the key depending on its type:

  • for value types, h pads the value to 32 bytes in the same way as when storing the value in memory.
  • for strings and byte arrays, h(k) is just the unpadded data.

ref: https://docs.soliditylang.org/en/v0.8.28/internals/layout_in_storage.html

可能需要把这个重新整理一下 进入教程

好的,那我更新一下这个分支,把这些信息写入教程。

Copy link
Contributor Author

@LingYe-WEB3 LingYe-WEB3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Update the method for reading the storage location of mappings."

@LingYe-WEB3
Copy link
Contributor Author

@XdpCs 我根据Solidity官方的文档更新了mapping数据存储位置的计算方式。希望能够教程有所帮助。

@LingYe-WEB3
Copy link
Contributor Author

@XdpCs 我根据Solidity官方的文档更新了mapping数据存储位置的计算方式。希望能够教程有所帮助。

ref: https://docs.soliditylang.org/en/v0.8.28/internals/layout_in_storage.html

@AmazingAng AmazingAng merged commit 6286e36 into AmazingAng:main Oct 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants