Skip to content

Commit

Permalink
Remove contracts and build for spuriousDragon
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Jul 24, 2020
1 parent f405ba9 commit 6475b35
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 188 deletions.
51 changes: 0 additions & 51 deletions contracts/upgradeability/ClassicEternalStorageProxy.sol

This file was deleted.

1 change: 0 additions & 1 deletion contracts/upgradeability/README.md
Expand Up @@ -11,4 +11,3 @@ During the development process and performing security audits, the following min
- Version field type was changed from `string` to `uint256`, as it reduces possible complexity and allows to easily introduce a version mutability requirement (`require(version > _version);` in `UpgradeabilityProxy.sol`).
- Additional assembly operation was introduced in `Proxy.sol`, opcodes in line `mstore(0x40, add(ptr, returndatasize))` guarantee the correct value of free memory pointer for execution of next instructions.
- Additional check in `UpgradeabilityProxy.sol` was added, `require(AddressUtils.isContract(implementation))` verifies that new implementation is not a regular address, but a contract. See [#256](https://github.com/poanetwork/tokenbridge-contracts/pull/256).
- Contract `ClassicEternalStorageProxy.sol` was added for the use in pre-Byzantium Ethereum Classic network, which does not support [EIP-211](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-211.md). See this comment in [#161](https://github.com/poanetwork/tokenbridge-contracts/pull/161#issuecomment-473888305).

This file was deleted.

6 changes: 0 additions & 6 deletions deploy/.env.example
@@ -1,12 +1,6 @@
#BRIDGE_MODE=ERC_TO_ERC
BRIDGE_MODE=NATIVE_TO_ERC

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
#FOREIGN_EVM_VERSION=spuriousDragon

DEPLOYMENT_ACCOUNT_PRIVATE_KEY=67..14
DEPLOYMENT_GAS_LIMIT_EXTRA=0.2
HOME_DEPLOYMENT_GAS_PRICE=10000000000
Expand Down
56 changes: 0 additions & 56 deletions deploy/README.md
Expand Up @@ -32,14 +32,6 @@ This example of an `.env` file for the `native-to-erc` bridge mode includes comm
# The type of bridge. Defines set of contracts to be deployed.
BRIDGE_MODE=NATIVE_TO_ERC

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#FOREIGN_EVM_VERSION=spuriousDragon

# The private key hex value of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks.
Expand Down Expand Up @@ -186,14 +178,6 @@ This example of an `.env` file for the `erc-to-erc` bridge mode includes comment
# The type of bridge. Defines set of contracts to be deployed.
BRIDGE_MODE=ERC_TO_ERC

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#FOREIGN_EVM_VERSION=spuriousDragon

# The private key hex value of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks.
Expand Down Expand Up @@ -321,14 +305,6 @@ This example of an `.env` file for the `erc-to-native` bridge mode includes comm
# The type of bridge. Defines set of contracts to be deployed.
BRIDGE_MODE=ERC_TO_NATIVE

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#FOREIGN_EVM_VERSION=spuriousDragon

# The private key hex value of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks.
Expand Down Expand Up @@ -555,14 +531,6 @@ This example of an `.env` file for the `AMB-ERC-TO-ERC` bridge mode includes com
# The type of bridge. Defines set of contracts to be deployed.
BRIDGE_MODE=AMB_ERC_TO_ERC

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#FOREIGN_EVM_VERSION=spuriousDragon

# The private key hex value of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks.
Expand Down Expand Up @@ -672,14 +640,6 @@ This example of an `.env` file for the `STAKE-AMB-ERC-TO-ERC` bridge mode includ
# The type of bridge. Defines set of contracts to be deployed.
BRIDGE_MODE=STAKE_AMB_ERC_TO_ERC

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#FOREIGN_EVM_VERSION=spuriousDragon

# The private key hex value of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks.
Expand Down Expand Up @@ -782,14 +742,6 @@ This example of an `.env` file for the `AMB-NATIVE-TO-ERC` bridge mode includes
# The type of bridge. Defines set of contracts to be deployed.
BRIDGE_MODE=AMB_NATIVE_TO_ERC

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#FOREIGN_EVM_VERSION=spuriousDragon

# The private key hex value of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks.
Expand Down Expand Up @@ -915,14 +867,6 @@ This example of an `.env` file for the `AMB-ERC-TO-NATIVE` bridge mode includes
# The type of bridge. Defines set of contracts to be deployed.
BRIDGE_MODE=AMB_ERC_TO_NATIVE

# If Home network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#HOME_EVM_VERSION=spuriousDragon

# If Foreign network does not support byzantium fork, should use contracts compiled for spuriousDragon
# Default value is byzantium
#FOREIGN_EVM_VERSION=spuriousDragon

# The private key hex value of the account responsible for contracts
# deployments and initial configuration. The account's balance must contain
# funds from both networks.
Expand Down
6 changes: 1 addition & 5 deletions deploy/src/constants.js
@@ -1,8 +1,5 @@
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
const EVM_TYPES = {
BYZANTIUM: 'byzantium',
SPURIOUSDRAGON: 'spuriousDragon'
}

const EXPLORER_TYPES = {
ETHERSCAN: 'etherscan',
BLOCKSCOUT: 'blockscout'
Expand All @@ -13,7 +10,6 @@ const REQUEST_STATUS = {

module.exports = {
ZERO_ADDRESS,
EVM_TYPES,
EXPLORER_TYPES,
REQUEST_STATUS
}
20 changes: 6 additions & 14 deletions deploy/src/loadContracts.js
@@ -1,17 +1,11 @@
/* eslint import/no-dynamic-require: 0 */
const { HOME_EVM_VERSION, FOREIGN_EVM_VERSION } = require('./loadEnv')
const { EVM_TYPES } = require('./constants')
const homeContracts = getContracts()
const foreignContracts = getContracts()

const homeContracts = getContracts(HOME_EVM_VERSION)
const foreignContracts = getContracts(FOREIGN_EVM_VERSION)

function getContracts(evmVersion) {
const buildPath = evmVersion === EVM_TYPES.SPURIOUSDRAGON ? 'spuriousDragon' : 'contracts'
const useClassicProxy = evmVersion === EVM_TYPES.SPURIOUSDRAGON
function getContracts() {
const buildPath = 'contracts'
return {
EternalStorageProxy: useClassicProxy
? require(`../../build/${buildPath}/ClassicEternalStorageProxy.json`)
: require(`../../build/${buildPath}/EternalStorageProxy.json`),
EternalStorageProxy: require(`../../build/${buildPath}/EternalStorageProxy.json`),
BridgeValidators: require(`../../build/${buildPath}/BridgeValidators.json`),
RewardableValidators: require(`../../build/${buildPath}/RewardableValidators.json`),
FeeManagerErcToErcPOSDAO: require(`../../build/${buildPath}/FeeManagerErcToErcPOSDAO.json`),
Expand All @@ -29,9 +23,7 @@ function getContracts(evmVersion) {
FeeManagerNativeToErc: require(`../../build/${buildPath}/FeeManagerNativeToErc.json`),
ForeignBridgeNativeToErc: require(`../../build/${buildPath}/ForeignBridgeNativeToErc.json`),
FeeManagerNativeToErcBothDirections: require(`../../build/${buildPath}/FeeManagerNativeToErcBothDirections.json`),
HomeBridgeNativeToErc: useClassicProxy
? require(`../../build/${buildPath}/ClassicHomeBridgeNativeToErc.json`)
: require(`../../build/${buildPath}/HomeBridgeNativeToErc.json`),
HomeBridgeNativeToErc: require(`../../build/${buildPath}/HomeBridgeNativeToErc.json`),
BlockReward: require(`../../build/${buildPath}/BlockReward.json`),
BlockRewardMock: require(`../../build/${buildPath}/BlockRewardMock.json`),
HomeAMB: require(`../../build/${buildPath}/HomeAMB.json`),
Expand Down
19 changes: 2 additions & 17 deletions deploy/src/loadEnv.js
Expand Up @@ -4,13 +4,12 @@ require('dotenv').config({
})
const { isAddress, toBN } = require('web3').utils
const envalid = require('envalid')
const { ZERO_ADDRESS, EVM_TYPES } = require('./constants')
const { ZERO_ADDRESS } = require('./constants')

const homePrefix = 'HOME'
const foreignPrefix = 'FOREIGN'

// Validations and constants
const evmVersions = [EVM_TYPES.BYZANTIUM, EVM_TYPES.SPURIOUSDRAGON]
const validBridgeModes = [
'NATIVE_TO_ERC',
'ERC_TO_ERC',
Expand Down Expand Up @@ -84,25 +83,11 @@ const {
VALIDATORS_REWARD_ACCOUNTS,
DEPLOY_REWARDABLE_TOKEN,
DEPLOY_INTEREST_RECEIVER,
HOME_FEE_MANAGER_TYPE,
HOME_EVM_VERSION,
FOREIGN_EVM_VERSION
HOME_FEE_MANAGER_TYPE
} = process.env

// Types validations

if (HOME_EVM_VERSION) {
if (!evmVersions.includes(HOME_EVM_VERSION)) {
throw new Error(`Invalid Home EVM Version: ${HOME_EVM_VERSION}. Supported values are ${evmVersions}`)
}
}

if (FOREIGN_EVM_VERSION) {
if (!evmVersions.includes(FOREIGN_EVM_VERSION)) {
throw new Error(`Invalid Foreign EVM Version: ${FOREIGN_EVM_VERSION}. Supported values are ${evmVersions}`)
}
}

if (!validBridgeModes.includes(BRIDGE_MODE)) {
throw new Error(`Invalid bridge mode: ${BRIDGE_MODE}`)
}
Expand Down
10 changes: 5 additions & 5 deletions deploy/src/utils/deployERC20Token.js
Expand Up @@ -6,7 +6,7 @@ const { deployContract, privateKeyToAddress, sendRawTxForeign } = require('../de
const { web3Foreign, deploymentPrivateKey, FOREIGN_RPC_URL } = require('../web3')

const {
foreignContracts: { ERC677BridgeToken }
foreignContracts: { ERC677MultiBridgeToken }
} = require('../loadContracts')

const {
Expand All @@ -22,16 +22,16 @@ async function deployToken() {
let foreignNonce = await web3Foreign.eth.getTransactionCount(DEPLOYMENT_ACCOUNT_ADDRESS)
console.log('\n[Foreign] deploying ERC20 token')
const erc677token = await deployContract(
ERC677BridgeToken,
[BRIDGEABLE_TOKEN_NAME, BRIDGEABLE_TOKEN_SYMBOL, BRIDGEABLE_TOKEN_DECIMALS],
ERC677MultiBridgeToken,
[BRIDGEABLE_TOKEN_NAME, BRIDGEABLE_TOKEN_SYMBOL, BRIDGEABLE_TOKEN_DECIMALS, '42'],
{ from: DEPLOYMENT_ACCOUNT_ADDRESS, network: 'foreign', nonce: foreignNonce }
)
foreignNonce++
console.log('[Foreign] ERC20 Token: ', erc677token.options.address)

console.log('[Foreign] minting 100 tokens and transfer them to ', DEPLOYMENT_ACCOUNT_ADDRESS)
console.log('[Foreign] minting 900 tokens and transfer them to ', DEPLOYMENT_ACCOUNT_ADDRESS)
const mintData = await erc677token.methods
.mint(DEPLOYMENT_ACCOUNT_ADDRESS, '100000000000000000000')
.mint(DEPLOYMENT_ACCOUNT_ADDRESS, '900000000000000000000')
.encodeABI({ from: DEPLOYMENT_ACCOUNT_ADDRESS })
const txMint = await sendRawTxForeign({
data: mintData,
Expand Down
2 changes: 0 additions & 2 deletions flatten.sh
Expand Up @@ -20,7 +20,6 @@ VALIDATOR_CONTRACTS_DIR=contracts/upgradeable_contracts

echo "Flattening common bridge contracts"
${FLATTENER} contracts/upgradeability/EternalStorageProxy.sol > flats/upgradeability/EternalStorageProxy_flat.sol
${FLATTENER} contracts/upgradeability/ClassicEternalStorageProxy.sol > flats/upgradeability/ClassicEternalStorageProxy_flat.sol
${FLATTENER} contracts/ERC677BridgeToken.sol > flats/ERC677BridgeToken_flat.sol
${FLATTENER} contracts/ERC677BridgeTokenRewardable.sol > flats/ERC677BridgeTokenRewardable_flat.sol
${FLATTENER} contracts/PermittableToken.sol > flats/PermittableToken_flat.sol
Expand All @@ -32,7 +31,6 @@ ${FLATTENER} ${VALIDATOR_CONTRACTS_DIR}/RewardableValidators.sol > flats/validat
echo "Flattening contracts related to native-to-erc bridge"
${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ForeignBridgeNativeToErc.sol > flats/native_to_erc20/ForeignBridgeNativeToErc_flat.sol
${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/HomeBridgeNativeToErc.sol > flats/native_to_erc20/HomeBridgeNativeToErc_flat.sol
${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/ClassicHomeBridgeNativeToErc.sol > flats/native_to_erc20/ClassicHomeBridgeNativeToErc_flat.sol
${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/FeeManagerNativeToErc.sol > flats/native_to_erc20/FeeManagerNativeToErc_flat.sol
${FLATTENER} ${BRIDGE_CONTRACTS_DIR}/native_to_erc20/FeeManagerNativeToErcBothDirections.sol > flats/native_to_erc20/FeeManagerNativeToErcBothDirections_flat.sol

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -7,7 +7,7 @@
"test": "scripts/test.sh",
"test:gasreport": "GASREPORT=true npm run test",
"test:gasreport:ci": "npm run test:gasreport && npx codechecks",
"compile": "truffle compile && truffle compile spuriousDragon",
"compile": "truffle compile",
"flatten": "bash flatten.sh",
"lint": "npm run lint:js && npm run lint:sol",
"lint:js": "eslint .",
Expand Down
5 changes: 2 additions & 3 deletions truffle-config.js
Expand Up @@ -2,9 +2,8 @@ const { CoverageSubprovider, Web3ProviderEngine } = require('@0x/sol-coverage')
const { TruffleArtifactAdapter } = require('@0x/sol-trace')
const { GanacheSubprovider } = require('@0x/subproviders')

const spuriousDragonVersion = process.argv[3] === 'spuriousDragon'
const contractsBuildDirectory = spuriousDragonVersion ? './build/spuriousDragon' : './build/contracts'
const evmVersion = spuriousDragonVersion ? 'spuriousDragon' : 'byzantium'
const contractsBuildDirectory = './build/contracts'
const evmVersion = 'byzantium'
const mochaOptions =
process.env.GASREPORT === 'true'
? {
Expand Down

0 comments on commit 6475b35

Please sign in to comment.