Skip to content

Bumping up solidity to version 0.7.x #197

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

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/Orchestrator.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./_external/Ownable.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/UFragments.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./_external/SafeMath.sol";
import "./_external/Ownable.sol";
Expand Down
18 changes: 10 additions & 8 deletions contracts/UFragmentsPolicy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./_external/SafeMath.sol";
import "./_external/Ownable.sol";
Expand Down Expand Up @@ -104,12 +104,13 @@ contract UFragmentsPolicy is Ownable {
require(inRebaseWindow());

// This comparison also ensures there is no reentrancy.
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now);
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < block.timestamp);

// Snap the rebase time to the start of this window.
lastRebaseTimestampSec = now.sub(now.mod(minRebaseTimeIntervalSec)).add(
rebaseWindowOffsetSec
);
lastRebaseTimestampSec = block
.timestamp
.sub(block.timestamp.mod(minRebaseTimeIntervalSec))
.add(rebaseWindowOffsetSec);

epoch = epoch.add(1);

Expand Down Expand Up @@ -140,7 +141,7 @@ contract UFragmentsPolicy is Ownable {

uint256 supplyAfterRebase = uFrags.rebase(epoch, supplyDelta);
assert(supplyAfterRebase <= MAX_SUPPLY);
emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now);
emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, block.timestamp);
}

/**
Expand Down Expand Up @@ -259,8 +260,9 @@ contract UFragmentsPolicy is Ownable {
* Otherwise, returns false.
*/
function inRebaseWindow() public view returns (bool) {
return (now.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec &&
now.mod(minRebaseTimeIntervalSec) < (rebaseWindowOffsetSec.add(rebaseWindowLengthSec)));
return (block.timestamp.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec &&
block.timestamp.mod(minRebaseTimeIntervalSec) <
(rebaseWindowOffsetSec.add(rebaseWindowLengthSec)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/ERC20Detailed.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Initializable.sol";
import "./IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/IERC20.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

/**
* @title ERC20 interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/Initializable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

/**
* @title Initializable
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/Ownable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Initializable.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/SafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

/**
* @title SafeMath
Expand Down
2 changes: 1 addition & 1 deletion contracts/lib/SafeMathInt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

pragma solidity 0.6.12;
pragma solidity 0.7.6;

/**
* @title SafeMathInt
Expand Down
2 changes: 1 addition & 1 deletion contracts/lib/UInt256Lib.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

/**
* @title Various utilities useful for uint256.
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ConstructorRebaseCallerContract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "../Orchestrator.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/Mock.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

contract Mock {
event FunctionCalled(string instanceName, string functionName, address caller);
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockDownstream.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockOracle.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockUFragments.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockUFragmentsPolicy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/RebaseCallerContract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "../Orchestrator.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/SafeMathIntMock.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Mock.sol";
import "../lib/SafeMathInt.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/UInt256LibMock.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.6.12;
pragma solidity 0.7.6;

import "./Mock.sol";
import "../lib/UInt256Lib.sol";
Expand Down
8 changes: 7 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export default {
solidity: {
compilers: [
{
version: '0.6.12',
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 200,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider increasing the number of runs to 9000 and seeing if it improves gas efficiency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increasing runs to 9000, doesnt improve noticeably

·--------------------------------------------------|---------------------------|--------------|----------------------------·
|               Solc version: 0.7.6                ·  Optimizer enabled: true  ·  Runs: 9000  ·  Block limit: 9500000 gas  │
···················································|···························|··············|·····························
|  Methods                                                                                                                 │
·····················|·····························|·············|·············|··············|··············|··············
|  Contract          ·  Method                     ·  Min        ·  Max        ·  Avg         ·  # calls     ·  usd (avg)  │
·····················|·····························|·············|·············|··············|··············|··············
|  Orchestrator      ·  addTransaction             ·      71318  ·     131876  ·      109945  ·           6  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  Orchestrator      ·  rebase                     ·      27292  ·     123293  ·       80519  ·          80  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  Orchestrator      ·  removeTransaction          ·      28441  ·      51244  ·       37462  ·           3  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  Orchestrator      ·  setTransactionEnabled      ·      25783  ·      29971  ·       27877  ·           2  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  Orchestrator      ·  transferOwnership          ·          -  ·          -  ·       30781  ·           1  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  approve                    ·      16674  ·      46746  ·       36628  ·          34  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  decreaseAllowance          ·      28507  ·      32787  ·       30647  ·           8  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  increaseAllowance          ·      32795  ·      47819  ·       38807  ·          10  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  permit                     ·      76621  ·      76633  ·       76629  ·           3  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  rebase                     ·      27579  ·      38298  ·       35084  ·          13  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  setMonetaryPolicy          ·          -  ·          -  ·       47254  ·           8  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  transfer                   ·      39769  ·      54745  ·       53379  ·          11  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  transferAll                ·      31058  ·      39458  ·       37358  ·           4  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  transferAllFrom            ·      31016  ·      46016  ·       34494  ·           5  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragments        ·  transferFrom               ·          -  ·          -  ·       46440  ·           2  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragmentsPolicy  ·  setCpiOracle               ·      31162  ·      46162  ·       38662  ·           4  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragmentsPolicy  ·  setDeviationThreshold      ·      15099  ·      30159  ·       18111  ·           5  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragmentsPolicy  ·  setMarketOracle            ·      31161  ·      46161  ·       38661  ·           4  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragmentsPolicy  ·  setOrchestrator            ·      31138  ·      46126  ·       38632  ·           4  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragmentsPolicy  ·  setRebaseLag               ·          -  ·          -  ·       30134  ·           2  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  UFragmentsPolicy  ·  setRebaseTimingParameters  ·      25435  ·      40471  ·       29379  ·          15  ·          -  │
·····················|·····························|·············|·············|··············|··············|··············
|  Deployments                                     ·                                          ·  % of limit  ·             │
···················································|·············|·············|··············|··············|··············
|  Orchestrator                                    ·          -  ·          -  ·      986760  ·      10.4 %  ·          -  │
···················································|·············|·············|··············|··············|··············
|  UFragments                                      ·          -  ·          -  ·     1614953  ·        17 %  ·          -  │
···················································|·············|·············|··············|··············|··············
|  UFragmentsPolicy                                ·          -  ·          -  ·     1166050  ·      12.3 %  ·          -  │
·--------------------------------------------------|-------------|-------------|--------------|--------------|-------------·

},
},
},
{
version: '0.4.24',
Expand Down
5 changes: 3 additions & 2 deletions truffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
module.exports = {
compilers: {
solc: {
version: '0.6.12',
version: '0.7.6',
settings: {
optimizer: {
enabled: false
enabled: true,
runs: 200,
}
}
}
Expand Down