Skip to content

Commit 16478ce

Browse files
ebuchmanhu55a1n1
andauthored
fix(docs): getting started for docker and neutrond (#264)
Co-authored-by: Shoaib Ahmed <[email protected]>
1 parent 399d731 commit 16478ce

File tree

6 files changed

+141
-57
lines changed

6 files changed

+141
-57
lines changed

docker/neutrond/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ import-local-accounts:
88
create-local-accounts: import-local-accounts
99
@echo "Local accounts have been created."
1010

11-
.PHONY: create-local-accounts import-local-accounts
11+
.PHONY: create-local-accounts import-local-accounts

docker/neutrond/data/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rm -rf /root/.neutrond/keyring-test &> /dev/null
66
neutrond tendermint unsafe-reset-all
77

88
# Init configuration files
9-
neutrond init test --chain-id test-1 --overwrite
9+
neutrond init test --chain-id testing --overwrite
1010

1111
# Modify default configurations
1212
sed -i 's/keyring-backend = "os"/keyring-backend = "test"/g' /root/.neutrond/config/client.toml

docs/getting_started.md

+91-25
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ Onwards with the installation and running our example app!
6565
### Installation
6666

6767
Quartz is built in Rust (+wasm32 target). It expects to interact with a CosmWasm compatible
68-
blockchain (eg. `neutrond`), built in Go (or run with Docker). And it requires `npm` for
69-
building the frontend. Here we cover how to install Rust, Quartz, and CosmWasm
70-
blockchains. You're responsible for installing Go and NPM.
68+
blockchain (eg. `neutrond`), built in Go (or run with Docker).
69+
It also requires a local version of `neutrond` for handling signing keys. And it requires `npm` for
70+
building the frontend. Here we cover how to install Rust, Quartz, and Neutrond. You're responsible for installing Go and NPM (and optionally Docker).
7171

7272
Pre-reqs:
7373
- Git
7474
- Make
75-
- Go or Docker
76-
- Docker desktop v.4.34.3 with `host networking` enabled [here](https://docs.docker.com/engine/network/drivers/host/?uuid=67f19d61-ae59-4996-9060-01ebef9a586c%0A#docker-desktop).
75+
- Go
76+
- Docker
77+
- For Mac, Docker desktop v.4.34.3 with `host networking` enabled [here](https://docs.docker.com/engine/network/drivers/host/?uuid=67f19d61-ae59-4996-9060-01ebef9a586c%0A#docker-desktop).
7778
- NPM
7879

7980
#### Install Rust
@@ -109,22 +110,62 @@ And check that it worked:
109110
quartz --help
110111
```
111112

112-
#### Install a CosmWasm Client
113+
#### Install Neutrond
113114

114-
For the local testnet, we can use `neutrond` with a single validator (we have a docker image for this).
115+
A version of `neutrond` is required both for running a node and for managing
116+
keys. Running the node can be done via docker, which is easier to get running,
117+
but the Go binary will have to be installed regardless for signing transactions.
115118

116-
For `neutrond`:
119+
To install the `neutrond` binary:
120+
121+
```bash
122+
git clone -b main https://github.com/neutron-org/neutron.git
123+
cd neutron
124+
git checkout v4.0.1
125+
make install-test-binary
126+
```
127+
128+
You can now start the node either using this version of `neutrond` or using
129+
Docker.
130+
131+
To use your local `neutrond` to run the node, you'll have to setup your
132+
config and genesis files. See the [neutrond setup guide](/docs/neutrond_setup.md), and then return back here and
133+
skip down to the bottom of this section.
134+
135+
Alternatively, you can start the node using docker.
136+
137+
If you're on Mac using Docker Desktop, make sure to enable [host networking](https://docs.docker.com/engine/network/drivers/host/?uuid=67f19d61-ae59-4996-9060-01ebef9a586c%0A#docker-desktop).
138+
139+
Then:
117140

118141
```bash
119142
cd docker
120143
docker compose up node
121144
```
122145

123146
It will pre-configure a few keys (admin, alice, etc.) and allocate funds to them.
124-
The default sending account for quartz txs is `admin`.
147+
The default sending account for txs is `admin`, as specified in
148+
`examples/transfers/quartz.toml`.
125149

126-
If building from source, you'll need to initialize the accounts yourself. See
127-
the guide on [setting up a CosmWasm chain](/docs/neutrond_setup.md) and then return back here.
150+
Finally, you'll need to import the keys from the docker container into your
151+
local `neutrond`. From inside the `docker` dir:
152+
153+
```bash
154+
tail -n 1 neutrond/data/accounts/admin.txt | neutrond keys add admin --no-backup --recover --keyring-backend=test
155+
```
156+
157+
If you already have a key called `admin` in your keystore you'll have to rename it first.
158+
159+
If you want to use a different name then `admin`, be sure to also change it in
160+
the `examples/transfers/quartz.toml` and everywhere we use it below.
161+
162+
Check that the key is there:
163+
164+
```bash
165+
neutrond keys show admin
166+
```
167+
168+
And you're good to go!
128169

129170
### Local neutrond Testnet Without SGX
130171

@@ -139,6 +180,30 @@ We can deploy the enclave and contract all at once using the `quartz dev`
139180
convenience command (like in the [quick start](#quick-start)), but here we'll
140181
show the individual commands.
141182

183+
### Configure Key
184+
185+
At the moment, we have to do an insecure operation to export the private key to
186+
be used for signing transactions so it can be used by the enclave. This is a
187+
temporary hack.
188+
189+
If you're using docker, the key is hardcoded:
190+
191+
```bash
192+
export ADMIN_SK=ffc4d3c9119e9e8263de08c0f6e2368ac5c2dacecfeb393f6813da7d178873d2
193+
```
194+
195+
Otherwise, you can set the key like so:
196+
197+
```bash
198+
export ADMIN_SK=$(yes | neutrond keys export admin --unsafe --unarmored-hex)
199+
```
200+
201+
Now make sure the key is set:
202+
203+
```bash
204+
echo $ADMIN_SK
205+
```
206+
142207
### Enclave
143208

144209
First we build and run the enclave code.
@@ -188,11 +253,6 @@ environment variable:
188253
export CONTRACT_ADDRESS=<CONTRACT_ADDRESS>
189254
```
190255

191-
You must also set the admin secret key:
192-
193-
```bash
194-
export ADMIN_SK=ffc4d3c9119e9e8263de08c0f6e2368ac5c2dacecfeb393f6813da7d178873d2
195-
```
196256

197257
3. Perform the handshake:
198258
```bash
@@ -209,11 +269,11 @@ environment variable:
209269
export PUBKEY=<PUBKEY>
210270
```
211271

212-
Now the contract is ready to start processing requests to the enclave. You will see logs from the enclave showing:
272+
Now the contract is ready to start processing requests to the enclave!
213273

214-
```bash
215-
2024-09-24T11:12:25.156779Z INFO Enclave is listening for requests...
216-
```
274+
The enclave process should be showing logs that it's listening for request.
275+
There's a bug so it won't right now, and will show some error you can ignore.
276+
Good times. Let's move on to setting up the frontend.
217277

218278
### Frontend
219279

@@ -235,8 +295,10 @@ You can run the front end on your local computer, so it is easy to test in a bro
235295
```
236296

237297
Now open `.env.local` and edit the values of `NEXT_PUBLIC_TRANSFERS_CONTRACT_ADDRESS` and
238-
`NEXT_PUBLIC_ENCLAVE_PUBLIC_KEY` to be the contract address and pubkey from the previous step. With quartz dev, they can be grabbed
239-
from the logs. From the manual process, you would have already stored them as environment variables.
298+
`NEXT_PUBLIC_ENCLAVE_PUBLIC_KEY` to be the contract address and pubkey from the previous step.
299+
You should have them stored as environment variables `$CONTRACT_ADDRESS` and
300+
`$PUBKEY`. (Note if you ran `quartz dev` instead of all the manual steps you can
301+
get them out of the logs)
240302

241303
4. Finally, start the frontend:
242304
```bash
@@ -251,22 +313,26 @@ if you are just testing and you don't clear your browser storage, you will be fi
251313

252314
You'll need to have the Keplr wallet browser extension installed and unlocked.
253315

254-
You may have to go to "Manage Chain Visibility" in Keplr settings to add the `My
255-
Testing Chain` so you can talk to your local chain and see your balance.
316+
You may have to go to "Manage Chain Visibility" in Keplr settings to add the
317+
`Local Neutron Testchain` so you can talk to your local chain and see your balance.
256318

257319
Create a new address in Keplr for testing purpose. You'll need to send this
258320
address some funds from the `admin` account setup with your local node. For
259321
instance, send 10M untrn with:
260322

261323
```bash
262-
neutrond tx bank send admin <KEPLR ADDRESS> 10000000untrn --chain-id testing
324+
neutrond tx bank send admin <KEPLR ADDRESS> 10000000untrn --chain-id testing --fees 10000untrn
263325
```
264326

265327
You should now see the funds on your local testnet on Keplr.
266328

267329
Now you can interact with the app by depositing funds, privately transferring
268330
them to other addresses, and finally withdrawing them.
269331

332+
If you want to test multiple addresses, create the other addresses in Keplr and
333+
be sure to send them some `untrn` from the `admin` account so they can pay for
334+
gas.
335+
270336
Be sure to check the enclave window to see the logs from your interaction with
271337
the app!
272338

docs/neutrond_setup.md

+45-27
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# CosmWasm Binaries: Manual Install and Configure
1+
# Neutrond Setup
22

3-
> Note - We highly recommend setting up `neutrond` with the docker image provided. However, we have provided these detailed instructions in case you wanted to take a deeper look.
3+
> Note - We would like to highly recommend setting up the `neutrond` node with the docker image provided. However, we also understand that docker is a poison upon the human soul, and thus provide these instructions for setting up the neutrond node locally, without imbibing such poision. It will probably take less time to follow these instructions than it will to build the docker image anyways. Up to you 🫡
44
55
Quartz expects to interact with a CosmWasm-based blockchain.
6-
The default/archetypal binary is `neutrond`. We have included instructions for `wasmd`, but it is not supported in the cli today.
6+
The default/archetypal binary is `neutrond`. Currently its hardcoded to use
7+
`neutrond` though of course we will make this configurable soon.
78

89
Here we describe how to get setup from scratch or how to use an existing `neutrond`
910
binary/network you have access to.
@@ -21,39 +22,33 @@ For `neutrond`:
2122
```bash
2223
git clone -b main https://github.com/neutron-org/neutron.git
2324
cd neutron
24-
git checkout v4.0.0
25-
make install
26-
```
27-
28-
For `wasmd` (NOTE - NOT SUPPORTED BY CLI):
29-
30-
```bash
31-
git clone https://github.com/cosmwasm/wasmd/
32-
cd wasmd
33-
git checkout v0.45.0
34-
go install ./cmd/wasmd
25+
git checkout v4.0.1
26+
make install-test-binary
3527
```
3628

3729
## Configure From Scratch
3830

3931
We have to initialize a new chain and load it with some accounts.
4032

41-
We'll assume you're using `neutrond` but it could be `wasmd` or any other.
33+
If you already have `neutrond` keys, you may need to rename them or use
34+
different names if the names overlap.
4235

4336
We also have to give the chain a chain ID. We'll use `testing`.
4437

4538
Run
4639

4740
```bash
48-
neutrond init <your name> --chain-id testing
41+
neutrond init yourname --chain-id testing --default-denom untrn
4942
```
5043

5144
to initialize the local neutrond folder.
5245

5346
Now open the file `~/.neutrond/config/client.toml` and change the field
5447
`keyring-backend` from `os` to `test`:
5548

56-
```toml keyring-backend = "test" ```
49+
```toml
50+
keyring-backend = "test"
51+
```
5752

5853
Now, finally, we can create a local admin key for your neutrond. You'll use this to
5954
deploy contracts:
@@ -62,25 +57,24 @@ deploy contracts:
6257
neutrond keys add admin
6358
```
6459

60+
If you already have a key called `admin` in your keystore it's advised to rename it first.
61+
If you want to use a different name then `admin`, be sure to also change it in
62+
the `examples/transfers/quartz.toml` and everywhere we use it below.
63+
6564
This should output a neutron address.
6665

6766
Now create the genesis file.
6867

6968
```bash
70-
# generate a second key for the validator
71-
neutrond keys add validator
72-
73-
# fund both accounts in genesis
74-
neutrond genesis add-genesis-account admin 100000000000stake,100000000000ucosm
75-
neutrond genesis add-genesis-account validator 100000000000stake,100000000000ucosm
69+
# fund the account in genesis
70+
neutrond add-genesis-account admin 100000000000untrn
7671

77-
# sign genesis tx from validator and compose genesis
78-
neutrond genesis gentx validator 100000000stake --chain-id testing
79-
neutrond genesis collect-gentxs
72+
# configure the ICS setup (neutrond expects to run as a consumer chain)
73+
neutrond add-consumer-section
8074
```
8175

8276
Before finally starting the node, for it to work with the front end, you need to
83-
configure CORS.
77+
configure CORS and a min gas price.
8478

8579
### Configure CORS
8680

@@ -102,6 +96,30 @@ address = "tcp://0.0.0.0:1317"
10296
enabled-unsafe-cors = true
10397
```
10498

99+
### Configure min gas
100+
101+
In `~/.neutrond/config/app.toml`, set the min gas price:
102+
103+
```toml
104+
minimum-gas-prices = "0.0001untrn"
105+
```
106+
107+
And in `~/.neutrond/config/genesis.json`, set the denom and the feemarket min gas price:
108+
109+
```json
110+
"fee_denom": "untrn",
111+
```
112+
113+
```json
114+
"min_base_gas_price": "0.000100000000000000",
115+
```
116+
117+
and
118+
119+
```json
120+
"base_gas_price": "0.000100000000000000",
121+
```
122+
105123
Now, finally:
106124

107125
## neutrond start

examples/transfers/frontend/src/config/chains/localNeutron.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ChainInfo } from '@keplr-wallet/types'
22

33
// Neutron local chain definition
44
export const localNeutron: ChainInfo = {
5-
chainId: 'test-1',
5+
chainId: 'testing',
66
chainName: 'Local Neutron Testchain',
77
rpc: 'http://localhost:26657',
88
rest: 'http://localhost:1317',

examples/transfers/quartz.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
mock_sgx = true
22
tx_sender = "admin"
3-
chain_id = "test-1"
3+
chain_id = "testing"
44
node_url = "http://127.0.0.1:26657"
55
ws_url = "ws://127.0.0.1:26657/websocket"
66
grpc_url = "http://127.0.0.1:9090"
77
enclave_rpc_addr = "http://127.0.0.1"
88
enclave_rpc_port = 11090
99
trusted_hash = ""
1010
trusted_height = 0
11-
release = true
11+
release = true

0 commit comments

Comments
 (0)