Skip to content

Commit

Permalink
docs: link README to ash.center (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
leopaul36 authored May 17, 2023
1 parent ecf3e4f commit bf3926d
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 362 deletions.
51 changes: 2 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,60 +29,13 @@ This collection has been tested to work with the following versions:
## Installation

```sh
# With Ansible >= 2.10
ansible-galaxy collection install git+https://github.com/AshAvalanche/ansible-avalanche-collection.git

# With Ansible 2.9
mkdir -p ansible_collections/ash
git clone https://github.com/AshAvalanche/ansible-avalanche-collection.git ansible_collections/ash/avalanche
```

## Getting started

Follow the [tutorials](https://ash.center/docs/toolkit/ansible-avalanche-collection/tutorials/local-test-network) on the [Ash docs website](https://ash.center/) to get started!

## Collection resources

### Modules

- [ash.avalanche.tx](./plugins/modules): submit a transaction to an Avalanche network
- [ash.avalanche.eth_call](./plugins/modules): `eth_call` a smart contract's function on an EVM Avalanche network

### Filters

- [ash.avalanche.convert](./plugins/filter): convert an amount between AVAX units
- [ash.avalanche.XXX_to_XXX](./plugins/filter): convert a string between encodings

### Roles

- [ash.avalanche.node](./roles/node): install, configure and upgrade Avalanche nodes
- [ash.avalanche.subnet](./roles/subnet): create Avalanche subnets
- [ash.avalanche.blockchain](./roles/blockchain): create Avalanche blockchains

### Playbooks

- [ash.avalanche.bootstrap_local_network](./playbooks/bootstrap_local_network.yml): bootstrap a local test network (`avalanchego_network_id: local`)
- [ash.avalanche.provision_nodes](./playbooks/provision_nodes.yml): provision nodes for Fuji or Mainnet (`avalanchego_network_id: fuji|mainnet`)
- [ash.avalanche.create_local_subnet](./playbooks/create_local_subnet.yml): create a Subnet on a local test network (**do not** use in production)
- [ash.avalanche.create_local_blockchains](./playbooks/create_local_blockchains.yml): create blockchains in a Subnet on a local test network (**do not** use in production)
- [ash.avalanche.transfer_avax](./playbooks/transfer_avax.yml): example of how to transfer AVAX from the X-Chain to the C-Chain (**do not** use in production)

## Inventory requirements

- `ash.avalanche.node`:
- **All the nodes** on which to install AvalancheGo have to be in the `avalanche_nodes` group.
- For local networks, **one of the nodes** has to be in the `bootstrap_node` group. This node has to **be started first to serve as a bootstrap node** for the others. For an example of how to do that, see the [bootstrap_local_network.yml](../../playbooks/bootstrap_local_network.yml) playbook.
- `ash.avalanche.subnet`:
- **The node used to make API calls** have to be in the `subnet_control_node` group.
- **The nodes to be added as validators** to the Subnet have to be in the `subnet_validators` group. The Ansible host has to be able to connect to those nodes via SSH.
- `ash.avalanche.blockchain`:
- **The node used to make API calls** have to be in the `subnet_control_node` group.
- **The validators** of the Subnet have to be in the `subnet_validators` group. The Ansible host has to be able to connect to those nodes via SSH.

## Roadmap
## Documentation

- [x] Avalanche transaction module
- [x] Subnet role
- [x] VMs management
- [x] Blockchain role
- [x] TLS support
Checkout [the reference documentation](https://ash.center/docs/toolkit/ansible-avalanche-collection/reference) on the [Ash docs website](https://ash.center/) for complete documentation.
53 changes: 1 addition & 52 deletions plugins/filter/README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1 @@
# ash.avalanche filters

The collection provides the following filters:

- [ash.avalanche.convert](#ashavalancheconvert): convert an amount between AVAX units
- [ash.avalanche.XXX_to_XXX](#ashavalanchexxx_to_xxx): convert a string between encodings

## ash.avalanche.convert

### Usage

This filter is useful to submit transactions without errors in the number of zeros:

```yaml
ash.avalanche.tx:
...
params:
...
amount: "{{ 25 | ash.avalanche.convert('AVAX', 'nAVAX') | int }}"
```
### Supported units
| Unit | Amount in wei |
| ----------------- | ------------------------------ |
| `wei` | `1` |
| `gwei` or `navax` | `1e9` (`1000000000`) |
| `avax` or `eth` | `1e18` (`1000000000000000000`) |

**Note:** The filter is not case sensitive: `ash.avalanche.convert('AVAX', 'nAVAX')` is the same as `ash.avalanche.convert('avax', 'navax')`

## ash.avalanche.XXX_to_XXX

### Usage

This is useful to convert string between different encodings, e.g. from hexadecimal to [CB58](https://support.avax.network/en/articles/4587395-what-is-cb58).

```yaml
# Example of cb58_to_hex conversion
- name: Convert NodeID to hexadecimal
set_fact:
node_id_hex: |-
{{ (get_node_id_res.json.result.nodeID | split('-'))[1]
| ash.avalanche.cb58_to_hex }}
```

### Supported conversions

- `cb58_to_hex`
- `cb58_to_bytes`
- `hex_to_cb58`
- `hex_to_bytes`
See [Filters](https://ash.center/docs/toolkit/ansible-avalanche-collection/reference/filters) for reference.
81 changes: 1 addition & 80 deletions plugins/modules/README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1 @@
# ash.avalanche modules

The collection provides the following modules:

- [ash.avalanche.tx](#ashavalanchetx) (alias: `ash.avalanche.transaction`): submit a transaction to an Avalanche network
- [ash.avalanche.eth_call](#ashavalancheeth_call): `eth_call` a smart contract's function on an EVM Avalanche network

## ash.avalanche.tx

### Supported API methods

- [Platform Chain (P-Chain) API](https://docs.avax.network/build/avalanchego-apis/p-chain): all the methods that create a transaction
- [Exchange Chain (X-Chain) API](https://docs.avax.network/build/avalanchego-apis/x-chain): all the methods that create a transaction
- [Contract Chain (C-Chain) API](https://docs.avax.network/build/avalanchego-apis/c-chain): only **Avalanche specific methods** (see [Avalanche Specific APIs](https://docs.avax.network/build/avalanchego-apis/c-chain/#avalanche-specific-apis)) that create a transaction

**Note:** You can identify transaction methods by looking at its signature: **it returns a `txID`**. E.g. for the `avm.import` method of the X-Chain:

```cpp
avm.import({
to: string,
sourceChain: string,
username: string,
password: string,
}) -> {
txID: string // This tells us that avm.import() creates a transaction
}
```

### Module arguments

| Argument | Required | Type | Default value | Comment |
| ----------------------- | -------- | ------ | ------------- | -------------------------------------------------------------------------------------------------------- |
| `blockchain` or `chain` | Yes | `str` | `None` | Blockchain to query. Can be `P`, `X` or `C/avax` |
| `method` | Yes | `str` | `None` | API method to call |
| `username` | Yes | `str` | `None` | Username of the user that will pay the transaction fees (and owns addresses in case of send transaction) |
| `password` | Yes | `str` | `None` | Password of the user. It is recommended to store the password in an Ansible vault. |
| `params` | Yes | `raw` | `None` | Parameters of the method (except `username` and `password`) |
| `http_host` | No | `str` | `'127.0.0.1'` | IP address that exposes the JSON RPC API |
| `http_port` | No | `str` | `9650` | Port that exposes the JSON RPC API |
| `protocol` | No | `str` | `'http'` | `http` or `https` |
| `retry_if_unknown` | No | `bool` | `True` | Retry to submit the transaction in case the transaction's status is `Unknown` |
| `max_retries` | No | `int` | `5` | Maximum number of retries in case the transaction's status is `Unknown` |
| `wait_validation` | No | `bool` | `False` | Wait for the transaction to be validated by the network |
| `wait_timeout` | No | `int` | `300` | Timeout when waiting for the transaction's validation |

**Note:** `username` and `password` are not redacted in the module output (replaced by `VALUE_SPECIFIED_IN_NO_LOG_PARAMETER`).

### JSON RPC endpoint construction

The JSON RPC endpoint used for the API calls is constructed as follows:

```jinja
{{ protocol }}://{{ http_host }}:{{ http_port }}/ext/bc/{{ blockchain }}
```

Some blockchains, like the C-Chain, have multiple RPC endpoints (see [Contract Chain (C-Chain) API](https://docs.avax.network/build/avalanchego-apis/c-chain/)). You have to specify the desired endpoint to use with the `blockchain` argument, e.g.:

```yaml
blockchain: C/avax
```
### Example playbook
The playbook [ash.avalanche.transfer_avax](../../playbooks/transfer_avax.yml) is provided as an example of how to use the `ash.avalanche.tx` module. See [ansible-avalanche-getting-started](https://github.com/AshAvalanche/ansible-avalanche-getting-started) for more.

## ash.avalanche.eth_call

### Module arguments

| Argument | Required | Type | Default value | Comment |
| --------------- | -------- | ----- | ------------- | --------------------------------------------------------------------------------------- |
| `rpc_url` | Yes | `str` | `None` | RPC endpoint to call |
| `contract_addr` | Yes | `str` | `None` | Address of the smart contract to query (in `0x...` format) |
| `abi` | Yes | `str` | `None` | JSON ABI of the smart contract. Can be retrieved from [Snowtrace](https://snowtrace.io) |
| `function_sig` | Yes | `str` | `None` | Signature of the function to call. Looks like `foo(uint32,bool)` |
| `parameters` | Yes | `raw` | `None` | List of parameters of the functions. |

### Example playbook

The playbook [ash.avalanche.node/ash-node](../../roles/node/tasks/ash-node.yml) makes use of this plugin to enrich the node configuration with on-chain data.
See [Modules](https://ash.center/docs/toolkit/ansible-avalanche-collection/reference/modules) for reference.
28 changes: 1 addition & 27 deletions roles/blockchain/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1 @@
# ash.avalanche.blockchain

This Ansible role allows to create an Avalanche blockchain.

## Role variables

| Variable | Comment | Default value |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| `avalanchego_http_host` | [--http-host](https://docs.avax.network/build/references/avalanchego-config-flags#--http-host-string) argument | `127.0.0.1` |
| `avalanchego_http_port` | [--http-port](https://docs.avax.network/build/references/avalanchego-config-flags#--http-port-int) argument | `9650` |
| `avalanchego_https_enabled` | Whether the HTTP API endpoints are using TLS or not | `false` |
| `subnet_id` | | `aUC7SX8QGVwsbwS4YNuavVTbinjJLrPjNNjdpZbbcFZZFSxFd` |
| `subnet_control_username` | | `ewoq` |
| `subnet_control_password` | | `I_l1ve_@_Endor` |
| `blockchain_vm` | The VM used by the blockchain. See [Available VMs and AvalancheGo compatibility](../node/README.md#available-vms-and-avalanchego-compatibility) for the names to use. | `timestampvm` |
| `blockchain_name` | The blockchain name. | `Timestamp Chain` |
| `blockchain_aliases` | The aliases to be linked to this blockchain. See [VM Configs](https://docs.avax.network/build/references/avalanchego-config-flags#vm-configs). | `['timestamp']` |
| `blockchain_genesis_params` | The params passed to the gensis function of the VM to build the blockchain genesis state. See [Create the Genesis Data](https://docs.avax.network/build/tutorials/platform/subnets/create-custom-blockchain#create-the-genesis-data). | `{'data': 'Hello world'}` |

## Inventory requirements

- **The node used to make API calls** have to be in the `subnet_control_node` group.
- **The Subnet validators** have to be in the `subnet_validators` group. The Ansible host has to be able to connect to those nodes via SSH (to create blockchain aliases.

## How to?

See [ansible-avalanche-getting-started](https://github.com/AshAvalanche/ansible-avalanche-getting-started) for how to create a blockchain.
See [ash.avalanche.blockchain](https://ash.center/docs/toolkit/ansible-avalanche-collection/reference/roles/avalanche-blockchain) for reference.
1 change: 1 addition & 0 deletions roles/blockscout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See [ash.avalanche.blockscout](https://ash.center/docs/toolkit/ansible-avalanche-collection/reference/roles/avalanche-blockscout) for reference.
25 changes: 1 addition & 24 deletions roles/faucet/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
# ash.avalanche.faucet

This Ansible role allows to deploy the [Avalanche Faucet](https://github.com/ava-labs/avalanche-faucet) as a Docker service.

| Variable | Comment | Default value |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `avalanche_faucet_image` | Base image of the Avalanche faucet | `ghcr.io/ashavalanche/faucet-image` |
| `avalanche_faucet_image_version` | Tag to be used | `disable-captcha-variable` |
| `avalanche_faucet_conf_dir` | Where to store the faucet config files | `/etc/avalanche/faucet/conf` |
| `avalanche_faucet_log_dir` | Where to store the faucet logs | `/var/log/avalanche/faucet` |
| `avalanche_faucet_user` | User that will run the faucet | `faucet` |
| `avalanche_faucet_group` | Group of the user running the faucet | `faucet` |
| `avalanche_faucet_docker_group` | Docker group of the target host | `docker` |
| `avalanche_faucet_port` | Port on which the faucet will attach on the target host | `8000` |
| `avalanche_faucet_chains` | Config file for the faucet (see [docs](https://github.com/ava-labs/avalanche-faucet#setup-evm-chain-configurations)) | NA |
| `avalanche_faucet_env` | Env file for the faucet (see [docs](https://github.com/ava-labs/avalanche-faucet#setup-environment-variables)) | NA |

## Inventory requirements

- The host on which to install the faucet have to be in the `faucet` group.

## How to?

See the [Subnet faucet](https://docs.ash.center/docs/tools/ansible-avalanche-collection/tutorials/subnet-faucet) tutorial to learn how to deploy the Avalanche Faucet.
See [ash.avalanche.faucet](https://ash.center/docs/toolkit/ansible-avalanche-collection/reference/roles/avalanche-faucet) for reference.
Loading

0 comments on commit bf3926d

Please sign in to comment.