Run a Sifchain Node on Akash

Akash is a decentralized cloud computing marketplace, that provides a fast, efficient, and low-cost peer-to-peer platform with easy deployments for developers. In this guide, we’ll set up a Sifchain node on Akash.

If you’re familiar with Akash and have deployed to the Akash cloud before, you can skip to the deployment configuration.

Getting Started

Before we can start deploying and setting up the validator, we’ll need to set up and configure the Akash CLI. We’ll start by setting up some shell variables which allows anyone to just use the commands in this guide as-is:

# mainnet
AKASH_NET="https://raw.githubusercontent.com/ovrclk/net/master/mainnet"

# version
AKASH_VERSION="$(curl -s "$AKASH_NET/version.txt")"

# chain id
export AKASH_CHAIN_ID="$(curl -s "$AKASH_NET/chain-id.txt")"

# akash rpc node
export AKASH_NODE="$(curl -s "$AKASH_NET/rpc-nodes.txt" | shuf -n 1)"

Install Akash

The Akash CLI is used to run all components of the Akash Network.

The easiest way to install Akash on macOS is by using homebrew:

brew tap ovrclk/tap
brew install akash
brew link akash --force

You can download, extract and install the akash binary from the release page for your system.

You can also install the latest version using godownloader:

curl https://raw.githubusercontent.com/ovrclk/akash/master/godownloader.sh | sh -s -- "v$AKASH_VERSION"

You can download, extract and install the akash binary for Windows from the release page .

Wallet Setup

Next, we’ll set up an Akash wallet and fund it. We’ll generate a new private key named default and encrypt to disk using the following command:

akash keys add default

This will generate your keys and you should see something similar to:

- name: test
  type: local
  address: akash1vremvq78ptn9a5xt9xtwy6uqyyytmpavtn79um
  pubkey: akashpub1addwnpepq03dk6eg2laqnr89e3hzfvu4aufpj9aapjmdcpx7v2c6caxu7xeax7naka3
  mnemonic: ""
  threshold: 0
  pubkeys: []


**Important** write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.

pistol hurry tray goat depart wide also rose kangaroo casual just arm wage float brave van fee country speak tiger pelican cake trade fabric

In this example, the generated wallet address is akash1vremvq78ptn9a5xt9xtwy6uqyyytmpavtn79um.

Next, we’ll export the wallet address and key name to shell variables for easy access later:

export AKASH_ACCOUNT_ADDRESS="$(akash keys show default -a)"
export AKASH_KEY_NAME="default"

Important: Save your mnemonic phrase somewhere safe and don’t ever share this with anyone. If someone has access to your phrase, they can recover your private key and control your wallet.

Now, you’re ready to fund your wallet. You can purchase the AKT token from any exchange listed here and withdraw it to your new wallet. Your account must have a minimum of 5AKT to create a deployment. This is used to fund the escrow account associated with the deployment and it is used to pay for services.

You can check your account balance using:

akash --node "$AKASH_NODE" query bank balances "$AKASH_ACCOUNT_ADDRESS"

We must create a certificate before deploying because it is used to ensure only owners can access their deployments. By default, a certificate is valid for 365 days and can be used for multiple deployments.

akash tx cert create client --from=$AKASH_KEY_NAME --chain-id $AKASH_CHAIN_ID --node $AKASH_NODE --fees 200uakt -y

This will generate a new certificate.

Deployment Configuration

Akash relies on a YAML configuration file using Stack Definition Language to describe the services, datacenters, pricing, configurations, etc. For our Sifchain node, we’ll use this for our deploy.yml:

---
version: "2.0"
services:
  sifchain:
    image: cryptoevangelist/sifchain-akash:latest
    expose:
      - port: 26657
        as: 80
        to:
          - global: true
      - port: 26656
        as: 26656
        to:
          - global: true
      - port: 1317
        as: 1317
        to:
          - global: true
    env:
      - CHAINNET=sifchain
      - MONIKER=ceme-sifchain
      - PEER_ADDRESSES=0d4981bdaf4d5d73bad00af3b1fa9d699e4d3bc0@44.235.108.41:26656,bcc2d07a14a8a0b3aa202e9ac106dec0bef91fda@13.55.247.60:26656,663dec65b754aceef5fcccb864048305208e7eb2@34.248.110.88:26656,0120f0a48e7e81cc98829ef4f5b39480f11ecd5a@52.76.185.17:26656,6535497f0152293d773108774a705b86c2249a9c@44.238.121.65:26656,fdf5cffc2b20a20fab954d3b6785e9c382762d14@34.255.133.248:26656,8c240f71f9e060277ce18dc09d82d3bbb05d1972@13.211.43.177:26656,9fbcb6bd5a7f20a716564157c4f6296d2faf5f64@18.138.208.95:26656
      - GENESIS_URL=https://rpc.sifchain.finance/genesis
      - GAS_PRICE=0.5rowan
profiles:
  compute:
    sifchain:
      resources:
        cpu:
          units: 2
        memory:
          size: 4Gi
        storage:
          size: 20Gi
  placement:
    eastcoast:
      attributes:
        datacenter: equinix-metal-ewr1
      signedBy:
        anyOf:
          - "akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63"
      pricing:
        sifchain:
          denom: uakt
          amount: 10
deployment:
  sifchain:
    eastcoast:
      profile: sifchain
      count: 1

The above specifies a single workload called sifchain, how much computational resources to allocate for each service under profiles.compute, named datacenter profiles under profiles.placement, and a map between datacenter profiles and compute profiles under deployment.

Deployment

We’ll use the following command to post our deployment and this triggers the Akash marketplace to match us with a provider.

akash tx deployment create deploy.yml --from $AKASH_KEY_NAME --node $AKASH_NODE --chain-id $AKASH_CHAIN_ID --fees 200uakt -b sync -y

This will return the transaction hash for our deploy creation immediately:

{"height":"0","txhash":"147B9818E286D29E20D829E39FB4E41E432166618FE30D3B95A65EDDDC12A10D","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":""}

You can use the txhash to query the transaction and get the status of your deploy order:

akash q tx 147B9818E286D29E20D829E39FB4E41E432166618FE30D3B95A65EDDDC12A10D --node=$AKASH_NODE
code: 0
codespace: ""
data: 0A130A116372656174652D6465706C6F796D656E74
gas_used: "96673"
gas_wanted: "200000"
height: "1294724"
info: ""
logs:
- events:
  - attributes:
    - key: module
      value: deployment
    - key: action
      value: deployment-created
    - key: version
      value: b409e599c1d1b901b9188d9f2f87bb0a1df02e188cb5cee752a3f02d407cdf3d
    - key: owner
      value: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
    - key: dseq
      value: "1294718"
    - key: module
      value: market
    - key: action
      value: order-created
    - key: owner
      value: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
    - key: dseq
      value: "1294718"
    - key: gseq
      value: "1"
    - key: oseq
      value: "1"
    type: akash.v1
  - attributes:
    - key: action
      value: create-deployment
    - key: sender
      value: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
    - key: sender
      value: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
    type: message
  - attributes:
    - key: recipient
      value: akash17xpfvakm2amg962yls6f84z3kell8c5lazw8j8
    - key: sender
      value: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
    - key: amount
      value: 200uakt
    - key: recipient
      value: akash14pphss726thpwws3yc458hggufynm9x77l4l2u
    - key: sender
      value: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
    - key: amount
      value: 5000000uakt
    type: transfer
  log: ""
  msg_index: 0
raw_log: '[{"events":[{"type":"akash.v1","attributes":[{"key":"module","value":"deployment"},{"key":"action","value":"deployment-created"},{"key":"version","value":"b409e599c1d1b901b9188d9f2f87bb0a1df02e188cb5cee752a3f02d407cdf3d"},{"key":"owner","value":"akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239"},{"key":"dseq","value":"1294718"},{"key":"module","value":"market"},{"key":"action","value":"order-created"},{"key":"owner","value":"akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239"},{"key":"dseq","value":"1294718"},{"key":"gseq","value":"1"},{"key":"oseq","value":"1"}]},{"type":"message","attributes":[{"key":"action","value":"create-deployment"},{"key":"sender","value":"akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239"},{"key":"sender","value":"akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239"}]},{"type":"transfer","attributes":[{"key":"recipient","value":"akash17xpfvakm2amg962yls6f84z3kell8c5lazw8j8"},{"key":"sender","value":"akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239"},{"key":"amount","value":"200uakt"},{"key":"recipient","value":"akash14pphss726thpwws3yc458hggufynm9x77l4l2u"},{"key":"sender","value":"akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239"},{"key":"amount","value":"5000000uakt"}]}]}]'
timestamp: "2021-06-09T06:43:33Z"
tx:
  '@type': /cosmos.tx.v1beta1.Tx
  auth_info:
    fee:
      amount:
      - amount: "200"
        denom: uakt
      gas_limit: "200000"
      granter: ""
      payer: ""
    signer_infos:
    - mode_info:
        single:
          mode: SIGN_MODE_DIRECT
      public_key:
        '@type': /cosmos.crypto.secp256k1.PubKey
        key: A/xV9a0eF9ii/1nzK5B9END6TLYQV8pHUnMRGjoV3HVi
      sequence: "46"
  body:
    extension_options: []
    memo: ""
    messages:
    - '@type': /akash.deployment.v1beta1.MsgCreateDeployment
      deposit:
        amount: "5000000"
        denom: uakt
      groups:
      - name: eastcoast
        requirements:
          attributes:
          - key: datacenter
            value: equinix-metal-ewr1
          signed_by:
            all_of: []
            any_of:
            - akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63
        resources:
        - count: 1
          price:
            amount: "10"
            denom: uakt
          resources:
            cpu:
              attributes: []
              units:
                val: "2000"
            endpoints:
            - kind: SHARED_HTTP
            - kind: RANDOM_PORT
            - kind: RANDOM_PORT
            memory:
              attributes: []
              quantity:
                val: "4294967296"
            storage:
              attributes: []
              quantity:
                val: "21474836480"
      id:
        dseq: "1294718"
        owner: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
      version: tAnlmcHRuQG5GI2fL4e7Ch3wLhiMtc7nUqPwLUB83z0=
    non_critical_extension_options: []
    timeout_height: "0"
  signatures:
  - hnSeb3huGRRnNRwVbxeUCSB4VcnOdeBIT7exYwqe+yASCr6O/nxe2wQ1Hv2JpgqfO3lwWwvFImmXzzkWMAzfww==
txhash: 13C9C2121BBFEED029C1CEDD65E302C88FB99ED8C7B4DDF6085606699778B6E6

Let’s extract some key values to shell variables based on the output from the last command for easy of use later:

export AKASH_DSEQ=1189453
export AKASH_GSEQ=1
export AKASH_OSEQ=1

You can verify your deployment status to ensure it’s open:

akash query deployment get --owner $AKASH_ACCOUNT_ADDRESS --node $AKASH_NODE --dseq $AKASH_DSEQ

Now, we can query the bids for our deploy:

akash query market bid list --owner=$AKASH_ACCOUNT_ADDRESS --node $AKASH_NODE --dseq $AKASH_DSEQ

You should see something similar to:

bids:
- bid:
    bid_id:
      dseq: "1189453"
      gseq: 1
      oseq: 1
      owner: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
      provider: akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
    created_at: "1189456"
    price:
      amount: "6"
      denom: uakt
    state: open
  escrow_account:
    balance:
      amount: "50000000"
      denom: uakt
    id:
      scope: bid
      xid: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239/1189453/1/1/akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
    owner: akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
    settled_at: "1189456"
    state: open
    transferred:
      amount: "0"
      denom: uakt
pagination:
  next_key: null
  total: "0"

In this example, we got a bid offered at 6 uAKT per block to execute the container. Let’s select the provider and extract that to a shell variable:

export AKASH_PROVIDER=akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7

The next step is to create a lease for the bid from the chosen provider above:

akash tx market lease create --chain-id $AKASH_CHAIN_ID --node $AKASH_NODE --owner $AKASH_ACCOUNT_ADDRESS --dseq $AKASH_DSEQ --gseq $AKASH_GSEQ --oseq $AKASH_OSEQ --provider $AKASH_PROVIDER --from $AKASH_KEY_NAME --fees 200uakt -y

Wait a few seconds for your lease to be created and you can check the status:

akash query market lease list — owner $AKASH_ACCOUNT_ADDRESS — node $AKASH_NODE — dseq $AKASH_DSEQ

You should see something similar to:

leases:
- escrow_payment:
    account_id:
      scope: deployment
      xid: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239/1189453
    balance:
      amount: "0"
      denom: uakt
    owner: akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
    payment_id: 1/1/akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
    rate:
      amount: "6"
      denom: uakt
    state: open
    withdrawn:
      amount: "0"
      denom: uakt
  lease:
    created_at: "1189485"
    lease_id:
      dseq: "1189453"
      gseq: 1
      oseq: 1
      owner: akash15dq022awkw60k0hggxqx0t64ttpfqr050yv239
      provider: akash1f6gmtjpx4r8qda9nxjwq26fp5mcjyqmaq5m6j7
    price:
      amount: "6"
      denom: uakt
    state: active
pagination:
  next_key: null
  total: "0"

Next, we’ll upload the manifest to deploy our image:

akash provider send-manifest deploy.yml --node $AKASH_NODE --dseq $AKASH_DSEQ --provider $AKASH_PROVIDER --from $AKASH_KEY_NAME

After the manifest is uploaded and our image is deployed, you can retrieve access details:

akash provider lease-status --node $AKASH_NODE --dseq $AKASH_DSEQ --from $AKASH_KEY_NAME --provider $AKASH_PROVIDER

You should see something similar to:

{
  "services": {
    "sifchain": {
      "name": "sifchain",
      "available": 1,
      "total": 1,
      "uris": [
        "t2uhad80jddgj2p2jqebvd7rl0.ingress.ewr1p0.mainnet.akashian.io"
      ],
      "observed_generation": 1,
      "replicas": 1,
      "updated_replicas": 1,
      "ready_replicas": 1,
      "available_replicas": 1
    }
  },
  "forwarded_ports": {
    "sifchain": [
      {
        "host": "cluster.ewr1p0.mainnet.akashian.io",
        "port": 1317,
        "externalPort": 30249,
        "proto": "TCP",
        "available": 1,
        "name": "sifchain"
      },
      {
        "host": "cluster.ewr1p0.mainnet.akashian.io",
        "port": 26656,
        "externalPort": 30316,
        "proto": "TCP",
        "available": 1,
        "name": "sifchain"
      }
    ]
  }
}

That’s it, we’re done! We’ve got our Sifchain node running on Akash. You can check the logs of the Sichain container using:

akash provider lease-logs --node "$AKASH_NODE" --dseq "$AKASH_DSEQ" --gseq "$AKASH_GSEQ" --oseq "$AKASH_OSEQ" --provider "$AKASH_PROVIDER" --from "$AKASH_KEY_NAME"

Leave a Reply

Your email address will not be published. Required fields are marked *