Looking for contracts for the UI I again encountered a weird response. In this case, the contract's "onchain creation bytecode" is the same as its "onchain runtime bytecode". I first thought this was a UI error but looking into the API response and the DB I could confirm it:
https://sourcify.dev/server/v2/contract/8453/0xB1A868BE8ABCB386400820355B3D6944AAD53224?fields=all
creationBytecode
- onchainBytecode "0x6080604052348015610010…664736f6c63430008140033" <-----
- recompiledBytecode "0x6101206040523480156200…664736f6c63430008140033"
runtimeBytecode
- onchainBytecode "0x6080604052348015610010…664736f6c63430008140033" <----
- recompiledBytecode "0x6080604052348015610010…664736f6c63430008140033"
The hashes are the same from the DB response
Query
-- Get runtime and creation bytecodes by address
SELECT
cd.chain_id,
cd.address,
-- rec_runtime.code AS rec_runtime_bytecode,
rec_runtime.code_hash as rec_runtime_hash,
-- onc_runtime.code as onc_runtime_bytecode,
onc_runtime.code_hash as onc_runtime_hash,
-- onc_creation.code as onc_creation_bytecode,
onc_creation.code_hash as onc_creation_hash,
-- rec_creation.code AS rec_creation_bytecode,
rec_creation.code_hash as rec_creation_hash
FROM contract_deployments cd
JOIN verified_contracts vc ON cd.id = vc.deployment_id
JOIN compiled_contracts cc ON vc.compilation_id = cc.id
join contracts on cd.contract_id = contracts.id
JOIN code rec_creation ON cc.creation_code_hash = rec_creation.code_hash
JOIN code rec_runtime ON cc.runtime_code_hash = rec_runtime.code_hash
join code onc_creation on contracts.creation_code_hash = onc_creation.code_hash
join code onc_runtime on contracts.runtime_code_hash = onc_runtime.code_hash
where cd.address=decode('B1A868BE8ABCB386400820355B3D6944AAD53224', 'hex');
| chain_id |
address |
rec_runtime_hash |
onc_runtime_hash |
onc_creation_hash |
rec_creation_hash |
| 8453 |
B1A868BE8ABCB386400820355B3D6944AAD53224 |
523108545387D3A34F2AF40A0121021492926C217EBBA28F46C4BDFDDE7CB85C |
A1487C7C0FE446096BA42CDD8092CC7DA67F6AE87BC4A33D173CE1E8F48C0F58 |
A1487C7C0FE446096BA42CDD8092CC7DA67F6AE87BC4A33D173CE1E8F48C0F58 |
549F17E7C5247EC58C1E05FB4818E888F1CD21756C2325257130101AF2B6D152 |
I wasn't able to reproduce this after importing from Etherscan as can be seen from the staging response: https://staging.sourcify.dev/server/v2/contract/8453/0xB1A868BE8ABCB386400820355B3D6944AAD53224?fields=all
We should further investigate this as I can see there are more contracts that have their "onchain creation code" == "onchain runtime code":
Query
SELECT COUNT(*) AS matching_contracts_count
FROM contracts
WHERE creation_code_hash = runtime_code_hash;
Result: 76609 contracts entries
Grouping by chain ie. contract_deployments entries:
Query
SELECT cd.chain_id, COUNT(*) AS contract_count
FROM contracts c
JOIN contract_deployments cd ON c.id = cd.contract_id
WHERE c.creation_code_hash = c.runtime_code_hash
GROUP BY cd.chain_id
ORDER BY contract_count DESC;
| chain_id |
contract_count |
| 8453 |
333492 |
| 80001 |
207305 |
| 5 |
152758 |
| 4 |
124177 |
| 3 |
76503 |
| 84531 |
49830 |
| 421613 |
20584 |
| 11155111 |
14917 |
| 69 |
11221 |
| 1 |
5813 |
| 420 |
5238 |
| 17000 |
4927 |
| 421611 |
4212 |
| 100 |
1545 |
| 77 |
1149 |
| 28 |
414 |
| 40 |
145 |
| 41 |
42 |
| 8217 |
28 |
| 420666 |
28 |
| 10200 |
19 |
| 99 |
15 |
| 167005 |
14 |
| 1101 |
11 |
| 534 |
11 |
| 167006 |
7 |
| 356256156 |
6 |
| 78430 |
4 |
| 78431 |
3 |
| 369 |
1 |
| 103090 |
1 |
Looking for contracts for the UI I again encountered a weird response. In this case, the contract's "onchain creation bytecode" is the same as its "onchain runtime bytecode". I first thought this was a UI error but looking into the API response and the DB I could confirm it:
https://sourcify.dev/server/v2/contract/8453/0xB1A868BE8ABCB386400820355B3D6944AAD53224?fields=all
The hashes are the same from the DB response
Query
I wasn't able to reproduce this after importing from Etherscan as can be seen from the staging response: https://staging.sourcify.dev/server/v2/contract/8453/0xB1A868BE8ABCB386400820355B3D6944AAD53224?fields=all
We should further investigate this as I can see there are more contracts that have their "onchain creation code" == "onchain runtime code":
Query
Result: 76609
contractsentriesGrouping by chain ie. contract_deployments entries:
Query