Skip to content

Commit

Permalink
add setup scripts and templates for testcoins
Browse files Browse the repository at this point in the history
  • Loading branch information
smk762 committed Jun 14, 2024
1 parent d7522b3 commit 3f1b528
Show file tree
Hide file tree
Showing 16 changed files with 567 additions and 95 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,7 @@ etomic_build/seed/DB
etomic_build/seed/stats.log
etomic_build/seed/unparsed.txt
iguana/exchanges/manychains
iguana/pubkey.txt
docker/.env
docker/run_DOC.sh
docker/run_MARTY.sh
193 changes: 98 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,22 @@ There is also the chance to win some KMD! The top 3 participants will receive 10
Sync'ing the KMD chain will take some time (over 24hrs), so you should start this process as soon as possible. Alternatively, you can use the [KMD testnet bootstrap](https://seed2.komodo.earth/boots/hfnet_blk_3940000.tar.gz) to speed up the process.


### Step 2: Setup docker and launch the other chains
During the testnet, we will notarise the DOC and MARTY test chains. We'll run these in [docker](https://www.docker.com/) containers - Follow the instructions below to install `docker` and `docker compose`.

- [Docker](https://docs.docker.com/engine/install/ubuntu/) / [w/ convenience script](https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script)
- [Docker Compose](https://docs.docker.com/compose/install/linux/#install-using-the-repository)
- Docker linux post install steps: https://docs.docker.com/engine/install/linux-postinstall/ , Configure Docker to start on boot with systemd

_You can also run these chains natively if you prefer, but you will need to build the komodod binary from source again (using the `master` branch)._

Now we can build and launch DOC & MARTY chains with the following commands:
```
cd ~/dPoW/docker
docker compose build # Build the docker images
docker compose up -d # Launch the chains in the background
docker compose logs -f -n 33 # Check the logs to confirm the chains are operational
```

Once these chains are running, you will need to [import the private key](https://komodoplatform.com/en/docs/smart-chains/api/wallet/#importprivkey) you generated in step 1 into the wallets for these chains.

To speed up the sync process, bootstraps for DOC and MARTY are kindly supplied by CHMEX via https://dexstats.info/bootstrap.php


### Step 3: Fund your nodes!
### Step 2: Fund your nodes!

- For DOC and MARTY, you can use the faucet button in the [Komodo Wallet](https://app.komodoplatform.com/#/dex) app. **DO NOT import your notary private keys into any other wallet apps. It should only ever be on your notary node server.** You can use the faucet while logged into a different wallet, and then simply send the funds to your notary node address.

- For KMD, ask in the #2024-testnet channel on Discord. As we are running `komodod` on a testnet branch, mainnet KMD will not work.


### Step 4: Register your pubkey
### Step 3: Register your pubkey

- Once you have your pubkey, post it in the #2024-testnet channel on Discord. You will be added to the testnet network within 24 hours, and will be able to start notarising.
- Make sure you have have launched the daemons with the [`pubkey` runtime parameter](https://komodoplatform.com/en/docs/smart-chains/setup/common-runtime-parameters/#pubkey), with your registered pubkey. This is required for notarisation to work. You can also add this to your `komodo.conf` file if you prefer to make sure it is included at each launch. If the chain is already running you can also use the [setpubkey](https://komodoplatform.com/en/docs/smart-chains/api/wallet/#setpubkey) method to set the pubkey.
- Open a pull request to this branch, adding your pubkey to the [testnet.json](https://github.com/KomodoPlatform/dPoW/blob/2023-testnet/iguana/testnet.json) file. Please ensure you include your Discord username within the pull request. New pubkeys will be added to the testnet network every 24 hours, and the update announced in the #2024-testnet channel on Discord.
- Once your pubkey is merged into the testnet.json file, you can start notarising!


### Step 5: Install dPoW
### Step 4: Install dPoW

- Make sure your chains are fully synced before you start notarising. You can check the status of your chains by using the [getinfo](https://komodoplatform.com/en/docs/smart-chains/api/control/#getinfo) method in the wallet API.
- Clone dPoW and checkout the `2024-testnet` branch
Expand All @@ -92,64 +70,129 @@ curl --url "http://127.0.0.1:7762" --data "{\"method\":\"walletpassphrase\",\"pa
- Open the Iguana P2P port with `sudo ufw allow 17762 comment '2024 Testnet Iguana'`


`cd iguana`
### Step 5: Setup docker and launch the other chains
During the testnet, we will notarise the DOC and MARTY test chains. We'll run these in [docker](https://www.docker.com/) containers - Follow the instructions below to install `docker` and `docker compose`.

#### Build iguana for notary operations
- [Docker](https://docs.docker.com/engine/install/ubuntu/) / [w/ convenience script](https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script)
- [Docker Compose](https://docs.docker.com/compose/install/linux/#install-using-the-repository)
- Docker linux post install steps: https://docs.docker.com/engine/install/linux-postinstall/ , Configure Docker to start on boot with systemd

_You can also run these chains natively if you prefer, but you will need to build the komodod binary from source again (using the `master` branch)._

`make`
Now we can build and launch DOC & MARTY chains with the following commands:
```
cd ~/dPoW/docker
./setup.sh # Setup misc configs
#
docker compose build # Build the docker images
docker compose up -d # Launch the chains in the background
docker compose logs -f -n 33 # Check the logs to confirm the chains are operational
```

#### Start main-net notarizations:
Once these chains are running, you will need to [import the private key](https://komodoplatform.com/en/docs/smart-chains/api/wallet/#importprivkey) you generated in step 1 into the wallets for these chains.

`./m_notary_main`
```
doc-cli importprivkey YOUR_PRIVATE_KEY
marty-cli importprivkey YOUR_PRIVATE_KEY
```

#### Start 3rd party notarizations:
To speed up the sync process, bootstraps for DOC and MARTY are kindly supplied by CHMEX via https://dexstats.info/bootstrap.php

`./m_notary_3rdparty`

#### Start 3rd party notarizations (in Docker):
### Step 6: Build and start Iguana

`./m_notary_3rdparty_docker`
- Build iguana for notary operations
```
cd ~/dPoW/iguana
make
```

Make sure KMD, DOC and MARTY daemons are running and sync'd , then start testnet notarizations with `./m_notary_testnet_2024`
You will need to make sure you have split utxos in each chain to be able to notarize. Check below under the `Create a splitfunds script` section for a script to help you manage your utxos.

### Step 6: Start the KMD, DOC and MARTY daemons
For Komodo, as we are using a newer build of the daemon you can also try out a the [new rpc methods](https://github.com/DeckerSU/notaries-rpc-tools) for notary nodes!

Create a file named `launch_testnet_chains.sh` and add the launch parameters.
- Use `komodo-cli nn_getwalletinfo` to get a summary of your notary wallet:
```
#!/bin/bash
{
"currentSeason": 9,
"nn_index": 1,
"nn_name": "nodename_1",
"pubkey": "027cc2dbc4652ec08589a557e1a01973a94186b587b140732de4589b36f95c7ac9",
"pubkey_address": "RHvMGxDces1zvLiD9hDgjV5mUjUK7kNs7z",
"ismine": true,
"transactions_count": 10,
"available_coins_count": 61,
"notaryvins_utxos_count": 59,
"others_utxos_count": 2
}
```
- use `komodo-cli nn_split` to split utxos:
```
{
"tx": "18c3171362dd81a62b8e2ba568994569d7b878af098ffa6bdf7cc6df12e4ab99",
"input_utxos_value": 0.98900000,
"input_utxos_count": 1,
"out_notaryvins_count": 10,
"out_utxos_value": 0.98790000,
"out_utxos_count": 1,
"estimated_tx_size": 348,
"real_tx_size": 651
}
```
_Note: As we are running a testnet, you wont see the returned txid on the mainnet KMD block explorer. Keep an eye out in the #2024-testnet channel for a link to the testnet block explorer once it is up and running_.

source ~/dPoW/iguana/pubkey.txt
**Good luck! Don't be shy to ask questions and learn from the Vetern Notary Node Operators in Discord!**

komodod -pubkey=$pubkey &
komodod -ac_name=MARTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -ac_staked=10 -addnode=65.21.77.109 -addnode=65.21.51.47 -pubkey=$pubkey &
komodod -ac_name=DOC -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -ac_staked=10 -addnode=65.21.77.109 -addnode=65.21.51.47 -pubkey=$pubkey &
```

Make the script executable with `chmod +x launch_testnet_chains.sh`, then launch the chains with `./launch_testnet_chains.sh`
## Bonus Tips

#### Create symbolic links for the komodod & komodo-cli
```
sudo ln -sf /home/$USER/komodo/src/komodo-cli /usr/local/bin/komodo-cli
sudo ln -sf /home/$USER/komodo/src/komodod /usr/local/bin/komodod
```

You can check the status of these chains with
#### check the status of coin deamons
```
tail -f ~/.komodo/debug.log
tail -f ~/.komodo/DOC/debug.log
tail -f ~/.komodo/MARTY/debug.log
```

### Import your private key to all chains
#### Import private key without rescanning
This will import without rescanning which is faster but will not display existing balance.
`komodo-cli importprivkey YOUR_PRIVATE_KEY "" true $(komodo-cli getblockcount)`

#### Check your balances
- `komodo-cli getbalance`
- `komodo-cli -ac_name=DOC getbalance` (or `doc-cli getbalance` if running in docker)
- `komodo-cli -ac_name=MARTY getbalance` (or `marty-cli getbalance` if running in docker)
```
komodo-cli importprivkey YOUR_PRIVATE_KEY "" true $(komodo-cli getblockcount) # This will import without rescanning which is faster but will not display existing balance.
komodo-cli -ac_name=DOC importprivkey YOUR_PRIVATE_KEY
komodo-cli -ac_name=MARTY importprivkey YOUR_PRIVATE_KEY
If any of these returns a zero balance, make sure the chain is fully synced and that you have imported your private key correctly. If in doubt, ask for help in the #2024-testnet channel on Discord.
#### Bootstrap chain data
- Make sure you stop the chain first with `komodo-cli stop` or `komodo-cli -ac_name=CHAINNAME stop`
- Delete existing chain data in `~/.komodo` or `~/.komodo/CHAINNAME`
```
rm -rf blocks/ chainstate/ database/ db.log fee_estimates.dat komodo.pid komodostate .lock notarisations/ realtime signedmasks
```
- Download bootstrap file with `wget <URL TO BOOTSTRAP>`
- Once the download is complete, extract the file with `tar -xvf <BOOTSTRAP FILE>`
### Check your balances
#### Wallet whitelist filter
- To mitigate potential spam attacks, you can implement a whitelist filter which only allows funds incoming from certain addresses. This can be done by adding the following to your `komodo.conf` or `CHAINNAME.conf` files:
```
komodo-cli getbalance
komodo-cli -ac_name=DOC getbalance
komodo-cli -ac_name=MARTY getbalance
whitelistaddress=R9gWj7fzSxZtJZCSDMQz5G5J7x4rg6UmiQ # Test coin faucet address (leave this as is)
whitelistaddress=YOUR_NODE_KMD_ADDRESS # Your registered KMD address (MUST be included, or else split utxos will not be available for notarisation)
```
If any of these returns a zero balance, make sure the chain is fully synced and that you have imported your private key correctly. If in doubt, ask for help in the #2024-testnet channel on Discord.
Add any extra addresses like your [Komodo Wallet](https://app.komodoplatform.com/) address which you might be sending funds from. If funds are recieved from a non-whitelisted address, they will be ignored (though they may still be visible on the block explorer). There are ways to recover these hidden funds which will be revealed to participants during the testnet.
### Create a splitfunds script
#### Create a splitfunds script
Create split script called `split_testnet.sh`. Use the following template as an example.
Expand Down Expand Up @@ -201,47 +244,7 @@ Add the following entry: `0 * * * * /home/YOURUSERNAME/split_testnet.sh > /home/
This will check/replenish your UTXOs every hour


### Start Iguana
```
cd ~/dPoW/iguana
./m_notary_build
./m_notary_testnet_2023
```

**Good luck! Don't be shy to ask questions and learn from the Vetern Notary Node Operators in Discord!**


## Bonus Tips

### Create symbolic links for the komodod & komodo-cli
```
sudo ln -sf /home/$USER/komodo/src/komodo-cli /usr/local/bin/komodo-cli
sudo ln -sf /home/$USER/komodo/src/komodod /usr/local/bin/komodod
```

### Bootstrap chain data

- Make sure you stop the chain first with `komodo-cli stop` or `komodo-cli -ac_name=CHAINNAME stop`
- Delete existing chain data in `~/.komodo` or `~/.komodo/CHAINNAME`
```
rm -rf blocks/ chainstate/ database/ db.log fee_estimates.dat komodo.pid komodostate .lock notarisations/ realtime signedmasks
```
- Download bootstrap file with `wget <URL TO BOOTSTRAP>`
- Once the download is complete, extract the file with `tar -xvf <BOOTSTRAP FILE>`


### Wallet whitelist filter
- To mitigate potential spam attacks, you can implement a whitelist filter which only allows funds incoming from certain addresses. This can be done by adding the following to your `komodo.conf` or `CHAINNAME.conf` files:
```
whitelistaddress=R9gWj7fzSxZtJZCSDMQz5G5J7x4rg6UmiQ # Test coin faucet address (leave this as is)
whitelistaddress=YOUR_NODE_KMD_ADDRESS # Your registered KMD address (MUST be included, or else split utxos will not be available for notarisation)
```
Add any extra addresses like your [Komodo Wallet](https://app.komodoplatform.com/) address which you might be sending funds from. If funds are recieved from a non-whitelisted address, they will be ignored (though they may still be visible on the block explorer). There are ways to recover these hidden funds which will be revealed to participants during the testnet.


### Extra resources
#### Extra resources
- Example `systemd` service file for KMD deamon & smartchains - https://github.com/smk762/DragonhoundTools/blob/master/server/systemd/komodo-deamon.service
- Webworker's scripts and tools https://github.com/webworker01/nntools
Expand Down
1 change: 1 addition & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-compose.yml
27 changes: 27 additions & 0 deletions docker/Dockerfile.KMD
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM komodoofficial/komodo:cd_release_a89b6e8_master

LABEL maintainer="[email protected]"

# Setup up user and working directory
ARG GROUP_ID
ARG USER_ID
ARG SERVICE_CLI
RUN addgroup --gid ${GROUP_ID} notarygroup
RUN adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} komodian
WORKDIR /home/komodian

RUN PATH=/usr/local/bin/:$PATH
RUN apt update && apt install -y nano htop libgomp1

HEALTHCHECK --start-period=15m --interval=15m --timeout=60s CMD CMD bash /usr/local/healthcheck.sh ${SERVICE_CLI} || exit 1
STOPSIGNAL SIGTERM

COPY healthcheck.sh /usr/local/bin
COPY entrypoint.sh /entrypoint.sh
COPY launch_files/ /

# Setup user and working directory
RUN chown -R komodian:notarygroup /home/komodian
USER komodian

ENTRYPOINT ["/entrypoint.sh"]
2 changes: 2 additions & 0 deletions docker/cli_wrappers/doc-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker exec -it doc komodo-cli -ac_name=DOC "$@"
2 changes: 2 additions & 0 deletions docker/cli_wrappers/marty-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker exec -it marty komodo-cli -ac_name=MARTY "$@"
24 changes: 24 additions & 0 deletions docker/conf_files/DOC.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
addnode=103.195.100.32 # Dragonhound_DEV
addnode=144.76.80.75 # Alright_DEV
addnode=148.113.1.52 # gcharang_AR
addnode=148.113.8.6 # gcharang_DEV
addnode=178.159.2.9 # Dragonhound_EU
addnode=209.222.101.247 # Dragonhound_NA
addnode=51.161.209.100 # gcharang_SH
addnode=65.21.77.109 # Alright_EU
addnode=77.75.121.138 # Dragonhound_AR
addnode=89.19.26.211 # Marmara1
addnode=89.19.26.212 # Marmara2
addnode=seed.komodostats.com # komodostats
addnode=seed.webworker.sh # webworker
daemon=1
rpcallowip=0.0.0.0/0
rpcworkqueue=256
server=1
txindex=1
whitelistaddress=R9gWj7fzSxZtJZCSDMQz5G5J7x4rg6UmiQ # Testcoin faucet address

port=62415
rpcbind=0.0.0.0:62416
rpcport=62416

24 changes: 24 additions & 0 deletions docker/conf_files/MARTY.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
addnode=103.195.100.32 # Dragonhound_DEV
addnode=144.76.80.75 # Alright_DEV
addnode=148.113.1.52 # gcharang_AR
addnode=148.113.8.6 # gcharang_DEV
addnode=178.159.2.9 # Dragonhound_EU
addnode=209.222.101.247 # Dragonhound_NA
addnode=51.161.209.100 # gcharang_SH
addnode=65.21.77.109 # Alright_EU
addnode=77.75.121.138 # Dragonhound_AR
addnode=89.19.26.211 # Marmara1
addnode=89.19.26.212 # Marmara2
addnode=seed.komodostats.com # komodostats
addnode=seed.webworker.sh # webworker
daemon=1
rpcallowip=0.0.0.0/0
rpcworkqueue=256
server=1
txindex=1
whitelistaddress=R9gWj7fzSxZtJZCSDMQz5G5J7x4rg6UmiQ # Testcoin faucet address

port=52592
rpcbind=0.0.0.0:52593
rpcport=52593

Loading

0 comments on commit 3f1b528

Please sign in to comment.