Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Update/binary kdf #364

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/data/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@
"href": "/komodo-defi-framework/tutorials/api-docker-telegram/"
},
{
"title": "Compile MM2 from Source",
"title": "Compile KDF from Source",
"href": "/komodo-defi-framework/tutorials/how-to-compile-mm2-from-source/"
},
{
"title": "How to Query the MM2 SQLite Database",
"title": "How to Query the KDF SQLite Database",
"href": "/komodo-defi-framework/tutorials/query-the-mm2-database/"
},
{
Expand Down Expand Up @@ -331,7 +331,7 @@
"href": "/komodo-wallet/desktop/access-log-files/"
},
{
"title": "Send Commands to an MM2 Instance Being Run by Komodo Wallet using Postman",
"title": "Send Commands to an KDF Instance Being Run by Komodo Wallet using Postman",
"href": "/komodo-wallet/desktop/send-commands-to-mm2-instance/"
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const title = "Komodo DeFi Framework Method: Add Node to Version Stat";
export const description = "The add_node_to_version_stat method adds a Node's name, IP address and PeerID to a local database to track which version of MM2 it is running.";
export const description = "The add_node_to_version_stat method adds a Node's name, IP address and PeerID to a local database to track which version of KDF it is running.";

# add\_node\_to\_version\_stat

The `add_node_to_version_stat` method adds a Node's name, IP address and PeerID to a local database to track which version of MM2 it is running. The name parameter is an arbitrary identifying string, such as "seed\_alpha" or "dragonhound\_DEV". The address parameter is the node's IP address or domain names. The Peer ID can be found in the MM2 log file after a connection has been initiated, and looks like the below:
The `add_node_to_version_stat` method adds a Node's name, IP address and PeerID to a local database to track which version of KDF it is running. The name parameter is an arbitrary identifying string, such as "seed\_alpha" or "dragonhound\_DEV". The address parameter is the node's IP address or domain names. The Peer ID can be found in the KDF log file after a connection has been initiated, and looks like the below:

`07 09:33:58, atomicdex_behaviour:610] INFO Local peer id: PeerId("12D3KooWReXsTVCKGAna1tzrD1jaUttTSs17ULFuvvzoGD9bqmmA")
`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const title = "Komodo DeFi Framework Method: Remove Node from Version Stat";
export const description = "The remove_node_from_version_stat method removes a Node from the local database that tracks which version of MM2 it is running.";
export const description = "The remove_node_from_version_stat method removes a Node from the local database that tracks which version of KDF it is running.";

# remove\_node\_from\_version\_stat

The `remove_node_from_version_stat` method removes a Node (by name) from the local database which tracks which version of MM2 it is running. The name parameter is an arbitrary identifying string, such as "seed\_alpha" or "dragonhound\_DEV".
The `remove_node_from_version_stat` method removes a Node (by name) from the local database which tracks which version of KDF it is running. The name parameter is an arbitrary identifying string, such as "seed\_alpha" or "dragonhound\_DEV".

## Arguments

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export const description =

# Komodo DeFi API configuration

Komodo DeFi-API configuration parameters, along with additional runtime flags, and per-process environment variables are [listed in the source code](https://github.com/KomodoPlatform/komodo-defi-framework/blob/main/mm2src/mm2_main/src/mm2.rs#L151-L205), and can be viewed by running the `./mm2 --help`.
Komodo DeFi-API configuration parameters, along with additional runtime flags, and per-process environment variables are [listed in the source code](https://github.com/KomodoPlatform/komodo-defi-framework/blob/main/mm2src/mm2_main/src/mm2.rs#L151-L205), and can be viewed by running the `./kdf --help`.

## MM2.json

When running the Komodo DeFi API via commandline with the `mm2` binary, some basic configuration parameters need to be defined in either an `MM2.json` file, or at runtime.
When running the Komodo DeFi API via commandline with the `kdf` binary, some basic configuration parameters need to be defined in either an `MM2.json` file, or at runtime.

### Configuration Parameters

Expand All @@ -19,7 +19,7 @@ When running the Komodo DeFi API via commandline with the `mm2` binary, some bas
| passphrase | string | Your passphrase; this is the source of each of your coins private keys. [**KEEP IT SAFE!**](https://www.youtube.com/watch?v=WFpxVbTqhB8) |
| rpc\_password | string | For RPC requests that need authentication, this will need to match the `userpass` value in the request body. |
| allow\_weak\_password | boolean | Optional, defaults to `false`. If `true`, will allow low entropy rpc\_password. If `false` rpc\_password must not have 3 of the same characters in a row, must be between 8-32 characters in length, must contain at least one of each of the following: numeric, uppercase, lowercase, special character (e.g. !#$\*). It also can not contain the word "password", or the chars `<`, `>`, or `&`. |
| dbdir | string | Optional, defaults to a subfolder named `DB` in the path of your `mm2` binary. This path will store the Komodo DeFi-API database data. |
| dbdir | string | Optional, defaults to a subfolder named `DB` in the path of your `kdf` binary. This path will store the Komodo DeFi-API database data. |
| rpcip | string | Optional, defaults to `127.0.0.1`. IP address to bind to for RPC server. |
| rpcport | integer | Optional, defaults to `7783`. Port to use for RPC communication. |
| rpc\_local\_only | boolean | Optional, defaults to `true`. If `false` the Komodo DeFi Framework API will allow rpc methods sent from external IP addresses. **Warning:** Only use this if you know what you are doing, and have put the appropriate security measures in place. |
Expand Down Expand Up @@ -111,7 +111,7 @@ The structure for adding additional coins can vary, please refer to the [listing

| Variable | Type | Description |
| ------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| MM2\_CONF\_PATH | string | A file path to load the `MM2.json` configuration file. Defaults to `MM2.json` in the same folder as the `mm2` binary. |
| MM2\_CONF\_PATH | string | A file path to load the `MM2.json` configuration file. Defaults to `MM2.json` in the same folder as the `kdf` binary. |
| MM\_COINS\_PATH | string | A file path to load the `coins` configuration file. A comprehensive version for public use is maintained in the [Komodo Platform coins github repository](https://github.com/KomodoPlatform/coins/blob/master/coins) |
| MM\_LOG | string | A file path to store the Komodo DeFi-API logs. |
| USERPASS | string | For convenience, this variable can store the value of your `rpc_password` to be referenced in any shell scripts |
Expand Down
2 changes: 1 addition & 1 deletion src/pages/komodo-defi-framework/setup/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ If everything installed successfully, a response that is similar to the followin
“Finished dev [optimized + debuginfo] target(s) in 3m 33s”
```

The Komodo DeFi Framework API executable is now built and available here: `~/komodo-defi-framework/target/debug/mm2`
The Komodo DeFi Framework API executable is now built and available here: `~/komodo-defi-framework/target/debug/kdf`
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ We also need to create an MM2.json file in the same directory as the `coins` fil
The MM2.json configuration commands can also be supplied at runtime, as below:

```bash
stdbuf -oL ./mm2 "{\"gui\":\"Docs_Walkthru\",\"netid\":8762, \"passphrase\":\"YOUR_PASSPHRASE_HERE\", \"rpc_password\":\"YOUR_PASSWORD_HERE\"}" &
stdbuf -oL ./kdf "{\"gui\":\"Docs_Walkthru\",\"netid\":8762, \"passphrase\":\"YOUR_PASSPHRASE_HERE\", \"rpc_password\":\"YOUR_PASSWORD_HERE\"}" &
```

Replace `YOUR_PASSPHRASE_HERE` and `YOUR_PASSWORD_HERE` with your actual passphrase and password, and then execute the command in the terminal.
Expand Down Expand Up @@ -167,7 +167,7 @@ You should now see your userpass printed to the console.
The `userpass` environment variable will remain in memory until the session is
closed. When you open up a new session later, you'll need to create the
`userpass` environment variable again. Additional environment variables for
the Komodo DeFi Framework API can be found in the [configure mm2
the Komodo DeFi Framework API can be found in the [configure KDF
guide](/komodo-defi-framework/setup/configure-mm2-json/).
</Note>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export const description = "This guide describes how to update a coins file in a

## Instructions

* Compile the latest `mm2` binary following [these instructions](/komodo-defi-framework/setup/)
* Place the `coins` file in the old format in the same directory as the compiled `mm2` binary
* Compile the latest `kdf` binary following [these instructions](/komodo-defi-framework/setup/)
* Place the `coins` file in the old format in the same directory as the compiled `kdf` binary
* Open a terminal and navigate to the directory with both the files
* Run the following command `./mm2 update_config coins coins_new`
* Run the following command `./kdf update_config coins coins_new`

<Note>
`mm2` can accept any valid paths as the arguments for the source and destination files
Expand All @@ -23,7 +23,7 @@ Success

* You will find a new file named `coins_new` in the same directory with the new format expected by Komodo DeFi Framework
* Rename the file named `coins` to `coins_old` and then `coins_new` to `coins`
* `mm2` will use the `coins` file in the new format the next time it is launched
* `kdf` will use the `coins` file in the new format the next time it is launched

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ For example:
```bash
mkdir -p ~/komodo-defi-framework/target/debug
cd ~/komodo-defi-framework/target/debug
wget https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/beta-2.1.4315/mm2-9fe6e9402-Linux-Release.zip
unzip mm2-9fe6e9402-Linux-Release.zip
wget $(curl --silent https://api.github.com/repos/KomodoPlatform/komodo-defi-framework/releases | jq -r '.[0].assets[] | select(.name | endswith("Linux-Release.zip")).browser_download_url')
unzip *Linux-Release.zip
```

Then you can proceed to [download the coins configuration file](/komodo-defi-framework/tutorials/how-to-become-a-liquidity-provider/#step-2-download-the-coins-configuration-file).
Expand Down Expand Up @@ -187,7 +187,7 @@ We now have basic scripts to use the Komodo DeFi Framework API as a liquidity pr
To start the Komodo DeFi Framework API:

```bash
stdbuf -oL nohup ./mm2
stdbuf -oL nohup ./kdf
```
</Note>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const description = "This guide describes how to query the MM2 SQLite dat

# How to Query the MM2 SQLite Database

The Komodo DeFi Framework API stores historical information such as swaps and orders within an SQLite database, located under the DB user data folder (e.g. {'{folder continaing mm2 binary}'}/DB/{'{wallet identifying hex string}'}/MM2.db').
The Komodo DeFi Framework API stores historical information such as swaps and orders within an SQLite database, located under the DB user data folder (e.g. {'{folder continaing kdf binary}'}/DB/{'{wallet identifying hex string}'}/MM2.db').

There are a variety of methods to query sqlite databases. Examples below show how to do a sqlite query in Linux terminal, but first you might need to install sqlite with `sudo apt install sqlite3`.

Expand Down Expand Up @@ -124,7 +124,7 @@ This table stores a record of results returned by registered nodes [tracked for
| -- | --------- | ------------ | -------------------------------------------- |
| 0 | id | INTEGER | Primary Key |
| 1 | name | VARCHAR(255) | Node name |
| 2 | version | VARCHAR(255) | Node Komodo DeFi Framework API (mm2) version |
| 2 | version | VARCHAR(255) | Node Komodo DeFi Framework API (kdf) version |
| 3 | timestamp | INTEGER | Timestamp |
| 4 | error | VARCHAR(255) | Error details |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apt-get install -y unzip jq curl
wget $(curl --silent https://api.github.com/repos/KomodoPlatform/komodo-defi-framework/releases | jq -r '.[0].assets[] | select(.name | endswith("Linux-Release.zip")).browser_download_url')
wget https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins
unzip *Linux-Release.zip
./mm2 "{\"netid\":8762,\"gui\":\"aws_cli\",\"passphrase\":\"SEED_WORDS_PLEASE_REPLACE\",\"rpc_password\":\"RPC_PASS_PLEASE_REPLACE\",\"myipaddr\":\"0.0.0.0\"}"
./kdf "{\"netid\":8762,\"gui\":\"aws_cli\",\"passphrase\":\"SEED_WORDS_PLEASE_REPLACE\",\"rpc_password\":\"RPC_PASS_PLEASE_REPLACE\",\"myipaddr\":\"0.0.0.0\"}"
```

## Install AWS CLI , get AWS access credentials
Expand Down Expand Up @@ -47,9 +47,9 @@ In the terminal commands below, note that you must first change the texts `REPLA
```bash
export AWS_ACCESS_KEY_ID=REPLACE_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=REPLACE_SECRET_ACCESS_KEY
aws ec2 create-key-pair --region us-east-1 --key-name mm2Keypair | jq -r .KeyMaterial > ~/.ssh/mm2.pem
chmod 400 ~/.ssh/mm2.pem
sgID=$(aws ec2 create-security-group --region us-east-1 --group-name sgMM2 --description "sg-mm2"| jq -r '.GroupId')
aws ec2 create-key-pair --region us-east-1 --key-name mm2Keypair | jq -r .KeyMaterial > ~/.ssh/kdf.pem
chmod 400 ~/.ssh/kdf.pem
sgID=$(aws ec2 create-security-group --region us-east-1 --group-name sgMM2 --description "sg-kdf"| jq -r '.GroupId')
aws ec2 authorize-security-group-ingress --region us-east-1 --group-name sgMM2 --protocol all --cidr 0.0.0.0/0
aws ec2 run-instances --region us-east-1 --image-id ami-083d24fb90054e5f0 --count 1 --instance-type t3.micro --key-name mm2Keypair --security-group-ids $sgID --user-data file://komodo_defi_framework_setup.txt
```
Expand All @@ -69,7 +69,7 @@ From the linked page above, copy the "IPv4 Public IP" of the instance and use it

```bash
nodeIp=REPLACE_PUBLIC_IP
ssh -o IdentitiesOnly=yes -i ~/.ssh/mm2.pem admin@$nodeIp 'curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"RPC_UserP@SSW0RD\",\"method\":\"version\"}"'
ssh -o IdentitiesOnly=yes -i ~/.ssh/kdf.pem admin@$nodeIp 'curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"RPC_UserP@SSW0RD\",\"method\":\"version\"}"'
```

Edit the command above as necessary to exchange one curl command for another from [the Komodo DeFi Framework API.](/komodo-defi-framework/api/)
Loading
Loading