Repository navigation
[Bug] 37_Signature: ECDSA.toEthSignedMessageHash should be internal, not public - #947
Open
pucedoteth wants to merge 1 commit into
Open
pucedoteth wants to merge 1 commit into
pucedoteth wants to merge 1 commit into
Conversation
The other two functions of this teaching ECDSA library are `internal`, but `toEthSignedMessageHash` is `public`. As chapter 17 explains, a `public`/`external` library function is reached through a `delegatecall`, so the library becomes a separately deployed contract that has to be linked: SignatureNFT's creation bytecode carries an unresolved `__$e3d8e53151ebe0b7203e2d17c613eec2e4$__` placeholder, and deploying it from the artifact fails until ECDSA is deployed and linked in. Making it `internal` inlines the function, drops the link reference, and removes a DELEGATECALL from every mint(). This matches MerkleProof in chapter 36 and OpenZeppelin's MessageHashUtils, and matches the English readme of this chapter, which already says `internal`.
pucedoteth
force-pushed
the
fix-ecdsa-library-visibility
branch
from
August 17, 2026 00:11
5263b38 to
e9da61f
Compare
This branch has not been deployed
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.
问题 / Problem
In
37_Signature/Signature.sol, the teachingECDSAlibrary declares two functionsinternaland onepublic:As chapter 17 (库合约) itself explains: 库合约中的函数可见性如果被设置为
public或者external,则在调用这个函数时会触发一次delegatecall。So this one
publicturnsECDSAinto a separately deployed contract that must be linked intoSignatureNFT. Compiling the chapter as-is:The creation bytecode contains an unresolved placeholder
__$e3d8e53151ebe0b7203e2d17c613eec2e4$__. Consequences for a learner following this chapter:SignatureNFTfrom the artifact with ethers.js / hardhat / web3 fails ("bytecode contains unresolved library placeholder") untilECDSAis deployed separately and linked in. Remix hides this by auto-deploying the library, so the chapter appears to work there and breaks everywhere else.mint()pays an extraDELEGATECALLto compute a pure keccak hash of a constant prefix.This looks unintended rather than pedagogical:
internal.MerkleProoflibrary in chapter 36 isinternal/privatethroughout and produces no link reference.MessageHashUtils.toEthSignedMessageHashisinternal.internal(Languages/en/37_Signature_en/readme.md:82) — only the.solfiles and the zh/pt-br readmes still saypublic.Chapter 17's
Stringslibrary is deliberatelypublicto demonstrate library linking, so that one is left untouched.修改 / Fix
public→internal, applied to the code and to the readme snippets that were still out of sync:37_Signature/Signature.sol37_Signature/readme.mdLanguages/en/37_Signature_en/Signature.solLanguages/pt-br/37_Signature/Signature.solLanguages/pt-br/37_Signature/readme.mdAfter the change:
SignatureNFTnow compiles to fully linked bytecode and deploys standalone. The whole workspace still builds (forge buildclean).Note: the checked-in
out/artifacts are not regenerated in this PR — they will pick up the change on the next build.