Fix the ABI finding logic #38
Merged
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.
Summary
This PR fixes a problem in the driver which made it unable to find the ABI of the contracts that it deployed.
Description
I found the following error log when trying to run a simple test through this framework:
This error stems from the the following piece of code:
Which is attempting to find the ABI of the contract that's being deployed in the JSON output of the compiler. The above works with
solcbut doesn't work withresolc. The reason for this is that the JSON schema of the output of both compilers is different. Here's an example:solccompiler:{ "metadata": "{\"compiler\":{\"version\":\"0.8.29+commit.ab55807c\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256[1]\",\"name\":\"p1\",\"type\":\"uint256[1]\"}],\"name\":\"f\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/omarabdulla/parity/era-compiler-tests/solidity/complex/array_one_element/callable.sol\":\"Callable\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"details\":{\"constantOptimizer\":false,\"cse\":false,\"deduplicate\":false,\"inliner\":true,\"jumpdestRemover\":false,\"orderLiterals\":false,\"peephole\":false,\"simpleCounterForLoopUncheckedIncrement\":true,\"yul\":true,\"yulDetails\":{\"optimizerSteps\":\"dhfoDgvulfnTUtnIfxa[r]EscLMVcul [j]Trpeulxa[r]cLgvifMCTUca[r]LSsTFOtfDnca[r]IulcscCTUtgvifMx[scCTUt] TOntnfDIulgvifMjmul[jul] VcTOcul jmul:fDnTOcmuO\",\"stackAllocation\":true}},\"runs\":200},\"remappings\":[],\"viaIR\":true},\"sources\":{\"/Users/omarabdulla/parity/era-compiler-tests/solidity/complex/array_one_element/callable.sol\":{\"keccak256\":\"0x6d0e7b9c3d7fc7a06fac7413ce4f0f02a110fe552ef33c642cf94c192fee5963\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://36f00835b9466e8697d13994e557f240e491f9515ef1e65c83aef134f0d1e1e4\",\"dweb:/ipfs/QmafYebPHZp6iwxY5NuD9FP8C9Y7X3vfcqNtm4Np8REcTt\"]}},\"version\":1}", "evm": { "bytecode": { "object": "REMOVED TO SAVE SPACE" }, "deployedBytecode": { "object": "REMOVED TO SAVE SPACE" }, "methodIdentifiers": { "f(uint256[1])": "09a31ea4" } }, "irOptimized": "REMOVED TO SAVE SPACE" }resolccompiler:{ "metadata": { "llvm_arguments": [], "optimizer_settings": { "is_debug_logging_enabled": false, "is_fallback_to_size_enabled": false, "is_verify_each_enabled": false, "level_back_end": "Aggressive", "level_middle_end": "Default", "level_middle_end_size": "Z" }, "revive_pallet_version": null, "revive_version": "0.3.0+commit.b238913.llvm-18.1.8", "solc_metadata": "{\"compiler\":{\"version\":\"0.8.30+commit.73712a01\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256[1]\",\"name\":\"p1\",\"type\":\"uint256[1]\"}],\"name\":\"f\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/omarabdulla/parity/era-compiler-tests/solidity/complex/array_one_element/callable.sol\":\"Callable\"},\"evmVersion\":\"prague\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"details\":{\"constantOptimizer\":false,\"cse\":false,\"deduplicate\":false,\"inliner\":false,\"jumpdestRemover\":false,\"orderLiterals\":false,\"peephole\":false,\"simpleCounterForLoopUncheckedIncrement\":true,\"yul\":true,\"yulDetails\":{\"optimizerSteps\":\"dhfoDgvulfnTUtnIfxa[r]EscLMVcul [j]Trpeulxa[r]cLgvifMCTUca[r]LSsTFOtfDnca[r]IulcscCTUtgvifMx[scCTUt] TOntnfDIulgvifMjmul[jul] VcTOcul jmul:fDnTOcmuO\",\"stackAllocation\":true}},\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/omarabdulla/parity/era-compiler-tests/solidity/complex/array_one_element/callable.sol\":{\"keccak256\":\"0x6d0e7b9c3d7fc7a06fac7413ce4f0f02a110fe552ef33c642cf94c192fee5963\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://36f00835b9466e8697d13994e557f240e491f9515ef1e65c83aef134f0d1e1e4\",\"dweb:/ipfs/QmafYebPHZp6iwxY5NuD9FP8C9Y7X3vfcqNtm4Np8REcTt\"]}},\"version\":1}", "solc_version": "0.8.30+commit.73712a01.Darwin.appleclang" }, "evm": { "assembly": "REMOVED TO SAVE SPACE", "bytecode": { "object": "REMOVED TO SAVE SPACE" }, "deployedBytecode": { "object": "REMOVED TO SAVE SPACE" }, "methodIdentifiers": { "f(uint256[1])": "09a31ea4" } }, "irOptimized": "REMOVED TO SAVE SPACE", "hash": "10335929ebaafc99c69b0bd9524253a31e13c491caf3e88c63fe40676d359a10", "factoryDependencies": {} }We can see that for the two compilers the path that the metadata (and the abi) exist at are a little different. For
solcit's at.metadata.output.abiand forresolcit's at.metadata.solc_metadata.output.abi.I implemented a short term solution to this (and described the more ideal long term solution in the code comments) where the driver is aware of the differences of the formats and it attempts to find the metadata and the ABI at the two paths listed above.
Once we get everything working and we want to productize the code we can implement something that's cleaner and respects the abstractions that we have a bit more.