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

Migrating to buidler #492

Merged
merged 105 commits into from Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
18ef61b
First start of migration to buidler
jjgonecrypto Apr 2, 2020
db992f2
Introducing unit tests
jjgonecrypto Apr 2, 2020
799ab46
trigger build
jjgonecrypto Apr 2, 2020
0a96f7f
trigger build v2
jjgonecrypto Apr 2, 2020
e36dda3
Fixing circleci config
jjgonecrypto Apr 2, 2020
72f7c2f
Fixing tests for Buidler
jjgonecrypto Apr 2, 2020
3245577
Migrating delegate approvals to unit
jjgonecrypto Apr 3, 2020
2060de8
SystemStatus to unit
jjgonecrypto Apr 3, 2020
c0d8111
Migrating ProxyERC20 to unit
jjgonecrypto Apr 3, 2020
8952e77
Adding fallback test to ProxyERC20
jjgonecrypto Apr 3, 2020
13af456
MixinResolver to unit tests
jjgonecrypto Apr 3, 2020
a84ab3c
SupplySchedule a WIP
jjgonecrypto Apr 3, 2020
6f4e487
Renaming common test setup
jjgonecrypto Apr 3, 2020
58e1a96
Minor updates
jjgonecrypto Apr 3, 2020
9a6d903
Fixing coverage
jjgonecrypto Apr 4, 2020
1d901df
Adding back timestamp tests
jjgonecrypto Apr 5, 2020
7d5c336
Upgrading to use timestamp from latest buidler
jjgonecrypto Apr 6, 2020
0baaca2
Merge branch 'develop' into migrating-to-buidler
jjgonecrypto Apr 6, 2020
4213109
SynthetixState
jjgonecrypto Apr 6, 2020
55453a3
Adding more checks to SupplySchedule
jjgonecrypto Apr 6, 2020
71d032e
Better approach to setup
jjgonecrypto Apr 6, 2020
97c3897
Refactoring ExchangeRates to use setup script
jjgonecrypto Apr 6, 2020
75970c2
Adding ABI check to ExchangeRates
jjgonecrypto Apr 6, 2020
908a3e1
Upgrading to solidity-coverage@0.7.3
jjgonecrypto Apr 6, 2020
31ab8a3
Removing unneeded settings
jjgonecrypto Apr 6, 2020
7ef10a2
Removing unneeded settings
jjgonecrypto Apr 6, 2020
2dde295
Revert "Removing unneeded settings"
jjgonecrypto Apr 6, 2020
40e1b4b
Fixing coverage
jjgonecrypto Apr 6, 2020
25c26a2
Fixing coverage tests to use starting timestamp
jjgonecrypto Apr 6, 2020
c14f992
New setup script WIP
jjgonecrypto Apr 7, 2020
ff96c8a
Better setup
jjgonecrypto Apr 7, 2020
9a19c32
Adding supply
jjgonecrypto Apr 7, 2020
3121fdb
Mock token functionality
jjgonecrypto Apr 7, 2020
617ddcd
Allowing for mocks as address resolver deps
jjgonecrypto Apr 7, 2020
48a0e1e
Depot test fixes
jjgonecrypto Apr 7, 2020
437f9fc
Fixing Depot tests with gas
jjgonecrypto Apr 7, 2020
31952c5
Adding MockSynth for Depot and EtherCollateral
jjgonecrypto Apr 7, 2020
651c7de
Test improvements for EtherCollateral
jjgonecrypto Apr 7, 2020
70e8682
Fixing most of EtherCollateral
jjgonecrypto Apr 7, 2020
afe504a
Merge branch 'develop' into migrating-to-buidler
jjgonecrypto Apr 7, 2020
75a55f4
Adding timeout for specifc long-running test
jjgonecrypto Apr 7, 2020
16f34dd
Update to using new unit coverage
jjgonecrypto Apr 7, 2020
d839c76
Merge branch 'develop' into migrating-to-buidler
jjgonecrypto Apr 7, 2020
30b04d0
Fixing tests
jjgonecrypto Apr 7, 2020
d68facb
Fixing legacy tests
jjgonecrypto Apr 7, 2020
aff92e9
Minor fixes
jjgonecrypto Apr 7, 2020
8ba7403
Fixing remaining EtherCollateral test
jjgonecrypto Apr 7, 2020
5005345
Adding more SynthetixState tests
jjgonecrypto Apr 7, 2020
a7a6788
Merge branch 'develop' into migrating-to-buidler
jjgonecrypto Apr 8, 2020
8cc103a
RewardEscrow migrated over
jjgonecrypto Apr 9, 2020
485de38
Fixing EtherCollateral
jjgonecrypto Apr 9, 2020
59524a2
Fixing coverage to use PR
jjgonecrypto Apr 9, 2020
84f9d84
Adding larger specific timeouts for coverage
jjgonecrypto Apr 9, 2020
361f1c9
Fixing timeouts for coverage
jjgonecrypto Apr 9, 2020
6fa1888
Synthetix WIP
jjgonecrypto Apr 9, 2020
4c24861
Synthetix more structure
jjgonecrypto Apr 10, 2020
d2e0889
Working through Synthetix tests
jjgonecrypto Apr 10, 2020
53cf526
Working thru Synthetix still, now with Issuer
jjgonecrypto Apr 10, 2020
200e1b4
More progress with Synthetix - now with generic mocks
jjgonecrypto Apr 10, 2020
8110123
Supporting exchange() in Synthetix tests
jjgonecrypto Apr 10, 2020
afb7563
fixing synthetix.mint()
jjgonecrypto Apr 11, 2020
4b22422
Fixing remainder of Synthetix tests
jjgonecrypto Apr 11, 2020
6da3d13
Fixing broken tests, der
jjgonecrypto Apr 11, 2020
d1845a7
Fixing EtherCollateral
jjgonecrypto Apr 11, 2020
75b9ba6
FeePoolState
jjgonecrypto Apr 11, 2020
316fdd0
Simpler implementation
jjgonecrypto Apr 11, 2020
cb13e1d
Exchanger WIP
jjgonecrypto Apr 13, 2020
454f379
Exchanger WIP
jjgonecrypto Apr 13, 2020
24d6142
Fixing Exchanger
jjgonecrypto Apr 13, 2020
dd3092e
Trimming up RewardEscrow to be a unit test
jjgonecrypto Apr 13, 2020
127cd99
Merge branch 'develop' into migrating-to-buidler
jjgonecrypto Apr 13, 2020
c433f9c
Adding Synth test
jjgonecrypto Apr 14, 2020
dc2d940
Adding more coverage to Synth test
jjgonecrypto Apr 14, 2020
5bb00e1
Fixing Issuer tests
jjgonecrypto Apr 15, 2020
b2280dc
Fixing tests
jjgonecrypto Apr 15, 2020
46f631a
Upgrading to solidity-coverage@0.7.4
jjgonecrypto Apr 15, 2020
0b75b2e
Depot Test Coverage
Apr 15, 2020
0164ebd
updateRatesWithDefaults moved
Apr 15, 2020
db8c3a9
Merge branch 'migrating-to-buidler' of github.com:Synthetixio/synthet…
Apr 15, 2020
40cad9e
Fixing Depot test
jjgonecrypto Apr 15, 2020
2d41fd2
Fixing RewardsDistribution
jjgonecrypto Apr 15, 2020
9744b1c
Porting over MultiCollateralSynth
jjgonecrypto Apr 15, 2020
cd453cf
Migrating FeePool tests
jjgonecrypto Apr 15, 2020
1119750
Fixing usages of getDecodedLogs
jjgonecrypto Apr 15, 2020
fb803fa
Purgeable Synth porting over
jjgonecrypto Apr 15, 2020
3ce6cbc
Final test :bow:
jjgonecrypto Apr 15, 2020
4f97c3d
Removing truffle migrations
jjgonecrypto Apr 15, 2020
d63cf9b
The death of truffle :skull_and_crossbones:
jjgonecrypto Apr 15, 2020
cc4be4e
Fixing circleci yml
jjgonecrypto Apr 15, 2020
0da43ed
The removal of ganache :boom:
jjgonecrypto Apr 15, 2020
04bd544
Updating lock
jjgonecrypto Apr 15, 2020
e808cd5
Cleaning up invocation
jjgonecrypto Apr 15, 2020
086eea4
Commenting out test failure from coverage
jjgonecrypto Apr 15, 2020
e7cdadc
The last vestigates of truffle...
jjgonecrypto Apr 15, 2020
9f19ce4
Moving test files back to test/contracts
jjgonecrypto Apr 15, 2020
3da8719
Cleaning up test helpers
jjgonecrypto Apr 16, 2020
e10c938
set default min stake time (#498)
jacko125 Apr 16, 2020
c296100
PR feedback
jjgonecrypto Apr 16, 2020
c103910
Merge branch 'migrating-to-buidler' of github.com:Synthetixio/synthet…
jjgonecrypto Apr 16, 2020
71e6e22
Removing contract and web3 globals
jjgonecrypto Apr 16, 2020
f1cbdb8
Adding chai for assertions and explicit usage of all globals
jjgonecrypto Apr 16, 2020
100c0c7
Cleaning up util usage and test setup
jjgonecrypto Apr 16, 2020
b54d60f
Ensuring web3 is properly wrapped into testUtils
jjgonecrypto Apr 16, 2020
7ea3aab
Fixing local testnet test
jjgonecrypto Apr 16, 2020
0ceafab
Cleanup
jjgonecrypto Apr 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions .circleci/config.yml
Expand Up @@ -32,7 +32,6 @@ jobs:
- 'v2-dependencies-{{ checksum "package-lock.json" }}'
- v2-dependencies-
- run: npm install
- run: npx truffle compile
- save_cache:
paths:
- node_modules
Expand All @@ -41,10 +40,6 @@ jobs:
root: .
paths:
- node_modules
# add compiled contracts to persisted workspace
# (note not currently working due to:
# https://github.com/trufflesuite/truffle/issues/2239#issuecomment-552041859)
- build

lint:
<<: *env_defaults
Expand All @@ -56,20 +51,16 @@ jobs:

test-contracts:
<<: *env_defaults
parallelism: 4
# can bump this up if need be: https://circleci.com/docs/2.0/configuration-reference/#docker-executor
resource_class: medium+ # default
steps:
- checkout
- attach_workspace:
at: .
- run: circleci tests glob "test/contracts/*.js" | circleci tests split --split-by=timings > /tmp/contracts-to-test
- run: npx buidler compile
- run:
name: Tests in parallel
name: Test and output gas used
command: |
set +e
npm run ganache > /dev/null & # start ganache in background
npm run test:core -- $(cat /tmp/contracts-to-test)
npm test
EXIT_CODE=$?
cat test-gas-used.log
printf "\\n"
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
build/*
coverage/*
7 changes: 1 addition & 6 deletions .eslintrc.js
@@ -1,11 +1,6 @@
module.exports = {
extends: ['standard', 'plugin:prettier/recommended', 'plugin:node/recommended'],
globals: {
artifacts: true,
assert: true,
contract: true,
web3: true,
},
globals: {},
env: {
mocha: true,
node: true,
Expand Down
7 changes: 2 additions & 5 deletions .gitignore
Expand Up @@ -5,12 +5,12 @@ deploy_settings.py

# gitignore - Truffle proj
.idea/
build/
build
bin/
node_modules
yarn-error.log

# mkdocs
# mkdocs
site/

# Our environment settings
Expand All @@ -22,9 +22,6 @@ flattened-contracts/
# For eth-gas-reporter in tests
test-gas-used.log

# For integration testing
keys.json

# vscode
.vscode/launch.json

Expand Down
8 changes: 6 additions & 2 deletions .solcover.js
@@ -1,11 +1,15 @@
const {
constants: { inflationStartTimestampInSecs },
} = require('.');

module.exports = {
port: 8545,
skipFiles: ['test-helpers'],
client: require('ganache-cli'), // use ganache-cli version listed in dev deps
providerOptions: {
default_balance_ether: 10000000000000, // extra zero just in case (coverage consumes more gas)
time: new Date('2019-03-06T00:00:00'),
time: new Date(inflationStartTimestampInSecs * 1000),
network_id: 55,
gasLimit: 0x1fffffffffffff,
},
mocha: {
grep: '@cov-skip', // Find everything with this tag
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -4,7 +4,8 @@ node_js:
- 10.16.3
env:
- COVERAGE=1
- GAS=1
# - GAS=1
script:
- if [ "$COVERAGE" = "1" ]; then npm run coverage && bash <(curl -s https://codecov.io/bash); fi
- if [ "$GAS" = "1" ]; then npm ci && npm test && npx codechecks; fi
# Replace with below once gas reporting works again
# - if [ "$GAS" = "1" ]; then npm test && npx codechecks; fi
38 changes: 38 additions & 0 deletions buidler.config.js
@@ -0,0 +1,38 @@
const { usePlugin } = require('@nomiclabs/buidler/config');

usePlugin('@nomiclabs/buidler-truffle5'); // uses and exposes web3 via buidler-web3 plugin
usePlugin('solidity-coverage');

const {
constants: { inflationStartTimestampInSecs },
} = require('.');

const GAS_PRICE = 20e9; // 20 GWEI

const baseNetworkConfig = {
allowUnlimitedContractSize: true,
blockGasLimit: 0x1fffffffffffff,
initialDate: new Date(inflationStartTimestampInSecs * 1000).toISOString(),
gasPrice: GAS_PRICE,
};
module.exports = {
GAS_PRICE,
solc: {
version: '0.4.25',
},
paths: {
sources: './contracts',
tests: './test/contracts',
artifacts: './build/artifacts',
cache: './build/cache',
},
networks: {
buidlerevm: baseNetworkConfig,
coverage: Object.assign(
{
url: 'http://localhost:8545',
},
baseNetworkConfig
),
},
};
2 changes: 1 addition & 1 deletion contracts/EtherCollateral.sol
Expand Up @@ -294,7 +294,7 @@ contract EtherCollateral is Owned, Pausable, ReentrancyGuard, MixinResolver {
uint256 loanAmount = loanAmountFromCollateral(msg.value);

// Require sETH to mint does not exceed cap
require(totalIssuedSynths.add(loanAmount) < issueLimit, "Loan Amount exceeds the supply cap. ");
require(totalIssuedSynths.add(loanAmount) < issueLimit, "Loan Amount exceeds the supply cap.");

// Get a Loan ID
loanID = _incrementTotalLoansCounter();
Expand Down
2 changes: 1 addition & 1 deletion contracts/Issuer.sol
Expand Up @@ -22,7 +22,7 @@ contract Issuer is MixinResolver {
// Minimum Stake time may not exceed 1 weeks.
uint public constant MAX_MINIMUM_STAKING_TIME = 1 weeks;

uint public minimumStakeTime = 8 hours; // default minimum waiting period after issuing synths
uint public minimumStakeTime = 24 hours; // default minimum waiting period after issuing synths

/* ========== ADDRESS RESOLVER CONFIGURATION ========== */

Expand Down
20 changes: 20 additions & 0 deletions contracts/test-helpers/GenericMock.sol
@@ -0,0 +1,20 @@
// Source adapted from https://github.com/EthWorks/Doppelganger/blob/master/contracts/Doppelganger.sol

/* solium-disable security/no-inline-assembly */
pragma solidity 0.4.25;


contract GenericMock {
mapping(bytes4 => bytes) mockConfig;

function() public {
bytes memory ret = mockConfig[msg.sig];
assembly {
return(add(ret, 0x20), mload(ret))
}
}

function mockReturns(bytes4 key, bytes value) public {
mockConfig[key] = value;
}
}
12 changes: 11 additions & 1 deletion contracts/test-helpers/MockExchanger.sol
Expand Up @@ -7,6 +7,7 @@ contract MockExchanger {
uint256 private _mockReclaimAmount;
uint256 private _mockRefundAmount;
uint256 private _mockNumEntries;
uint256 private _mockMaxSecsLeft;

ISynthetix synthetix;

Expand All @@ -17,7 +18,6 @@ contract MockExchanger {
// Mock settle function
function settle(address from, bytes32 currencyKey)
external
view
returns (uint256 reclaimed, uint256 refunded, uint numEntriesSettled)
{
if (_mockReclaimAmount > 0) {
Expand All @@ -28,9 +28,15 @@ contract MockExchanger {
synthetix.synths(currencyKey).issue(from, _mockRefundAmount);
}

_mockMaxSecsLeft = 0;

return (_mockReclaimAmount, _mockRefundAmount, _mockNumEntries);
}

function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) public view returns (uint) {
return _mockMaxSecsLeft;
}

function settlementOwing(address account, bytes32 currencyKey) public view returns (uint, uint, uint) {
return (_mockReclaimAmount, _mockRefundAmount, _mockNumEntries);
}
Expand All @@ -46,4 +52,8 @@ contract MockExchanger {
function setNumEntries(uint256 _numEntries) external {
_mockNumEntries = _numEntries;
}

function setMaxSecsLeft(uint _maxSecsLeft) external {
_mockMaxSecsLeft = _maxSecsLeft;
}
}
63 changes: 63 additions & 0 deletions contracts/test-helpers/MockSynth.sol
@@ -0,0 +1,63 @@
pragma solidity ^0.4.25;

import "../ExternStateToken.sol";
import "../interfaces/ISystemStatus.sol";


// Mock synth that also adheres to system status

contract MockSynth is ExternStateToken {
ISystemStatus private systemStatus;
bytes32 public currencyKey;

constructor(
address _proxy,
TokenState _tokenState,
string _name,
string _symbol,
uint _totalSupply,
address _owner,
bytes32 _currencyKey
) public ExternStateToken(_proxy, _tokenState, _name, _symbol, _totalSupply, 18, _owner) {
currencyKey = _currencyKey;
}

// Allow SystemStatus to be passed in directly
function setSystemStatus(ISystemStatus _status) external {
systemStatus = _status;
}

// Used for PurgeableSynth to test removal
function setTotalSupply(uint256 _totalSupply) external {
totalSupply = _totalSupply;
}

function transfer(address to, uint value) external optionalProxy returns (bool) {
systemStatus.requireSynthActive(currencyKey);

return _transfer_byProxy(messageSender, to, value);
}

function transferFrom(address from, address to, uint value) external optionalProxy returns (bool) {
systemStatus.requireSynthActive(currencyKey);

return _transferFrom_byProxy(messageSender, from, to, value);
}

event Issued(address indexed account, uint value);

event Burned(address indexed account, uint value);

// Allow these functions which are typically restricted to internal contracts, be open to us for mocking
function issue(address account, uint amount) external {
tokenState.setBalanceOf(account, tokenState.balanceOf(account).add(amount));
totalSupply = totalSupply.add(amount);
emit Issued(account, amount);
}

function burn(address account, uint amount) external {
tokenState.setBalanceOf(account, tokenState.balanceOf(account).sub(amount));
totalSupply = totalSupply.sub(amount);
emit Burned(account, amount);
}
}
7 changes: 7 additions & 0 deletions contracts/test-helpers/PublicEST.sol
Expand Up @@ -18,4 +18,11 @@ contract PublicEST is ExternStateToken {
function transferFrom(address from, address to, uint value) external optionalProxy returns (bool) {
return _transferFrom_byProxy(messageSender, from, to, value);
}

// Index all parameters to make them easier to find in raw logs (as this will be emitted via a proxy and not decoded)
event Received(address indexed sender, uint256 indexed inputA, bytes32 indexed inputB);

function somethingToBeProxied(uint256 inputA, bytes32 inputB) external {
emit Received(messageSender, inputA, inputB);
}
}
11 changes: 10 additions & 1 deletion index.js
Expand Up @@ -93,4 +93,13 @@ const getUsers = ({ network = 'mainnet', user } = {}) => {
return user ? users.find(({ name }) => name === user) : users;
};

module.exports = { getTarget, getSource, getSynths, toBytes32, getUsers };
module.exports = {
getTarget,
getSource,
getSynths,
toBytes32,
getUsers,
constants: {
inflationStartTimestampInSecs: 1551830400, // 2019-03-06T00:00:00Z
},
};
6 changes: 0 additions & 6 deletions migrations/1_initial_migration.js

This file was deleted.