Skip to content

Instantly share code, notes, and snippets.

@dokterbob
Created March 26, 2021 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dokterbob/778f65a2cfeabe5915977910eebf44c0 to your computer and use it in GitHub Desktop.
Save dokterbob/778f65a2cfeabe5915977910eebf44c0 to your computer and use it in GitHub Desktop.
Building avalanchego on SmartOS

Steps to reproduce

  1. Install SmartOS

  2. Login as root (over SSH)

  3. Create zone (https://wiki.smartos.org/how-to-create-a-zone/):

    imgadm import cfa9c88e-03f8-11eb-9980-879ff7980a9f # 20.3.0 64-bit
    vmadm create <<EOL
    
    {
        "brand": "joyent",
        "image_uuid": "cfa9c88e-03f8-11eb-9980-879ff7980a9f",
        "alias": "avalanchego",
        "hostname": "avalanchego",
        "resolvers": ["8.8.8.8", "8.8.4.4"],
        "max_physical_memory": 2048,
        "maintain_resolvers": true,
        "nics": [
           {
             "nic_tag": "admin",
             "ip": "dhcp"
         }
     ]
    }
    EOL
  4. Login to zone: zlogin <uuid>

  5. Install build dependencies: pkgin install go115 git gcc9 gcc9-libs

  6. Set GOPATH:

    export PATH=$PATH:$(go env GOPATH)/bin
    export GOPATH=$(go env GOPATH)
    
  7. Create a disk-based tmp directory, by default SmartOS zones use a RAM-disk tmpfs which has only 256 MB allocated (and we don't want to waste RAM on this):

    mkdir -f tmp
    export TMPDIR=~/tmp
    
  8. Clone and build custom fork of coreth (https://github.com/ava-labs/coreth):

    git clone --branch solaris_fixups https://github.com/dokterbob/coreth.git ~/go/src/github.com/ava-labs/coreth
    
  9. Follow variant of official installation instructions (https://github.com/ava-labs/avalanchego):

    go get -v -d github.com/ava-labs/avalanchego/...
    cd $GOPATH/src/github.com/ava-labs/avalanchego
    scripts/build_avalanche.sh
    mkdir build/plugins
    scripts/build_coreth.sh ~/go/src/github.com/ava-labs/coreth build/plugins/evm
    

    The latter command seems to arbitrarily fail with /opt/local/go115/pkg/tool/solaris_amd64/link: running gcc failed: wait: no child processes and needs to be repeated until a working binary comes out. This is possibly due to an out of memory or similar condition.

  10. Run avalanchego like a true boss:

    ./build/avalanchego
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment