Skip to content

Commit

Permalink
Merge pull request #3 from enigmampc/master
Browse files Browse the repository at this point in the history
Updating to Latest Heaad
  • Loading branch information
mohammedpatla authored Jul 24, 2020
2 parents 284f6e2 + 0339f9d commit 3d91b7e
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 14 deletions.
16 changes: 10 additions & 6 deletions docs/lcd-server-example.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
1. Put this file in `/etc/systemd/system/secret-lcd.service`
2. Make sure `/bin/secretcli` is the right path for secretcli
3. Make sure port 443 is open
4. Make sure `secret-1` is the right chain ID
4. Make sure `--chain-id` is the right chain ID
5. Make sure `ubuntu` is the right user
6. Enable on startup: `sudo systemctl enable secret-lcd`
7. Start now: `sudo systemctl start secret-lcd`

```
[Unit]
Expand All @@ -13,7 +11,7 @@ After=network.target
[Service]
Type=simple
ExecStart=/bin/secretcli rest-server --chain-id secret-1 --laddr tcp://0.0.0.0:1337
ExecStart=/bin/secretcli rest-server --chain-id secret-1 --laddr tcp://127.0.0.1:1337
User=ubuntu
Restart=always
StartLimitInterval=0
Expand All @@ -24,8 +22,14 @@ LimitNOFILE=65535
WantedBy=multi-user.target
```

Enable on startup and start:
```bash
sudo systemctl enable secret-lcd
sudo systemctl start secret-lcd
```

Then, install caddy: https://caddyserver.com/docs/download#debian-ubuntu-raspbian
Edit /etc/caddy/Caddyfile to have this inside (Replace `bootstrap.int.testnet.enigma.co` with your domain name):
Edit `/etc/caddy/Caddyfile` to have this inside (Replace `bootstrap.int.testnet.enigma.co` with your domain name):
```
bootstrap.int.testnet.enigma.co
Expand All @@ -48,5 +52,5 @@ reverse_proxy 127.0.0.1:1337
And then:
```bash
sudo systemctl enable caddy.service
sudo systemctl start caddy.service
sudo systemctl start caddy.service
```
68 changes: 68 additions & 0 deletions docs/testnet/deploy-contract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## WARNING - Work in progress and unfinished

### General

The general steps we perform to create a secret contract are:

1. Upload Code - Upload some optimized wasm code, no state nor contract address (example Standard ERC20 contract)
2. Instantiate Contract - Instantiate a code reference with some initial state, creates new address (example set token name, max issuance, etc for my ERC20 token)
3. Execute Contract - This may support many different calls, but they are all unprivileged usage of a previously instantiated contract, depends on the contract design (example: Send ERC20 token, grant approval to other contract)

In this guide we will focus on steps 1 and 2.

You can read more about the process, and other comparisons to Solidity, in the [cosmwasm documentation](https://www.cosmwasm.com/docs/getting-started/smart-contracts).

### 1. Download the prebuilt contract

`<todo: add link>`

### 2. Upload the optimized contract.wasm:

```
secretcli tx compute store contract.wasm --from <wallet_name> --gas auto -y
```

#### Check that your code was uploaded properly

List current smart contract code

```
secretcli query compute list-code
[
{
"id": 1,
"creator": "secret1klqgym9m7pcvhvgsl8mf0elshyw0qhruy4aqxx",
"data_hash": "0C667E20BA2891536AF97802E4698BD536D9C7AB36702379C43D360AD3E40A14",
"source": "",
"builder": ""
}
]
```

You should see the `data_hash` of `TBD` with your address as the `creator`

### 3. Instantiate the Smart Contract

At this point the contract's been uploaded and stored on the testnet, but there's no "instance". This allows to deploy multiple instances from the same code, for example if you wanted to create multiple different "ERC-20" coins from the same base contract. You can read more about the logic behind this decision, and other comparisons to Solidity, in the [cosmwasm documentation](https://www.cosmwasm.com/docs/getting-started/smart-contracts).

To create an instance of this project we must also provide some JSON input data, a starting count.

```
INIT="{\"count\": 100000000}"
CODE_ID=<code_id from previous step>
secretcli tx compute instantiate $CODE_ID "$INIT" --from a --label "my counter" -y --keyring-backend test
```
With the contract now initialized, we can find its address

secretcli query compute list-contract-by-code 1

Our instance is secret18vd8fpwxzck93qlwghaj6arh4p7c5n8978vsyg

We can query the contract state

CONTRACT=secret18vd8fpwxzck93qlwghaj6arh4p7c5n8978vsyg
secretcli query compute contract-state smart $CONTRACT "{\"get_count\": {}}"

And we can increment our counter

secretcli tx compute execute $CONTRACT "{\"increment\": {}}" --from a
8 changes: 8 additions & 0 deletions docs/testnet/verify-sgx.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,11 @@ ERROR: failed to create attestation report: Error calling the VM: SGX_ERROR_SERV
```

Make sure the `aesmd-service` is running `systemctl status aesmd.service`

* I'm seeing `CONFIGURATION_AND_SW_HARDENING_NEEDED` in the `isvEnclaveQuoteStatus` field

This could mean a number of different things related to the configuration of the machine, but one such example we encountered was if hyper-threading is enabled in the BIOS. It must be disabled (see: https://software.intel.com/security-software-guidance/software-guidance/l1-terminal-fault)

* I'm seeing `SGX_ERROR_DEVICE_BUSY`

Most likely you tried reinstalling the driver and rerunning the enclave - restarting should solve the problem
4 changes: 1 addition & 3 deletions docs/validators-and-full-nodes/join-validator-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ perl -i -pe 's/^minimum-gas-prices = .+?$/minimum-gas-prices = "0.1uscrt"/' ~/.s
sudo systemctl restart secret-node
```

Your validator will not propose transactions that specify `--gas-price` lower than the `minimun-gas-price` you set here.

This is the main parameter the affects your ROI, so you should adjust it with time.
Your validator will not accept transactions that specify `--gas-price` lower than the `minimun-gas-price` you set here.

### 3. Generate a new key pair for yourself (change `<key-alias>` with any word of your choice, this is just for your internal/personal reference):

Expand Down
8 changes: 6 additions & 2 deletions docs/validators-and-full-nodes/setup-sgx.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ If you're running a local machine and not a cloud-based VM -
Note: `sgx_linux_x64_driver_2.6.0_602374c.bin` is the latest driver as of July 13, 2020. Please check under https://download.01.org/intel-sgx/sgx-linux/ that this is still the case. If not, please send us a PR or notify us.

```bash
#! /bin/bash

UBUNTUVERSION=$(lsb_release -r -s | cut -d '.' -f 1)
PSW_PACKAGES='libsgx-enclave-common libsgx-urts sgx-aesm-service libsgx-uae-service autoconf libtool'
PSW_PACKAGES='libsgx-enclave-common libsgx-urts sgx-aesm-service libsgx-uae-service autoconf libtool make'

if (($UBUNTUVERSION < 16)); then
echo "Your version of Ubuntu is not supported. Must have Ubuntu 16.04 and up. Aborting installation script..."
Expand Down Expand Up @@ -101,6 +103,8 @@ Then you can use this script (or run the commands one-by-one), which was tested
### Install SGX SDK + Driver

```bash
#! /bin/bash

UBUNTUVERSION=$(lsb_release -r -s | cut -d '.' -f 1)

if (($UBUNTUVERSION < 16)); then
Expand All @@ -117,7 +121,7 @@ echo "##### Installing missing packages #####"
echo "#######################################\n\n"

# Install needed packages for script
sudo apt install -y lynx parallel gdebi
sudo apt install -y lynx parallel gdebi make

# Create a working directory to download and install the SDK inside
mkdir -p "$HOME/.sgxsdk"
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4625,9 +4625,9 @@ lodash.uniq@^4.5.0:
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=

lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.3, lodash@^4.17.5:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==

loglevel@^1.6.8:
version "1.6.8"
Expand Down

0 comments on commit 3d91b7e

Please sign in to comment.