Fix oracle error patterns and oracle e2e tests (#585)
This commit is contained in:
parent
6e1f57493a
commit
5e95b5d8c5
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -205,7 +205,7 @@ jobs:
|
||||
- name: Login to docker registry
|
||||
run: docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} -p ${{ github.token }}
|
||||
- name: Deploy contracts
|
||||
run: ${{ steps.cache-repo.outputs.cache-hit }} && e2e-commons/up.sh deploy blocks
|
||||
run: ${{ steps.cache-repo.outputs.cache-hit }} && e2e-commons/up.sh deploy generate-amb-tx blocks
|
||||
- name: Pull e2e oracle image
|
||||
run: |
|
||||
docker-compose -f ./e2e-commons/docker-compose.yml pull oracle-amb
|
||||
|
@ -63,17 +63,19 @@ describe('arbitrary message bridging', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
describe('Confirm Relay', () => {
|
||||
it('should process lost affirmation-request via confirm relay', async () => {
|
||||
const value = await homeBox.methods.value().call()
|
||||
assert(value === '789', 'incorrect value')
|
||||
})
|
||||
if (process.env.ULTIMATE !== 'true') {
|
||||
describe('Confirm Relay', () => {
|
||||
it('should process lost affirmation-request via confirm relay', async () => {
|
||||
const value = await homeBox.methods.value().call()
|
||||
assert(value === '789', 'incorrect value')
|
||||
})
|
||||
|
||||
it('should process lost signature-request & collected-signatures via confirm relay', async () => {
|
||||
const value = await foreignBox.methods.value().call()
|
||||
assert(value === '123', 'incorrect value')
|
||||
it('should process lost signature-request & collected-signatures via confirm relay', async () => {
|
||||
const value = await foreignBox.methods.value().call()
|
||||
assert(value === '123', 'incorrect value')
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
describe('Home to Foreign', () => {
|
||||
describe('Subsidized Mode', () => {
|
||||
it('should bridge message', async () => {
|
||||
|
@ -14,7 +14,10 @@ const {
|
||||
waitForFunds,
|
||||
waitForUnsuspend,
|
||||
watchdog,
|
||||
nonceError
|
||||
isGasPriceError,
|
||||
isSameTransactionError,
|
||||
isInsufficientBalanceError,
|
||||
isNonceError
|
||||
} = require('./utils/utils')
|
||||
const { EXIT_CODES, EXTRA_GAS_PERCENTAGE, MAX_GAS_LIMIT } = require('./utils/constants')
|
||||
|
||||
@ -189,12 +192,11 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
||||
e.message
|
||||
)
|
||||
|
||||
const message = e.message.toLowerCase()
|
||||
if (message.includes('replacement transaction underpriced')) {
|
||||
if (isGasPriceError(e)) {
|
||||
logger.info('Replacement transaction underpriced, forcing gas price update')
|
||||
GasPrice.start(config.id)
|
||||
failedTx.push(job)
|
||||
} else if (isResend || message.includes('transaction with the same hash was already imported')) {
|
||||
} else if (isResend || isSameTransactionError(e)) {
|
||||
resendJobs.push(job)
|
||||
} else {
|
||||
// if initial transaction sending has failed not due to the same hash error
|
||||
@ -203,14 +205,14 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
||||
failedTx.push(job)
|
||||
}
|
||||
|
||||
if (message.includes('insufficient funds')) {
|
||||
if (isInsufficientBalanceError(e)) {
|
||||
insufficientFunds = true
|
||||
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}.`
|
||||
)
|
||||
} else if (nonceError(e)) {
|
||||
} else if (isNonceError(e)) {
|
||||
nonce = await readNonce(true)
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,22 @@ function privateKeyToAddress(privateKey) {
|
||||
return privateKey ? new Web3().eth.accounts.privateKeyToAccount(add0xPrefix(privateKey)).address : null
|
||||
}
|
||||
|
||||
function nonceError(e) {
|
||||
function isGasPriceError(e) {
|
||||
const message = e.message.toLowerCase()
|
||||
return message.includes('replacement transaction underpriced')
|
||||
}
|
||||
|
||||
function isSameTransactionError(e) {
|
||||
const message = e.message.toLowerCase()
|
||||
return message.includes('transaction with the same hash was already imported') || message.includes('already known')
|
||||
}
|
||||
|
||||
function isInsufficientBalanceError(e) {
|
||||
const message = e.message.toLowerCase()
|
||||
return message.includes('insufficient funds')
|
||||
}
|
||||
|
||||
function isNonceError(e) {
|
||||
const message = e.message.toLowerCase()
|
||||
return (
|
||||
message.includes('transaction nonce is too low') ||
|
||||
@ -155,7 +170,10 @@ module.exports = {
|
||||
watchdog,
|
||||
add0xPrefix,
|
||||
privateKeyToAddress,
|
||||
nonceError,
|
||||
isGasPriceError,
|
||||
isSameTransactionError,
|
||||
isInsufficientBalanceError,
|
||||
isNonceError,
|
||||
getRetrySequence,
|
||||
promiseAny,
|
||||
readAccessListFile,
|
||||
|
Loading…
Reference in New Issue
Block a user