Skip to content

Commit fb7eccc

Browse files
authored
Merge pull request #58 from aws-samples/solana
Solana
2 parents 48f4710 + 45c6f37 commit fb7eccc

File tree

10 files changed

+76
-657
lines changed

10 files changed

+76
-657
lines changed

lib/solana/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ Create your own copy of `.env` file and edit it to update with your AWS Account
129129
```bash
130130
pwd
131131
# Make sure you are in aws-blockchain-node-runners/lib/solana
132-
npm i --save-dev @types/node
133132
npx cdk deploy solana-common
134133
```
135134

lib/solana/lib/assets/node-cw-dashboard.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,42 @@ export const SingleNodeCWDashboardJSON = {
283283
"period": 60,
284284
"title": "nvme1n1 Volume Read/Write throughput (bytes/sec)"
285285
}
286+
},
287+
{
288+
"height": 5,
289+
"width": 6,
290+
"y": 15,
291+
"x": 6,
292+
"type": "metric",
293+
"properties": {
294+
"metrics": [
295+
[ "CWAgent", "disk_used_percent", "InstanceId", "${INSTANCE_ID}", "device", "nvme1n1", "path", "/var/solana/data", "fstype", "xfs", { "region": "${REGION}", "label": "/home/ubuntu/l2geth-source/l2geth-datadir" } ]
296+
],
297+
"sparkline": true,
298+
"view": "singleValue",
299+
"region": "${REGION}",
300+
"title": "nvme1n1 Disk Used (%)",
301+
"period": 60,
302+
"stat": "Average"
303+
}
304+
},
305+
{
306+
"height": 5,
307+
"width": 6,
308+
"y": 15,
309+
"x": 12,
310+
"type": "metric",
311+
"properties": {
312+
"metrics": [
313+
[ "CWAgent", "disk_used_percent", "InstanceId", "${INSTANCE_ID}", "device", "nvme2n1", "path", "/var/solana/accounts", "fstype", "xfs", { "region": "${REGION}", "label": "/home/ubuntu/l2geth-source/l2geth-datadir" } ]
314+
],
315+
"sparkline": true,
316+
"view": "singleValue",
317+
"region": "${REGION}",
318+
"title": "nvme2n1 Disk Used (%)",
319+
"period": 60,
320+
"stat": "Average"
321+
}
286322
}
287323
]
288324
}

lib/solana/lib/assets/solana/node-consensus-template.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export RUST_LOG=error
88
export RUST_BACKTRACE=full
99
export SOLANA_METRICS_CONFIG=__SOLANA_METRICS_CONFIG__
1010

11+
#See https://github.com/aws-samples/aws-blockchain-node-runners/issues/31
12+
ulimit -n 1000000
13+
1114
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
1215
export EC2_INTERNAL_IP=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/local-ipv4)
1316

lib/solana/lib/assets/solana/node-heavy-rpc-template.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export RUST_LOG=error
88
export RUST_BACKTRACE=full
99
export SOLANA_METRICS_CONFIG=__SOLANA_METRICS_CONFIG__
1010

11+
#See https://github.com/aws-samples/aws-blockchain-node-runners/issues/31
12+
ulimit -n 1000000
13+
1114
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
1215
export EC2_INTERNAL_IP=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/local-ipv4)
1316

lib/solana/lib/assets/solana/node-light-rpc-template.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ export RUST_LOG=error
88
export RUST_BACKTRACE=full
99
export SOLANA_METRICS_CONFIG=__SOLANA_METRICS_CONFIG__
1010

11+
#See https://github.com/aws-samples/aws-blockchain-node-runners/issues/31
12+
ulimit -n 1000000
13+
1114
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
1215
export EC2_INTERNAL_IP=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/local-ipv4)
1316

14-
# TODO: Delete below
15-
# --gossip-port 8800 \
16-
# --dynamic-port-range 8801-8814 \ SG ports 8802-8814
17-
# --no-port-check \
18-
1917
/home/solana/bin/solana-validator \
2018
--ledger /var/solana/data/ledger \
2119
--identity /home/solana/config/validator-keypair.json \

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ sudo bash -c "cat >/etc/security/limits.d/90-solana-nofiles.conf <<EOF
110110
* - nofile 1000000
111111
EOF"
112112

113-
echo 'Preparing directories and file system for Solana installation'
113+
echo 'Preparing fs for Solana installation'
114114
sudo mkdir /var/solana
115115
sudo mkdir /var/solana/data
116116
sudo mkdir /var/solana/accounts
117117

118118
if [[ "$STACK_ID" != "none" ]]; then
119-
echo "Install and enable CloudFormation helper scripts"
119+
echo "Install CloudFormation helper scripts"
120120
mkdir -p /opt/aws/
121121
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
122122
sudo ln -s /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup
@@ -213,8 +213,9 @@ sudo usermod -aG sudo solana
213213
cd /home/solana
214214
sudo mkdir ./bin
215215

216-
echo "Downloading x86 binaries for version v$SOLANA_VERSION"
216+
ln -s /var/solana/data/ledger /home/solana
217217

218+
echo "Downloading x86 binaries for version v$SOLANA_VERSION"
218219
sudo wget -q https://github.com/solana-labs/solana/releases/download/v$SOLANA_VERSION/solana-release-x86_64-unknown-linux-gnu.tar.bz2
219220
sudo tar -xjvf solana-release-x86_64-unknown-linux-gnu.tar.bz2
220221
sudo mv solana-release/bin/* ./bin/
@@ -233,22 +234,22 @@ else
233234
fi
234235
if [[ "$SOLANA_NODE_TYPE" == "consensus" ]]; then
235236
if [[ $NODE_IDENTITY_SECRET_ARN == "none" ]]; then
236-
echo "Storing generated node identity to AWS Secrets Manager"
237+
echo "Store node identity to AWS Secrets Manager"
237238
NODE_IDENTITY=$(sudo ./solana-keygen pubkey /home/solana/config/vote-account-keypair.json)
238239
sudo aws secretsmanager create-secret --name "solana-node/"$NODE_IDENTITY --description "Solana Node Identity Secret created for stack $CF_STACK_NAME" --secret-string file:///home/solana/config/validator-keypair.json --region $AWS_REGION
239240
fi
240241
if [[ $VOTE_ACCOUNT_SECRET_ARN == "none" ]]; then
241242
echo "Create Vote Account Secret"
242243
sudo ./solana-keygen new --no-passphrase -o /home/solana/config/vote-account-keypair.json
243244
NODE_IDENTITY=$(sudo ./solana-keygen pubkey /home/solana/config/vote-account-keypair.json)
244-
echo "Storing Vote Account Secret to AWS Secrets Manager"
245+
echo "Store Vote Account Secret to AWS Secrets Manager"
245246
sudo aws secretsmanager create-secret --name "solana-node/"$NODE_IDENTITY --description "Solana Vote Account Secret created for stack $CF_STACK_NAME" --secret-string file:///home/solana/config/vote-account-keypair.json --region $AWS_REGION
246247

247248
if [[ $AUTHORIZED_WITHDRAWER_ACCOUNT_SECRET_ARN == "none" ]]; then
248249
echo "Create Authorized Withdrawer Account Secret"
249250
sudo ./solana-keygen new --no-passphrase -o /home/solana/config/authorized-withdrawer-keypair.json
250251
NODE_IDENTITY=$(sudo ./solana-keygen pubkey /home/solana/config/authorized-withdrawer-keypair.json)
251-
echo "Storing Authorized Withdrawer Account to AWS Secrets Manager"
252+
echo "Store Authorized Withdrawer Account to AWS Secrets Manager"
252253
sudo aws secretsmanager create-secret --name "solana-node/"$NODE_IDENTITY --description "Authorized Withdrawer Account Secret created for stack $CF_STACK_NAME" --secret-string file:///home/solana/config/authorized-withdrawer-keypair.json --region $AWS_REGION
253254

254255
else
@@ -265,13 +266,13 @@ if [[ "$SOLANA_NODE_TYPE" == "consensus" ]]; then
265266
echo "Creating Vote Account on-chain"
266267
sudo ./solana create-vote-account /home/solana/config/vote-account-keypair.json /home/solana/config/validator-keypair.json /home/solana/config/authorized-withdrawer-keypair.json
267268

268-
echo "Deleting Transaction Funding Account Secret from the local disc"
269+
echo "Delete Transaction Funding Account Secret from the local disc"
269270
sudo rm /root/.config/solana/id.json
270271
else
271272
echo "Vote Account not created. Please create it manually: https://docs.solana.com/running-validator/validator-start#create-vote-account"
272273
fi
273274

274-
echo "Deleting Authorized Withdrawer Account from the local disc"
275+
echo "Delete Authorized Withdrawer Account from the local disc"
275276
sudo rm /home/solana/config/authorized-withdrawer-keypair.json
276277
else
277278
echo "Get Vote Account Secret from AWS Secrets Manager"

lib/solana/lib/common-stack.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ export class SolanaCommonStack extends cdk.Stack {
3535
resources: [`arn:aws:autoscaling:${region}:${this.AWS_ACCOUNT_ID}:autoScalingGroup:*:autoScalingGroupName/solana-*`],
3636
actions: ["autoscaling:CompleteLifecycleAction"],
3737
}));
38+
39+
instanceRole.addToPolicy(
40+
new iam.PolicyStatement({
41+
resources: [
42+
`arn:aws:s3:::cloudformation-examples`,
43+
`arn:aws:s3:::cloudformation-examples/*`,
44+
],
45+
actions: ["s3:ListBucket", "s3:*Object", "s3:GetBucket*"],
46+
})
47+
);
3848

3949
new cdk.CfnOutput(this, "Instance Role ARN", {
4050
value: instanceRole.roleArn,

0 commit comments

Comments
 (0)