Skip to content

Removed federator.key and added a env var for that #339

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

Merged
merged 3 commits into from
May 24, 2022
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ See the ['federator'](./federator/README.md) for more information about federati

An integration test is prepared for contracts and federators. To properly run integration test, you need check network config in the `truffle-config.js` and `package.json` in `bridge` folder with your test chains' configuration before run `npm run deployIntegrationTest`.

For testing purposes only, an empty `test.local.federator.key` file is available in `federator/config`, which fulfills the role that a `federator.key` file would have in production.
For testing purposes only, you can let `env.FEDERATOR_KEY` empty, which fulfills the role that a `FEDERATOR_KEY` key would have in production.
Also, a `test.local.config.js` configuration is provided in `federator/config` for the same purpose, acting as the `config.js` file would in a productive environment.

1. Check `mnemonic.key` in `bridge`
Expand Down
1 change: 1 addition & 0 deletions federator/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FEDERATOR_KEY=08141073f8a519b93255153c334438bb9cd998eb9b51f9723cc07931655c90df
4 changes: 2 additions & 2 deletions federator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config/config.js
config/federator.key
rskregtest.json
development.json
development_1.json
Expand All @@ -7,7 +8,6 @@ mirrorDevelopment.json
soliditycoverage.json
test.json
latestBlock.txt
config/federator.key
test/lib/*.txt
coverage
manuallyCheck.txt
Expand All @@ -18,4 +18,4 @@ heartbeat.log
federator.log
/built
/abis
/config/test.local.federator.key
.env
4 changes: 2 additions & 2 deletions federator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The federators will be the owners of the contracts willing to allow to cross the

## Config

Go to /federator/config copy `config.sample.js` file and rename it to `config.js` set mainchain and sidechain to point to the json files of the networks you are using, for example rsktestnet-kovan.json and kovan.json, `make sure to set the host parameter of those files`. Create the file `federator.key` inside the config folder, and add the private key of the member of the Federation contract. The members of the federation are controled by the MultiSig contract, same that is owner of the Bridge and AllowedTokens contracts.
Go to /federator/config copy `config.sample.js` file and rename it to `config.js` set mainchain and sidechain to point to the json files of the networks you are using, for example rsktestnet-kovan.json and kovan.json, `make sure to set the host parameter of those files`. Add a value to the key `FEDERATOR_KEY` in the .env file, and add the private key of the member of the Federation contract. The members of the federation are controled by the MultiSig contract, same that is owner of the Bridge and AllowedTokens contracts.
You will also need to add an [etherscan api key](https://etherscan.io/myapikey) in this config file.
## Usage

Expand All @@ -30,7 +30,7 @@ module.exports = {
sidechain: [require('./kovan.json')],
runEvery: 1, // In minutes,
confirmations: 10,// Number of blocks before processing it,
privateKey: require('federator.key'),
privateKey: process.env.FEDERATOR_KEY || '',
storagePath: './db',
etherscanApiKey: '<YOUR ETHERSCAN API KEY>',
runHeartbeatEvery: 1, // Frequency for emitting HeartBeat events
Expand Down
7 changes: 5 additions & 2 deletions federator/config/config.sample.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const fs = require("fs");
const dotenv = require('dotenv');

dotenv.config();

module.exports = {
mainchain: require("./rsktestnet.json"), //the json containing the smart contract addresses in rsk
sidechain: [
require("./kovan.json"), //the json containing the smart contract addresses in eth
],
runEvery: 2, // In minutes,
privateKey: fs.readFileSync(`${__dirname}/federator.key`, "utf8"),
privateKey: process.env.FEDERATOR_KEY || '',
storagePath: "./db",
etherscanApiKey: "",
runHeartbeatEvery: 1, // In hours
Expand Down
7 changes: 5 additions & 2 deletions federator/config/test.local.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const fs = require("fs");
const dotenv = require('dotenv');

dotenv.config();

module.exports = {
mainchain: require("./development.json"), //the json containing the smart contract addresses in rsk
sidechain: require("./mirrorDevelopment.json"), //the json containing the smart contract addresses in eth
runEvery: 2, // In minutes,
privateKey: fs.readFileSync(`${__dirname}/test.local.federator.key`, "utf8"),
privateKey: process.env.FEDERATOR_KEY || '',
storagePath: "./db",
etherscanApiKey: "",
runHeartbeatEvery: 1, // In hours
Expand Down
14 changes: 14 additions & 0 deletions federator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions federator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"abi-decoder": "^2.4.0",
"axios": "^0.21.2",
"datadog-metrics": "^0.9.3",
"dotenv": "^16.0.1",
"ethereumjs-tx": "^1.3.7",
"ethereumjs-util": "^6.1.0",
"express": "^4.17.1",
Expand All @@ -41,6 +42,7 @@
"@types/jest": "^27.0.1",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"axios": "^0.21.2",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -49,12 +51,11 @@
"node-notifier": "^8.0.1",
"nodemon": "^2.0.15",
"prettier": "2.3.2",
"tar": ">=4.4.18",
"tmpl": "^1.0.5",
"ts-node": "^10.2.1",
"typescript": "^4.3.5",
"web3-core-promievent": "^1.2.11",
"tmpl": "^1.0.5",
"axios": "^0.21.2",
"tar": ">=4.4.18"
"web3-core-promievent": "^1.2.11"
},
"resolutions": {
"axios": "^0.21.2",
Expand Down