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

Deploy fixes #40

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ coverage
deploy/*.config
deploy/*.env*
!deploy/.env.example
!deploy/.env.kovan-sokol
!deploy/.env.mainnet-xdai
upgrade/*.env*
!upgrade/.env.example
coverage.json

.env
41 changes: 0 additions & 41 deletions deploy.sh

This file was deleted.

119 changes: 119 additions & 0 deletions deploy/.env.kovan-sokol
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# WARNING: Do not commit secrets in this file


# The type of bridge. Defines set of contracts to be deployed.

BRIDGE_MODE=MULTI_AMB_ERC_TO_ERC

# The address of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks. This must be an account on the trezor
# trezorctl ethereum get-address -n "m/44'/60'/0'/0/1"
HOME_DEPLOYMENT_ACCOUNT_ADDRESS=0xcceFb7EF9956B08B69c951Ed4f4A176972F700F1
# trezorctl ethereum get-address -n "m/44'/1'/0'/0/1"
FOREIGN_DEPLOYMENT_ACCOUNT_ADDRESS=0xE3423F92acB011F24D64154daA65247039DbffA3

FOREIGN_EXPLORER_URL=https://kovan.etherscan.io/api


# Extra gas added to the estimated gas of a particular deployment/configuration transaction
# E.g. if estimated gas returns 100000 and the parameter is 0.2,
# the transaction gas limit will be (100000 + 100000 * 0.2) = 120000
DEPLOYMENT_GAS_LIMIT_EXTRA=0.2
# The "gasPrice" parameter set in every deployment/configuration transaction on
# Home network (in Wei).
HOME_DEPLOYMENT_GAS_PRICE=1200000000
HOME_GAS_PRICE=1200000000
# The "gasPrice" parameter set in every deployment/configuration transaction on
# Foreign network (in Wei).
FOREIGN_DEPLOYMENT_GAS_PRICE=1200000000
# The timeout limit to wait for receipt of the deployment/configuration
# transaction.
GET_RECEIPT_INTERVAL_IN_MILLISECONDS=3000

# The RPC channel to a Home node able to handle deployment/configuration
# transactions.
HOME_RPC_URL=https://sokol.poa.network/
HOME_CHAIN_ID=77
HOME_KEY_DERIVATION_PATH="m/44'/60'/0'/0"
HOME_EXPLORER_URL=https://blockscout.com/poa/sokol/api

# Address on Home network with permissions to change parameters of the bridge contract.
# For extra security we recommended using a multi-sig wallet contract address here.
HOME_BRIDGE_OWNER=0xcceFb7EF9956B08B69c951Ed4f4A176972F700F1
# Address on Home network with permissions to upgrade the bridge contract
HOME_UPGRADEABLE_ADMIN=0xcceFb7EF9956B08B69c951Ed4f4A176972F700F1
# The default daily transaction limit in Wei. As soon as this limit is exceeded, any
# transaction which requests to relay assets will fail.
HOME_DAILY_LIMIT=30000000000000000000000000
# The default maximum limit for one transaction in Wei. If a single transaction tries to
# relay funds exceeding this limit it will fail. HOME_MAX_AMOUNT_PER_TX must be
# less than HOME_DAILY_LIMIT.
HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000
# The default minimum limit for one transaction in Wei. If a transaction tries to relay
# funds below this limit it will fail. This is required to prevent dryout
# validator accounts.
HOME_MIN_AMOUNT_PER_TX=500000000000000000

# The RPC channel to a Foreign node able to handle deployment/configuration
# transactions.
FOREIGN_RPC_URL=https://kovan.infura.io/
FOREIGN_CHAIN_ID=42
FOREIGN_KEY_DERIVATION_PATH="m/44'/1'/0'/0"
# Address on Foreign network with permissions to change parameters of the bridge contract.
# For extra security we recommended using a multi-sig wallet contract address here.
FOREIGN_BRIDGE_OWNER=0xE3423F92acB011F24D64154daA65247039DbffA3
# Address on Foreign network with permissions to upgrade the bridge contract and the
# bridge validator contract.
FOREIGN_UPGRADEABLE_ADMIN=0xE3423F92acB011F24D64154daA65247039DbffA3
# The default daily limit in Wei. As soon as this limit is exceeded, any transaction
# requesting to relay assets will fail.
FOREIGN_DAILY_LIMIT=15000000000000000000000000
# The default maximum limit per one transaction in Wei. If a transaction tries to relay
# funds exceeding this limit it will fail. FOREIGN_MAX_AMOUNT_PER_TX must be less
# than FOREIGN_DAILY_LIMIT.
FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000
# The default minimum limit for one transaction in Wei. If a transaction tries to relay
# funds below this limit it will fail.
FOREIGN_MIN_AMOUNT_PER_TX=500000000000000000

# The address of the existing AMB bridge in the Home network that will be used to pass messages
# to the Foreign network.
HOME_AMB_BRIDGE=0xFe446bEF1DbF7AFE24E81e05BC8B271C1BA9a560
# The address of the existing AMB bridge in the Foreign network that will be used to pass messages
# to the Home network.
FOREIGN_AMB_BRIDGE=0xfe446bef1dbf7afe24e81e05bc8b271c1ba9a560
# The gas limit that will be used in the execution of the message passed to the mediator contract
# in the Foreign network.
HOME_MEDIATOR_REQUEST_GAS_LIMIT=2000000
# The gas limit that will be used in the execution of the message passed to the mediator contract
# in the Home network.
FOREIGN_MEDIATOR_REQUEST_GAS_LIMIT=2000000

# Variable to define whether to collect fee on bridge transfers
# On this bridge mode only BOTH_DIRECTIONS is supported, leave false to disable fees collection
HOME_REWARDABLE=false
# On this this bridge mode, fees collection on home side is not supported, should be false.
FOREIGN_REWARDABLE=false

# Fee to be taken for every transaction directed from the Home network to the Foreign network
# Makes sense only when HOME_REWARDABLE=BOTH_DIRECTIONS
# e.g. 0.1% fee
HOME_TRANSACTIONS_FEE=0.001
# Fee to be taken for every transaction directed from the Foreign network to the Home network
# Makes sense only when HOME_REWARDABLE=BOTH_DIRECTIONS
# e.g. 0.1% fee
FOREIGN_TRANSACTIONS_FEE=0.001

# List of accounts where rewards should be transferred in Home network separated by space without quotes
# Makes sense only when HOME_REWARDABLE=BOTH_DIRECTIONS
#E.g. HOME_MEDIATOR_REWARD_ACCOUNTS=0x 0x 0x
HOME_MEDIATOR_REWARD_ACCOUNTS=0xcceFb7EF9956B08B69c951Ed4f4A176972F700F1

# address of an already deployed PermittableToken contract that will be used as an implementation for all new created tokens
# leave empty, if you want to deploy a new PermittableToken for further usage
HOME_ERC677_TOKEN_IMAGE=0x769Aed9d3F34f320010fa31cd04Fe3bAD8700033

BRIDGE_UTILS_ON_HOME_ADDRESS=0x3BBAD838bd46692583CF811884d3CDcD7cb65045
FOREIGN_ALLOW_TOKEN_LIST=0xd6E34821F508e4247Db359CFceE0cb5e8050972a,0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa

114 changes: 114 additions & 0 deletions deploy/.env.mainnet-xdai
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# WARNING: Do not commit secrets in this file

# The type of bridge. Defines set of contracts to be deployed.

BRIDGE_MODE=MULTI_AMB_ERC_TO_ERC

# The address of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks. This must be an account on the trezor
HOME_DEPLOYMENT_ACCOUNT_ADDRESS=0xA06C2B0b8a2EECA46eac0ca6Cc958Dc94101dC5d
FOREIGN_DEPLOYMENT_ACCOUNT_ADDRESS=0xA06C2B0b8a2EECA46eac0ca6Cc958Dc94101dC5d

FOREIGN_EXPLORER_URL=https://api.etherscan.io/api

# Extra gas added to the estimated gas of a particular deployment/configuration transaction
# E.g. if estimated gas returns 100000 and the parameter is 0.2,
# the transaction gas limit will be (100000 + 100000 * 0.2) = 120000
DEPLOYMENT_GAS_LIMIT_EXTRA=0.2
# The "gasPrice" parameter set in every deployment/configuration transaction on
# Home network (in Wei).
HOME_DEPLOYMENT_GAS_PRICE=1000000000
HOME_GAS_PRICE=1000000000
# The "gasPrice" parameter set in every deployment/configuration transaction on
# Foreign network (in Wei).
FOREIGN_DEPLOYMENT_GAS_PRICE=181000000000
# The timeout limit to wait for receipt of the deployment/configuration
# transaction.
GET_RECEIPT_INTERVAL_IN_MILLISECONDS=3000

# The RPC channel to a Home node able to handle deployment/configuration
# transactions.
HOME_RPC_URL=https://rpc.xdaichain.com/
HOME_CHAIN_ID=100
HOME_KEY_DERIVATION_PATH="m/44'/60'/0'/0"
HOME_EXPLORER_URL=https://blockscout.com/poa/xdai/api

# Address on Home network with permissions to change parameters of the bridge contract.
# For extra security we recommended using a multi-sig wallet contract address here.
HOME_BRIDGE_OWNER=0xA06C2B0b8a2EECA46eac0ca6Cc958Dc94101dC5d
# Address on Home network with permissions to upgrade the bridge contract
HOME_UPGRADEABLE_ADMIN=0xA06C2B0b8a2EECA46eac0ca6Cc958Dc94101dC5d
# The default daily transaction limit in Wei. As soon as this limit is exceeded, any
# transaction which requests to relay assets will fail.
HOME_DAILY_LIMIT=30000000000000000000000000
# The default maximum limit for one transaction in Wei. If a single transaction tries to
# relay funds exceeding this limit it will fail. HOME_MAX_AMOUNT_PER_TX must be
# less than HOME_DAILY_LIMIT.
HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000
# The default minimum limit for one transaction in Wei. If a transaction tries to relay
# funds below this limit it will fail. This is required to prevent dryout
# validator accounts.
HOME_MIN_AMOUNT_PER_TX=500000000000000000

# The RPC channel to a Foreign node able to handle deployment/configuration
# transactions.
FOREIGN_RPC_URL=https://mainnet.infura.io
FOREIGN_CHAIN_ID=1
FOREIGN_KEY_DERIVATION_PATH="m/44'/60'/0'/0"
# Address on Foreign network with permissions to change parameters of the bridge contract.
# For extra security we recommended using a multi-sig wallet contract address here.
FOREIGN_BRIDGE_OWNER=0xA06C2B0b8a2EECA46eac0ca6Cc958Dc94101dC5d
# Address on Foreign network with permissions to upgrade the bridge contract and the
# bridge validator contract.
FOREIGN_UPGRADEABLE_ADMIN=0xA06C2B0b8a2EECA46eac0ca6Cc958Dc94101dC5d
# The default daily limit in Wei. As soon as this limit is exceeded, any transaction
# requesting to relay assets will fail.
FOREIGN_DAILY_LIMIT=15000000000000000000000000
# The default maximum limit per one transaction in Wei. If a transaction tries to relay
# funds exceeding this limit it will fail. FOREIGN_MAX_AMOUNT_PER_TX must be less
# than FOREIGN_DAILY_LIMIT.
FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000
# The default minimum limit for one transaction in Wei. If a transaction tries to relay
# funds below this limit it will fail.
FOREIGN_MIN_AMOUNT_PER_TX=500000000000000000

# The address of the existing AMB bridge in the Home network that will be used to pass messages
# to the Foreign network.
HOME_AMB_BRIDGE=0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59
# The address of the existing AMB bridge in the Foreign network that will be used to pass messages
# to the Home network.
FOREIGN_AMB_BRIDGE=0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e
# The gas limit that will be used in the execution of the message passed to the mediator contract
# in the Foreign network.
HOME_MEDIATOR_REQUEST_GAS_LIMIT=2000000
# The gas limit that will be used in the execution of the message passed to the mediator contract
# in the Home network.
FOREIGN_MEDIATOR_REQUEST_GAS_LIMIT=2000000

# Variable to define whether to collect fee on bridge transfers
# On this bridge mode only BOTH_DIRECTIONS is supported, leave false to disable fees collection
HOME_REWARDABLE=false
# On this this bridge mode, fees collection on home side is not supported, should be false.
FOREIGN_REWARDABLE=false

# Fee to be taken for every transaction directed from the Home network to the Foreign network
# Makes sense only when HOME_REWARDABLE=BOTH_DIRECTIONS
# e.g. 0.1% fee
HOME_TRANSACTIONS_FEE=0.001
# Fee to be taken for every transaction directed from the Foreign network to the Home network
# Makes sense only when HOME_REWARDABLE=BOTH_DIRECTIONS
# e.g. 0.1% fee
FOREIGN_TRANSACTIONS_FEE=0.001

# List of accounts where rewards should be transferred in Home network separated by space without quotes
# Makes sense only when HOME_REWARDABLE=BOTH_DIRECTIONS
#E.g. HOME_MEDIATOR_REWARD_ACCOUNTS=0x 0x 0x
HOME_MEDIATOR_REWARD_ACCOUNTS=0xA06C2B0b8a2EECA46eac0ca6Cc958Dc94101dC5d

# address of an already deployed PermittableToken contract that will be used as an implementation for all new created tokens
# leave empty, if you want to deploy a new PermittableToken for further usage
HOME_ERC677_TOKEN_IMAGE=

BRIDGE_UTILS_ON_HOME_ADDRESS=0xa79206F956461e053DbCF33ADDFa77553Df58D7F
FOREIGN_ALLOW_TOKEN_LIST=0x954b890704693af242613edEf1B603825afcD708,0x6B175474E89094C44Da98b954EedeAC495271d0F
12 changes: 12 additions & 0 deletions deploy/bridgeDeploymentResults.json.kovan-sokol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"homeBridge": {
"homeBridgeMediator": {
"address": "0xf9906aD189CC61d0158Cbc770cFB726a084bc6e0"
}
},
"foreignBridge": {
"foreignBridgeMediator": {
"address": "0x97bB40dB0fb70eeb4e2121B6d708BD91ec4D1a43"
}
}
}
10 changes: 1 addition & 9 deletions deploy/src/deploymentUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ async function deployContract(contractJson, args, { network, nonce }) {
nonce
})

if (apiUrl) {
let constructorArguments
if (args.length) {
constructorArguments = result.substring(contractJson.bytecode.length)
}
await verifier({ artifact: contractJson, constructorArguments, address: tx.contractAddress, apiUrl, apiKey })
}

return instance
}

Expand Down Expand Up @@ -117,7 +109,7 @@ async function sendRawTx({ data, nonce, to, from, url, gasPrice, value }) {

const provider = getWeb3Provider(url)

console.log('Signing transaction…')
console.log('Signing transaction…', { rawTx })

const signedTransaction = await provider.eth.signTransaction(rawTx)
const txHash = await sendNodeRequest(url, 'eth_sendRawTransaction', signedTransaction.raw)
Expand Down
41 changes: 11 additions & 30 deletions deploy/upgradePermittableTokenImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,21 @@ const {
homeContracts: { ERC677BridgeTokenPermittable, HomeMultiAMBErc20ToErc677 }
} = require('./src/loadContracts')

const { HOME_DEPLOYMENT_ACCOUNT_ADDRESS, HOME_MEDIATOR_ADDRESS, HOME_TOKENS_TO_UPGRADE } = env
const { HOME_DEPLOYMENT_ACCOUNT_ADDRESS } = env

const {
homeBridge: {
homeBridgeMediator: { address: homeProxyAddress }
}
} = require('./bridgeDeploymentResults.json')

async function upgradePermittableTokenImage() {
console.log('\n[Home] Deploying new ERC677 token image from ', HOME_DEPLOYMENT_ACCOUNT_ADDRESS)

const homeMediator = new web3Home.eth.Contract(HomeMultiAMBErc20ToErc677.abi, HOME_MEDIATOR_ADDRESS)

assert.strictEqual(
await homeMediator.methods.owner().call(),
HOME_DEPLOYMENT_ACCOUNT_ADDRESS,
'This operation must be peformed by the owner of the home mediator'
)

console.log(` Home mediator: ${homeProxyAddress}`)
let nonce = await web3Home.eth.getTransactionCount(HOME_DEPLOYMENT_ACCOUNT_ADDRESS)
console.log(` Nonce: ${nonce}`)

const chainId = await web3Home.eth.getChainId()
assert.strictEqual(chainId > 0, true, 'Invalid chain ID')
const erc677token = await deployContract(ERC677BridgeTokenPermittable, ['', '', 0, chainId], {
const erc677token = await deployContract(ERC677BridgeTokenPermittable, ['', '', 0], {
from: HOME_DEPLOYMENT_ACCOUNT_ADDRESS,
nonce
})
Expand All @@ -37,29 +34,13 @@ async function upgradePermittableTokenImage() {
nonce++

console.log('[Home] Setting the token image to the implementation')
const homeMediator = new web3Home.eth.Contract(HomeMultiAMBErc20ToErc677.abi, homeProxyAddress)

await homeMediator.methods.setTokenImage(homeTokenImage).send({
from: HOME_DEPLOYMENT_ACCOUNT_ADDRESS,
nonce
})

nonce++

const homeTokenList = HOME_TOKENS_TO_UPGRADE.split(',').map(a => a.trim())
// eslint-disable-next-line no-restricted-syntax
for (const homeTokenAddress of homeTokenList) {
console.log('[Home] upgrading metadata of token ', homeTokenAddress)
const token = new web3Home.eth.Contract(ERC677BridgeTokenPermittable.abi, homeTokenAddress)
const migrateData = await token.methods
.migrateTokenMetadata()
.send({ from: HOME_DEPLOYMENT_ACCOUNT_ADDRESS, nonce })

console.log('New symbol', await token.methods.symbol().call())
console.log('New name', await token.methods.name().call())

nonce++
}

console.log('success')
}

Expand Down
Loading