Skip to content

Commit 92da978

Browse files
committed
feat: Quick start. Run it all using docker and systemctl with ./scripts/run.sh
1 parent 65537b5 commit 92da978

File tree

7 files changed

+111
-35
lines changed

7 files changed

+111
-35
lines changed

_QUICKSTART.md

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,62 @@ It may be used to create a script in future.
77
It assumes that the Ethereum Local Network and Secret Local Network are being run on a remote machine running Linux, since macOS may not support SGX.
88
The guide uses `scp` to copy file changes that are being made on a local machine across to the remote machine. Alternatively make the changes directly on the remote server using `vim` or similar, or otheriwse configure your code editor like Visual Studio Code to do so.
99

10-
### Local Machine
10+
### Super Quick Start
11+
12+
* Clone https://github.com/svub/nunya into `~/nunya`
13+
* Fetch latest from branch 'submit-pubkey'
14+
```
15+
git fetch origin submit-pubkey:submit-pubkey
16+
git checkout submit-pubkey
17+
```
18+
* Clone https://github.com/ltfschoen/SecretPath into `~/ltfschoen`
19+
* Fetch latest from branch 'nunya'
20+
```
21+
git fetch origin nunya:nunya
22+
git checkout nunya
23+
```
24+
* Run the following on a remote server:
25+
```
26+
./scripts/run.sh
27+
```
28+
* Wait for it to all load
29+
* Run
30+
```
31+
cd ~/nunya && nvm use && yarn run secret:submitRequestValue
32+
```
33+
OR
34+
```
35+
cd ~/nunya && nvm use && yarn run secret:submitRetrievePubkey
36+
```
37+
* Watch the logs
38+
* Ethereum Local Node
39+
```
40+
journalctl -u ethlocal.service -f
41+
```
42+
* Optionally store in a file:
43+
```
44+
journalctl -u ethlocal.service -f | tee ~/nunya/ethlocal.service.log
45+
```
46+
* Secret Local Node
47+
```
48+
docker logs -f --tail 10 secretdev
49+
```
50+
* Optionally store in a file:
51+
```
52+
docker logs -f secretdev | tee ~/nunya/secret-docker.log
53+
```
54+
* Relayer
55+
```
56+
journalctl -u relayer.service -f
57+
```
58+
* Optionally store in a file:
59+
```
60+
journalctl -u relayer.service -f | tee ~/nunya/relayer.service.log
61+
```
62+
63+
### Slow Start
64+
65+
#### Local Machine
1166

1267
```
1368
cd /Users/luke/code/clones/github/svub/nunya
@@ -26,9 +81,9 @@ DESTINATION=/root/nunya/packages/secret-contracts-scripts/src/config/config.ts
2681
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
2782
```
2883

29-
### Remote server
84+
#### Remote server
3085

31-
#### Terminal Tab 1
86+
##### Terminal Tab 1
3287

3388
* Start here
3489

@@ -59,7 +114,7 @@ scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
59114

60115
* TODO - turn into service that can start and stop and reset
61116

62-
#### Terminal Tab 2
117+
##### Terminal Tab 2
63118

64119
```bash
65120
@@ -72,7 +127,7 @@ scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
72127

73128
* TODO - turn into service that can start and stop and reset
74129

75-
#### Terminal Tab 3
130+
##### Terminal Tab 3
76131

77132
```bash
78133
@@ -175,7 +230,7 @@ scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
175230
docker exec -it secretdev secretcli query bank balances secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg | jq
176231
```
177232

178-
#### Terminal Tab 4
233+
##### Terminal Tab 4
179234

180235
```bash
181236
cd ~/nunya
@@ -215,7 +270,7 @@ scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
215270
python3 web_app.py
216271
```
217272

218-
#### Terminal Tab 3
273+
##### Terminal Tab 3
219274

220275
* RUN AFTER RELAYER STARTED
221276

@@ -247,6 +302,6 @@ scp -r root@$REMOTE_IP:$SOURCE $DESTINATION
247302
INFO [enclave_contract_engine::wasm3] debug_print: "msg: PostExecutionMsg {\n result: \"eyJfcmVxdWVzdF9pZCI6eyJuZXR3b3JrIjoiMzEzMzciLCJ0YXNrX2lkIjoiNCJ9LCJfa2V5IjpbMiwyNTEsMTg4LDE0MywxNjMsMTExLDM0LDE1OCwxNjcsODIsMTE1LDE4OSwyNSwyMzksMTcyLDEyNiw4LDY3LDIzMCwxMzgsNTAsNzcsODEsMTEzLDEyMiwyMDEsNzYsMjE5LDI0Myw1NSwxMzQsMjE0LDg2XSwiX2NvZGUiOjAsIl9udW55YV9idXNpbmVzc19jb250cmFjdF9hZGRyZXNzIjoiMHhBRkZGMzExODIxQzNGM0FGODYzQzcxMDNCQjE3QkRDMUJhMDQ2MDNEIn0=\"
248303
```
249304

250-
### Notes
305+
#### Notes
251306

252307
* Note: Restart all nodes and re-do steps in Terminal Tab 2 if any of the changes are made since it's faster, otherwise the CODE_ID and CONTRACT_ADDRESS may change requiring updating the config file between uploading and instantiation, which is annoying.

_SETUP.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
### Usage Guidelines <a id="usage"></a>
1111

12+
**Quick Start** with section: [_QUICKSTART.md](./_QUICKSTART.md), otherwise if that doesn't work:
13+
1214
**Start Here** with section [Setup Secret](#setup-secret") and follow the instructions from there.
1315

1416
Help judges and other developers understand the project.
@@ -613,9 +615,7 @@ cd SecretPath/TNLS-Relayers
613615
614616
* Setup
615617
```
616-
conda create --name secretpath_env python=3.11
617-
y
618-
y
618+
conda -y create --name secretpath_env python=3.11
619619
```
620620
621621
* Outputs:

scripts/ethlocal/node.sh

Whitespace-only changes.

scripts/ethlocal/start.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@
33
NAME="hardhat_ethereum_development_node"
44
# FIXME: Permission denied
55
# NODE_PATH="/opt/ethlocal/hardhat"
6-
# FIXME: Permission denied
76
# Note: Check if can execute a file with a given user:
87
# `sudo -u ethlocal_service test -x /opt/ethlocal/hardhat || { echo "otheruser cannot execute the file"; }`
98
NODE_PATH="/root/nunya/packages/hardhat/node_modules/.bin/hardhat"
109

1110
PORT="8545"
1211

13-
# Note: Must be inside a hardhat project to run the command otherwise error
14-
# Error HH1: You are not inside a Hardhat project.
15-
# It runs this from directory root `/` hence the error. Suggest move into a script where can change directory.
16-
CMD="$NODE_PATH node --network hardhat \
17-
--no-deploy \
18-
--watch \
19-
--port $PORT
12+
# Important: systemd service must be configured with the `WorkingDirectory` pointing to a Hardhat project
13+
# that you may debug here with `echo $PWD` if necessary
14+
CMD="$NODE_PATH node --network hardhat --no-deploy --watch --port $PORT
2015
"
2116

2217
echo "-----------------------"

scripts/relayer/node.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
DIRECTORY=/root/miniconda3
4+
if [ ! -d "$DIRECTORY" ]; then
5+
echo "$DIRECTORY does not exist."
6+
7+
mkdir -p ~/miniconda3
8+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
9+
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
10+
rm ~/miniconda3/miniconda.sh
11+
fi
12+
13+
# activate miniconda
14+
source ~/miniconda3/bin/activate
15+
conda init --all
16+
source ~/.zshrc
17+
18+
conda create -y --name secretpath_env python=3.11
19+
20+
# install relayer dependencies and activate conda environment
21+
conda activate secretpath_env
22+
pip install -r requirements.txt --no-dependencies
23+
pip install --upgrade lru-dict
24+
25+
python3 web_app.py
26+

scripts/relayer/start.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#!/usr/bin/env bash
22

33
NAME="relayer_service"
4-
NODE_PATH="/opt/relayer"
5-
PORT="8545"
64

7-
CMD="python3 $NODE_PATH/web_app.py
5+
CMD="/root/nunya/scripts/relayer/node.sh
86
"
97

108
echo "-----------------------"

scripts/run.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ mkdir -p $DB_STORAGE/.chains
142142

143143
mkdir -p /opt/ethlocal
144144
cp ~/nunya/scripts/ethlocal/start.sh /opt/ethlocal
145+
cp ~/nunya/scripts/ethlocal/node.sh /opt/ethlocal
145146
sudo chown -R ethlocal_service /opt/ethlocal
146147
sudo chmod 755 /opt/ethlocal/start.sh
148+
sudo chmod 755 /opt/ethlocal/node.sh
147149

148150
# create a soft link to this file in my present directory:
149151

@@ -181,6 +183,10 @@ touch /etc/systemd/system/ethlocal.service
181183
echo 'SyslogFacility=local7'
182184
echo 'KillSignal=SIGHUP'
183185
echo 'ExecStart=/opt/ethlocal/start.sh'
186+
# Note: Must be inside a hardhat project to run the command otherwise error
187+
# Error HH1: You are not inside a Hardhat project.
188+
# It runs this from directory root `/` hence the error. Suggest move into a script where can change directory.
189+
echo 'WorkingDirectory=/root/nunya/packages/hardhat' # must be run inside a Hardhat project
184190
echo '[Install]'
185191
echo 'WantedBy=multi-user.target'
186192
} > /etc/systemd/system/ethlocal.service
@@ -238,29 +244,25 @@ docker exec -it secretdev secretcli tx bank send secret1ap26qrlp8mcq2pg6r47w43l0
238244
# Part 4
239245

240246
# TODO - update to clone and checkout if folder not exist
241-
cd ~/nunya
242-
nvm use
243247
cd ~/ltfschoen/SecretPath/TNLS-Relayers
244-
git stash
245-
git pull origin nunya
246-
git checkout nunya
248+
# git stash
249+
# git pull origin nunya
250+
# git checkout nunya
247251

248-
## TODO - configure thes files
252+
## TODO - configure these files
249253
# /root/ltfschoen/SecretPath/TNLS-Relayers/config.yml
250254
# /root/ltfschoen/SecretPath/TNLS-Relayers/.env
251255

252-
conda activate secretpath_env
253-
pip install -r requirements.txt --no-dependencies
254-
pip install --upgrade lru-dict
255-
256256
# Part 5
257257

258258
sudo adduser relayer_service --system --no-create-home
259259

260260
mkdir -p /opt/relayer
261261
cp ~/nunya/scripts/relayer/start.sh /opt/relayer
262+
cp ~/nunya/scripts/relayer/node.sh /opt/relayer
262263
sudo chown -R relayer_service /opt/relayer
263264
sudo chmod 755 /opt/relayer/start.sh
265+
sudo chmod 755 /opt/relayer/node.sh
264266

265267
sudo rm /opt/relayer/web_app.py
266268
# create symlink in /opt/relayer to /root/ltfschoen/SecretPath/TNLS-Relayers/web_app.py
@@ -270,7 +272,6 @@ sudo chown -R relayer_service ~/ltfschoen/SecretPath/TNLS-Relayers
270272
# change permission to symlink and where it points to
271273
sudo chmod 755 /opt/relayer/web_app.py
272274
sudo chmod 755 ~/ltfschoen/SecretPath/TNLS-Relayers/web_app.py
273-
ls -al /opt/relayer
274275

275276
# Create service file
276277

@@ -291,6 +292,7 @@ touch /etc/systemd/system/relayer.service
291292
echo 'SyslogIdentifier=relayer'
292293
echo 'SyslogFacility=local7'
293294
echo 'KillSignal=SIGHUP'
295+
echo 'WorkingDirectory=/root/ltfschoen/SecretPath/TNLS-Relayers' # run from inside the project where dependencies are installed
294296
echo 'ExecStart=/opt/relayer/start.sh'
295297
echo '[Install]'
296298
echo 'WantedBy=multi-user.target'
@@ -308,5 +310,5 @@ systemctl status relayer
308310

309311
cd ~/nunya
310312
nvm use
311-
yarn run secret:submitRequestValue
312-
yarn run secret:submitRetrievePubkey
313+
# yarn run secret:submitRequestValue
314+
# yarn run secret:submitRetrievePubkey

0 commit comments

Comments
 (0)