Forum

Trouble with "verify and publish"

I had deployed and used a simple contract on my private network. Then I clicked “verify and publish” but got an “internal server error”.

The blockscout log contained an error as shown below. My SECRET_KEY_BASE env var is less than 64 bytes. Would it make sense to change it and restart the blockscout service, or is there something else I would have to do? I worry that the database, or something, might also need some tweak.

Request: GET /address/0x45785b440860B3a43CCbB5e3E322f5184E24818C/contract_verifications/new

** (exit) an exception was raised:
** (ArgumentError) cookie store expects conn.secret_key_base to be at least 64 bytes
(plug 1.10.3) lib/plug/session/cookie.ex:202: Plug.Session.COOKIE.validate_secret_key_base/1
(plug 1.10.3) lib/plug/session/cookie.ex:194: Plug.Session.COOKIE.derive/3
(plug 1.10.3) lib/plug/session/cookie.ex:114: Plug.Session.COOKIE.put/4
(plug 1.10.3) lib/plug/session.ex:89: anonymous fn/3 in Plug.Session.before_send/2
(elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
(plug 1.10.3) lib/plug/conn.ex:1687: Plug.Conn.run_before_send/2
(plug 1.10.3) lib/plug/conn.ex:407: Plug.Conn.send_resp/1
(block_scout_web 0.0.1) lib/block_scout_web/controllers/address_contract_verification_controller.ex:1: BlockScoutWeb.AddressContractVerificationController.action/2

@viktorbaranov have you any thoughts on this?

Just change SECRET_KEY_BASE

Use mix phx.gen.secret to generate a new Secret Key Base string to protect production assets.

Reference: https://docs.blockscout.com/for-developers/information-and-settings/env-variables

Thanks for the tip; that was very helpful!!

Sadly, I still have trouble with Verify and Publish, though.

With a very simple contract, the web interface says “There was an error compiling your contract”. In the log, I see that it looks like it is trying to interpret some html as solidity source, as if such a thing were possible!

The contract is this:

pragma solidity ^0.7.4;

contract StringSaver {
string saved;

constructor() {
    saved = "";
}

function get() public view returns (string memory) {
    return saved;
}

function set(string calldata val) public {
    saved = val;
}
}

The log says this:
2021-04-24T19:50:37.192 application=plug request_id=FnjjKmDZhOQeEMYARfxB [info] POST /verify_smart_contract/contract_verifications
2021-04-24T19:50:37.193 application=que [info] [Que] Queued new Job for Explorer.SmartContract.PublisherWorker
2021-04-24T19:50:37.194 application=que [info] [Que] Starting Job # 8 with Explorer.SmartContract.PublisherWorker
2021-04-24T19:50:37.194 application=plug request_id=FnjjKmDZhOQeEMYARfxB [info] Sent 204 in 1ms
2021-04-24T19:50:37.519 application=phoenix [info] CONNECTED TO BlockScoutWeb.UserSocket in 908µs
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Parameters: {"locale" => "en", "vsn" => "2.0.0"} 2021-04-24T19:50:37.554 application=indexer fetcher=block_catchup first_block_number=134477 last_block_number=0 missing_block_count=1 shrunk=false [info] Index had to catch up. 2021-04-24T19:50:37.554 application=indexer fetcher=block_catchup [info] Checking if index needs to catch up in 2500ms. 2021-04-24T19:50:37.624 application=phoenix [info] JOINED blocks:indexing in 22µs Parameters: {}
2021-04-24T19:50:37.624 application=phoenix [info] JOINED addresses:0x954c4F187120931dF842ec6849888250eBb4DB74 in 22µs
Parameters: %{}
/opt/app/apps/explorer/priv/solc_compilers/v0.7.4+commit.3f05b770.js:1

^
SyntaxError: Unexpected token ‘<’
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (/opt/app/apps/explorer/priv/compile_solc.js:12:24)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)
/opt/app/apps/explorer/priv/solc_compilers/v0.7.4+commit.3f05b770.js:1

@viktorbaranov is this supposed to work?

Blockscout downloads compilers from an external URL https://solc-bin.ethereum.org/bin. Please check that your instance has access to it.

If /opt/app/apps/explorer/priv/solc_compilers/v0.7.4+commit.3f05b770.js is corrupted, it is better to remove it and Blockscout will try to download compiler again with the next contract verification, if it has access to the URL with compiler source.

OK, I deleted /opt/app/apps/explorer/priv/solc_compilers/v0.7.4+commit.3f05b770.js, and tried again.

BS downloads another would-be compiler, but actually it is an html page saying 404 file not found. The end result is the same.

I don’t know exactly what url it is trying to fetch to get the compiler. https://solc-bin.ethereum.org/bin links to an xml page saying “the specified key does not exist”.

Maybe you could suggest some urls I could use to manually download some versions of the compiler? Interested in 0.7.4 and 0.8.0.

2021-04-29T23:32:56.928 application=plug request_id=Fnp4Mx2dHmi_WVwDIIQB [info] POST /verify_smart_contract/contract_verifications
2021-04-29T23:32:56.929 application=que [info] [Que] Queued new Job for Explorer.SmartContract.PublisherWorker
2021-04-29T23:32:56.929 application=que [info] [Que] Starting Job # 13 with Explorer.SmartContract.PublisherWorker
2021-04-29T23:32:56.930 application=plug request_id=Fnp4Mx2dHmi_WVwDIIQB [info] Sent 204 in 1ms
/opt/app/apps/explorer/priv/solc_compilers/v0.7.4+commit.3f05b770.js:1

^

I don’t know exactly what url it is trying to fetch to get the compiler. https://solc-bin.ethereum.org/bin links to an xml page saying “the specified key does not exist”.

Maybe you could suggest some urls I could use to manually download some versions of the compiler? Interested in 0.7.4 and 0.8.0.

For instance,
https://solc-bin.ethereum.org/bin/soljson-v0.7.4+commit.3f05b770.js

Thank you, that was very helpful!

I got it working for a very simple contract by doing this:

rm /opt/app/apps/explorer/priv/solc_compilers/v0.7.4+commit.3f05b770.js

wget https://solc-bin.ethereum.org/bin/soljson-v0.7.4+commit.3f05b770.js

cp -p soljson-v0.7.4+commit.3f05b770.js /opt/app/apps/explorer/priv/solc_compilers/v0.7.4+commit.3f05b770.js

So, It seems there is a bug in the BS downloading code. Understandable, given the complexity (and changes) to the instructions for downloading solidity!