Skip to content

Commit

Permalink
basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dubbelosix committed Mar 4, 2023
1 parent 8295770 commit 01e1a5c
Show file tree
Hide file tree
Showing 27 changed files with 887 additions and 14 deletions.
2 changes: 1 addition & 1 deletion hosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
ansible_user=ubuntu

[validators]
validator1 ansible_host=186.233.187.64 ansible_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_ed25519
validator ansible_host=186.233.187.64 ansible_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_ed25519
8 changes: 0 additions & 8 deletions lib/git.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion roles/common/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
accounts_disk: "nvme1n1"
ledger_disk: "nvme1n1"
swap_mb: 100000

4 changes: 4 additions & 0 deletions roles/common/files/download_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
sudo systemctl stop sol.service
python3 /mnt/snapshot-finder.py --snapshot_path /mnt/solana-snapshots
sudo systemctl start sol.service
41 changes: 41 additions & 0 deletions roles/common/files/montip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import urllib.request
import threading
import json
import time

MAINNET = "https://api.mainnet-beta.solana.com"
LOCAL = "http://localhost:8899"
PAYLOAD = {"jsonrpc":"2.0","id":1, "method":"getSlot", "params":[{"commitment":"processed"}]}

def get_slot(req, jsondata, result, idx):
response = urllib.request.urlopen(req, jsondata)
res = response.read()
slotnum = json.loads(res)["result"]
result[idx] = slotnum


if __name__ == "__main__":
jsondata = json.dumps(PAYLOAD)
jsondataasbytes = jsondata.encode('utf-8')
content_len = len(jsondataasbytes)
while True:
tlist = []
reqlist = []
resultlist = [0,0]
for c,u in enumerate([LOCAL, MAINNET]):
req = urllib.request.Request(u)
req.add_header('Content-Type', 'application/json; charset=utf-8')
req.add_header('Content-Length', content_len)
req.add_header('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36')
reqlist.append((req, jsondataasbytes, resultlist, c))
for r in reqlist:
tlist.append(threading.Thread(target = get_slot, args = r))
for t in tlist:
t.start()
for t in tlist:
t.join()
print("reference : %s"%(resultlist[1]))
print("my node : %s"%(resultlist[0]))
print("slots behind reference : %s"%(resultlist[1] - resultlist[0]))
print("=====\n")
time.sleep(10)
7 changes: 7 additions & 0 deletions roles/common/files/restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
if [ $# -eq 0 ]
then
python3 /mnt/snapcheck.py
fi
sudo systemctl stop sol.service
sudo systemctl start sol.service
36 changes: 36 additions & 0 deletions roles/common/files/snapcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import urllib.request
import threading
import json
import time

LOCAL = "http://localhost:8899"
PAYLOAD = {"jsonrpc":"2.0","id":1,"method":"getHighestSnapshotSlot"}

def get_snap_slot(req, jsondata):
response = urllib.request.urlopen(req, jsondata)
res = response.read()
slotnum = json.loads(res)["result"]["incremental"]
return slotnum

if __name__ == "__main__":
jsondata = json.dumps(PAYLOAD)
jsondataasbytes = jsondata.encode('utf-8')
content_len = len(jsondataasbytes)
latest_snap = None
while True:
req = urllib.request.Request(LOCAL)
req.add_header('Content-Type', 'application/json; charset=utf-8')
req.add_header('Content-Length', content_len)
req.add_header('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36')
if latest_snap is None:
latest_snap = get_snap_slot(req,jsondataasbytes)
print("current incr snapshot slot: %s\nsleeping..."%(latest_snap))
stime = int(time.time())
time.sleep(1)
latest_incr = get_snap_slot(req,jsondataasbytes)
if latest_incr == latest_snap:
time.sleep(1)
else:
etime = int(time.time()) - stime
break
print("latest incr snapshot slot: %s\nslept: %s seconds"%(latest_incr,etime))
Loading

0 comments on commit 01e1a5c

Please sign in to comment.