Skip to content

Commit

Permalink
Merge branch 'develop' into updating-mainnet-ovm-feeds-for-ocr
Browse files Browse the repository at this point in the history
  • Loading branch information
barrasso authored Feb 11, 2022
2 parents ca0dc6a + 5e25a0b commit 570fccd
Show file tree
Hide file tree
Showing 134 changed files with 55,441 additions and 57,949 deletions.
58 changes: 53 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,35 @@ jobs:
- attach_workspace:
at: .
- run: npx hardhat compile --optimizer --fail-oversize
job-fork-tests-ovm:
working_directory: ~/repo
docker:
- image: synthetixio/docker-node:16.13-ubuntu
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_TOKEN
steps:
- checkout
- attach_workspace:
at: .
- run:
command: npm run fork:ovm
background: true
- cmd-wait-for-port:
port: 8545
- run:
name: Run integration tests on l2
command: |
NEW_CONTRACTS=$(node bin.js sips --layer=base --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l2 --compile --use-fork
else
npx hardhat test:integration:l2 --compile --deploy --use-sips --use-fork
fi;
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
job-fork-tests:
working_directory: ~/repo
docker:
Expand All @@ -57,16 +86,20 @@ jobs:
command: npm run fork:mainnet
background: true
- cmd-wait-for-port:
port: 8545
port: 9545
- run:
name: Run integration tests on l1
command: |
NEW_CONTRACTS=$(node bin.js sips --layer=base --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l1 --use-fork
npx hardhat test:integration:l1 --compile --use-fork --provider-port 9545
else
npx hardhat test:integration:l1 --compile --deploy --use-sips --use-fork
npx hardhat test:integration:l1 --compile --deploy --use-sips --use-fork --provider-port 9545
fi;
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
job-integration-tests:
working_directory: ~/repo
machine:
Expand Down Expand Up @@ -112,6 +145,10 @@ jobs:
name: Run dual layer 1 and layer 2 integration tests
command: |
npx hardhat test:integration:dual --deploy
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
job-lint:
working_directory: ~/repo
docker:
Expand Down Expand Up @@ -180,7 +217,7 @@ jobs:
- attach_workspace:
at: .
- run:
command: npm run fork:mainnet
command: npm run fork -- --target-network mainnet --port 8545
background: true
- cmd-wait-for-port:
port: 8545
Expand All @@ -189,8 +226,12 @@ jobs:
command: |
UPCOMING_RELEASE=$(node bin.js releases --layer=base --unreleased --with-sources --name-only)
if [ ! -z "$UPCOMING_RELEASE" ]; then
npx hardhat simulate:migration --release "$UPCOMING_RELEASE" --generate --test
npx hardhat simulate:migration --generate --test
fi;
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
job-static-analysis:
working_directory: ~/repo
docker:
Expand Down Expand Up @@ -336,6 +377,10 @@ jobs:
root: .
paths:
- gasReporterOutput-*.json
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
job-validate-deployments:
working_directory: ~/repo
docker:
Expand Down Expand Up @@ -406,6 +451,9 @@ workflows:
- job-fork-tests:
requires:
- job-prepare
- job-fork-tests-ovm:
requires:
- job-prepare
- job-simulate-release:
requires:
- job-prepare
Expand Down
25 changes: 25 additions & 0 deletions .circleci/src/jobs/job-fork-tests-ovm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Starts a fork of OVM, deploys the latest release, and runs L2 integration tests
{{> job-header-node.yml}}
steps:
- checkout
- attach_workspace:
at: .
- run:
command: npm run fork:ovm
background: true
- cmd-wait-for-port:
port: 8545
- run:
name: Run integration tests on l2
command: |
# Only compile and deploy when there are new contracts
NEW_CONTRACTS=$(node bin.js sips --layer=base --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l2 --compile --use-fork
else
npx hardhat test:integration:l2 --compile --deploy --use-sips --use-fork
fi;
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
10 changes: 7 additions & 3 deletions .circleci/src/jobs/job-fork-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ steps:
command: npm run fork:mainnet
background: true
- cmd-wait-for-port:
port: 8545
port: 9545
- run:
name: Run integration tests on l1
command: |
# Only compile and deploy when there are new contracts
NEW_CONTRACTS=$(node bin.js sips --layer=base --unreleased --with-sources)
if [ -z "$NEW_CONTRACTS" ]; then
npx hardhat test:integration:l1 --use-fork
npx hardhat test:integration:l1 --compile --use-fork --provider-port 9545
else
npx hardhat test:integration:l1 --compile --deploy --use-sips --use-fork
npx hardhat test:integration:l1 --compile --deploy --use-sips --use-fork --provider-port 9545
fi;
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
4 changes: 4 additions & 0 deletions .circleci/src/jobs/job-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ steps:
name: Run dual layer 1 and layer 2 integration tests
command: |
npx hardhat test:integration:dual --deploy
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
8 changes: 6 additions & 2 deletions .circleci/src/jobs/job-simulate-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ steps:
- attach_workspace:
at: .
- run:
command: npm run fork:mainnet
command: npm run fork -- --target-network mainnet --port 8545
background: true
- cmd-wait-for-port:
port: 8545
Expand All @@ -15,5 +15,9 @@ steps:
# Only compile and deploy when there are new contracts
UPCOMING_RELEASE=$(node bin.js releases --layer=base --unreleased --with-sources --name-only)
if [ ! -z "$UPCOMING_RELEASE" ]; then
npx hardhat simulate:migration --release "$UPCOMING_RELEASE" --generate --test
npx hardhat simulate:migration --generate --test
fi;
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
4 changes: 4 additions & 0 deletions .circleci/src/jobs/job-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ steps:
root: .
paths:
- gasReporterOutput-*.json
- store_test_results:
path: /tmp/junit/
- store_artifacts:
path: /tmp/junit/
2 changes: 2 additions & 0 deletions .circleci/src/workflows/workflow-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- job-fork-tests:
{{> require-prepare.yml}}
- job-fork-tests-ovm:
{{> require-prepare.yml}}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Simulate release on fork & test
Expand Down
9 changes: 1 addition & 8 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ const {

module.exports = {
port: 8545,
skipFiles: [
'test-helpers',
'migrations',
'legacy',
'EscrowChecker.sol',
'ExchangeRatesWithoutInvPricing.sol',
'EmptyEtherWrapper.sol',
],
skipFiles: ['test-helpers', 'migrations', 'legacy', 'EscrowChecker.sol', 'EmptyEtherWrapper.sol'],
providerOptions: {
default_balance_ether: 10000000000000, // extra zero just in case (coverage consumes more gas)
time: new Date(inflationStartTimestampInSecs * 1000),
Expand Down
15 changes: 1 addition & 14 deletions contracts/BaseMigration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ pragma solidity ^0.5.16;
import "./Owned.sol";

contract BaseMigration is Owned {
address public deployer;

constructor(address _owner) internal Owned(_owner) {
deployer = msg.sender;
}
constructor(address _owner) internal Owned(_owner) {}

// safety value to return ownership (anyone can invoke)
function returnOwnership(address forContract) public {
Expand All @@ -26,13 +22,4 @@ contract BaseMigration is Owned {
require(legacySuccess, "Legacy nomination failed");
}
}

function _requireDeployer() private view {
require(msg.sender == deployer, "Only the deployer can invoke this");
}

modifier onlyDeployer() {
_requireDeployer();
_;
}
}
22 changes: 7 additions & 15 deletions contracts/BaseSynthetix.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import "./interfaces/ISynthetix.sol";
// Internal references
import "./interfaces/ISynth.sol";
import "./TokenState.sol";
import "./interfaces/ISynthetixState.sol";
import "./interfaces/ISystemStatus.sol";
import "./interfaces/IExchanger.sol";
import "./interfaces/IIssuer.sol";
Expand All @@ -26,7 +25,6 @@ contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {
bytes32 public constant sUSD = "sUSD";

// ========== ADDRESS RESOLVER CONFIGURATION ==========
bytes32 private constant CONTRACT_SYNTHETIXSTATE = "SynthetixState";
bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus";
bytes32 private constant CONTRACT_EXCHANGER = "Exchanger";
bytes32 private constant CONTRACT_ISSUER = "Issuer";
Expand All @@ -50,16 +48,11 @@ contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {

// Note: use public visibility so that it can be invoked in a subclass
function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
addresses = new bytes32[](5);
addresses[0] = CONTRACT_SYNTHETIXSTATE;
addresses[1] = CONTRACT_SYSTEMSTATUS;
addresses[2] = CONTRACT_EXCHANGER;
addresses[3] = CONTRACT_ISSUER;
addresses[4] = CONTRACT_REWARDSDISTRIBUTION;
}

function synthetixState() internal view returns (ISynthetixState) {
return ISynthetixState(requireAndGetAddress(CONTRACT_SYNTHETIXSTATE));
addresses = new bytes32[](4);
addresses[0] = CONTRACT_SYSTEMSTATUS;
addresses[1] = CONTRACT_EXCHANGER;
addresses[2] = CONTRACT_ISSUER;
addresses[3] = CONTRACT_REWARDSDISTRIBUTION;
}

function systemStatus() internal view returns (ISystemStatus) {
Expand Down Expand Up @@ -147,14 +140,13 @@ contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {
}

function _canTransfer(address account, uint value) internal view returns (bool) {
(uint initialDebtOwnership, ) = synthetixState().issuanceData(account);

if (initialDebtOwnership > 0) {
if (issuer().debtBalanceOf(account, sUSD) > 0) {
(uint transferable, bool anyRateIsInvalid) =
issuer().transferableSynthetixAndAnyRateIsInvalid(account, tokenState.balanceOf(account));
require(value <= transferable, "Cannot transfer staked or escrowed SNX");
require(!anyRateIsInvalid, "A synth or SNX rate is invalid");
}

return true;
}

Expand Down
Loading

0 comments on commit 570fccd

Please sign in to comment.