Skip to content
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

Merged
merged 53 commits into from
Sep 18, 2019
Merged

Add support for AMB contracts #199

merged 53 commits into from
Sep 18, 2019

Conversation

patitonar
Copy link
Contributor

This PR includes:

  • Oracle support for AMB
  • Monitor support for AMB
  • Oracle-e2e updated with AMB tests
  • Contract submodule updated to a commit that includes AMB work. Once the set of contracts is released, we should update the submodule to the new version.

monitor-e2e should be updated to include tests for AMB. We can create an issue to later address this.

# 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
@patitonar patitonar added oracle related to TokenBridge oracle monitor related to TokenBridge monitor labels Sep 6, 2019
@patitonar patitonar self-assigned this Sep 6, 2019
@akolotov akolotov requested a review from rzadp September 6, 2019 12:11
Copy link
Contributor

@rzadp rzadp left a 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}`)
Copy link
Contributor

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.

Copy link
Contributor Author

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 () => {
Copy link
Contributor

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

Copy link
Contributor Author

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)
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 20bbd3a

Copy link
Collaborator

@akolotov akolotov left a 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?

@patitonar
Copy link
Contributor Author

@akolotov Removed everything related to defrayal mode

Copy link
Collaborator

@akolotov akolotov left a 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) {
Copy link
Collaborator

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}

Copy link
Contributor Author

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('') != '' %}
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it disappeared

let xSignatures
let xAffirmations
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) {
xSignatures = foreignDeposits.filter(processedMsgNotDelivered(homeDeposits))
Copy link
Collaborator

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.

Copy link
Contributor Author

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

@@ -57,25 +58,45 @@ function compareTransferForeign(home) {
}

async function main() {
const { foreignDeposits, homeDeposits, homeWithdrawals, foreignWithdrawals, isExternalErc20 } = await eventsInfo()
const {
foreignDeposits,
Copy link
Collaborator

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

@@ -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)
Copy link
Collaborator

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

withdrawals: foreignWithdrawals.length
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) {
return {
deliveryDiff: homeDeposits.length - foreignDeposits.length,
Copy link
Collaborator

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}

Copy link
Contributor Author

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

@akolotov akolotov changed the base branch from master to develop September 17, 2019 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
monitor related to TokenBridge monitor oracle related to TokenBridge oracle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants