Skip to content

Commit b18b613

Browse files
committed
changing the way we build the node, and adding a bunch of env variables to support that
1 parent 7a4bf05 commit b18b613

File tree

5 files changed

+59
-9
lines changed

5 files changed

+59
-9
lines changed

lib/allora/allora.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,8 @@ new AlloraStack(app, 'allora-single-node', {
5050
alloraTopicId: process.env.ALLORA_TOPIC_ID || '3',
5151
alloraEnv: process.env.ALLORA_ENV || 'dev',
5252
alloraNetworkName: process.env.ALLORA_NETWORK_NAME || 'edgenet',
53+
alloraAccountName: process.env.ALLORA_ACCOUNT_NAME || 'secret',
54+
alloraAccountMnemonic: process.env.ALLORA_ACCOUNT_MNEMONIC || 'secret',
55+
alloraAccountPassphrase: process.env.ALLORA_ACCOUNT_PASSPHRASE || 'secret',
56+
alloraNodeRpc: process.env.ALLORA_NODE_RPC || 'https://localhost:26657',
5357
});

lib/allora/lib/allora-stack.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export interface AlloraStackProps extends cdk.StackProps {
2929
alloraTopicId: string;
3030
alloraEnv: string;
3131
alloraNetworkName: string;
32+
alloraAccountName: string;
33+
alloraAccountMnemonic: string;
34+
alloraAccountPassphrase: string;
35+
alloraNodeRpc: string;
3236
}
3337

3438

@@ -44,7 +48,11 @@ export class AlloraStack extends cdk.Stack {
4448
alloraWorkerName,
4549
alloraTopicId,
4650
alloraEnv,
47-
alloraNetworkName
51+
alloraNetworkName,
52+
alloraAccountName,
53+
alloraAccountMnemonic,
54+
alloraAccountPassphrase,
55+
alloraNodeRpc
4856
} = props;
4957
const { region } = env;
5058

@@ -131,7 +139,11 @@ export class AlloraStack extends cdk.Stack {
131139
_ALLORA_WORKER_NAME_: alloraWorkerName,
132140
_ALLORA_TOPIC_ID_: alloraTopicId,
133141
_ALLORA_ENV_: alloraEnv,
134-
_ALLORA_NETWORK_NAME_ : alloraNetworkName
142+
_ALLORA_NETWORK_NAME_ : alloraNetworkName,
143+
_ALLORA_ACCOUNT_NAME_ : alloraAccountName,
144+
_ALLORA_ACCOUNT_MNEMONIC_ : alloraAccountMnemonic,
145+
_ALLORA_ACCOUNT_PASSPHRASE_ : alloraAccountPassphrase,
146+
_ALLORA_NODE_RPC_ : alloraNodeRpc,
135147
});
136148

137149
// Create UserData for EC2 instance

lib/allora/lib/assets/user-data/node.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ echo "ALLORA_WORKER_NAME=${_ALLORA_WORKER_NAME_}" >> /etc/environment
1212
echo "ALLORA_TOPIC_ID=${_ALLORA_TOPIC_ID_}" >> /etc/environment
1313
echo "ALLORA_ENV=${_ALLORA_ENV_}" >> /etc/environment
1414
echo "ALLORA_NETWORK_NAME=${_ALLORA_NETWORK_NAME_}" >> /etc/environment
15+
echo "ALLORA_ACCOUNT_NAME=${_ALLORA_ACCOUNT_NAME_}" >> /etc/environment
16+
echo "ALLORA_ACCOUNT_MNEMONIC=${_ALLORA_ACCOUNT_MNEMONIC_}" >> /etc/environment
17+
echo "ALLORA_ACCOUNT_PASSPHRASE=${_ALLORA_ACCOUNT_PASSPHRASE_}" >> /etc/environment
18+
echo "ALLORA_NODE_RPC=${_ALLORA_NODE_RPC_}" >> /etc/environment
1519

1620
source /etc/environment
1721

@@ -40,9 +44,10 @@ sudo systemctl enable docker.service
4044
sudo systemctl start docker.service
4145

4246
# Install docker-compose
43-
sudo pip3 install docker-compose
47+
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
48+
sudo chmod +x /usr/local/bin/docker-compose
49+
docker-compose version
4450

45-
allocmd generate worker --name $ALLORA_WORKER_NAME --topic $ALLORA_TOPIC_ID --env $ALLORA_ENV --network $ALLORA_NETWORK_NAME
4651

4752
#install AWS CLI
4853
echo 'Installing AWS CLI v2'
@@ -54,6 +59,19 @@ ln /usr/local/bin/aws /usr/bin/aws
5459

5560
cfn-signal -e $? --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION
5661

62+
# clone node repo
63+
cd ~
64+
git clone https://github.com/allora-network/allora-offchain-node.git node-repo
65+
cd node-repo
66+
67+
touch .env
68+
echo "ALLORA_ACCOUNT_NAME=$ALLORA_ACCOUNT_NAME" >> .env
69+
echo "ALLORA_ACCOUNT_MNEMONIC=$ALLORA_ACCOUNT_MNEMONIC" >> .env
70+
echo "ALLORA_ACCOUNT_PASSPHRASE=$ALLORA_ACCOUNT_PASSPHRASE" >> .env
71+
echo "ALLORA_NODE_RPC=$ALLORA_NODE_RPC" >> .env
72+
73+
docker-compose up --build
74+
5775
echo "----------------------------------------------"
5876
echo "[user-data] Allora user-data script successful"
5977
echo "----------------------------------------------"

lib/allora/sample-configs/.env-sample-full

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
#allora node run config
2+
3+
#Must fill all these in
4+
ALLORA_ACCOUNT_NAME="xxxxxxxxxxx"
5+
ALLORA_ACCOUNT_MNEMONIC="xxxxxxxxxxx"
6+
ALLORA_ACCOUNT_PASSPHRASE="xxxxxxxxxxx"
17
AWS_ACCOUNT_ID="xxxxxxxxxxx"
8+
###############################
9+
10+
ALLORA_NODE_RPC=https://localhost:26657
211
AWS_RESOURCE_NAME_PREFIX="AlloraWorkerx"
312
AWS_REGION="us-east-1"
413
AWS_INSTANCE_TYPE="t3.medium"
@@ -16,4 +25,4 @@ EDGE_DATA_VOL_THROUGHPUT="125"
1625
ALLORA_WORKER_NAME="aws"
1726
ALLORA_TOPIC_ID="3"
1827
ALLORA_ENV="dev"
19-
ALLORA_NETWORK_NAME="edgenet"
28+
ALLORA_NETWORK_NAME="edgenet"

lib/allora/test/.env-test

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
AWS_RESOURCE_NAME_PREFIX="AlloraWorkerTest"
1+
#allora node run config
2+
3+
#Must fill all these in
4+
ALLORA_ACCOUNT_NAME="xxxxxxxxxxx"
5+
ALLORA_ACCOUNT_MNEMONIC="xxxxxxxxxxx"
6+
ALLORA_ACCOUNT_PASSPHRASE="xxxxxxxxxxx"
27
AWS_ACCOUNT_ID="xxxxxxxxxxx"
8+
###############################
9+
10+
ALLORA_NODE_RPC=https://localhost:26657
11+
AWS_RESOURCE_NAME_PREFIX="AlloraWorkerx"
312
AWS_REGION="us-east-1"
4-
AWS_AMI_ID="ami-04b70fa74e45c3917"
5-
AWS_INSTANCE_TYPE="t2.medium"
13+
AWS_INSTANCE_TYPE="t3.medium"
614
AWS_VPC_MAX_AZS="1"
715
AWS_VPC_NAT_GATEWAYS="0"
816
AWS_VPC_CIDR_MASK="24"
917

10-
1118
# Data volume configuration
1219
EDGE_DATA_VOL_TYPE="gp3" # Other options: "io1" | "io2" | "gp3" | "instance-store" . IMPORTANT: "instance-store" NOT recommended as it is ephermal and will be reset after stopping the instance. Use "instance-store" option only with instance types that support that feature, like popular for node g4dn, d3, i3en, and i4i instance families
1320
EDGE_DATA_VOL_SIZE="256" # Current required data size to keep both snapshot archive and unarchived version of it (not applicable for "instance-store")

0 commit comments

Comments
 (0)