Remove unused upgrade dir (#614)
This commit is contained in:
parent
f862da73f3
commit
0d191e198c
|
@ -11,6 +11,4 @@ Dockerfile
|
|||
flats
|
||||
contracts.sublime-project
|
||||
contracts.sublime-workspace
|
||||
upgrade/*.env*
|
||||
!upgrade/.env.example
|
||||
build/
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
node_modules
|
||||
deploy
|
||||
upgrade
|
||||
coverage
|
||||
|
|
|
@ -10,6 +10,4 @@ coverage.json
|
|||
deploy/*.config
|
||||
deploy/*.env*
|
||||
!deploy/.env.example
|
||||
upgrade/*.env*
|
||||
!upgrade/.env.example
|
||||
.vscode
|
||||
|
|
|
@ -23,11 +23,6 @@ COPY ./deploy/package.json ./deploy/
|
|||
COPY ./deploy/package-lock.json ./deploy/
|
||||
RUN cd ./deploy; npm install --only=prod; cd ..
|
||||
|
||||
COPY ./upgrade/package.json ./upgrade/
|
||||
COPY ./upgrade/package-lock.json ./upgrade/
|
||||
RUN cd ./upgrade; npm install --only=prod; cd ..
|
||||
|
||||
COPY ./upgrade ./upgrade
|
||||
COPY deploy.sh deploy.sh
|
||||
COPY ./deploy ./deploy
|
||||
|
||||
|
|
|
@ -14,10 +14,6 @@ COPY ./deploy/package.json ./deploy/
|
|||
COPY ./deploy/package-lock.json ./deploy/
|
||||
RUN cd ./deploy; npm install; cd ..
|
||||
|
||||
COPY ./upgrade/package.json ./upgrade/
|
||||
COPY ./upgrade/package-lock.json ./upgrade/
|
||||
RUN cd ./upgrade; npm install; cd ..
|
||||
|
||||
COPY truffle-config.js truffle-config.js
|
||||
COPY ./contracts ./contracts
|
||||
RUN npm run compile
|
||||
|
@ -29,7 +25,6 @@ COPY .eslintignore .eslintignore
|
|||
COPY .eslintrc .eslintrc
|
||||
COPY .prettierrc .prettierrc
|
||||
|
||||
COPY ./upgrade ./upgrade
|
||||
COPY deploy.sh deploy.sh
|
||||
COPY ./deploy ./deploy
|
||||
COPY .solhint.json .solhint.json
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
FOREIGN_RPC_URL=https://mainnet.infura.io/v3/API_KEY
|
||||
FOREIGN_PRIVKEY=0x...
|
||||
FOREIGN_BRIDGE_ADDRESS=0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016
|
||||
FOREIGN_START_BLOCK=9122083
|
||||
FOREIGN_GAS_PRICE=1000000000
|
||||
|
||||
# leader or confirm
|
||||
ROLE=confirm
|
||||
|
||||
NEW_IMPLEMENTATION_ETH_BRIDGE=
|
||||
SAI_TOKENS_RECEIVER=
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"extends": ["plugin:node/recommended", "airbnb-base", "plugin:prettier/recommended"],
|
||||
"plugins": ["node"],
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"rules": {
|
||||
"no-use-before-define": ["error", { "functions": false }],
|
||||
"node/no-unpublished-require": "off",
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
.env
|
||||
node_modules
|
|
@ -1 +0,0 @@
|
|||
10.18
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"printWidth": 120,
|
||||
"bracketSpacing": true
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
### How to run upgrade scripts
|
||||
|
||||
Install dependencies in root project and compile the contracts
|
||||
```bash
|
||||
cd ..
|
||||
npm i
|
||||
npm run compile
|
||||
```
|
||||
|
||||
Install dependencies from `upgrade` folder
|
||||
```bash
|
||||
cd upgrade
|
||||
npm i
|
||||
```
|
||||
|
||||
Create `.env` file
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Complete the variables in `.env` file. The `ROLE` variable indicates if the validator will send the creation transaction on the multisig wallet or if it will send the confirmation.
|
||||
|
||||
Run the script. The following are available:
|
||||
* `npm run upgradeBridgeOnForeign`
|
|
@ -1,265 +0,0 @@
|
|||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [{ "name": "", "type": "uint256" }],
|
||||
"name": "owners",
|
||||
"outputs": [{ "name": "", "type": "address" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [{ "name": "owner", "type": "address" }],
|
||||
"name": "removeOwner",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [{ "name": "transactionId", "type": "uint256" }],
|
||||
"name": "revokeConfirmation",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [{ "name": "", "type": "address" }],
|
||||
"name": "isOwner",
|
||||
"outputs": [{ "name": "", "type": "bool" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{ "name": "", "type": "uint256" },
|
||||
{ "name": "", "type": "address" }
|
||||
],
|
||||
"name": "confirmations",
|
||||
"outputs": [{ "name": "", "type": "bool" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{ "name": "pending", "type": "bool" },
|
||||
{ "name": "executed", "type": "bool" }
|
||||
],
|
||||
"name": "getTransactionCount",
|
||||
"outputs": [{ "name": "count", "type": "uint256" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [{ "name": "owner", "type": "address" }],
|
||||
"name": "addOwner",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [{ "name": "transactionId", "type": "uint256" }],
|
||||
"name": "isConfirmed",
|
||||
"outputs": [{ "name": "", "type": "bool" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [{ "name": "transactionId", "type": "uint256" }],
|
||||
"name": "getConfirmationCount",
|
||||
"outputs": [{ "name": "count", "type": "uint256" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [{ "name": "", "type": "uint256" }],
|
||||
"name": "transactions",
|
||||
"outputs": [
|
||||
{ "name": "destination", "type": "address" },
|
||||
{ "name": "value", "type": "uint256" },
|
||||
{ "name": "data", "type": "bytes" },
|
||||
{ "name": "executed", "type": "bool" }
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getOwners",
|
||||
"outputs": [{ "name": "", "type": "address[]" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{ "name": "from", "type": "uint256" },
|
||||
{ "name": "to", "type": "uint256" },
|
||||
{ "name": "pending", "type": "bool" },
|
||||
{ "name": "executed", "type": "bool" }
|
||||
],
|
||||
"name": "getTransactionIds",
|
||||
"outputs": [{ "name": "_transactionIds", "type": "uint256[]" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [{ "name": "transactionId", "type": "uint256" }],
|
||||
"name": "getConfirmations",
|
||||
"outputs": [{ "name": "_confirmations", "type": "address[]" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "transactionCount",
|
||||
"outputs": [{ "name": "", "type": "uint256" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [{ "name": "_required", "type": "uint256" }],
|
||||
"name": "changeRequirement",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [{ "name": "transactionId", "type": "uint256" }],
|
||||
"name": "confirmTransaction",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{ "name": "destination", "type": "address" },
|
||||
{ "name": "value", "type": "uint256" },
|
||||
{ "name": "data", "type": "bytes" }
|
||||
],
|
||||
"name": "submitTransaction",
|
||||
"outputs": [{ "name": "transactionId", "type": "uint256" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "MAX_OWNER_COUNT",
|
||||
"outputs": [{ "name": "", "type": "uint256" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "required",
|
||||
"outputs": [{ "name": "", "type": "uint256" }],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{ "name": "owner", "type": "address" },
|
||||
{ "name": "newOwner", "type": "address" }
|
||||
],
|
||||
"name": "replaceOwner",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [{ "name": "transactionId", "type": "uint256" }],
|
||||
"name": "executeTransaction",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "name": "_owners", "type": "address[]" },
|
||||
{ "name": "_required", "type": "uint256" }
|
||||
],
|
||||
"payable": false,
|
||||
"type": "constructor"
|
||||
},
|
||||
{ "payable": true, "type": "fallback" },
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": true, "name": "sender", "type": "address" },
|
||||
{ "indexed": true, "name": "transactionId", "type": "uint256" }
|
||||
],
|
||||
"name": "Confirmation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": true, "name": "sender", "type": "address" },
|
||||
{ "indexed": true, "name": "transactionId", "type": "uint256" }
|
||||
],
|
||||
"name": "Revocation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [{ "indexed": true, "name": "transactionId", "type": "uint256" }],
|
||||
"name": "Submission",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [{ "indexed": true, "name": "transactionId", "type": "uint256" }],
|
||||
"name": "Execution",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [{ "indexed": true, "name": "transactionId", "type": "uint256" }],
|
||||
"name": "ExecutionFailure",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": true, "name": "sender", "type": "address" },
|
||||
{ "indexed": false, "name": "value", "type": "uint256" }
|
||||
],
|
||||
"name": "Deposit",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [{ "indexed": true, "name": "owner", "type": "address" }],
|
||||
"name": "OwnerAddition",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [{ "indexed": true, "name": "owner", "type": "address" }],
|
||||
"name": "OwnerRemoval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [{ "indexed": false, "name": "required", "type": "uint256" }],
|
||||
"name": "RequirementChange",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"name": "upgrade-xdai",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "GPLv3",
|
||||
"scripts": {
|
||||
"upgradeBridgeOnForeign": "node src/upgradeBridgeOnForeign.js",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^8.2.0",
|
||||
"web3": "^1.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-config-airbnb-base": "^14.0.0",
|
||||
"eslint-config-prettier": "^6.7.0",
|
||||
"eslint-plugin-node": "^10.0.0",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"prettier": "^1.19.1"
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
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,
|
||||
FOREIGN_BRIDGE_ADDRESS,
|
||||
ROLE,
|
||||
FOREIGN_START_BLOCK,
|
||||
FOREIGN_GAS_PRICE,
|
||||
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, 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 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: FOREIGN_BRIDGE_ADDRESS,
|
||||
fromBlock: FOREIGN_START_BLOCK,
|
||||
gasPrice: FOREIGN_GAS_PRICE,
|
||||
address,
|
||||
data
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
upgradeBridgeOnForeign()
|
|
@ -1,68 +0,0 @@
|
|||
const { toBN } = require('web3').utils
|
||||
|
||||
const confirmTransaction = async ({ contract, fromBlock = 0, destination, data, address, gasPrice }) => {
|
||||
const submissions = await contract.getPastEvents('Submission', { fromBlock, toBlock: 'latest' })
|
||||
|
||||
if (!submissions.length) {
|
||||
throw new Error('No submissions found.')
|
||||
}
|
||||
const filteredSubmission = []
|
||||
await Promise.all(
|
||||
submissions.map(async s => {
|
||||
const { transactionId } = s.returnValues
|
||||
const transaction = await contract.methods.transactions(transactionId).call()
|
||||
if (transaction.destination === destination && transaction.data === data) {
|
||||
if (!transaction.executed) {
|
||||
console.log(
|
||||
`Found a transaction to confirm. Id: ${transactionId}, Block: ${s.blockNumber}, Data: ${transaction.data}`
|
||||
)
|
||||
filteredSubmission.push(s)
|
||||
return
|
||||
}
|
||||
console.log(
|
||||
`Found a transaction that was already executed. Id: ${transactionId}, Block: ${s.blockNumber}, Data: ${transaction.data}`
|
||||
)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (filteredSubmission.length > 1) {
|
||||
throw new Error('More than one transaction found.')
|
||||
} else if (filteredSubmission.length === 0) {
|
||||
throw new Error('No transaction to confirm.')
|
||||
}
|
||||
const { transactionId } = filteredSubmission[0].returnValues
|
||||
const estimatedGas = await contract.methods.confirmTransaction(transactionId).estimateGas({ from: address })
|
||||
const gas = addExtraGas(estimatedGas)
|
||||
|
||||
const receipt = await contract.methods.confirmTransaction(transactionId).send({ from: address, gas, gasPrice })
|
||||
console.log(`Confirmation status: ${receipt.status} - Tx Hash: ${receipt.transactionHash}`)
|
||||
}
|
||||
|
||||
function addExtraGas(initialGas) {
|
||||
const gas = toBN(initialGas)
|
||||
const extraPercentage = toBN(4)
|
||||
|
||||
return gas.mul(extraPercentage)
|
||||
}
|
||||
|
||||
const callMultiSigWallet = async ({ role, contract, destination, fromBlock, gasPrice, address, data }) => {
|
||||
if (role === 'leader') {
|
||||
const gas = await contract.methods.submitTransaction(destination, 0, data).estimateGas({ from: address })
|
||||
const receipt = await contract.methods
|
||||
.submitTransaction(destination, 0, data)
|
||||
.send({ from: address, gas: addExtraGas(gas), gasPrice })
|
||||
console.log(`Submission status: ${receipt.status} - Tx Hash: ${receipt.transactionHash}`)
|
||||
} else {
|
||||
await confirmTransaction({
|
||||
fromBlock,
|
||||
contract,
|
||||
destination,
|
||||
data,
|
||||
address,
|
||||
gasPrice
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = callMultiSigWallet
|
|
@ -1,17 +0,0 @@
|
|||
const { toBN } = require('web3').utils
|
||||
|
||||
const validatorState = async (web3, address, multiSigWallet) => {
|
||||
const balance = await web3.eth.getBalance(address)
|
||||
console.log(`Validator ${address} balance is ${balance}`)
|
||||
if (toBN(balance).isZero()) {
|
||||
throw new Error(`Balance is zero.`)
|
||||
}
|
||||
|
||||
const isOwner = await multiSigWallet.methods.isOwner(address).call()
|
||||
|
||||
if (!isOwner) {
|
||||
throw new Error(`The validator is not part of the multisig wallet.`)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = validatorState
|
Loading…
Reference in New Issue