Skip to content

Commit

Permalink
chore: update README and unused codes
Browse files Browse the repository at this point in the history
  • Loading branch information
inon-man committed Sep 1, 2023
1 parent 92a82df commit 8b15387
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 48 deletions.
32 changes: 11 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ This solution has 2 components:
2. `curl -o docker-compose.yml https://raw.githubusercontent.com/classic-terra/oracle-feeder/main/docker-compose.yml`

3. Review the docker-compose.yml service oracle-feeder and change ENV accordingly
* ORACLE_FEEDER_PASSWORD=password (Optional) (Oracle feeder keyring password)
* ORACLE_FEEDER_MNENOMIC="mnemonic" (Mandatory) (Oracle feeder mnemonic, this address will be responsible for updating price)
* ORACLE_FEEDER_VALIDATORS=terravaloper1xxx (Mandatory) (Oracle feeder validator that feeder address is bount to) [How to bound?](feeder/README.md#make-a-new-key-for-oracle-votes) (**REMEMBER TO BOUND YOUR VOTER TO VALIDATOR BEFORE RUNNING**)
* ORACLE_FEEDER_LCD_ADDRESS=https://terra-classic-lcd.publicnode.com,https://lcd.terraclassic.community (Optional)
* ORACLE_FEEDER_CHAIN_ID=columbus-5 (Optional)
* ORACLE_FEEDER_ADDR_PREFIX=terra (Optional)

* ORACLE_FEEDER_PASSWORD=password (required) Oracle feeder keyring password
* ORACLE_FEEDER_MNENOMIC=word1 word2... (required) (Oracle feeder mnemonic, this address will be responsible for updating price)
* ORACLE_FEEDER_VALIDATORS=terravaloper1xxx (required) (Oracle feeder validator that feeder address is bount to) [How to bound?](feeder/README.md#make-a-new-key-for-oracle-votes) (**REMEMBER TO BOUND YOUR VOTER TO VALIDATOR BEFORE RUNNING**)
* ORACLE_FEEDER_LCD_ADDRESS=https://terra-classic-lcd.publicnode.com,https://lcd.terraclassic.community (optional)
* ORACLE_FEEDER_CHAIN_ID=columbus-5 (optional)

4. Bring up your stack by running

Expand All @@ -52,16 +51,7 @@ This solution has 2 components:

## Manual deployment instructions

1. Install nodejs v18.x [Node.js version 18 or greater](https://nodejs.org/)

```sh
curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh
chmod +x /tmp/nodesource_setup.sh
sudo /tmp/nodesource_setup.sh
sudo apt-get install nodejs -y
node --version
> v18.15.0
```
1. Install Node.js (https://nodejs.org/)

2. Clone this repository

Expand Down Expand Up @@ -95,14 +85,14 @@ npm install
# configure to use feeder account
npm start add-key

# start voting
# start voting (note: multiple lcd-url and validators can be specified)
$ npm start vote -- \
-d http://localhost:8532/latest \
--data-source-url http://localhost:8532/latest \
--lcd-url https://terra-classic-lcd.publicnode.com \
--lcd-url https://lcd.terraclassic.community \
--chain-id columbus-5 \
--validators terravaloper1xx \
--validators terravaloper1yy \
--password "<password>"
--validators <terravaloper address> \
--password <password>
```

### Cheat Sheet:
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ services:
environment:
- ORACLE_FEEDER_DATA_SOURCE_URL=http://oracle-price-server:8532/latest
- ORACLE_FEEDER_PASSWORD=password
- ORACLE_FEEDER_MNENOMIC=mnemonic
- ORACLE_FEEDER_VALIDATORS=terravaloper1xxx
- ORACLE_FEEDER_MNENOMIC=word1 word2...
- ORACLE_FEEDER_VALIDATORS=terravaloper1...
restart: always
networks:
- terra-classic

networks:
terra-classic:
driver: bridge
driver: bridge
2 changes: 1 addition & 1 deletion feeder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV ORACLE_FEEDER_CHAIN_ID=columbus-5
ENV ORACLE_FEEDER_KEY_NAME=voter
ENV ORACLE_FEEDER_KEY_PATH=voter.json
ENV ORACLE_FEEDER_COIN_TYPE=330
ENV ORACLE_FEEDER_ADDR_PREFIX="terra"
ENV ORACLE_FEEDER_ADDR_PREFIX=terra

WORKDIR /app

Expand Down
12 changes: 6 additions & 6 deletions feeder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ You can start feeder with arguments or env.
-d http://localhost:8532/latest \
--lcd-url https://lcd.terraclassic.community \
--chain-id colmbus-5 \
--validators anrvaloper1xx \
--validators anrvaloper1yy \
--password "<password>"
--validators terravaloper1xx \
--validators terravaloper1yy \
--password <password>
```

* Env
Expand All @@ -77,9 +77,9 @@ You can start feeder with arguments or env.
| `data-source-url` | `ORACLE_FEEDER_DATA_SOURCE_URL` | Price server URL. | http://localhost:8532/latest |
| `lcd-url` | `ORACLE_FEEDER_LCD_ADDRESS` | LCD server URL (can be multiple) | https://lcd.terraclassic.community |
| `chain-id` | `ORACLE_FEEDER_CHAIN_ID` | Chain ID. | `colmbus-5 ` |
| `validators` | `ORACLE_FEEDER_VALIDATORS` | Validator to submit prices for (can be multiple) | `anrvaloper1xx...` |
| `validators` | `ORACLE_FEEDER_VALIDATORS` | Validator to submit prices for (can be multiple) | `terravaloper1xx...` |
| `key-name` | `ORACLE_FEEDER_KEY_NAME` | name to be given to the key that will be encrypted in file| `voter` |
| `coin-type` | `ORACLE_FEEDER_COIN_TYPE` | coin type used to derive the public address (default 118) | `118` |
| `coin-type` | `ORACLE_FEEDER_COIN_TYPE` | coin type used to derive the public address (default 330) | `330` |
| `key-path` | `ORACLE_FEEDER_KEY_PATH` | signing key store path (default voter.json) | `voter.json` |
| Unsupported | `ORACLE_FEEDER_ADDR_PREFIX` | | `` |
| Unsupported | `ORACLE_FEEDER_ADDR_PREFIX` | | `terra` |
| Unsupported | `ORACLE_FEEDER_IV_SALT` | salt used in IV vector | `myHashedIV` |
8 changes: 2 additions & 6 deletions feeder/src/addKey.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as keystore from './keystore'
import * as promptly from 'promptly'

export async function addKey(filePath: string, coinType: string, keyName: string, prefix: string): Promise<void> {
export async function addKey(filePath: string, coinType: string, keyName: string): Promise<void> {
let password = process.env.ORACLE_FEEDER_PASSWORD || ''
let mnemonic = process.env.ORACLE_FEEDER_MNENOMIC || ''

Expand Down Expand Up @@ -34,10 +34,6 @@ export async function addKey(filePath: string, coinType: string, keyName: string
return
}

if (!prefix) {
prefix = await promptly.prompt(`\nEnter the address prefix: `)
}

await keystore.save(filePath, keyName, password, mnemonic, coinType, prefix)
await keystore.save(filePath, keyName, password, mnemonic, coinType)
console.info(`saved!`)
}
7 changes: 3 additions & 4 deletions feeder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function registerCommands(parser: ArgumentParser): void {
required: false,
})

voteCommand.addArgument([`--validators`], {
voteCommand.addArgument([`-v`, `--validators`], {
action: `append`,
help: `validators address (e.g. terravaloper1...), can have multiple`,
dest: `validators`,
Expand Down Expand Up @@ -96,9 +96,8 @@ async function main(): Promise<void> {
registerCommands(parser)
const args = parser.parseArgs()

args.prefix = args.prefix || process.env.ORACLE_FEEDER_ADDR_PREFIX || process.env.ADDR_PREFIX

if (args.subparser_name === `vote`) {
args.prefix = args.prefix || process.env.ORACLE_FEEDER_ADDR_PREFIX
args.lcdUrl =
args.lcdUrl || (process.env.ORACLE_FEEDER_LCD_ADDRESS && process.env.ORACLE_FEEDER_LCD_ADDRESS.split(',')) || []

Expand Down Expand Up @@ -126,7 +125,7 @@ async function main(): Promise<void> {

await vote(args)
} else if (args.subparser_name === `add-key`) {
await addKey(args.keyPath, args.coinType, args.keyName, args.prefix)
await addKey(args.keyPath, args.coinType, args.keyName)
}
}

Expand Down
8 changes: 1 addition & 7 deletions feeder/src/keystore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ interface Entity {

interface PlainEntity {
privateKey: string
publicKey: string
terraAddress: string
terraValAddress: string
}

const ivSalt = process.env.ORACLE_FEEDER_IV_SALT || 'myHashedIV'
Expand Down Expand Up @@ -60,8 +57,7 @@ export async function save(
name: string,
password: string,
mnemonic: string,
coinType: string,
prefix: string
coinType: string
): Promise<void> {
if (!fs.existsSync(filePath)) {
fs.writeFileSync(filePath, '')
Expand All @@ -78,8 +74,6 @@ export async function save(
const ciphertext = encrypt(
JSON.stringify({
privateKey: mnemonicKey.privateKey.toString(`hex`),
terraAddress: mnemonicKey.accAddress,
terraValAddress: mnemonicKey.valAddress,
}),
password
)
Expand Down

0 comments on commit 8b15387

Please sign in to comment.