CosmWasm / optimizer

Dockerfile and script to deterministically produce the smallest possible Wasm for your Rust contract
Apache License 2.0
123 stars 60 forks source link

warning: spurious network error #70

Closed gburgi closed 2 years ago

gburgi commented 2 years ago

Hi! I'm stuck trying to optimize a smart contract. When I run rust-optimizer in the root folder of a clean copy of https://github.com/InterWasm/cw-template I get some network problems...

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  cosmwasm/rust-optimizer:0.12.4
Info: RUSTC_WRAPPER=sccache
Info: sccache stats before build
Compile requests                      0
Compile requests executed             0
Cache hits                            0
Cache misses                          0
Cache timeouts                        0
Cache read errors                     0
Forced recaches                       0
Cache write errors                    0
Compilation failures                  0
Cache errors                          0
Non-cacheable compilations            0
Non-cacheable calls                   0
Non-compilation calls                 0
Unsupported compiler calls            0
Average cache write               0.000 s
Average cache read miss           0.000 s
Average cache read hit            0.000 s
Failed distributed compilations       0
Cache location                  Local disk: "/root/.cache/sccache"
Cache size                            0 bytes
Max cache size                       10 GiB
Building contract in /code ...
    Updating crates.io index
warning: spurious network error (2 tries remaining): failed to resolve address for github.com: Name does not resolve; class=Net (12)
warning: spurious network error (1 tries remaining): failed to resolve address for github.com: Name does not resolve; class=Net (12)
error: failed to get `cosmwasm-std` as a dependency of package `c01 v0.1.0 (/code)`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  network failure seems to have happened
  if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  failed to resolve address for github.com: Name does not resolve; class=Net (12)

I haven't a proxy or similar...

Can somebody help me please?

maurolacy commented 2 years ago

Are you in Windows, right? For what I've seen, this can be caused by many issues (corporate network, wrong env vars / proxy settings, Windows / WSL version, ...)

This is likely NOT a rust-optimizer issue. I suggest you to take a look to the following threads:

If you fix it, please comment what worked for you, as this may be useful to others.

gburgi commented 2 years ago

Hi @maurolacy, thanks. No, I'm in MacOS

System Software Overview:
      System Version: macOS 11.6 (20G165)
      Kernel Version: Darwin 20.6.0

Docker:
      Version:  19.03.13

If I locally run: RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown

I haven't any issue:

Compiling proc-macro2 v1.0.28
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.74
   Compiling serde_derive v1.0.127
   Compiling serde v1.0.127
   Compiling ryu v1.0.5
   Compiling serde_json v1.0.66
   Compiling crunchy v0.2.2
   Compiling itoa v0.4.7
   Compiling schemars v0.8.3
   Compiling byteorder v1.4.3
   Compiling static_assertions v1.1.0
   Compiling hex v0.4.3
   Compiling dyn-clone v1.0.4
   Compiling base64 v0.13.0
   Compiling uint v0.9.1
   Compiling quote v1.0.9
   Compiling serde_derive_internals v0.25.0
   Compiling schemars_derive v0.8.3
   Compiling thiserror-impl v1.0.26
   Compiling cosmwasm-derive v1.0.0-beta4
   Compiling thiserror v1.0.26
   Compiling serde-json-wasm v0.3.2
   Compiling cosmwasm-std v1.0.0-beta4
   Compiling cw-storage-plus v0.11.1
   Compiling cosmwasm-storage v1.0.0-beta
   Compiling cw2 v0.11.1
   Compiling c02 v0.1.0 (/Users/gustavo/Projects/c02)
    Finished release [optimized] target(s) in 39.34s

So, I think the problem is not my machine nor network... I have no proxy, no VPN... I also try adding git-fetch-with-cli = true in cargo config file... Same result.

maurolacy commented 2 years ago

Perhaps the problem is DNS resolution from inside the docker container?

Can you try entering the container and checking DNS resolution works?

gburgi commented 2 years ago

The problem gone upgrading docker version to 20.10.11.

Thanks @maurolacy !