Skip to content

Server crashes when a compiled contract does not have metadata in the output #2207

@kuzdogan

Description

@kuzdogan

I just came across a case that breaks and crashes the server instead of catching a general error.

For some reason, some of the contracts in this file (flattened) do not have "metadata" in the JSON output, ie. the field is: "metadata": "". This might just be an old version bug (0.4.18) and I asked the Solidity team about it.

Contract: https://repo.sourcify.dev/1/0xdAC17F958D2ee523a2206206994597C13D831ec7
Endpoint: POST /v2/verify

chain-1-0xdAC17F95-standard-json-input.json
output.json

To reproduce, verify the contract above with Compilation Target: TetherToken.sol:BasicToken

You can see from the above output too that BasicToken has empty metadata.

I noticed the error happens here:

https://github.com/ethereum/sourcify/blob/4f814bbd86fb878fc2b3cc9942022d3bc8282ed7/packages/lib-sourcify/src/Compilation/SolidityCompilation.ts#L202-L206

We need to fix several things here:

  • We should not assume there will be a metadata from the SolidityCompilation (e.g. pre-metadata (<v0.4.7) contracts) and have proper handling for that. I think this is always generated for Vyper?
  • Even if during the compilation or after compilation an error is thrown, this should have been caught gracefully. This is more imporant than the above point.

Metadata

Metadata

Assignees

Labels

🪲 bugSomething isn't working

Type

Projects

Status

COMPLETED

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions