Code Monkey home page Code Monkey logo

apm's Introduction

Avalanche Plugin Manager (apm)

Note: This code is currently in Alpha. Proceed at your own risk.

apm is a command-line tool to manage virtual machines binaries for avalanchego.

apm allows users to build their own custom repositories to provide virtual machine and subnet definitions outside of the avalanche-plugins-core repository. avalanche-plugins-core is a community-sourced set of plugins and subnets that ships with the apm, but users have the option of adding their own using the add-repository command.

Installation

Pre-Built Binaries

Instructions

To download a binary for the latest release, run:

curl -sSfL https://raw.githubusercontent.com/ava-labs/apm/master/scripts/install.sh | sh -s

The binary will be installed inside the ./bin directory (relative to where the install command was run).

Downloading binaries from the Github UI will cause permission errors on Mac.

To add the binary to your path, run

cd bin
export PATH=$PWD:$PATH

To add it to your path permanently, add an export command to your shell initialization script (ex: .bashrc).

Installing in Custom Location

To download the binary into a specific directory, run:

curl -sSfL https://raw.githubusercontent.com/ava-labs/apm/master/scripts/install.sh | sh -s -- -b <relative directory>

Source

If you are planning on building from source, you will need golang >= 1.18.x installed.

To build from source, you can use the provided build script from the repository root.

./scripts/build.sh

The resulting apm binary will be available in ./build/apm.

Commands

add-repository

Starts tracking a plugin repository.

apm add-repository --alias ava-labs/core --url https://github.com/ava-labs/avalanche-plugins-core.git --branch master

Parameters:

  • --alias: The alias of the repository to track (must be in the form of foo/bar i.e organization/repository).
  • --url: The url to the repository.
  • --branch: The branch name to track.

install-vm

Installs a virtual machine by its alias. Either a partial alias (e.g spacesvm) or a fully qualified name including the repository (e.g ava-labs/core:spacesvm) to disambiguate between multiple repositories can be used.

If multiple matches are found (e.g repository-1/foovm, repository-2/foovm), you will be required to specify the fully qualified name of the virtual machine to disambiguate the repository to install from.

This will install the virtual machine binary to your avalanchego plugin path.

apm install-vm --vm spacesvm

Parameters:

  • --vm: The alias of the VM to install.

join-subnet

Joins a subnet by its alias. Either a partial alias (e.g spaces) or a fully qualified name including the repository (e.g ava-labs/core:spaces) to disambiguate between multiple repositories can be used.

This will install dependencies for the subnet by calling install-vm on each virtual machine required by the subnet.

If multiple matches are found (e.g repository-1/foo, repository-2/foo), you will be required to specify the fully qualified name of the subnet definition to disambiguate the repository to install from.

apm join-subnet --subnet spaces

Parameters:

  • --subnet: The alias of the VM to install.

list-repositories

Lists all tracked repositories.

apm list-repositories

uninstall-vm

Installs a virtual machine by its alias.

If multiple matches are found (e.g repository-1/foovm, repository-2/foovm), you will be required to specify the fully qualified name of the virtual machine to disambiguate the repository to install from.

This will remove the virtual machine binary from your avalanchego plugin path.

apm uninstall-vm --vm spacesvm

Parameters:

  • --vm: The alias of the VM to uninstall.

update

Fetches the latest plugin definitions from all tracked repositories.

apm list-repositories

upgrade

Upgrades a virtual machine binary. If one is not provided, this will upgrade all virtual machine binaries in your avalanchego plugin path with the latest synced definitions.

For a virtual machine to be upgraded, it must have been installed using the apm.

apm upgrade

Parameters

  • --vm: (Optional) The alias of the VM to upgrade. If none is provided, all VMs are upgraded.

remove-repository

Stops tracking a repository and wipes all local definitions from that repository.

apm remove-repository --alias organization/repository

Parameters:

  • --alias: The alias of the repository to start tracking.

Examples

  1. Install the spaces subnet!
./build/apm join-subnet --subnet spaces
  1. You'll see some output like this:
$ ./build/apm join-subnet --subnet spaces

Installing virtual machines for subnet Ai42MkKqk8yjXFCpoHXw7rdTWSHiKEMqh5h8gbxwjgkCUfkrk.
Downloading https://github.com/ava-labs/spacesvm/archive/refs/tags/v0.0.3.tar.gz...
HTTP response 200 OK
Calculating checksums...
Saw expected checksum value of 1ac250f6c40472f22eaf0616fc8c886078a4eaa9b2b85fbb4fb7783a1db6af3f
Creating sources directory...
Unpacking ava-labs/avalanche-plugins-core:spacesvm...
Running install script at scripts/build.sh...
Building spacesvm in ./build/sqja3uK17MJxfC7AN8nGadBw9JK5BcrsNwNynsqP5Gih8M5Bm
Building spaces-cli in ./build/spaces-cli
Moving binary sqja3uK17MJxfC7AN8nGadBw9JK5BcrsNwNynsqP5Gih8M5Bm into plugin directory...
Cleaning up temporary files...
Adding virtual machine sqja3uK17MJxfC7AN8nGadBw9JK5BcrsNwNynsqP5Gih8M5Bm to installation registry...
Successfully installed ava-labs/avalanche-plugins-core:[email protected] in /Users/joshua.kim/go/src/github.com/ava-labs/avalanchego/build/plugins/sqja3uK17MJxfC7AN8nGadBw9JK5BcrsNwNynsqP5Gih8M5Bm
Updating virtual machines...
Node at 127.0.0.1:9650/ext/admin was offline. Virtual machines will be available upon node startup.
Whitelisting subnet Ai42MkKqk8yjXFCpoHXw7rdTWSHiKEMqh5h8gbxwjgkCUfkrk...
Finished installing virtual machines for subnet Ai42MkKqk8yjXFCpoHXw7rdTWSHiKEMqh5h8gbxwjgkCUfkrk.

Setting up Credentials for a Private Plugin Repository

You'll need to specify the --credentials-file flag which contains your github personal access token.

Example token file:

username: joshua-kim (for GitHub, this field doesn't matter. You can use your username as a placeholder)
password: <personal access token here>

Example command to download a subnet's VMs from a private repository:

apm join-subnet --subnet=foobar --credentials-file=/home/joshua-kim/token

apm's People

Contributors

felipemadero avatar joshua-kim avatar patrick-ogrady avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

Forkers

metalblockchain

apm's Issues

Add Metadata commands

Add support for commands to:

  1. Search for a vm/subnet by keyword apm search "key-value"
  2. Lookup info of a vm/subnet by its alias apm info foobarvm

Support SubnetConfigs per-network

We should add a field to support network-level subnetConfigs. The most simple way would probably be to add a map type like so:

subnet-config:
   mainnet: <config>
   testnet: <config>
   ...

Support Upgrading Configs

APM should support a subnet adding new upgrade bytes (it can do this multiple times)

  • The upgrade bytes should be tracked and downloaded when the subnet is imported

Remove vms/subnet headers in avalanche-plugins-core

Currently we have weird headers in plugin definitions, for example:

vm:
   { actual vm here }

These are unnecessary and were only originally added in when I was confused on how to use the yaml library. We should gut these before avalanche-cli's integration w/ apm is released.

Move file management code from CLI to APM

There are several functions in the CLI's apmintegration package that belong in the APM itself. Mostly on reading the installed repos and listing what's available. This ticket should move that functionality into the APM. I separate ticket can change how the CLI integrates the APM.

Move away from LevelDB

LevelDB isn't a great storage abstraction for this. Would be better to just serialize state in a json/yaml file

We'll need to:

  1. Replace database with a statefile
  2. Replace the definition registry with file-system lookups

TUI interface

It'd be cool to have some kind of TUI interface for people who aren't as CLI savvy. The bubbletea framework looks promising.

Create a proof-of-concept package signing flow using subnet admin keys

After our discussion with the security team, we'd like to try signing and verifying packages using subnet admin keys. These will use p-chain addresses for signatures and can come from soft keys or from ledgers.

We need to check that each subnet release is signed appropriately. We should also verify that the subnet id does not change across updates.

If this does not work, we can switch to GPG signing with Yubikeys.

Add support for multiple SubnetIDs for Subnets which exist in multiple networks

Some networks might have multiple corresponding subnetIds. For example, I might have a network foo that I want to be able to install + join. It might have subnetID 1234 for testnet, but 5678 for mainnet, but both use the same foovm. We might want subnet definitions to look something like this:

alias: foo
networks: 
 testnet:
  subnetID: 1234
 mainnet:
  subnetID: 5678
vms:
 - foovm
...

... and users could join a subnet like so:

apm join-subnet --subnet-alias=foo --network=mainnet

This will only be needed once dynamic-whitelisting is enabled, at which point we can start using those APIs to correctly whitelist the right subnet id.

Support Upgrading VMs

APM should be able to support a subnet changing VMs during an upgrade

  • It should support listing multiple VMs with the same name but with different versions
  • It should also track historical VM versions (i.e. don't delete vm configs on update)

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.