/ .devnet / README.md
README.md
  1  # Instructions
  2  
  3  ## 0. Create EC2 instances
  4  
  5  Start by creating EC2 instances in the AWS console.
  6  - Ubuntu 22.04 LTS (not Amazon Linux)
  7  - Security Group - Inbound Policy
  8    - SSH - Port 22 - 0.0.0.0/0 (or your IP)
  9    - Custom TCP - Port 3030 - 0.0.0.0/0 (or your IP)
 10    - Custom TCP - Port 4130 - 0.0.0.0/0
 11    - Custom TCP - Port 5000 - 0.0.0.0/0
 12  
 13  Be sure the give the EC2 instances a name tag, i.e. `devnet`.
 14  
 15  Make sure you set the correct SSH `.pem` and have the `.pem` in your `~/.ssh` directory.
 16  
 17  ## 1. `config.sh`
 18  
 19  This script generates the SSH config for the EC2 instances.
 20  
 21  #### Install `jq`
 22  
 23  This script requires `jq` to be installed.
 24  
 25  On macOS, you can install `jq` with Homebrew:
 26  ```bash
 27  brew install jq
 28  ```
 29  
 30  On Ubuntu, you can install `jq` with apt:
 31  ```bash
 32  sudo apt install jq
 33  ```
 34  
 35  #### AWS Credentials
 36  
 37  This script requires the `aws` CLI.
 38  [Install `aws`](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
 39  (For macOS, there is an installer PKG in the link)
 40  
 41  Then run:
 42  ```bash
 43  aws configure
 44  ```
 45  You will be prompted to enter the following information:
 46  - AWS Access Key ID
 47  - AWS Secret Access Key
 48  - Default region name (e.g., us-east-1)
 49  - Default output format (e.g., json)
 50  This information will be used to authenticate your AWS CLI requests.
 51  
 52  To get your `ACCESS_KEY` and `SECRET_KEY`, go to AWS IAM dashboard and follow these steps:
 53  1. In the IAM dashboard, click on "Users" in the left navigation pane and then click the "Add user" button.
 54  2. Click the "Next: Permissions" button.
 55  3. Click the "Attach existing policies directly" button.
 56  4. Search for "AmazonEC2FullAccess" and select it.
 57  5. Click "Next" and click the "Create user" button.
 58  6. Select the user and click "Create access key".
 59  7. Select "Command Line Interface (CLI)".
 60  8. Click "Create Access Key".
 61  9. Copy the "Access key" and "Secret access key" and paste them into the `aws configure` command.
 62  
 63  Try running:
 64  ```bash
 65  aws sts get-caller-identity
 66  ```
 67  If you get an error, you may need to wait a few minutes for your IAM user to be created.
 68  If you get a response like the following, you are good to go:
 69  ```json
 70  {
 71      "UserId": "XXXXXXXXXXXXXXXXXXXXX",
 72      "Account": "123456789012",
 73      "Arn": "arn:aws:iam::123456789012:user/your-iam-username"
 74  }
 75  ```
 76  
 77  ## 2. `install.sh`
 78  
 79  This script installs alphaos on clean EC2 instances.
 80  
 81  This script assumes you have ran `config.sh` and copy/pasted the output into `~/.ssh/config`.
 82  
 83  This script will:
 84  - Clone alphaos
 85  - Install Rust
 86  - Install dependencies
 87  - Install alphaos
 88  
 89  ## 3. `reinstall.sh`
 90  
 91  If you are actively developing, you can use this script to reinstall alphaos on the EC2 instances.
 92  
 93  This script will fetch the latest changes from the Github branch that you specify, and reinstall alphaos.
 94  
 95  ## 4. `start.sh`
 96  
 97  This script starts alphaos on the EC2 instances.
 98  
 99  ## 5. `monitor.sh`
100  
101  This script monitors the EC2 instances.
102  
103  #### Switch Nodes (forward)
104  
105  To toggle to the next node in a local devnet, run:
106  ```
107  Ctrl+b n
108  ```
109  
110  #### Switch Nodes (backwards)
111  
112  To toggle to the previous node in a local devnet, run:
113  ```
114  Ctrl+b p
115  ```
116  
117  #### Select a Node (choose-tree)
118  
119  To select a node in a local devnet, run:
120  ```
121  Ctrl+b w
122  ```
123  
124  #### Select a Node (manually)
125  
126  To select a node manually in a local devnet, run:
127  ```
128  Ctrl+b :select-window -t {NODE_ID}
129  ```
130  
131  #### Exit (But Keeps the Devnet Running)
132  
133  To exit the monitor, run:
134  ```
135  Ctrl+b :kill-session
136  ```
137  Then, press `Enter`.
138  
139  ## 6. `analytics.sh` (optional)
140  
141  This script generates analytics for the EC2 instances.
142  
143  To run this optional script, you must have Node.js installed.
144  
145  ## 7. `stop.sh`
146  
147  This script stops alphaos on the EC2 instances.
148  
149  ## 8. `clean.sh`
150  
151  This script stops alphaos on the EC2 instances, and removes the ledger DB from the EC2 instances.