-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add support for AMB contracts #199
Conversation
# Conflicts: # oracle-e2e/run-tests.sh
# Conflicts: # oracle-e2e/deploy.js # oracle-e2e/docker-compose.yml # oracle-e2e/run-tests.sh # oracle/config/base.config.js # oracle/src/services/gasPrice.js # oracle/src/utils/utils.js # oracle/test/gasPrice.test.js
# Conflicts: # .prettierrc # commons/abis.js # commons/package.json # e2e-commons/docker-compose.yml # monitor/eventsStats.js # monitor/utils/events.js # oracle/src/services/gasPrice.js # oracle/test/gasPrice.test.js # yarn.lock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's missing explanation in Operational Modes and in Oracle Architecture
gasPriceOptions | ||
}) | ||
} else { | ||
logger.info(`Validator not responsible for relaying CollectedSignatures ${colSignature.transactionHash}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth to change it to guard clause in order to reduce nesting, i.e.:
if (authorityResponsibleForRelay !== web3Home.utils.toChecksumAddress(config.validatorAddress)) {
logger.info(`Validator not responsible for relaying CollectedSignatures ${colSignature.transactionHash}`)
return
}
logger.info(`Processing CollectedSignatures ${colSignature.transactionHash}`)
(...)
Applicable to existing processCollectedSignatures/index.js
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Please check 0aa3b20
|
||
rootLogger.debug(`Processing ${signatures.length} CollectedSignatures events`) | ||
const callbacks = signatures.map(colSignature => | ||
limit(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth to replace it in order to reduce nesting:
const callbacks = signatures.map(colSignature => async () => {
const { authorityResponsibleForRelay, messageHash, NumberOfCollectedSignatures } = colSignature.returnValues
(...)
}.map(promise => limit(promise))
Applicable to other existing usages of promise-limit
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Applied the changes, please take a look da69c64
|
||
const requiredSignatures = [] | ||
requiredSignatures.length = NumberOfCollectedSignatures | ||
requiredSignatures.fill(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be replaced with:
const requiredSignatures = (new Array(NumberOfCollectedSignatures)).fill(0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 20bbd3a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patitonar could you simplify the delta by removing everything that it is related to the defrayal
mode that was postponed?
@akolotov Removed everything related to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge accurately with the master - there are lots of changes related to configuration parameters.
@@ -107,6 +107,22 @@ async function main(bridgeMode) { | |||
balanceDiff: Number(Web3Utils.fromWei(diff)), | |||
lastChecked: Math.floor(Date.now() / 1000) | |||
} | |||
} else if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think that it make sense to measure balance difference for pure AMB. It will be required for the token bridges on top of AMB.
For AMB let's return {home:{},foreign:{},lastChecked:xxxxx}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ef447b7
@@ -9,7 +9,9 @@ HOME_POLLING_INTERVAL={{ HOME_POLLING_INTERVAL }} | |||
## Foreign contract | |||
FOREIGN_RPC_URL={{ FOREIGN_RPC_URL }} | |||
FOREIGN_BRIDGE_ADDRESS={{ FOREIGN_BRIDGE_ADDRESS }} | |||
{% if ERC20_TOKEN_ADDRESS | default('') != '' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should disappear after merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it disappeared
monitor/alerts.js
Outdated
let xSignatures | ||
let xAffirmations | ||
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) { | ||
xSignatures = foreignDeposits.filter(processedMsgNotDelivered(homeDeposits)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please consider either to change names foreignDeposits
, homeDeposits
, homeWithdrawals
and foreignWithdrawals
to more common (e.g. foreignToHomeRequests
, homeToForeignRequests
, foreignToHomeConfirmations
and homeToForeignConfirmations
) under this PR or create another issue to address it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion, fixed 4370fd2
monitor/eventsStats.js
Outdated
@@ -57,25 +58,45 @@ function compareTransferForeign(home) { | |||
} | |||
|
|||
async function main() { | |||
const { foreignDeposits, homeDeposits, homeWithdrawals, foreignWithdrawals, isExternalErc20 } = await eventsInfo() | |||
const { | |||
foreignDeposits, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see comment for changes in alert.js
monitor/getShortEventStats.js
Outdated
@@ -1,19 +1,35 @@ | |||
require('dotenv').config() | |||
const eventsInfo = require('./utils/events') | |||
const { BRIDGE_MODES } = require('../commons') | |||
|
|||
async function main(bridgeMode) { | |||
const { foreignDeposits, homeDeposits, homeWithdrawals, foreignWithdrawals } = await eventsInfo(bridgeMode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see comment for changes in alert.js
monitor/getShortEventStats.js
Outdated
withdrawals: foreignWithdrawals.length | ||
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) { | ||
return { | ||
deliveryDiff: homeDeposits.length - foreignDeposits.length, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for AMB it is necessary to change checkWorkers.js
as so it outputs:
{"home":{"toForeign":1513,"fromForeign":1651},"foreign":{"fromHome":1513,"toHome":1655}, "lastChecked":1568748063,"fromHomeToForeignDiff":0,"fromForeignToHomeDiff":-4,"timeDiff":69}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the output. Please check 9c87c23
# Conflicts: # deployment/roles/oracle/templates/.env.j2 # monitor/utils/events.js
This PR includes:
monitor-e2e should be updated to include tests for AMB. We can create an issue to later address this.