Only consider using this if you are already familiar with the SETUP file and have already followed the steps to install all relevant dependencies, since this document assumes that has already been done and skips many steps.
It may be used to create a script in future.
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.
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.
-
Setup remote editing
- Install and open Visual Studio Code
- Install Plugin "Remote Explorer"
- Remote Explorer
- Click SSH > + (Note: Use your own IP address)
- Enter
ssh [email protected]
, choose to update /Users/luke/ssh/config - Click 172.105.184.209 > "root" > "Connect in Current Window"
- Enter
- Go to Extensions, search for "solidity", and click the apply that extension to "SSH 172.105.184.209" for syntax highlighting
- Use the "Terminal" in Visual Studio code to interact
-
Clone https://github.com/svub/nunya into
~/nunya
-
Fetch latest from branch 'submit-pubkey'
git fetch origin submit-pubkey:submit-pubkey git checkout submit-pubkey
-
Clone https://github.com/ltfschoen/SecretPath into
~/ltfschoen
-
Fetch latest from branch 'nunya'
git fetch origin nunya:nunya git checkout nunya
-
Run the following on a remote server:
./scripts/run.sh
-
Wait for it to all load
-
Run
cd ~/nunya && nvm use && yarn run secret:submitRequestValue
OR
cd ~/nunya && nvm use && yarn run secret:submitRetrievePubkey
-
Watch the logs
- Ethereum Local Node
journalctl -u ethlocal.service -f
- Optionally store in a file:
journalctl -u ethlocal.service -f | tee ~/nunya/ethlocal.service.log
- Optionally store in a file:
- Secret Local Node
docker logs -f --tail 10 secretdev
- Optionally store in a file:
docker logs -f secretdev | tee ~/nunya/secret-docker.log
- Optionally store in a file:
- Relayer
journalctl -u relayer.service -f
- Optionally store in a file:
journalctl -u relayer.service -f | tee ~/nunya/relayer.service.log
- Optionally store in a file:
- Ethereum Local Node
cd /Users/luke/code/clones/github/svub/nunya
REMOTE_IP=172.105.184.209
SOURCE=/Users/luke/code/clones/github/svub/nunya/packages/hardhat/.env
DESTINATION=/root/nunya/packages/hardhat/.env
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
SOURCE=/Users/luke/code/clones/github/svub/nunya/packages/secret-contracts-scripts/.env
DESTINATION=/root/nunya/packages/secret-contracts-scripts/.env
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
SOURCE=/Users/luke/code/clones/github/svub/nunya/packages/secret-contracts-scripts/src/config/config.ts
DESTINATION=/root/nunya/packages/secret-contracts-scripts/src/config/config.ts
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
* Start here
ssh [email protected]
cd ~/nunya
nvm use
git fetch origin submit-pubkey:submit-pubkey
git checkout submit-pubkey
cd ~/nunya/packages/secret-contracts/secret-gateway
git submodule update --init --recursive
nvm use
docker stop secretdev && docker rm secretdev
* WAIT
make start-server
* OPTIONAL (IF NECESSARY)
docker logs -f --tail 10 secretdev
* TODO - turn into service that can start and stop and reset
ssh [email protected]
cd ~/nunya
nvm use
yarn hardhat:chain
* TODO - turn into service that can start and stop and reset
ssh [email protected]
cd ~/nunya
nvm use
yarn hardhat:clean
yarn hardhat:compile
yarn hardhat:deploy --network localhost
yarn run secret:setEVMGatewayAddress
* PREPARE ABI USED FOR ROUTING INFO
* UPDATE CONFIG `gatewayContractAdminAddress` before deploy Secret Gateway
SOURCE=/Users/luke/code/clones/github/svub/nunya/packages/secret-contracts-scripts/src/config/config.ts
DESTINATION=/root/nunya/packages/secret-contracts-scripts/src/config/config.ts
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
cd ~/nunya/packages/secret-contracts/nunya-contract
make clean
make build
cd ~/nunya/packages/secret-contracts/secret-gateway
make clean
make build
cd ~/nunya
yarn install
yarn run secret:clean
yarn run secret:uploadGateway
OR (combine with instantiate)
```bash
yarn run secret:uploadAndInstantiateGateway
```
* UPDATE CONFIG AND RUN ON LOCAL IF DIFFERS
SOURCE=/Users/luke/code/clones/github/svub/nunya/packages/secret-contracts-scripts/src/config/config.ts
DESTINATION=/root/nunya/packages/secret-contracts-scripts/src/config/config.ts
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
* IMPORTANT: If the CODE_HASH changes due to changes in the Secret Gateway codebase, it is also necessary to update the `code_hash` in the Relay to match it.
yarn run secret:instantiateGateway
- Get the Secret Gateway public key (signing verification key '0x' prefixed hex string) and base64 encryption key
yarn run secret:querySecretGatewayPubkey
Example output:
```
res queryPubkey: {
encryption_key: '...',
verification_key: '0x...'
}
```
* Paste `verification_key` into Gateway.sol for value of `secret_gateway_signer_pubkey`
* Redeploy if differs Gateway.sol
* Paste them into config.ts, `gatewayContractPublicKey` with `verification_key` and `gatewayContractEncryptionKeyForChaChaPoly1305` with `encryption_key`
* UPDATE CONFIG AND RUN ON LOCAL IF DIFFERS
```bash
SOURCE=/Users/luke/code/clones/github/svub/nunya/packages/secret-contracts-scripts/src/config/config.ts
DESTINATION=/root/nunya/packages/secret-contracts-scripts/src/config/config.ts
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
yarn run secret:clean
yarn run secret:upload
OR (combine with instantiate)
```bash
yarn run secret:uploadAndInstantiateNunya
```
# UPDATE IF DIFFERS config.ts
yarn run secret:instantiate
# UPDATE IF DIFFERS config.ts
docker exec -it secretdev secretcli tx bank send secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03 secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg 100000000000000000uscrt -y
docker exec -it secretdev secretcli query bank balances secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg | jq
cd ~/nunya
nvm use
cd ~/ltfschoen/SecretPath/TNLS-Relayers
git fetch origin nunya:nunya
git checkout nunya
- IF NECESSARY
REMOTE_IP=172.105.184.209
SOURCE=/Users/luke/code/clones/github/ltfschoen/SecretPath/TNLS-Relayers/config.yml
DESTINATION=/root/ltfschoen/SecretPath/TNLS-Relayers/config.yml
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
REMOTE_IP=172.105.184.209
SOURCE=/Users/luke/code/clones/github/ltfschoen/SecretPath/TNLS-Relayers/.env
DESTINATION=/root/ltfschoen/SecretPath/TNLS-Relayers/.env
scp -r $SOURCE root@$REMOTE_IP:$DESTINATION
docker exec -it secretdev secretcli tx bank send secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03 secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg 100000000000000000uscrt -y
docker exec -it secretdev secretcli query bank balances secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg | jq
conda activate secretpath_env
pip install -r requirements.txt --no-dependencies
pip install --upgrade lru-dict
python3 web_app.py
-
RUN AFTER RELAYER STARTED
-
Record logs from Localsecret since the output is too long otherwise. Press CTRL+C to cancel when PostExecution occurs in Ethereum Local Network logs to indicate it has finished.
docker logs -f secretdev | tee ~/nunya/docker.log
- Run end-to-end transaction
cd ~/nunya
nvm use
yarn run secret:submitRequestValue
yarn run secret:submitRetrievePubkey
- Copy Localsecret logs from remote machine to local.
REMOTE_IP=172.105.184.209
SOURCE=/root/nunya/docker.log
DESTINATION=/Users/luke/code/clones/github/svub/nunya
scp -r root@$REMOTE_IP:$SOURCE $DESTINATION
- Decode the base64
result
value (e.g.eyJ...n0=\
from Localsecret logs at https://base64.guru/converter/decode/text
INFO [enclave_contract_engine::wasm3] debug_print: "msg: PostExecutionMsg {\n result: \"eyJfcmVxdWVzdF9pZCI6eyJuZXR3b3JrIjoiMzEzMzciLCJ0YXNrX2lkIjoiNCJ9LCJfa2V5IjpbMiwyNTEsMTg4LDE0MywxNjMsMTExLDM0LDE1OCwxNjcsODIsMTE1LDE4OSwyNSwyMzksMTcyLDEyNiw4LDY3LDIzMCwxMzgsNTAsNzcsODEsMTEzLDEyMiwyMDEsNzYsMjE5LDI0Myw1NSwxMzQsMjE0LDg2XSwiX2NvZGUiOjAsIl9udW55YV9idXNpbmVzc19jb250cmFjdF9hZGRyZXNzIjoiMHhBRkZGMzExODIxQzNGM0FGODYzQzcxMDNCQjE3QkRDMUJhMDQ2MDNEIn0=\"
- 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.