Skip to content

Instantly share code, notes, and snippets.

@andy108369
Last active May 2, 2023 12:29
Show Gist options
  • Save andy108369/9902ec74a4a905b5e8dc4f67673cd193 to your computer and use it in GitHub Desktop.
Save andy108369/9902ec74a4a905b5e8dc4f67673cd193 to your computer and use it in GitHub Desktop.

How to use provider-services CLI (testnet-02, GPU)

Prepare your AKT wallet & Akash network config

  1. get the provider-services binary

https://github.com/akash-network/provider/releases/tag/v0.3.0-rc6

install it to /usr/local/bin/provider-services

  1. set the following environment variables
# Note: you can rename "client" to "default" or "mykey123" .. it is up to you to name your wallet
export AKASH_FROM=client
# Note: you can use a different keyring backend if you wish to protect your key with the passhprase - "file" or "os"
export AKASH_KEYRING_BACKEND=test

export AKASH_GAS=auto
# Never change AKASH_GAS_PRICES ! it should correspond to the AKASH_MINIMUM_GAS_PRICES=0.025uakt set on all validators.
export AKASH_GAS_PRICES=0.025uakt
# You can slightly increase AKASH_GAS_ADJUSTMENT if your transactions are running out of gas
export AKASH_GAS_ADJUSTMENT=1.5

export AKASH_BROADCAST_MODE=sync
export AKASH_NODE=https://rpc.testnet-02.aksh.pw:443
export AKASH_CHAIN_ID=$(curl -s -k $AKASH_NODE/status | jq -r '.result.node_info.network')

# you can export AKASH_YES=1 this if you want the client broadcast transactions without the confirmation [y/N]
# export AKASH_YES=1
  1. create (or recover) your key

Either create a new key:

provider-services keys add $AKASH_FROM

Or recover (having that you know your mnemonic seed):

provider-services keys add $AKASH_FROM --recover
  1. get some AKT from the faucet

http://faucet.testnet-02.aksh.pw

Deploy something

  1. verify you have more than 10 AKT
provider-services query bank balances $(AKASH_OUTPUT= provider-services keys show $AKASH_FROM -a) -o json | jq -r '.balances[].amount|tonumber / pow(10;6)'
  1. generate and publish your client certificate

Note: Do this only once or whenever your client certificate expires.

provider-services tx cert generate client
provider-services tx cert publish client
  1. deploy some SDL
  • broadcast the order request
provider-services tx deployment create gpu.yaml
  • find your order request dseq number

Note: if you see nothing, it is likely that the providers did not have time to broadcast their response yet. Usually try to query the market order list again in about 12 seconds, which corresponds to two blocks.

$ provider-services query market order list --state open
orders:
- created_at: "140495"
  order_id:
    dseq: "140494"
  • see if you got any bids from the providers on the network
$ provider-services query market bid list --state open --dseq 140494
bids:
- bid:
    bid_id:
      dseq: "140494"
      gseq: 1
      oseq: 1
      owner: akash1h24fljt7p0nh82cq0za0uhsct3sfwsfu9w3c9h
      provider: akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v
    created_at: "140496"
    price:
      amount: "5.720320000000000000"
      denom: uakt
    state: open

You can also calculate the pricing/month (in AKT) based on the pricing given by the bidding providers in uakt, in this example that'd be: (5.72032*((60/6)*60*24*30))/10^6 2.4711782400 AKT/month having that 1 block in the Akash Network takes 6 seconds.

  • accept the bid
provider-services tx market lease create --dseq 140494 --provider akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v
  • finally, send your deployment manifest file to the provider
provider-services send-manifest gpu.yaml --dseq 140494
  • don't forget to deposit more AKT for your deployment/lease to last longer

this command adds 10 AKT to your deployment

provider-services tx deployment deposit 10000000uakt --dseq 140494
  • verify how many days your lease is going to last
provider-services query escrow blocks-remaining --owner $(AKASH_OUTPUT= provider-services keys show $AKASH_FROM -a) --dseq 140494 -o json | jq -r '(.estimated_time_remaining/pow(10;9))/60/60/24 | (. * 100 | round / 100)'

Now you can query your deployment:

provider-services query deployment get --owner $(AKASH_OUTPUT= provider-services keys show $AKASH_FROM -a) --dseq 140494

provider-services query market lease get --owner $(AKASH_OUTPUT= provider-services keys show $AKASH_FROM -a) --dseq 140494 --provider akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v

provider-services lease-status --dseq 140494 --provider akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v

provider-services lease-events --dseq 140494 --provider akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v

provider-services lease-logs --dseq 140494 --provider akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v
  • spawn into your deployment service (the container Pod in K8s terminology)

the gpu-test is the service name from the deployment manifest

provider-services lease-shell --dseq 140494 --provider akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v --tty --stdin -- gpu-test sh
  • close your deployment when you are done
provider-services tx deployment close --dseq 140494

Tips & tricks

CLI like a Pro

Instead of specifying --owner $(AKASH_OUTPUT= provider-services keys show $AKASH_FROM -a), --dseq 140494, --provider akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v each time, you can just export them, e.g.:

export AKASH_OWNER=$(AKASH_OUTPUT= provider-services keys show $AKASH_FROM -a)
export AKASH_DSEQ=140494
export AKASH_PROVIDER=akash143ypn84kuf379tv9wvcxsmamhj83d5pg2rfc8v

Note: your dseq & provider values will be different from the ones shown in this example.

The provider-services binary will automatically pick them up!

The caveat is that you have to unset these variables before creating & working with next deployment:

unset AKASH_DSEQ AKASH_PROVIDER AKASH_OWNER

update deployment without redeployment

Update your deploy.yaml (akash deployment SDL manifest), broadcast it to the blockchain and then send it to the provider:

provider-services tx deployment update deploy.yaml --dseq <your dseq number>
provider-services send-manifest deploy.yaml --dseq <your dseq number>

This will cause the provider update the deployment (as long as the provider has enough resources, see https://docs.akash.network/providers/akash-provider-troubleshooting/force-new-replicaset-workaround)

Troubleshooting

Out of gas?

Sometimes the transaction might fail due to low gas paid for the transaction. This normally should not happen but it could. For sake of example I simulated this error by significantly decreasing the value of AKASH_GAS_ADJUSTMENT so you can see how the "out of gas" transaction looks like:

$ export AKASH_GAS_ADJUSTMENT=0.1
$ provider-services tx deployment close --dseq 141156
{"body":{"messages":[{"@type":"/akash.deployment.v1beta3.MsgCloseDeployment","id":{"owner":"akash1h24fljt7p0nh82cq0za0uhsct3sfwsfu9w3c9h","dseq":"141156"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[{"denom":"uakt","amount":"549"}],"gas_limit":"21940","payer":"","granter":""}},"signatures":[]}

confirm transaction before signing and broadcasting [y/N]: y
{"height":"0","txhash":"8332576D9CB57871A2DAE14014F10619DE3B871BD4D85D7CF71EB1FA85DDA4D8","codespace":"sdk","code":11,"data":"","raw_log":"out of gas in location: WritePerByte; gasWanted: 21940, gasUsed: 22366: out of gas","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}

The out of gas transactions always have code 11

Such transactions won't make into a block, hence they can't be queried:

$ provider-services query tx 8332576D9CB57871A2DAE14014F10619DE3B871BD4D85D7CF71EB1FA85DDA4D8
Error: RPC error -32603 - Internal error: tx (8332576D9CB57871A2DAE14014F10619DE3B871BD4D85D7CF71EB1FA85DDA4D8) not found

Normally, just retry the broadcasting the transaction. You may want to increase the value of AKASH_GAS_ADJUSTMENT.

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