lidofinance / lidofinance/diffyscan

zkSync explorer fetcher likely broken: missing solcInput (KeyError downstream) + ContractName casing mismatch

Open
#163 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
142
Forks
20
Avg merge
1d 13h
Merged PRs (30d)
15

Description

Summary

The zkSync explorer fetcher (_get_contract_from_zksync in diffyscan/utils/explorer.py) returns a contract dict incompatible with downstream code, and has a key-casing inconsistency. zkSync contract verification appears to be broken (surfaced during an audit of the docs vs code).

1. Missing solcInput → KeyError downstream

The fetcher returns (explorer.py ~251-255):

contract = {
    "name": data["ContractName"],
    "sources": json.loads(data["sourceCode"]["sources"]),
    "compiler": data["CompilerVersion"],
}

There is no solcInput key. But downstream, both:

  • run_source_diffdiffyscan.py:204: get_solc_sources(contract_code["solcInput"])
  • run_bytecode_diffdiffyscan.py:70: solc_input = contract_source_code["solcInput"]

read contract["solcInput"] unconditionally — there is no zkSync-specific branch anywhere in diffyscan.py. A verified zkSync contract reaching this path raises KeyError: 'solcInput'.

2. ContractName casing inconsistency

data = response["request"]
if "contractName" not in data:     # lowercase presence check
    _error_no_source_code_and_exit(contract)
contract = {
    "name": data["ContractName"],  # uppercase read
    "compiler": data["CompilerVersion"],
    ...
}

The presence guard checks lowercase contractName, but the reads use ContractName / CompilerVersion. Depending on the real API casing this either always trips the "not verified / no source" branch, or raises KeyError on the read.

Impact

zkSync source/bytecode verification likely fails for every contract via this path.

Suggested next steps

  • Confirm the live zkSync explorer API response shape (key casing; whether it returns standard-json solc input).
  • Construct a proper solcInput for the zkSync path (or add a downstream branch), and align the key casing.

Found via a docs-vs-code audit; not yet reproduced against a live zkSync contract.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with _get_contract_from_zksync in diffyscan/utils/explorer.py and trace the solcInput reads in diffyscan.py at lines 70 and 204. Confirm the live zkSync explorer response casing and whether it provides standard-json solc input. Done means the zkSync contract shape matches downstream expectations and source/bytecode verification no longer fails with casing or solcInput errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, solidity
Domain
backend, blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.