blockscout icon indicating copy to clipboard operation
blockscout copied to clipboard

can't seem to verify smart contract on my local blockscount

Open wighawag opened this issue 2 years ago • 3 comments

Description

Hi, I am using a local blockscount instance hosted on a LAN network under ethereum.local I use the following setup: https://github.com/wighawag/blockscout/tree/1183e1265dfce5f6d8563d1b7bb8b40fb0682f77/docker-compose

(I added smart-contract-verifier service which was not there by default and configured the envs variable to run on ethereum.local)

I get the following error when execute etherscan verification submission on it :

 | 2023-11-07T13:42:20.741 application=explorer [error] Smart-contract verification error: Invalid metadata.chain_id
backend                         | 2023-11-07T13:42:20.741 [error] Task #PID<0.10981.4> started from #PID<0.15910.3> terminating
backend                         | ** (Protocol.UndefinedError) protocol String.Chars not implemented for %{"code" => 3, "message" => "Invalid metadata.chain_id"} of type Map. This protocol is implemented for the following type(s): Atom, BitString, Cldr.Currency, Cldr.LanguageTag, Cldr.LanguageTag.T, Cldr.LanguageTag.U, Cldr.Unit, Date, DateTime, Decimal, ExJsonSchema.Validator.Error.AdditionalItems, ExJsonSchema.Validator.Error.AdditionalProperties, ExJsonSchema.Validator.Error.AllOf, ExJsonSchema.Validator.Error.AnyOf, ExJsonSchema.Validator.Error.Const, ExJsonSchema.Validator.Error.Contains, ExJsonSchema.Validator.Error.ContentEncoding, ExJsonSchema.Validator.Error.ContentMediaType, ExJsonSchema.Validator.Error.Dependencies, ExJsonSchema.Validator.Error.Enum, ExJsonSchema.Validator.Error.False, ExJsonSchema.Validator.Error.Format, ExJsonSchema.Validator.Error.IfThenElse, ExJsonSchema.Validator.Error.ItemsNotAllowed, ExJsonSchema.Validator.Error.MaxItems, ExJsonSchema.Validator.Error.MaxLength, ExJsonSchema.Validator.Error.MaxProperties, ExJsonSchema.Validator.Error.Maximum, ExJsonSchema.Validator.Error.MinItems, ExJsonSchema.Validator.Error.MinLength, ExJsonSchema.Validator.Error.MinProperties, ExJsonSchema.Validator.Error.Minimum, ExJsonSchema.Validator.Error.MultipleOf, ExJsonSchema.Validator.Error.Not, ExJsonSchema.Validator.Error.OneOf, ExJsonSchema.Validator.Error.Pattern, ExJsonSchema.Validator.Error.PropertyNames, ExJsonSchema.Validator.Error.Required, ExJsonSchema.Validator.Error.Type, ExJsonSchema.Validator.Error.UniqueItems, Explorer.Chain.Address, Explorer.Chain.Data, Explorer.Chain.Hash, FileInfo.Mime, Float, Floki.Selector, Floki.Selector.AttributeSelector, Floki.Selector.Combinator, Floki.Selector.Functional, Floki.Selector.PseudoClass, Hex.Solver.Assignment, Hex.Solver.Constraints.Empty, Hex.Solver.Constraints.Range, Hex.Solver.Constraints.Union, Hex.Solver.Incompatibility, Hex.Solver.PackageRange, Hex.Solver.Term, Integer, List, NaiveDateTime, Postgrex.Copy, Postgrex.Query, Que.Job, RemoteIp.Block, Time, URI, Version, Version.Requirement
backend                         |     (elixir 1.14.5) lib/string/chars.ex:3: String.Chars.impl_for!/1
backend                         |     (elixir 1.14.5) lib/string/chars.ex:22: String.Chars.to_string/1
backend                         |     (explorer 5.3.1) lib/explorer/smart_contract/solidity/publisher.ex:225: Explorer.SmartContract.Solidity.Publisher.unverified_smart_contract/5
backend                         |     (explorer 5.3.1) lib/explorer/smart_contract/solidity/publisher.ex:103: Explorer.SmartContract.Solidity.Publisher.publish_with_standard_json_input/2
backend                         |     (explorer 5.3.1) lib/explorer/smart_contract/solidity/publisher_worker.ex:54: Explorer.SmartContract.Solidity.PublisherWorker.perform/1
backend                         |     (elixir 1.14.5) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
backend                         |     (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
backend                         | Function: #Function<3.127712543/0 in Que.Job.perform/1>
backend                         |     Args: []
backend                         | 2023-11-07T13:42:20.745 application=que [info] [Que] Failed Job # 2 with Explorer.SmartContract.Solidity.PublisherWorker
backend                         | 2023-11-07T13:42:24.897 application=indexer fetcher=empty_blocks_to_refetch [info] Start sanitizing of empty b

Type of the installation

Docker-compose

Type of the JSON RPC archive node

Geth

Type of the chain

Local (--dev)

Link to the page

No response

Steps to reproduce

No response

Backend version

https://github.com/blockscout/blockscout/commit/1e832d995cc71b3b66b8fc6d51d5273924c1bbba

Frontend version

https://github.com/blockscout/blockscout/commit/1e832d995cc71b3b66b8fc6d51d5273924c1bbba

Elixir & Erlang/OTP versions

docker

Operating system

No response

Additional information

No response

wighawag avatar Nov 07 '23 13:11 wighawag

Same error when uploading json through the web interface

wighawag avatar Nov 07 '23 14:11 wighawag

same error

backend                         | {"time":"2023-11-28T12:24:09.929Z","severity":"info","message":"Smart-contract verification via flattened file started","metadata":{}}
backend                         | {"time":"2023-11-28T12:24:09.929Z","severity":"info","message":"Sent 200 in 3ms on POST /api/v2/smart-contracts/0xc860494990d45c0d8f41ec8e2761581b7b9302ac/verification/via/flattened-code?","metadata":{"duration":3797,"endpoint":"/api/v2/smart-contracts/0xc860494990d45c0d8f41ec8e2761581b7b9302ac/verification/via/flattened-code?","method":"POST","request_id":"F5vI95PPu30YChwAAAip","status":"200","unit":"microsecond"}}
backend                         | {"time":"2023-11-28T12:24:10.569Z","severity":"error","message":"Smart-contract verification error: Invalid metadata.chain_id","metadata":{}}
backend                         | {"time":"2023-11-28T12:24:10.569Z","severity":"error","message":"Task #PID<0.9998.0> started from #PID<0.9997.0> terminating\n** (Protocol.UndefinedError) protocol String.Chars not implemented for %{\"code\" => 3, \"message\" => \"Invalid metadata.chain_id\"} of type Map. This protocol is implemented for the following type(s): Atom, BitString, Cldr.Currency, Cldr.LanguageTag, Cldr.LanguageTag.T, Cldr.LanguageTag.U, Cldr.Unit, Date, DateTime, Decimal, ExJsonSchema.Validator.Error.AdditionalItems, ExJsonSchema.Validator.Error.AdditionalProperties, ExJsonSchema.Validator.Error.AllOf, ExJsonSchema.Validator.Error.AnyOf, ExJsonSchema.Validator.Error.Const, ExJsonSchema.Validator.Error.Contains, ExJsonSchema.Validator.Error.ContentEncoding, ExJsonSchema.Validator.Error.ContentMediaType, ExJsonSchema.Validator.Error.Dependencies, ExJsonSchema.Validator.Error.Enum, ExJsonSchema.Validator.Error.False, ExJsonSchema.Validator.Error.Format, ExJsonSchema.Validator.Error.IfThenElse, ExJsonSchema.Validator.Error.ItemsNotAllowed, ExJsonSchema.Validator.Error.MaxItems, ExJsonSchema.Validator.Error.MaxLength, ExJsonSchema.Validator.Error.MaxProperties, ExJsonSchema.Validator.Error.Maximum, ExJsonSchema.Validator.Error.MinItems, ExJsonSchema.Validator.Error.MinLength, ExJsonSchema.Validator.Error.MinProperties, ExJsonSchema.Validator.Error.Minimum, ExJsonSchema.Validator.Error.MultipleOf, ExJsonSchema.Validator.Error.Not, ExJsonSchema.Validator.Error.OneOf, ExJsonSchema.Validator.Error.Pattern, ExJsonSchema.Validator.Error.PropertyNames, ExJsonSchema.Validator.Error.Required, ExJsonSchema.Validator.Error.Type, ExJsonSchema.Validator.Error.UniqueItems, Explorer.Chain.Address, Explorer.Chain.Data, Explorer.Chain.Hash, FileInfo.Mime, Float, Floki.Selector, Floki.Selector.AttributeSelector, Floki.Selector.Combinator, Floki.Selector.Functional, Floki.Selector.PseudoClass, Hex.Solver.Assignment, Hex.Solver.Constraints.Empty, Hex.Solver.Constraints.Range, Hex.Solver.Constraints.Union, Hex.Solver.Incompatibility, Hex.Solver.PackageRange, Hex.Solver.Term, Integer, List, NaiveDateTime, Postgrex.Copy, Postgrex.Query, Que.Job, RemoteIp.Block, Time, URI, Version, Version.Requirement\n    (elixir 1.14.5) lib/string/chars.ex:3: String.Chars.impl_for!/1\n    (elixir 1.14.5) lib/string/chars.ex:22: String.Chars.to_string/1\n    (explorer 5.3.2) lib/explorer/smart_contract/solidity/publisher.ex:224: Explorer.SmartContract.Solidity.Publisher.unverified_smart_contract/5\n    (explorer 5.3.2) lib/explorer/smart_contract/solidity/publisher.ex:63: Explorer.SmartContract.Solidity.Publisher.publish/3\n    (explorer 5.3.2) lib/explorer/smart_contract/solidity/publisher_worker.ex:65: Explorer.SmartContract.Solidity.PublisherWorker.broadcast/4\n    (elixir 1.14.5) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2\n    (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3\nFunction: #Function<3.127712543/0 in Que.Job.perform/1>\n    Args: []","metadata":{"error":{"initial_call":null,"reason":"** (Protocol.UndefinedError) protocol String.Chars not implemented for %{\"code\" => 3, \"message\" => \"Invalid metadata.chain_id\"} of type Map. This protocol is implemented for the following type(s): Atom, BitString, Cldr.Currency, Cldr.LanguageTag, Cldr.LanguageTag.T, Cldr.LanguageTag.U, Cldr.Unit, Date, DateTime, Decimal, ExJsonSchema.Validator.Error.AdditionalItems, ExJsonSchema.Validator.Error.AdditionalProperties, ExJsonSchema.Validator.Error.AllOf, ExJsonSchema.Validator.Error.AnyOf, ExJsonSchema.Validator.Error.Const, ExJsonSchema.Validator.Error.Contains, ExJsonSchema.Validator.Error.ContentEncoding, ExJsonSchema.Validator.Error.ContentMediaType, ExJsonSchema.Validator.Error.Dependencies, ExJsonSchema.Validator.Error.Enum, ExJsonSchema.Validator.Error.False, ExJsonSchema.Validator.Error.Format, ExJsonSchema.Validator.Error.IfThenElse, ExJsonSchema.Validator.Error.ItemsNotAllowed, ExJsonSchema.Validator.Error.MaxItems, ExJsonSchema.Validator.Error.MaxLength, ExJsonSchema.Validator.Error.MaxProperties, ExJsonSchema.Validator.Error.Maximum, ExJsonSchema.Validator.Error.MinItems, ExJsonSchema.Validator.Error.MinLength, ExJsonSchema.Validator.Error.MinProperties, ExJsonSchema.Validator.Error.Minimum, ExJsonSchema.Validator.Error.MultipleOf, ExJsonSchema.Validator.Error.Not, ExJsonSchema.Validator.Error.OneOf, ExJsonSchema.Validator.Error.Pattern, ExJsonSchema.Validator.Error.PropertyNames, ExJsonSchema.Validator.Error.Required, ExJsonSchema.Validator.Error.Type, ExJsonSchema.Validator.Error.UniqueItems, Explorer.Chain.Address, Explorer.Chain.Data, Explorer.Chain.Hash, FileInfo.Mime, Float, Floki.Selector, Floki.Selector.AttributeSelector, Floki.Selector.Combinator, Floki.Selector.Functional, Floki.Selector.PseudoClass, Hex.Solver.Assignment, Hex.Solver.Constraints.Empty, Hex.Solver.Constraints.Range, Hex.Solver.Constraints.Union, Hex.Solver.Incompatibility, Hex.Solver.PackageRange, Hex.Solver.Term, Integer, List, NaiveDateTime, Postgrex.Copy, Postgrex.Query, Que.Job, RemoteIp.Block, Time, URI, Version, Version.Requirement\n    (elixir 1.14.5) lib/string/chars.ex:3: String.Chars.impl_for!/1\n    (elixir 1.14.5) lib/string/chars.ex:22: String.Chars.to_string/1\n    (explorer 5.3.2) lib/explorer/smart_contract/solidity/publisher.ex:224: Explorer.SmartContract.Solidity.Publisher.unverified_smart_contract/5\n    (explorer 5.3.2) lib/explorer/smart_contract/solidity/publisher.ex:63: Explorer.SmartContract.Solidity.Publisher.publish/3\n    (explorer 5.3.2) lib/explorer/smart_contract/solidity/publisher_worker.ex:65: Explorer.SmartContract.Solidity.PublisherWorker.broadcast/4\n    (elixir 1.14.5) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2\n    (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3\n"}}}
backend                         | {"time":"2023-11-28T12:24:10.572Z","severity":"info","message":"[Que] Failed Job # 1 with Explorer.SmartContract.Solidity.PublisherWorker","metadata":{}}

iavl avatar Nov 28 '23 12:11 iavl

@wighawag have you initalized the CHAIN_ID variable in the common-blockscout.env? this fixed it for me

RonTuretzky avatar Feb 12 '24 17:02 RonTuretzky

blockscout has changed since then but I still can't verify smart contract on my local blockscout / node

I tried CHAIN_ID @RonTuretzky but now I see that the sc-verifier is not running by default i added it to the docker-compose file but verification still fails

wighawag avatar Mar 27 '24 12:03 wighawag

Actually it is working. I restarted all after clearing all saved data and I can now verify both from command line and the interface

wighawag avatar Mar 27 '24 13:03 wighawag

To be clear I had to add the following in docker-compose/geth.yml

sc-verifier:
    extends:
      file: ./services/smart-contract-verifier.yml
      service: smart-contract-verifier
    ports:
      - 8082:8050

and change the following in docker-compose/envs/common-blockscout.env

I commented out the following which connect to a remote verifier:

# MICROSERVICE_SC_VERIFIER_URL=https://eth-bytecode-db.services.blockscout.com/
# MICROSERVICE_SC_VERIFIER_TYPE=eth_bytecode_db

and added instead these:

MICROSERVICE_SC_VERIFIER_URL=http://smart-contract-verifier:8050/
MICROSERVICE_SC_VERIFIER_TYPE=sc_verifier

I also set the CHAIN_ID like @RonTuretzky suggested

wighawag avatar Mar 27 '24 13:03 wighawag