Skip to content

Commit

Permalink
Fix modifying metadata of test contract Constructor. Also fix test
Browse files Browse the repository at this point in the history
The test was built incorrectly but it was passing because the artifact.json of ConstructorModified has the bytecode of Constructor. The test should actually deploy Constructor but verify using ConstructorModified to get a partial match.
  • Loading branch information
kuzdogan committed Jan 10, 2025
1 parent 5f2c431 commit 9c734fb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 30 deletions.
62 changes: 39 additions & 23 deletions packages/lib-sourcify/test/sources/Constructor/metadata.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,67 @@
{
"compiler": { "version": "0.8.26+commit.8a97fa7a" },
"compiler": {
"version": "0.8.26+commit.8a97fa7a"
},
"language": "Solidity",
"output": {
"abi": [
{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" },
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "getActiveConfig",
"name": "read",
"outputs": [
{
"components": [
{ "internalType": "address", "name": "vrf", "type": "address" },
{
"internalType": "bytes32",
"name": "key_hash",
"type": "bytes32"
}
],
"internalType": "struct Type.InitiazationObject",
"internalType": "uint256",
"name": "",
"type": "tuple"
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"devdoc": { "kind": "dev", "methods": {}, "version": 1 },
"userdoc": { "kind": "user", "methods": {}, "version": 1 }
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
},
"settings": {
"compilationTarget": {
"contracts/CBORInTheMiddle.sol": "DeploymentHelper"
"contracts/StorageConstructor.sol": "StorageConstructor"
},
"evmVersion": "cancun",
"libraries": {},
"metadata": { "bytecodeHash": "ipfs" },
"optimizer": { "enabled": true, "runs": 200 },
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
},
"sources": {
"contracts/CBORInTheMiddle.sol": {
"keccak256": "0x2718b880b03105e97950bd1cbb1134720edc5187ebdb9440b2cb3753d929b295",
"license": "MIT",
"contracts/StorageConstructor.sol": {
"keccak256": "0x08f38c93765803ab3f816f21c34a503f19d8f4b1e8749f0cfd19ddd9f7945611",
"urls": [
"bzz-raw://f97208d403360b74cb5d7b2fb3f4f7ba74dc4a7d75aa938bc01bef3343454454",
"dweb:/ipfs/QmXzbTMxEBzmthqQ74XNjK7sqUVMP1YcJDrvhtzzpWU4Lg"
"bzz-raw://7bfd5c535266833f3753a007b3cbe5c94f8157f1006e90755bc5d4424274d6a2",
"dweb:/ipfs/QmXUiWh7uFVRCvuUxnTWNHW4byrrqQwGsxjJpV7pwAyGVS"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"type": "function"
}
],
"bytecode": "0x6080604052348015600e575f80fd5b5060405161014c38038061014c8339818101604052810190602e9190606b565b805f81905550506091565b5f80fd5b5f819050919050565b604d81603d565b81146056575f80fd5b50565b5f815190506065816046565b92915050565b5f60208284031215607d57607c6039565b5b5f6088848285016059565b91505092915050565b60af8061009d5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c806357de26a414602a575b5f80fd5b60306044565b604051603b91906062565b60405180910390f35b5f8054905090565b5f819050919050565b605c81604c565b82525050565b5f60208201905060735f8301846055565b9291505056fea26469706673582212208a693a7ed29129e25fc67a65f83955fb3d86f5fbc378940d697827714b955df564736f6c634300081a0033"
"bytecode": "0x6080604052348015600e575f80fd5b5060405161014c38038061014c8339818101604052810190602e9190606b565b805f81905550506091565b5f80fd5b5f819050919050565b604d81603d565b81146056575f80fd5b50565b5f815190506065816046565b92915050565b5f60208284031215607d57607c6039565b5b5f6088848285016059565b91505092915050565b60af8061009d5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c806357de26a414602a575b5f80fd5b60306044565b604051603b91906062565b60405180910390f35b5f8054905090565b5f819050919050565b605c81604c565b82525050565b5f60208201905060735f8301846055565b9291505056fea2646970667358221220fdd288b10b21a40b31e4e025a8c19db0027750c1dbb01660f7c8cc8780c0d16664736f6c634300081a0033"
}
15 changes: 9 additions & 6 deletions packages/lib-sourcify/test/verification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,21 @@ describe('lib-sourcify tests', () => {

// For https://github.com/ethereum/sourcify/pull/1623
it('should verify a contract partially with the creation bytecode after transformation fields are normalized', async () => {
const contractFolderPath = path.join(
__dirname,
'sources',
'ConstructorModified',
);
const contractFolderPath = path.join(__dirname, 'sources', 'Constructor');
const { contractAddress, txHash } = await deployFromAbiAndBytecode(
signer,
contractFolderPath,
['12345'],
);

const modifiedContractFolderPath = path.join(
__dirname,
'sources',
'ConstructorModified',
);

const match = await checkAndVerifyDeployed(
contractFolderPath,
modifiedContractFolderPath,
sourcifyChainHardhat,
contractAddress,
txHash,
Expand Down

0 comments on commit 9c734fb

Please sign in to comment.