Skip to content

Commit

Permalink
Add new upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
k1rill-fedoseev committed May 11, 2020
1 parent 59de8e4 commit 3c0c646
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion test/erc_to_native/foreign_bridge.test.js
Expand Up @@ -2220,7 +2220,6 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => {
otherSideBridge.address
).should.be.fulfilled


await sai.mint(foreignBridgeProxy.address, 100)

await foreignBridgeProxy.fixLockedSai(accounts[9], { from: accounts[1] }).should.be.rejected
Expand Down
3 changes: 2 additions & 1 deletion upgrade/.env.example
@@ -1,10 +1,11 @@
FOREIGN_RPC_URL=https://mainnet.infura.io/v3/API_KEY
FOREIGN_PRIVKEY=0x...
FOREING_BRIDGE_ADDRESS=0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016
FOREIGN_BRIDGE_ADDRESS=0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016
FOREIGN_START_BLOCK=9122083
FOREIGN_GAS_PRICE=1000000000

# leader or confirm
ROLE=confirm

NEW_IMPLEMENTATION_ETH_BRIDGE=
SAI_TOKENS_RECEIVER=
15 changes: 10 additions & 5 deletions upgrade/src/upgradeBridgeOnForeign.js
Expand Up @@ -2,36 +2,41 @@ require('dotenv').config()
const Web3 = require('web3')
const multiSigWalletAbi = require('../abi/multiSigwallet')
const proxyAbi = require('../../build/contracts/EternalStorageProxy').abi
const bridgeAbi = require('../../build/contracts/ForeignBridgeErcToNative').abi
const callMultiSigWallet = require('./utils/callMultiSigWallet')
const validatorState = require('./utils/validatorState')

const {
FOREIGN_PRIVKEY,
FOREIGN_RPC_URL,
FOREING_BRIDGE_ADDRESS,
FOREIGN_BRIDGE_ADDRESS,
ROLE,
FOREIGN_START_BLOCK,
FOREIGN_GAS_PRICE,
NEW_IMPLEMENTATION_ETH_BRIDGE
NEW_IMPLEMENTATION_ETH_BRIDGE,
SAI_TOKENS_RECEIVER
} = process.env

const web3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL))
const { address } = web3.eth.accounts.wallet.add(FOREIGN_PRIVKEY)

const upgradeBridgeOnForeign = async () => {
try {
const proxy = new web3.eth.Contract(proxyAbi, FOREING_BRIDGE_ADDRESS)
const proxy = new web3.eth.Contract(proxyAbi, FOREIGN_BRIDGE_ADDRESS)
const foreignBridge = new web3.eth.Contract(bridgeAbi, FOREIGN_BRIDGE_ADDRESS)
const ownerAddress = await proxy.methods.upgradeabilityOwner().call()
const multiSigWallet = new web3.eth.Contract(multiSigWalletAbi, ownerAddress)

await validatorState(web3, address, multiSigWallet)

const data = proxy.methods.upgradeTo('5', NEW_IMPLEMENTATION_ETH_BRIDGE).encodeABI()
const fixData = foreignBridge.methods.fixLockedSai(SAI_TOKENS_RECEIVER).encodeABI()

const data = proxy.methods.upgradeToAndCall('6', NEW_IMPLEMENTATION_ETH_BRIDGE, fixData).encodeABI()

await callMultiSigWallet({
role: ROLE,
contract: multiSigWallet,
destination: FOREING_BRIDGE_ADDRESS,
destination: FOREIGN_BRIDGE_ADDRESS,
fromBlock: FOREIGN_START_BLOCK,
gasPrice: FOREIGN_GAS_PRICE,
address,
Expand Down

0 comments on commit 3c0c646

Please sign in to comment.