-
Notifications
You must be signed in to change notification settings - Fork 413
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
Investigate: Library without immutables cannot be verified with matchWithDeployedBytecode
because of placeholders in bytecode
#996
Comments
I think this can help you guys. |
Also I am curious about your opinion on this issue, do you think such a contract can be considered as a library contract, at least its source code verification results describe it as a library. But the ADDRESS in its bytecode is not its address, which makes it violate some library restrictions, such as not being self-destructible! |
It's definitely this, I cite the docs here:
Now I'll debug and search for a way to catch this case |
I think that we can check for
followed by a |
I need to check if:
|
|
Thanks for the feedback |
We should also check on which Solidity version "call protection" was implemented and check the version of the contract as well. |
We asked more info to the Solidity team, they say:
We'll wait to fix this this for now. |
I've checked with the Solidity team and it seems there are two cases:
Can you please check the 1. case and make sure we cover that? |
@kuzdogan confirmed. The following library pragma solidity 0.8.19;
library Ballot {
function giveRightToVote() public {
uint8 tempnumber = 0;
tempnumber += 1;
}
} when {
"functionDebugData": {},
"generatedSources": [],
"immutableReferences": {
"library_deploy_address": [
{
"length": 32,
"start": 36
}
]
},
"linkReferences": {},
"object": "6004361015600c57600080fd5b6000803560e01c63fe073d1114602157600080fd5b307f0000000000000000000000000000000000000000000000000000000000000000146054578060031936011260545780f35b80fdfea26469706673582212201f5947cd5b1859e5538635710cbb976896344300763d9c3f1c9ed5ebf1ee6a5764736f6c63430008130033",
"opcodes": "PUSH1 0x4 CALLDATASIZE LT ISZERO PUSH1 0xC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP1 CALLDATALOAD PUSH1 0xE0 SHR PUSH4 0xFE073D11 EQ PUSH1 0x21 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST ADDRESS PUSH32 0x0 EQ PUSH1 0x54 JUMPI DUP1 PUSH1 0x3 NOT CALLDATASIZE ADD SLT PUSH1 0x54 JUMPI DUP1 RETURN JUMPDEST DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 0x1F MSIZE SELFBALANCE 0xCD JUMPDEST XOR MSIZE 0xE5 MSTORE8 DUP7 CALLDATALOAD PUSH18 0xCBB976896344300763D9C3F1C9ED5EBF1EE PUSH11 0x5764736F6C634300081300 CALLER ",
"sourceMap": "24:119:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
} but when {
"functionDebugData": {...},
"generatedSources": [...],
"immutableReferences": {},
"linkReferences": {},
"object": "730000000000000000000000000000000000000000301460806040526004361060335760003560e01c8063fe073d11146038575b600080fd5b818015604357600080fd5b50604a604c565b005b60006057600182605b565b5050565b60ff8181168382160190811115608157634e487b7160e01b600052601160045260246000fd5b9291505056fea2646970667358221220520c77e3449f05c27b1014df9e58e5f2b6463f139ea3cefde935a6f15b27f03a64736f6c63430008130033",
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH1 0x33 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0xFE073D11 EQ PUSH1 0x38 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 DUP1 ISZERO PUSH1 0x43 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x4A PUSH1 0x4C JUMP JUMPDEST STOP JUMPDEST PUSH1 0x0 PUSH1 0x57 PUSH1 0x1 DUP3 PUSH1 0x5B JUMP JUMPDEST POP POP JUMP JUMPDEST PUSH1 0xFF DUP2 DUP2 AND DUP4 DUP3 AND ADD SWAP1 DUP2 GT ISZERO PUSH1 0x81 JUMPI PUSH4 0x4E487B71 PUSH1 0xE0 SHL PUSH1 0x0 MSTORE PUSH1 0x11 PUSH1 0x4 MSTORE PUSH1 0x24 PUSH1 0x0 REVERT JUMPDEST SWAP3 SWAP2 POP POP JUMP INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 MSTORE 0xC PUSH24 0xE3449F05C27B1014DF9E58E5F2B6463F139EA3CEFDE935A6 CALL JUMPDEST 0x27 CREATE GASPRICE PUSH5 0x736F6C6343 STOP ADDMOD SGT STOP CALLER ",
"sourceMap": "24:119:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;45:96;;;;;;;;;;;;;:::i;:::-;;;89:16;119:15;133:1;89:16;119:15;:::i;:::-;-1:-1:-1;;45:96:0:o;14:245:1:-;102:4;81:12;;;95;;;77:31;;120:13;;117:136;;;175:10;170:3;166:20;163:1;156:31;210:4;207:1;200:15;238:4;235:1;228:15;117:136;14:245;;;;:::o"
} |
* legacy compilation placeholder test case * via-IR test case
I came across a contract (library) that could only be verified with the
creatorTxHash
as the recompiled deployed bytecode contains0000000
s akin to immutables, but the library does not actually have immutables in the source code.The contract is: https://testnet.snowtrace.io/address/0x28CA70cc5732D042381F9240bf45aB1b493aEFef#code
The part that differ is the bytes 1 to 21 in the bytecode, as below, which has the contract address
0x28CA70cc5732D042381F9240bf45aB1b493aEFef
value filled in during deployment.Recompiled deployed bytecode:
Onchain deployed bytecode
I couldn't really point out in the source code where this placeholder part is coming from. It might be useful to know where it's coming from when we're verifying similar contracts.
Also, another reason to have creation bytecode as the basis of the verification?
View in Huly HI-403
The text was updated successfully, but these errors were encountered: