Code Monkey home page Code Monkey logo

avash's Introduction

Avash — The Avalanche Shell Client

This is a temporary stateful shell execution environment used to deploy networks locally, manage their processes, and run network tests.

Avash opens a shell environment of its own. This environment is completely wiped when Avash exits. Any Avalanche nodes deployed by Avash should be exited as well, leaving only their stash (containing only their log files) behind.

Avash provides the ability to run Lua scripts which can execute a sequence of shell commands in Avash. This allows for automation of regular tasks. For instance, different network configurations can be programmed into a lua script and deployed as-needed, allowing for rapid tests against various network types.

Installation

Requirements

  • Golang 1.15.5+
  • An Avalanche Client Implementing Avalanche Standard CLI Flags

Quick Setup

Install and build an Avalanche client

go get github.com/ava-labs/avash
cd $GOPATH/src/github.com/ava-labs/avash
go build

Now you can fire up a 5 node staking network:

./avash
Config file set: /Users/username/.avash.yaml
Avash successfully configured.
avash> runscript scripts/five_node_staking.lua
RunScript: Running scripts/five_node_staking.lua
RunScript: Successfully ran scripts/five_node_staking.lua

For full documentation of Avash configuration and commands, please see the official Avalanche Documentation.

Using Avash

Opening a shell

Super easy, just type ./avash and it will open a shell environment.

Configuration

By default Avash will look for a configuration file named either .avash.yaml or .avash.yml located in the following paths.

  • $HOME/
  • .
  • /etc/avash/

If no config file is found then Avash will create one at $HOME/.avash.yaml.

./avash
Config file not found: .avash.yaml
Created empty config file: /Users/username/.avash.yaml

Alternatively you can pass in a --config flag with a path to your config file. NOTE you must put the full path. ~/ will not resolve to $HOME/.

 ./avash --config=/Users/username/path/to/config/my-config-file.yaml
Config file set: /Users/username/path/to/config/my-config-file.yaml
Avash successfully configured.

If no config file is found at the path which was passed to --config then Avash will create one at $HOME/. Avash will use the filename which was passed to --config.

./avash --config=/Users/username/path/to/config/my-config-file.yaml
Config file not found: /Users/username/path/to/config/my-config-file.yaml
Created empty config file: /Users/username/my-config-file.yaml

If you have multiple config files Avash will load the values from a single file in decreasing preference:

  • --config
  • $HOME/
  • .
  • /etc/avash/

Help

For your first command, type help in Avash to see the commands available.

You can also type help [command] to see the list of options available for that command.

Ex:

help procmanager
help procmanager start

Commands

  • avaxwallet - Tools for interacting with Avalanche Payments over the network.
  • callrpc - Issues an RPC call to a node.
  • exit - Exit the shell.
  • help - Help about any command.
  • network - Tools for interacting with remote hosts.
  • procmanager - Access the process manager for the avash client.
  • runscript - Runs the provided script.
  • setoutput - Sets shell log output.
  • startnode - Starts a node process and gives it a name.
  • varstore - Tools for creating variable stores and printing variables within them.

Writing Scripts

Avash imports the gopher-lua library to run lua scripts.

Scripts have certain hooks available to them which allows the user to write code which invokes the current Avash environment.

The functions available to Lua are:

  • avash_call - Takes a string and runs it as an Avash command, returning output
  • avash_sleepmicro - Takes an unsigned integer representing microseconds and sleeps for that long
  • avash_setvar - Takes a variable scope (string), a variable name (string), and a variable (string) and places it in the variable store. The scope must already have been created.

When writing Lua, the standard Lua functionality is available to automate the execution of series of Avash commands. This allows a developer to automate:

  • Local network deployments
  • Sending transations, both virtuous and conflicting
  • Order transaction test cases
  • Save the value of UTXO sets and test results to disk
  • Compare the values of two nodes UTXO sets
  • Track expected results and compare them with real nodes

Example Lua scripts are in the ./scripts directory.

Funding a Wallet

On a local network, the 3 blockchains on the default subnet—the X-Chain, C-Chain and P-Chain—each have a pre-funded private key, PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN. This private key has 300m AVAX on the X-Chain, 50m AVAX on the C-Chain and 30m AVAX on the P-Chain—20m of which is unlocked and 10m which is locked and stakeable. For more details, see Fund a local test network tutorial.

avash's People

Contributors

aaronbuchwald avatar abi87 avatar bb-2 avatar cgcardona avatar cmontag avatar collincusce avatar connorbode avatar cryptonote-social avatar danlaine avatar decanus avatar holisticode avatar jpop32 avatar kevin-madhu avatar manthanhd avatar moreati avatar otherview avatar paool avatar patrick-ogrady avatar remigastaldi avatar rohrschacht avatar sanghren avatar tyler-smith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avash's Issues

Set up fail as `go get` is deprecated

Following the set up instructions, I am running go get github.com/ava-labs/avash. This gives the following error. Sounds like the fix would be the publish this as a versioned package.

go get: installing executables with 'go get' in module mode is deprecated.
	Use 'go install pkg@version' instead.

Also tried the following but doesn't work.

go install ava-labs/avash@latest
go install: ava-labs/avash@latest: malformed module path "ava-labs/avash": missing dot in first path element

Use the same local certs/keys as Gecko

When starting nodes, Avash uses certs in avash/certs/keyX.
Right now, keys 1 through 5 are the same as staker1.key, ..., staker5.key in gecko/keys/local.
These keys are currently funded when running a local network but those keys may change in the future.

What do you think of pointing Avash to use the keys/local files in the gecko repo instead of replicating them in avash/certs?

Validate config file when starting Avash

If the config file is incorrect Avash just kinda rolls along. We should check to make sure the Ava binary is where it says it is, the loglevels are valid, or anything else. Just exit if they're not.

Please edit docs/directory

the avax docs are a little off:
https://github.com/ava-labs/avash
This says "cd $GOPATH/src/github.com/ava-labs/avash"
But
go get github.com/ava-labs/avash
installs a diretory not named avash, it is named "[email protected]", so it doesn't match the install docs.

Also the website says "An Avalanche Client Implementing Avalanche Standard CLI Flags", which sort of comes before the Quick Setup, and is sort of confusing 💘

C-Chain cant bootstrap

Hey, im trying to run avash five_node_staking.lua, the C-Chain gets stuck bootstraping(from health.getLiveness). In the logs I get this error:
ERROR[07-29|09:25:00] /chains/manager.go#250: error while creating vm: Unrecognized remote plugin message:

This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.

Im on Ubuntu 20.04 LTS, I just did git pull and buid in both avash ans gecko

Location of avash and gecko:
/home/nita/go/src/github.com/ava-labs/gecko
/home/nita/go/src/github.com/ava-labs/avash

echo $GOPATH/home/nita/go
go version go1.13.8 linux/amd64

0.log

Add callrpc command

Add a callrpc command to issue RPC commands to any node.

callrpc <nodename> <rpcmethod> <varscope> <varname> args...

Run script run nothing

PS D:\workspace-test\avash> .\avash.exe
Config file not found: .avash.yaml
Created empty config file: C:\Users\test/.avash.yaml
avash> runscript scripts/five_node_staking.lua
avash>

did everything doc told and node didn't start

Version flag

Please add a flag to quickly check the version of an avash executable.

avash installation issue and a work around

Hi there, I tried the avash installation and go get github.com/ava-labs/avash throwed the following error:

package go.uber.org/multierr: unrecognized import path "go.uber.org/multierr" (https fetch: Get https://go.uber.org/multierr?go-get=1: net/http: TLS handshake timeout)

This might be related to paths but not sure exactly, here is my environment variables for Go on a mac os 10.15.2.

export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"

However, here is a work around in case someone come across this issue:

mkdir -p $GOPATH/src/go.uber.org
cd $GOPATH/src/go.uber.org
git clone [email protected]:uber-go/multierr.git
git clone [email protected]:uber-go/atomic.git

Then the avash build works fine.

Installation fails to work as intended if "go.mod" file present

INTRO:

After installing gecko 0.5.5, I was confused why the standard avash install directions were not working:
$ go get github.com/ava-labs/avash
$ cd $GOPATH/src/github.com/ava-labs/avash
No such file or directory
The initial sign that things to wrong is the "avash" folder is not present in the $GOPATH

SUMMARY:

I discovered the core issue is that avash cannot be installed in a directory that has a "go.mod" file present, such as the gecko installation directory. Install directions for avash should warn user to be either in a clean directory, or perhaps switch to cd $GOPATH since that should not have "go.mod" directly in it.

DETAILS:

Let's revisit my issue via docker. I create a "mike" user to mimic conditions on my regular bare metal system:

TEST 1: ITS GOING TO BE UGLY

docker run --name avashtest1 -it ubuntu:bionic bash
apt update
apt install -y curl git mercurial make binutils bison gcc build-essential golang
adduser mike
su - mike
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /home/mike/.gvm/scripts/gvm
gvm install go1.13.12
gvm use go1.13.12 --default
echo System general setup done.
go get -d -v github.com/ava-labs/gecko/...
cd $GOPATH/src/github.com/ava-labs/gecko
pwd # /home/mike/.gvm/pkgsets/go1.13.12/global/src/github.com/ava-labs/gecko
./scripts/build.sh
./build/ava --version # avalanche/0.5.5
test -f go.mod && echo WARNING: go.mod file found. Avash will not install correctly. Please switch to another directory. || echo INFO: go.mod file not found. Avash ready for installation.
go get github.com/ava-labs/avash
cd $GOPATH/src/github.com/ava-labs/avash # No such file or directory

What happened? The presence of "go.mod" file caused it to be built and stored as a module!
$ find ~/ | grep /avash$
/home/mike/.gvm/pkgsets/go1.13.12/global/bin/avash
/home/mike/.gvm/pkgsets/go1.13.12/global/pkg/mod/cache/download/github.com/ava-labs/avash

TEST 2: THIS WORKS

docker run --name avashtest2 -it ubuntu:bionic bash
apt update
apt install -y curl git mercurial make binutils bison gcc build-essential golang
adduser mike
su - mike
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /home/mike/.gvm/scripts/gvm
gvm install go1.13.12
gvm use go1.13.12 --default
echo System general setup done.
go get -d -v github.com/ava-labs/gecko/...
cd $GOPATH/src/github.com/ava-labs/gecko
pwd # /home/mike/.gvm/pkgsets/go1.13.12/global/src/github.com/ava-labs/gecko
./scripts/build.sh
./build/ava --version # avalanche/0.5.5
cd $GOPATH # Let's go a directory without "go.mod" file
test -f go.mod && echo WARNING: go.mod file found. Avash will not install correctly. Please switch to another directory. || echo INFO: go.mod file not found. Avash ready for installation.
go get github.com/ava-labs/avash
cd $GOPATH/src/github.com/ava-labs/avash
pwd # /home/mike/.gvm/pkgsets/go1.13.12/global/src/github.com/ava-labs/avash
go build

$ find ~/ | grep /avash$
/home/mike/.gvm/pkgsets/go1.13.12/global/bin/avash
/home/mike/.gvm/pkgsets/go1.13.12/global/src/github.com/ava-labs/avash
/home/mike/.gvm/pkgsets/go1.13.12/global/src/github.com/ava-labs/avash/avash

$ file avash
avash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, not stripped

Use network alias "local" as default for cli param "network-id"

There's now a proper alias for the local network Network ID. It's "local". If someone passes network-id=local to the gecko node, it will translate that to 12345. This is better because it keeps default network IDs standard. Since Avash technically "implements" Gecko, please use the same system with the same default being "local".

runtime error in function avash_call

Hello, when I want to run a .lua script i get an error:

RunScript: Failed to run scripts/five_node_network.lua
runtime error: invalid memory address or nil pointer dereference
stack traceback: in function 'avash_call'
scripts/five_node_network.lua:12: in main chunk

the problem comes from the avash_call function.
I specify that the functions avash_sleepmicro and avash_setvar work well.

How i can fix it ?

Inconsistent node exits

Occasionally, after running several nodes (specific case was 4 from script), exit command will not properly call stop on all running nodes.

Support `yaml` and `yml` equally

Currently avash only looks for the yaml extension for its config file.

As yml is equally standard for YAML files, both should be supported.

Avash did not start avalanchego

Was not able to get project running following the readme. After starting avalanchego in a separate process then starting avash fixed it. Is avash supposed to automatically start it?

Broken dependencies

After going through a fresh install of go and this package, I get the following after running go build:

../avalanchego/utils/crypto/secp256k1r.go:15:2: cannot find package "github.com/decred/dcrd/dcrec/secp256k1/v3" in any of:
	/usr/local/go/src/github.com/decred/dcrd/dcrec/secp256k1/v3 (from $GOROOT)
	/Users/doug/go/src/github.com/decred/dcrd/dcrec/secp256k1/v3 (from $GOPATH)
../avalanchego/utils/crypto/secp256k1r.go:13:2: cannot find package "github.com/decred/dcrd/dcrec/secp256k1/v3/ecdsa" in any of:
	/usr/local/go/src/github.com/decred/dcrd/dcrec/secp256k1/v3/ecdsa (from $GOROOT)
	/Users/doug/go/src/github.com/decred/dcrd/dcrec/secp256k1/v3/ecdsa (from $GOPATH)
../../spf13/viper/internal/encoding/hcl/codec.go:8:2: cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:
	/usr/local/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOROOT)
	/Users/doug/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOPATH)

The first two can be resolved by changing the following lines in ava-labs/avalanchego/utils/crypto/secp256k1r.go:

"github.com/decred/dcrd/dcrec/secp256k1/v3/ecdsa" to "github.com/decred/dcrd/dcrec/secp256k1/ecdsa"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v3" to secp256k1 "github.com/decred/dcrd/dcrec/secp256k1"

Output from ls in ~/go/src/github.com/decred/dcrd/dcrec/secp256k1:

README.md			ecdh_test.go			field.go			loadprecomputed.go		privkey_test.go
bench_test.go			ecdsa				field_bench_test.go		modnscalar.go			pubkey.go
compressedbytepoints.go		ellipticadaptor.go		field_test.go			modnscalar_bench_test.go	pubkey_test.go
curve.go			ellipticadaptor_test.go		genprecomps.go			modnscalar_test.go		schnorr
curve_test.go			error.go			genstatics.go			nonce.go
doc.go				error_test.go			go.mod				nonce_test.go
ecdh.go				example_test.go			go.sum				privkey.go

I'm not sure how to resolve the last one, as I'm not familiar with the package. But it seems its directory structure has been altered.

Output from ls in ~/go/src/github.com/hashicorp/hcl:

CHANGELOG.md			eval_context.go			guide				json				schema.go
LICENSE				expr_call.go			hcldec				merged.go			spec.md
README.md			expr_list.go			hcled				merged_test.go			specsuite
cmd				expr_map.go			hclparse			ops.go				static_expr.go
diagnostic.go			expr_unwrap.go			hclsimple			ops_test.go			structure.go
diagnostic_text.go		ext				hclsyntax			pos.go				structure_at_pos.go
diagnostic_text_test.go		go.mod				hcltest				pos_scanner.go			traversal.go
didyoumean.go			go.sum				hclwrite			pos_scanner_test.go		traversal_for_expr.go
doc.go				gohcl				integrationtest			pos_test.go			traversal_for_expr_test.go

My go version:

go version go1.17.4 darwin/amd64

I'm unsure whether this is an isolated issue with just my environment, but considering I just did a fresh install of go, I doubt it.

Tab key command completion

Pressing the tab key should auto-complete a command in terminal if the current text is a unique start to that command.

formatting.CB58 is not a type

I got this error while compiling the source code

formatting.CB58 is not a type

What version of avalanchgo should I use with avash on master?

Invalid ava binary location error

Hello, I am trying to run ./avash but I got the following error:

Invalid ava binary location: /home/myuser/go/src/github.com/ava-labs/avalanchego/build/avalanchego
Make sure your $GOPATH is set or provide a configuration file with a valid `avalancheLocation` value. See README.md for more details.

How can I provide a avalancheLocation? Currently it is installed at:

/home/myuser/avalanche-node/avalanchego

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.