Zilliqa / zq2

Zilliqa 2.0 code base
Apache License 2.0
9 stars 0 forks source link

Contract deployment fails with internal "connection refused" error in single-node Zilliqa setup (not RPC connection) #1622

Open PurrProof opened 1 week ago

PurrProof commented 1 week ago

Contract Deployment Fails with "Connection Refused" Error When Running Zilliqa Node Manually

Description:

I am running a Zilliqa node using the following command:

$ RUST_LOG=zilliqa=warn,zilliqa=info ./target/debug/zilliqa 65d7f4da9bedc8fb79cbf6722342960bbdfb9759bc0d9e3fb4989e831ccbc227 -c config-single-node.toml 2>&1
2024-10-11T11:06:21.328011Z  INFO zilliqa::p2p_node: 99: peer_id=12D3KooWESMZ2ttSxDwjfnNe23sHCqsJf6sNEKwgHkdgtCHDsbWU
2024-10-11T11:06:21.849639Z  INFO zilliqa::node_launcher: 138: JSON-RPC server listening on port 4201

This approach to run the node is based on the script from Zilliqa's repo.

When trying to deploy a contract using the GoZilliqa SDK, I encounter the following logs:

2024-10-11T11:05:29.813321Z  INFO zilliqa::exec: 566: executing txn hash=e5358c7f823125c4ea53f5e4a104b97327d5b70e35674961276af2a124a428aa txn=VerifiedTransaction { tx: Zilliqa { tx: TxZilliqa { chain_id: 1, nonce: 1, gas_price: ZilAmount(2000000016), gas_limit: ScillaGas(100000), to_addr: 0x0000000000000000000000000000000000000000, amount: ZilAmount(0), code: "...", signer: 0x8d393a22e4476ff8212de13fe1939de2a236f0a7, hash: e5358c7f823125c4ea53f5e4a104b97327d5b70e35674961276af2a124a428aa }

2024-10-11T11:05:29.816857Z  WARN zilliqa::consensus: 842: transaction failed to execute hash=e5358c7f823125c4ea53f5e4a104b97327d5b70e35674961276af2a124a428aa error=Transport(Http(Stream(hyper_util::client::legacy::Error(Connect, ConnectError("tcp connect error", Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })))))

especially this: error=Transport(Http(Stream(hyper_util::client::legacy::Error(Connect, ConnectError("tcp connect error", Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })))))

The error message indicates a Connection Refused issue, and the transaction fails. However, the transaction is reported as processed in the response:

{
    "id": 0,
    "jsonrpc": "2.0",
    "result": {
        "Info": "Txn processed",
        "TranID": "0xe5358c7f823125c4ea53f5e4a104b97327d5b70e35674961276af2a124a428aa"
    }
}

When I start the Zilliqa node using docker compose up, the contract deploys successfully, and no such connection issue occurs.

Possible Issue:

Can you please help clarify the source of this connection refusal error when manually starting the node, and suggest a fix or workaround?

rrw-zilliqa commented 1 week ago

This is probably due to you not running Scilla - see the code in z2/src/ for details (or use scripts/z2 run to run your network). I believe this behaviour to be correct:

Whilst the subsequent treatment of the txn might bear investigation (I'm not sure to what extent we should fail txns or keep them around forever in the hope that one day they will succeed - at least, until another txn with the same nonce and higher gas fee turns up), I'd allege that this is a fairly minor issue given that Scilla should normally be available.

I guess one question (for @JamesHinshelwood ?) is whether the node should outright abort when it can't connect to Scilla.

PurrProof commented 1 week ago

No, this is definitely not because Scilla isn’t running.

I’m sure Scilla is compiled into this Zilliqa binary:
$ RUST_LOG=zilliqa=warn,zilliqa=info ./target/debug/zilliqa 65d7f4da9bedc8fb79cbf6722342960bbdfb9759bc0d9e3fb4989e831ccbc227 -c config-single-node.toml 2>&1

The tests from evm_scilla_js_tests, run with pnpm hardhat test, including the Scilla-related tests, work well on this Zilliqa binary.

Problem appears, when I try to deploy scilla-contract via Gozilliqa. Same Go-script works as expected (contract deployed), when I run ZQ2 with `docker compose up -d'.