Refactor oracle configuration (#584)
This commit is contained in:
parent
8ed6550635
commit
6e1f57493a
@ -27,17 +27,6 @@
|
||||
set_fact:
|
||||
ORACLE_VALIDATOR_ADDRESS: "{{ VADDRESS.stdout }}"
|
||||
|
||||
- name: Get foreign erc type
|
||||
become_user: "{{ compose_service_user }}"
|
||||
shell: docker-compose run --rm --entrypoint "node scripts/initialChecks.js" bridge_affirmation
|
||||
args:
|
||||
chdir: "{{ bridge_path }}/oracle"
|
||||
register: ERCTYPE
|
||||
|
||||
- name: Set FOREIGN_ERC_TYPE variable
|
||||
set_fact:
|
||||
FOREIGN_ERC_TYPE: "{{ (ERCTYPE.stdout).foreignERC | default('') }}"
|
||||
|
||||
- name: Extend docker compose file for erc to native
|
||||
set_fact: composefileoverride="-f docker-compose-transfer.yml"
|
||||
when: ORACLE_BRIDGE_MODE == "ERC_TO_NATIVE"
|
||||
|
@ -6,8 +6,6 @@ COMMON_HOME_RPC_URL=http://parity1:8545
|
||||
COMMON_FOREIGN_RPC_URL=http://parity2:8545
|
||||
COMMON_HOME_BRIDGE_ADDRESS=0x8397be90BCF57b0B71219f555Fe121b22e5a994C
|
||||
COMMON_FOREIGN_BRIDGE_ADDRESS=0x1feB40aD9420b186F019A717c37f5546165d411E
|
||||
ORACLE_VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
COMMON_HOME_GAS_PRICE_SUPPLIER_URL=
|
||||
COMMON_HOME_GAS_PRICE_SPEED_TYPE=standard
|
||||
COMMON_HOME_GAS_PRICE_FALLBACK=1000000000
|
||||
|
@ -6,8 +6,6 @@ COMMON_HOME_RPC_URL=http://parity1:8545
|
||||
COMMON_FOREIGN_RPC_URL=http://parity2:8545
|
||||
COMMON_HOME_BRIDGE_ADDRESS=0x5118AC62AE912Dd5B51EEfF7338c4fcb0248Ba8c
|
||||
COMMON_FOREIGN_BRIDGE_ADDRESS=0x32198D570fffC7033641F8A9094FFDCaAEF42624
|
||||
ORACLE_VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
COMMON_HOME_GAS_PRICE_SUPPLIER_URL=https://gasprice.poa.network/
|
||||
COMMON_HOME_GAS_PRICE_SPEED_TYPE=standard
|
||||
COMMON_HOME_GAS_PRICE_FALLBACK=1
|
||||
|
@ -15,42 +15,46 @@ docker network create --driver bridge ultimate || true
|
||||
docker-compose up -d parity1 parity2 e2e
|
||||
|
||||
startValidator () {
|
||||
db_env="-e ORACLE_QUEUE_URL=amqp://$4 -e ORACLE_REDIS_URL=redis://$3"
|
||||
db_env="-e ORACLE_QUEUE_URL=amqp://$3 -e ORACLE_REDIS_URL=redis://$2"
|
||||
|
||||
docker-compose $1 run -d --name $3 redis
|
||||
docker-compose $1 run -d --name $4 rabbit
|
||||
docker-compose $1 run -d --name $2 redis
|
||||
docker-compose $1 run -d --name $3 rabbit
|
||||
|
||||
if [[ -z "$MODE" || "$MODE" == erc-to-native ]]; then
|
||||
docker-compose $1 run $2 $db_env -d oracle-erc20-native yarn watcher:signature-request
|
||||
docker-compose $1 run $2 $db_env -d oracle-erc20-native yarn watcher:collected-signatures
|
||||
docker-compose $1 run $2 $db_env -d oracle-erc20-native yarn watcher:affirmation-request
|
||||
docker-compose $1 run $2 $db_env -d oracle-erc20-native yarn watcher:transfer
|
||||
docker-compose $1 run $oraclePK $db_env -d oracle-erc20-native yarn watcher:signature-request
|
||||
docker-compose $1 run $oracleAddr $db_env -d oracle-erc20-native yarn watcher:collected-signatures
|
||||
docker-compose $1 run $oracleAddr $db_env -d oracle-erc20-native yarn watcher:affirmation-request
|
||||
docker-compose $1 run $oracleAddr $db_env -d oracle-erc20-native yarn watcher:transfer
|
||||
fi
|
||||
if [[ -z "$MODE" || "$MODE" == amb ]]; then
|
||||
docker-compose $1 run $2 $db_env -d oracle-amb yarn watcher:signature-request
|
||||
docker-compose $1 run $2 $db_env -d oracle-amb yarn watcher:collected-signatures
|
||||
docker-compose $1 run $2 $db_env -d oracle-amb yarn watcher:affirmation-request
|
||||
docker-compose $1 run $2 $db_env -d oracle-amb yarn watcher:information-request
|
||||
docker-compose $1 run $oraclePK $db_env -d oracle-amb yarn watcher:signature-request
|
||||
docker-compose $1 run $oracleAddr $db_env -d oracle-amb yarn watcher:collected-signatures
|
||||
docker-compose $1 run $oracleAddr $db_env -d oracle-amb yarn watcher:affirmation-request
|
||||
docker-compose $1 run $oracleAddr $db_env -d oracle-amb yarn watcher:information-request
|
||||
fi
|
||||
|
||||
docker-compose $1 run $2 $db_env -d oracle-amb yarn sender:home
|
||||
docker-compose $1 run $2 $db_env -d oracle-amb yarn sender:foreign
|
||||
docker-compose $1 run $2 $db_env -d oracle-amb yarn manager:shutdown
|
||||
docker-compose $1 run $oraclePK $db_env -d oracle-amb yarn sender:home
|
||||
docker-compose $1 run $oraclePK $db_env -d oracle-amb yarn sender:foreign
|
||||
docker-compose $1 run $oracleAddr $db_env -d oracle-amb yarn manager:shutdown
|
||||
}
|
||||
|
||||
while [ "$1" != "" ]; do
|
||||
if [ "$1" == "oracle" ]; then
|
||||
startValidator "-p validator1" "" redis rabbit
|
||||
oracleAddr="-e ORACLE_VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
||||
oraclePK="-e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||
startValidator "-p validator1" redis rabbit
|
||||
fi
|
||||
|
||||
if [ "$1" == "oracle-validator-2" ]; then
|
||||
oracle2Values="-e ORACLE_VALIDATOR_ADDRESS=0xdCC784657C78054aa61FbcFFd2605F32374816A4 -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=5a5c3645d0f04e9eb4f27f94ed4c244a225587405b8838e7456f7781ce3a9513"
|
||||
startValidator "-p validator2" "$oracle2Values" redis2 rabbit2
|
||||
oracleAddr="-e ORACLE_VALIDATOR_ADDRESS=0xdCC784657C78054aa61FbcFFd2605F32374816A4"
|
||||
oraclePK="-e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=5a5c3645d0f04e9eb4f27f94ed4c244a225587405b8838e7456f7781ce3a9513"
|
||||
startValidator "-p validator2" redis2 rabbit2
|
||||
fi
|
||||
|
||||
if [ "$1" == "oracle-validator-3" ]; then
|
||||
oracle3Values="-e ORACLE_VALIDATOR_ADDRESS=0xDcef88209a20D52165230104B245803C3269454d -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=f877f62a1c19f852cff1d29f0fb1ecac18821c0080d4cc0520c60c098293dca1"
|
||||
startValidator "-p validator3" "$oracle3Values" redis3 rabbit3
|
||||
oracleAddr="-e ORACLE_VALIDATOR_ADDRESS=0xDcef88209a20D52165230104B245803C3269454d"
|
||||
oraclePK="-e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=f877f62a1c19f852cff1d29f0fb1ecac18821c0080d4cc0520c60c098293dca1"
|
||||
startValidator "-p validator3" redis3 rabbit3
|
||||
fi
|
||||
|
||||
if [ "$1" == "alm" ]; then
|
||||
@ -84,13 +88,17 @@ while [ "$1" != "" ]; do
|
||||
if [ "$1" == "alm-e2e" ]; then
|
||||
MODE=amb
|
||||
|
||||
startValidator "-p validator1" "" redis rabbit
|
||||
oracleAddr="-e ORACLE_VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
||||
oraclePK="-e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||
startValidator "-p validator1" redis rabbit
|
||||
|
||||
oracle2Values="-e ORACLE_VALIDATOR_ADDRESS=0xdCC784657C78054aa61FbcFFd2605F32374816A4 -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=5a5c3645d0f04e9eb4f27f94ed4c244a225587405b8838e7456f7781ce3a9513"
|
||||
startValidator "-p validator2" "$oracle2Values" redis2 rabbit2
|
||||
oracleAddr="-e ORACLE_VALIDATOR_ADDRESS=0xdCC784657C78054aa61FbcFFd2605F32374816A4"
|
||||
oraclePK="-e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=5a5c3645d0f04e9eb4f27f94ed4c244a225587405b8838e7456f7781ce3a9513"
|
||||
startValidator "-p validator2" redis2 rabbit2
|
||||
|
||||
oracle3Values="-e ORACLE_VALIDATOR_ADDRESS=0xDcef88209a20D52165230104B245803C3269454d -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=f877f62a1c19f852cff1d29f0fb1ecac18821c0080d4cc0520c60c098293dca1"
|
||||
startValidator "-p validator3" "$oracle3Values" redis3 rabbit3
|
||||
oracleAddr="-e ORACLE_VALIDATOR_ADDRESS=0xDcef88209a20D52165230104B245803C3269454d"
|
||||
oraclePK="-e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=f877f62a1c19f852cff1d29f0fb1ecac18821c0080d4cc0520c60c098293dca1"
|
||||
startValidator "-p validator3" redis3 rabbit3
|
||||
fi
|
||||
|
||||
if [ "$1" == "generate-amb-tx" ]; then
|
||||
@ -98,19 +106,20 @@ while [ "$1" != "" ]; do
|
||||
fi
|
||||
|
||||
if [ "$1" == "manual-amb-relay" ]; then
|
||||
oraclePK="-e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||
env="-e COMMON_HOME_BRIDGE_ADDRESS=0x5A42E119990c3F3A80Fea20aAF4c3Ff4DB240Cc9 -e COMMON_FOREIGN_BRIDGE_ADDRESS=0x897527391ad3837604973d78D3514f44c36AB9FC"
|
||||
# these tx hash are hardcoded and need to be updated manually
|
||||
# once e2e environment setup process is changed
|
||||
echo '0xea625a823bc5018dc3a4efe349f623e5ebb8c987b55f44d50d6556f42af9a400' > txHashes.txt
|
||||
docker-compose -p validator1 run -v $(pwd)/txHashes.txt:/tmp/txHashes.txt $env oracle-amb yarn confirm:affirmation-request \
|
||||
docker-compose -p validator1 run -v $(pwd)/txHashes.txt:/tmp/txHashes.txt $oraclePK $env oracle-amb yarn confirm:affirmation-request \
|
||||
/tmp/txHashes.txt \
|
||||
0x031c42e44485002c9215a5b1b75e9516131485ce29884a58765bf7a0038538f9
|
||||
docker-compose -p validator1 run $env oracle-amb yarn confirm:signature-request \
|
||||
docker-compose -p validator1 run $oraclePK $env oracle-amb yarn confirm:signature-request \
|
||||
0x1506a18af91afe732167ccbc178b55fc2547da4a814d13c015b6f496cf171754 | tee .tmp.log
|
||||
tx_hash=$(cat .tmp.log | grep generatedTransactionHash | jq -r .generatedTransactionHash)
|
||||
rm .tmp.log
|
||||
rm txHashes.txt
|
||||
docker-compose -p validator1 run $env oracle-amb yarn confirm:collected-signatures $tx_hash
|
||||
docker-compose -p validator1 run $oraclePK $env oracle-amb yarn confirm:collected-signatures $tx_hash
|
||||
fi
|
||||
|
||||
shift # Shift all the parameters down by one
|
||||
|
@ -100,6 +100,8 @@ describe('erc to native', () => {
|
||||
|
||||
const transferValue = homeWeb3.utils.toWei('0.05')
|
||||
|
||||
// transfer that should not be processed by the filter
|
||||
await erc20Token.methods.transfer(secondUser.address, transferValue).send({ from: user.address, gas: 100000 })
|
||||
// send tokens to foreign bridge
|
||||
await erc20Token.methods
|
||||
.transfer(COMMON_FOREIGN_BRIDGE_ADDRESS, transferValue)
|
||||
|
@ -8,7 +8,8 @@ const {
|
||||
FOREIGN_AMB_ABI
|
||||
} = require('../../commons')
|
||||
const { web3Home, web3Foreign } = require('../src/services/web3')
|
||||
const { privateKeyToAddress } = require('../src/utils/utils')
|
||||
const { add0xPrefix, privateKeyToAddress } = require('../src/utils/utils')
|
||||
const { EXIT_CODES } = require('../src/utils/constants')
|
||||
|
||||
const {
|
||||
ORACLE_BRIDGE_MODE,
|
||||
@ -79,9 +80,22 @@ const foreignConfig = {
|
||||
const maxProcessingTime =
|
||||
parseInt(ORACLE_MAX_PROCESSING_TIME, 10) || 4 * Math.max(homeConfig.pollingInterval, foreignConfig.pollingInterval)
|
||||
|
||||
let validatorPrivateKey
|
||||
if (ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY) {
|
||||
validatorPrivateKey = add0xPrefix(ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY)
|
||||
const derived = privateKeyToAddress(validatorPrivateKey)
|
||||
if (ORACLE_VALIDATOR_ADDRESS && derived.toLowerCase() !== ORACLE_VALIDATOR_ADDRESS.toLowerCase()) {
|
||||
console.error(
|
||||
`Derived address from private key - ${derived} is different from ORACLE_VALIDATOR_ADDRESS=${ORACLE_VALIDATOR_ADDRESS}`
|
||||
)
|
||||
process.exit(EXIT_CODES.INCOMPATIBILITY)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
eventFilter: {},
|
||||
validatorAddress: ORACLE_VALIDATOR_ADDRESS || privateKeyToAddress(ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY),
|
||||
validatorPrivateKey,
|
||||
validatorAddress: ORACLE_VALIDATOR_ADDRESS || privateKeyToAddress(validatorPrivateKey),
|
||||
maxProcessingTime,
|
||||
shutdownKey: 'oracle-shutdown',
|
||||
home: homeConfig,
|
||||
|
@ -1,20 +1,7 @@
|
||||
const baseConfig = require('./base.config')
|
||||
const { ERC20_ABI } = require('../../commons')
|
||||
const { ERC20_ABI, ZERO_ADDRESS } = require('../../commons')
|
||||
const { EXIT_CODES } = require('../src/utils/constants')
|
||||
|
||||
const initialChecksJson = process.argv[3]
|
||||
|
||||
if (!initialChecksJson) {
|
||||
throw new Error('initial check parameter was not provided.')
|
||||
}
|
||||
|
||||
let initialChecks
|
||||
try {
|
||||
initialChecks = JSON.parse(initialChecksJson)
|
||||
} catch (e) {
|
||||
throw new Error('Error on decoding values from initial checks.')
|
||||
}
|
||||
|
||||
const id = `${baseConfig.id}-transfer`
|
||||
|
||||
if (baseConfig.id !== 'erc-native') {
|
||||
@ -22,14 +9,14 @@ if (baseConfig.id !== 'erc-native') {
|
||||
process.exit(EXIT_CODES.WATCHER_NOT_REQUIRED)
|
||||
}
|
||||
|
||||
// exact address of the token contract is set in the watcher.js checkConditions() function
|
||||
baseConfig.foreign.eventContract = new baseConfig.foreign.web3.eth.Contract(ERC20_ABI, ZERO_ADDRESS)
|
||||
|
||||
module.exports = {
|
||||
...baseConfig,
|
||||
main: {
|
||||
...baseConfig.foreign,
|
||||
eventContract: new baseConfig.foreign.web3.eth.Contract(ERC20_ABI, initialChecks.bridgeableTokenAddress)
|
||||
},
|
||||
main: baseConfig.foreign,
|
||||
event: 'Transfer',
|
||||
eventFilter: { to: process.env.COMMON_FOREIGN_BRIDGE_ADDRESS },
|
||||
eventFilter: { to: baseConfig.foreign.bridgeAddress },
|
||||
sender: 'home',
|
||||
queue: 'home-prioritized',
|
||||
name: `watcher-${id}`,
|
||||
|
@ -1,26 +0,0 @@
|
||||
require('../env')
|
||||
const { getTokensState } = require('../src/utils/tokenState')
|
||||
const { FOREIGN_ERC_TO_NATIVE_ABI } = require('../../commons')
|
||||
const { web3Foreign } = require('../src/services/web3')
|
||||
|
||||
const emptyLogger = {
|
||||
debug: () => {},
|
||||
info: () => {}
|
||||
}
|
||||
|
||||
async function initialChecks() {
|
||||
const { ORACLE_BRIDGE_MODE, COMMON_FOREIGN_BRIDGE_ADDRESS } = process.env
|
||||
let result = {}
|
||||
|
||||
if (ORACLE_BRIDGE_MODE === 'ERC_TO_NATIVE') {
|
||||
const bridge = new web3Foreign.eth.Contract(FOREIGN_ERC_TO_NATIVE_ABI, COMMON_FOREIGN_BRIDGE_ADDRESS)
|
||||
result = await getTokensState(bridge, emptyLogger)
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(result))
|
||||
return result
|
||||
}
|
||||
|
||||
const result = initialChecks()
|
||||
|
||||
module.exports = result
|
@ -10,10 +10,8 @@ CONFIG="${2}.config.js"
|
||||
LOG="${LOGS_DIR}${2}.txt"
|
||||
TX_HASH=${@:3}
|
||||
|
||||
CHECKS=$(node scripts/initialChecks.js)
|
||||
|
||||
if [ "${NODE_ENV}" = "production" ]; then
|
||||
exec node "${WORKER}" "${CONFIG}" "$CHECKS" $TX_HASH
|
||||
exec node "${WORKER}" "${CONFIG}" $TX_HASH
|
||||
else
|
||||
node "${WORKER}" "${CONFIG}" "$CHECKS" $TX_HASH | tee -a "${LOG}" | pino-pretty
|
||||
node "${WORKER}" "${CONFIG}" $TX_HASH | tee -a "${LOG}" | pino-pretty
|
||||
fi
|
||||
|
@ -9,9 +9,9 @@ const { sendTx } = require('./tx/sendTx')
|
||||
const { checkHTTPS, watchdog, syncForEach, addExtraGas } = require('./utils/utils')
|
||||
const { EXIT_CODES, EXTRA_GAS_PERCENTAGE, MAX_GAS_LIMIT } = require('./utils/constants')
|
||||
|
||||
const { ORACLE_VALIDATOR_ADDRESS, ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY, ORACLE_ALLOW_HTTP_FOR_RPC } = process.env
|
||||
const { ORACLE_ALLOW_HTTP_FOR_RPC } = process.env
|
||||
|
||||
if (process.argv.length < 5) {
|
||||
if (process.argv.length < 4) {
|
||||
logger.error('Please check the number of arguments, transaction hash is not present')
|
||||
process.exit(EXIT_CODES.GENERAL_ERROR)
|
||||
}
|
||||
@ -29,7 +29,7 @@ function readTxHashes(filePath) {
|
||||
.filter(isTxHash)
|
||||
}
|
||||
|
||||
const txHashesArgs = process.argv.slice(4)
|
||||
const txHashesArgs = process.argv.slice(3)
|
||||
const rawTxHashes = txHashesArgs.filter(isTxHash)
|
||||
const txHashesFiles = txHashesArgs.filter(path => fs.existsSync(path)).flatMap(readTxHashes)
|
||||
const txHashes = [...rawTxHashes, ...txHashesFiles]
|
||||
@ -152,7 +152,7 @@ async function sendJobTx(jobs) {
|
||||
const { web3 } = config.sender === 'foreign' ? config.foreign : config.home
|
||||
|
||||
const chainId = await getChainId(web3)
|
||||
let nonce = await getNonce(web3, ORACLE_VALIDATOR_ADDRESS)
|
||||
let nonce = await getNonce(web3, config.validatorAddress)
|
||||
|
||||
await syncForEach(jobs, async job => {
|
||||
let gasLimit
|
||||
@ -170,7 +170,7 @@ async function sendJobTx(jobs) {
|
||||
gasPrice,
|
||||
amount: '0',
|
||||
gasLimit,
|
||||
privateKey: ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY,
|
||||
privateKey: config.validatorPrivateKey,
|
||||
to: job.to,
|
||||
chainId,
|
||||
web3
|
||||
@ -189,7 +189,7 @@ async function sendJobTx(jobs) {
|
||||
)
|
||||
|
||||
if (e.message.toLowerCase().includes('insufficient funds')) {
|
||||
const currentBalance = await web3.eth.getBalance(ORACLE_VALIDATOR_ADDRESS)
|
||||
const currentBalance = await web3.eth.getBalance(config.validatorAddress)
|
||||
const minimumBalance = gasLimit.multipliedBy(gasPrice)
|
||||
logger.error(
|
||||
`Insufficient funds: ${currentBalance}. Stop processing messages until the balance is at least ${minimumBalance}.`
|
||||
|
@ -8,8 +8,6 @@ const estimateGas = require('../processSignatureRequests/estimateGas')
|
||||
const { AlreadyProcessedError, AlreadySignedError, InvalidValidatorError } = require('../../utils/errors')
|
||||
const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants')
|
||||
|
||||
const { ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY } = process.env
|
||||
|
||||
const limit = promiseLimit(MAX_CONCURRENT_EVENTS)
|
||||
|
||||
function processSignatureRequestsBuilder(config) {
|
||||
@ -37,7 +35,7 @@ function processSignatureRequestsBuilder(config) {
|
||||
const { sender, executor } = parseAMBMessage(message)
|
||||
logger.info({ sender, executor }, `Processing signatureRequest ${messageId}`)
|
||||
|
||||
const signature = web3.eth.accounts.sign(message, `0x${ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY}`)
|
||||
const signature = web3.eth.accounts.sign(message, config.validatorPrivateKey)
|
||||
|
||||
let gasEstimate
|
||||
try {
|
||||
|
@ -8,8 +8,6 @@ const estimateGas = require('./estimateGas')
|
||||
const { AlreadyProcessedError, AlreadySignedError, InvalidValidatorError } = require('../../utils/errors')
|
||||
const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants')
|
||||
|
||||
const { ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY } = process.env
|
||||
|
||||
const limit = promiseLimit(MAX_CONCURRENT_EVENTS)
|
||||
|
||||
function processSignatureRequestsBuilder(config) {
|
||||
@ -48,7 +46,7 @@ function processSignatureRequestsBuilder(config) {
|
||||
expectedMessageLength
|
||||
})
|
||||
|
||||
const signature = web3.eth.accounts.sign(message, `0x${ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY}`)
|
||||
const signature = web3.eth.accounts.sign(message, config.validatorPrivateKey)
|
||||
|
||||
let gasEstimate
|
||||
try {
|
||||
|
@ -10,7 +10,6 @@ const { getNonce, getChainId } = require('./tx/web3')
|
||||
const {
|
||||
addExtraGas,
|
||||
checkHTTPS,
|
||||
privateKeyToAddress,
|
||||
syncForEach,
|
||||
waitForFunds,
|
||||
waitForUnsuspend,
|
||||
@ -19,9 +18,7 @@ const {
|
||||
} = require('./utils/utils')
|
||||
const { EXIT_CODES, EXTRA_GAS_PERCENTAGE, MAX_GAS_LIMIT } = require('./utils/constants')
|
||||
|
||||
const { ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY, ORACLE_TX_REDUNDANCY } = process.env
|
||||
|
||||
const ORACLE_VALIDATOR_ADDRESS = privateKeyToAddress(ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY)
|
||||
const { ORACLE_TX_REDUNDANCY } = process.env
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
logger.error('Please check the number of arguments, config file was not provided')
|
||||
@ -84,7 +81,7 @@ async function readNonce(forceUpdate) {
|
||||
logger.debug('Reading nonce')
|
||||
if (forceUpdate) {
|
||||
logger.debug('Forcing update of nonce')
|
||||
return getNonce(web3, ORACLE_VALIDATOR_ADDRESS)
|
||||
return getNonce(web3, config.validatorAddress)
|
||||
}
|
||||
|
||||
const nonce = await redis.get(nonceKey)
|
||||
@ -93,7 +90,7 @@ async function readNonce(forceUpdate) {
|
||||
return Number(nonce)
|
||||
} else {
|
||||
logger.warn("Nonce wasn't found in the DB")
|
||||
return getNonce(web3, ORACLE_VALIDATOR_ADDRESS)
|
||||
return getNonce(web3, config.validatorAddress)
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +165,7 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
||||
gasPrice,
|
||||
amount: '0',
|
||||
gasLimit,
|
||||
privateKey: ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY,
|
||||
privateKey: config.validatorPrivateKey,
|
||||
to: job.to,
|
||||
chainId,
|
||||
web3: web3Redundant
|
||||
@ -208,7 +205,7 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
||||
|
||||
if (message.includes('insufficient funds')) {
|
||||
insufficientFunds = true
|
||||
const currentBalance = await web3.eth.getBalance(ORACLE_VALIDATOR_ADDRESS)
|
||||
const currentBalance = await web3.eth.getBalance(config.validatorAddress)
|
||||
minimumBalance = gasLimit.multipliedBy(gasPrice)
|
||||
logger.error(
|
||||
`Insufficient funds: ${currentBalance}. Stop processing messages until the balance is at least ${minimumBalance}.`
|
||||
@ -238,7 +235,7 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
||||
if (insufficientFunds) {
|
||||
logger.warn('Insufficient funds. Stop sending transactions until the account has the minimum balance')
|
||||
channel.close()
|
||||
waitForFunds(web3, ORACLE_VALIDATOR_ADDRESS, minimumBalance, resume, logger)
|
||||
waitForFunds(web3, config.validatorAddress, minimumBalance, resume, logger)
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
|
@ -9,12 +9,9 @@ const logger = pino({
|
||||
enabled: process.env.NODE_ENV !== 'test',
|
||||
name: config.name,
|
||||
level: process.env.ORACLE_LOG_LEVEL || 'debug',
|
||||
base:
|
||||
process.env.NODE_ENV === 'production'
|
||||
? {
|
||||
validator: process.env.ORACLE_VALIDATOR_ADDRESS
|
||||
}
|
||||
: {}
|
||||
base: {
|
||||
validator: config.validatorAddress
|
||||
}
|
||||
})
|
||||
|
||||
setLogger(logger)
|
||||
|
@ -11,7 +11,7 @@ async function sendTx({ privateKey, data, nonce, gasPrice, amount, gasLimit, to,
|
||||
gasPrice,
|
||||
gas: gasLimit
|
||||
},
|
||||
`0x${privateKey}`
|
||||
privateKey
|
||||
)
|
||||
|
||||
return new Promise((res, rej) =>
|
||||
|
@ -153,6 +153,7 @@ module.exports = {
|
||||
addExtraGas,
|
||||
setIntervalAndRun,
|
||||
watchdog,
|
||||
add0xPrefix,
|
||||
privateKeyToAddress,
|
||||
nonceError,
|
||||
getRetrySequence,
|
||||
|
Loading…
Reference in New Issue
Block a user