Skip to content

Commit

Permalink
Directory Reorg to incorporate v1 contracts (UMAprotocol#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrice32 authored May 6, 2019
1 parent 822a14e commit 5286406
Show file tree
Hide file tree
Showing 93 changed files with 422 additions and 195 deletions.
23 changes: 13 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
key: protocol-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Compile contracts
command: $(npm bin)/truffle compile
command: ./ci/build.sh
- save_cache:
key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }}
paths:
Expand All @@ -43,11 +43,8 @@ jobs:
- restore_cache:
key: protocol-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: JS Formatting
command: npm run prettier_check
- run:
name: Lint Solidity
command: $(npm bin)/solhint --max-warnings=1 contracts/**/*.sol
name: Lint
command: ./ci/lint.sh
slither:
docker:
- image: trailofbits/eth-security-toolbox
Expand Down Expand Up @@ -117,11 +114,15 @@ jobs:
paths:
- node_modules
- run:
name: Run coverage
command: npm run coverage
name: Run v0 coverage
command: ./ci/coverage.sh ~/protocol/v0
- store_artifacts:
path: v0/coverage
- run:
name: Run v1 coverage
command: ./ci/coverage.sh ~/protocol/v1
- store_artifacts:
path: coverage
destination: coverage
path: v1/coverage
echidna:
docker:
- image: trailofbits/eth-security-toolbox
Expand Down Expand Up @@ -159,6 +160,7 @@ jobs:
key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Deploy Contracts
working_directory: ~/protocol/v0
command: $(npm bin)/truffle migrate --reset --network test
- restore_cache:
keys:
Expand Down Expand Up @@ -193,6 +195,7 @@ jobs:
key: sponsor-dapp-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Apply Deployment Registry
working_directory: ~/protocol/v0
command: $(npm bin)/apply-registry
- run:
name: Build DApp
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
node_modules/*
build/*
node_modules
build
bridge.log
package-lock.json
coverage/*
coverage
coverage.json
out.log
.GckmsOverride.js
Expand Down
7 changes: 0 additions & 7 deletions .solcover.js

This file was deleted.

4 changes: 3 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"quotes": ["error", "double"],
"max-line-length": ["error", 120],
"compiler-fixed": false,
"max-states-count": false
"max-states-count": false,
"no-simple-event-func-name": false,
"function-max-lines": false
}
}

3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
Migrations.sol

10 changes: 10 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e

PROTOCOL_DIR=$(pwd)

cd $PROTOCOL_DIR/v0
$(npm bin)/truffle compile

cd $PROTOCOL_DIR/v1
$(npm bin)/truffle compile
18 changes: 18 additions & 0 deletions ci/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
set -e

# The truffle directory is passed in as the first argument.
TRUFFLE_DIR=$1

PROTOCOL_DIR=$(pwd)

# Note: the following is necessary because the vanilla solidity-coverage tool is outdated and not compatible with solidity 0.5.0+.
# We can may be able to get rid of the curl below once solidity-parser merges PR #18.
# There may also be an option to use solidity-coverage@beta package, but we have yet to test that.
curl https://raw.githubusercontent.com/maxsam4/solidity-parser/solidity-0.5/build/parser.js > node_modules/solidity-parser-sc/build/parser.js

# $1 is the truffle directory over which we want to run the coverage tool.
cd $TRUFFLE_DIR
cp -R $PROTOCOL_DIR/common ./
cp -R $PROTOCOL_DIR/node_modules ./
$(npm bin)/solidity-coverage
12 changes: 12 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

PROTOCOL_DIR=$(pwd)

# Lint JS
echo "Linting JS"
npm run prettier_check

# Lint Solidity
echo "Linting Solidity"
$(npm bin)/solhint --max-warnings=1 'v0/contracts/**/*.sol' 'v1/contracts/**/*.sol'
2 changes: 1 addition & 1 deletion ci/run_echidna_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Note: this assumes the .sol and .yaml files are 1:1 and have the same name.
run_echidna_test() {
local prefix=contracts/echidna_tests/
local prefix=v0/contracts/echidna_tests/
local solidity_fname=$prefix$1.sol
local config_fname=$prefix$1.yaml
local contract_name=$2
Expand Down
3 changes: 0 additions & 3 deletions ci/run_manticore_tests.sh

This file was deleted.

15 changes: 13 additions & 2 deletions ci/run_slither.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/usr/bin/env bash
set -e

PROTOCOL_DIR=$(pwd)
sudo chmod -R a+rwx /usr/local/lib/node_modules
truffle compile
slither --exclude=naming-convention,solc-version,pragma,external-function,reentrancy-benign,reentrancy-no-eth,arbitrary-send,locked-ether,reentrancy-eth .

run_slither() {
cd $1
truffle compile

cd $PROTOCOL_DIR
slither --exclude=naming-convention,solc-version,pragma,external-function,reentrancy-benign,reentrancy-no-eth,arbitrary-send,locked-ether,reentrancy-eth $1
}

run_slither $PROTOCOL_DIR/v0
run_slither $PROTOCOL_DIR/v1
55 changes: 39 additions & 16 deletions ci/run_truffle_tests.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/usr/bin/env bash
set -e

PROTOCOL_DIR=$(pwd)

# Verifies persistent deployments stored in the networks/ directory.
check_deployment() {
# $1 is network_id
local fname=networks/$1.json
local network_name=$2
# $1 is the operating directory
cd $1

# Remove the build directory.
rm -rf build

# Make sure the contracts are compiled and the registry is applied.
$(npm bin)/truffle compile
$(npm bin)/apply-registry

# $2 is network_id
local fname=networks/$2.json
local network_name=$3
if [ -e $fname ]
then
echo "Checking ${network_name} deployment stored in ${fname}."
Expand All @@ -15,20 +27,31 @@ check_deployment() {
fi
}

# Test migration
$(npm bin)/truffle migrate --reset --network ci
run_tests() {
# $1 is the operating directory
cd $1

# Ensure the migration is recoverable with only the artifacts saved in networks/.
rm -rf build
$(npm bin)/truffle compile
$(npm bin)/apply-registry
# Test migration
$(npm bin)/truffle migrate --reset --network ci

# Ensure the migration is recoverable with only the artifacts saved in networks/.
rm -rf build
$(npm bin)/truffle compile
$(npm bin)/apply-registry

# Verify the validity of the ci migration.
$(npm bin)/truffle exec ./scripts/CheckDeploymentValidity.js --network ci

# Run standard truffle tests
$(npm bin)/truffle test --network ci
}

# Verify the validity of the ci migration.
$(npm bin)/truffle exec ./scripts/CheckDeploymentValidity.js --network ci
# Run tests for v0.
run_tests $PROTOCOL_DIR/v0

# Verify the validity of mainnet and ropsten deployments if they exist.
check_deployment 1 mainnet
check_deployment 3 ropsten
# Verify the validity of the v0 mainnet and ropsten deployments if they exist.
check_deployment $PROTOCOL_DIR/v0 1 mainnet
check_deployment $PROTOCOL_DIR/v0 3 ropsten

# Run standard truffle tests
$(npm bin)/truffle test --network ci
# Run tests for v1.
run_tests $PROTOCOL_DIR/v1
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions common/globalSolcoverConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
copyPackages: ["openzeppelin-solidity"],
compileCommand: "../../node_modules/.bin/truffle compile",
testCommand: "../../node_modules/.bin/truffle test --network coverage",
port: 8545,
skipFiles: ["Migrations.sol", "echidna_tests", "test"]
};
File renamed without changes.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"scripts": {
"prettier": "npm run prettier_vanilla -- --write",
"prettier_check": "npm run prettier_vanilla -- --check",
"prettier_vanilla": "prettier 'test/**/*.js' 'migrations/*.js' 'scripts/*.js' 'gckms/*.js' '*.js' 'sponsor-dapp/src/**/*.js'",
"//": "comment on the below script - we can get rid of the curl below once solidity-parser merges PR #18",
"coverage": "curl https://raw.githubusercontent.com/maxsam4/solidity-parser/solidity-0.5/build/parser.js > node_modules/solidity-parser-sc/build/parser.js && $(npm bin)/solidity-coverage"
"prettier_vanilla": "prettier '**/test/**/*.js' '**/migrations/*.js' '**/scripts/*.js' 'common/**/*.js' '*.js' 'sponsor-dapp/src/**/*.js'"
},
"author": "UMA Team",
"license": "MIT",
Expand Down
5 changes: 4 additions & 1 deletion scripts/deploy_dapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ PROTOCOL_DIR=$(pwd)
# Shift the arguments to provide to gcloud app deploy.
shift

# Move to the v0 directory for contract compilation.
cd $PROTOCOL_DIR/v0

# Compile contracts, load deployed addresses for mainnet and ropsten.
echo "Compiling contracts."
$(npm bin)/truffle compile
Expand All @@ -47,7 +50,7 @@ fi
set -e

# Link the contracts dir to the dapp dir and build the dapp.
cd sponsor-dapp
cd $PROTOCOL_DIR/sponsor-dapp
echo "Linking contracts to dapp."
npm run link-contracts
echo "Building dapp."
Expand Down
2 changes: 1 addition & 1 deletion sponsor-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"link-contracts": "ln -sfn ../../build/contracts src/contracts",
"link-contracts": "ln -sfn ../../v0/build/contracts src/contracts",
"prettier": "prettier --write 'src/**/*.js'"
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion sponsor-dapp/src/identifiers.json
3 changes: 3 additions & 0 deletions v0/.solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const globalSolcoverConfig = require("../common/globalSolcoverConfig.js");

module.exports = globalSolcoverConfig;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract CentralizedOracle is OracleInterface, Withdrawable, Testable {

// Adds the provided identifier as a supported identifier.
function addSupportedIdentifier(bytes32 identifier) external onlyOwner {
if(!supportedIdentifiers[identifier]) {
if (!supportedIdentifiers[identifier]) {
supportedIdentifiers[identifier] = true;
emit AddSupportedIdentifier(identifier);
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ contract ContractCreator is Withdrawable {
address internal storeAddress;
address internal priceFeedAddress;

constructor(address registryAddress, address _oracleAddress, address _storeAddress, address _priceFeedAddress)
public
{
constructor(
address registryAddress,
address _oracleAddress,
address _storeAddress,
address _priceFeedAddress
) public {
registry = Registry(registryAddress);
oracleAddress = _oracleAddress;
storeAddress = _storeAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pragma solidity ^0.5.0;

import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";


contract ExpandedIERC20 is IERC20 {
// Burns a specific amount of tokens. Burns the sender's tokens, so it is safe to leave this method permissionless.
function burn(uint value) external;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5286406

Please sign in to comment.