Skip to content

Commit 570574e

Browse files
authored
Merge branch 'master' into sbigelow/travis
2 parents 68c793f + d075d9c commit 570574e

30 files changed

+592
-74
lines changed

CRIBBED_CODE.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Licensing inclusion for the following files which were originally taken from the OpenZeppelin Solidity token contracts and later modified by us:
2+
3+
source/libraries/token/BasicToken.sol
4+
source/libraries/token/ERC20.sol
5+
source/libraries/token/ERC20Basic.sol
6+
source/libraries/token/StandardToken.sol
7+
8+
The MIT License (MIT)
9+
10+
Copyright (c) 2016 Smart Contract Solutions, Inc.
11+
12+
Permission is hereby granted, free of charge, to any person obtaining
13+
a copy of this software and associated documentation files (the
14+
"Software"), to deal in the Software without restriction, including
15+
without limitation the rights to use, copy, modify, merge, publish,
16+
distribute, sublicense, and/or sell copies of the Software, and to
17+
permit persons to whom the Software is furnished to do so, subject to
18+
the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included
21+
in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

source/contracts/Augur.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ contract Augur is Controlled, Extractable {
3434
event TokensMinted(address indexed universe, address indexed token, address indexed target, uint256 amount);
3535
event TokensBurned(address indexed universe, address indexed token, address indexed target, uint256 amount);
3636
event FeeWindowCreated(address indexed universe, address feeWindow, uint256 startTime, uint256 endTime, uint256 id);
37+
event WhitelistAddition(address addition);
38+
event RegistryAddition(bytes32 key, address addition, bytes20 commitHash, bytes32 bytecodeHash);
3739

3840
mapping(address => bool) private universes;
3941

@@ -279,6 +281,16 @@ contract Augur is Controlled, Extractable {
279281
return true;
280282
}
281283

284+
function logContractAddedToWhitelist(address _addition) public onlyControllerCaller returns (bool) {
285+
WhitelistAddition(_addition);
286+
return true;
287+
}
288+
289+
function logContractAddedToRegistry(bytes32 _key, address _address, bytes20 _commitHash, bytes32 _bytecodeHash) public onlyControllerCaller returns (bool) {
290+
RegistryAddition(_key, _address, _commitHash, _bytecodeHash);
291+
return true;
292+
}
293+
282294
function getProtectedTokens() internal returns (address[] memory) {
283295
return new address[](0);
284296
}

source/contracts/Controller.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ contract Controller is IController {
6666

6767
function addToWhitelist(address _target) public onlyWhitelistedCallers returns (bool) {
6868
whitelist[_target] = true;
69+
getAugur().logContractAddedToWhitelist(_target);
6970
return true;
7071
}
7172

@@ -85,6 +86,7 @@ contract Controller is IController {
8586

8687
function registerContract(bytes32 _key, address _address, bytes20 _commitHash, bytes32 _bytecodeHash) public onlyOwnerCaller returns (bool) {
8788
registry[_key] = ContractDetails(_key, _address, _commitHash, _bytecodeHash);
89+
getAugur().logContractAddedToRegistry(_key, _address, _commitHash, _bytecodeHash);
8890
return true;
8991
}
9092

source/contracts/factories/DisputeCrowdsourcerFactory.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma solidity 0.4.18;
33
import 'libraries/Delegator.sol';
44
import 'reporting/IDisputeCrowdsourcer.sol';
55
import 'reporting/IMarket.sol';
6-
import 'reporting/IFeeWindow.sol';
76
import 'IController.sol';
87

98

source/contracts/factories/MarketFactory.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pragma solidity 0.4.18;
22

33

44
import 'libraries/Delegator.sol';
5-
import 'reporting/IFeeWindow.sol';
65
import 'reporting/IMarket.sol';
76
import 'reporting/IReputationToken.sol';
87
import 'trading/ICash.sol';

source/contracts/libraries/Delegator.sol

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,9 @@ contract Delegator is DelegationTarget {
2323
assembly {
2424
//0x40 is the address where the next free memory slot is stored in Solidity
2525
let _calldataMemoryOffset := mload(0x40)
26+
// new "memory end" including padding. The bitwise operations here ensure we get rounded up to the nearest 32 byte boundary
27+
let _size := and(add(calldatasize, 0x1f), not(0x1f))
2628
// Update the pointer at 0x40 to point at new free memory location so any theoretical allocation doesn't stomp our memory in this call
27-
let _size := 0
28-
switch gt(calldatasize, 32)
29-
case 1 {
30-
_size := calldatasize
31-
} default {
32-
_size := 32
33-
}
3429
mstore(0x40, add(_calldataMemoryOffset, _size))
3530
// Copy method signature and parameters of this call into memory
3631
calldatacopy(_calldataMemoryOffset, 0x0, calldatasize)

source/contracts/reporting/FeeWindow.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import 'reporting/Reporting.sol';
1616
import 'libraries/math/SafeMathUint256.sol';
1717
import 'libraries/math/RunningAverage.sol';
1818
import 'reporting/IFeeWindow.sol';
19-
import 'factories/FeeWindowFactory.sol';
2019
import 'libraries/Extractable.sol';
2120
import 'libraries/token/VariableSupplyToken.sol';
2221
import 'reporting/IFeeToken.sol';
@@ -42,7 +41,7 @@ contract FeeWindow is DelegationTarget, VariableSupplyToken, Extractable, Initia
4241
function initialize(IUniverse _universe, uint256 _feeWindowId) public onlyInGoodTimes beforeInitialized returns (bool) {
4342
endInitialization();
4443
universe = _universe;
45-
startTime = _feeWindowId * universe.getDisputeRoundDurationInSeconds();
44+
startTime = _feeWindowId.mul(universe.getDisputeRoundDurationInSeconds());
4645
// Initialize this to some reasonable value to handle the first market ever created without branching code
4746
reportingGasPrice.record(Reporting.getDefaultReportingGasPrice());
4847
feeToken = FeeTokenFactory(controller.lookup("FeeTokenFactory")).createFeeToken(controller, this);
@@ -108,7 +107,7 @@ contract FeeWindow is DelegationTarget, VariableSupplyToken, Extractable, Initia
108107
}
109108

110109
if (_totalFeeStake == 0) {
111-
return;
110+
return true;
112111
}
113112

114113
// CASH
@@ -173,7 +172,7 @@ contract FeeWindow is DelegationTarget, VariableSupplyToken, Extractable, Initia
173172
}
174173

175174
function getEndTime() public afterInitialized view returns (uint256) {
176-
return getStartTime() + Reporting.getDisputeRoundDurationSeconds();
175+
return getStartTime().add(Reporting.getDisputeRoundDurationSeconds());
177176
}
178177

179178
function getFeeToken() public afterInitialized view returns (IFeeToken) {

source/contracts/reporting/Market.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
405405
}
406406

407407
function getDesignatedReportingEndTime() public view returns (uint256) {
408-
return endTime + Reporting.getDesignatedReportingDurationSeconds();
408+
return endTime.add(Reporting.getDesignatedReportingDurationSeconds());
409409
}
410410

411411
function getNumParticipants() public view returns (uint256) {

source/contracts/reporting/ReputationToken.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ contract ReputationToken is DelegationTarget, Extractable, ITyped, Initializable
122122

123123
function updateSiblingMigrationTotal(IReputationToken _token) public returns (bool) {
124124
require(_token != this);
125-
IUniverse _supposedUniverse = _token.getUniverse();
126-
require(_token == universe.getParentUniverse().getChildUniverse(_supposedUniverse.getParentPayoutDistributionHash()).getReputationToken());
125+
IUniverse _shadyUniverse = _token.getUniverse();
126+
require(_token == universe.getParentUniverse().getChildUniverse(_shadyUniverse.getParentPayoutDistributionHash()).getReputationToken());
127127
totalTheoreticalSupply += migratedToSibling[_token];
128128
migratedToSibling[_token] = _token.getTotalMigrated();
129129
totalTheoreticalSupply -= migratedToSibling[_token];

source/contracts/reporting/Universe.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
5656
require(forkingMarket == IMarket(0));
5757
require(isContainerForMarket(IMarket(msg.sender)));
5858
forkingMarket = IMarket(msg.sender);
59-
forkEndTime = controller.getTimestamp() + Reporting.getForkDurationSeconds();
59+
forkEndTime = controller.getTimestamp().add(Reporting.getForkDurationSeconds());
6060
controller.getAugur().logUniverseForked();
6161
return true;
6262
}
@@ -65,7 +65,7 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
6565
uint256 _totalRepSupply = reputationToken.getTotalTheoreticalSupply();
6666
forkReputationGoal = _totalRepSupply.div(2); // 50% of REP migrating results in a victory in a fork
6767
disputeThresholdForFork = _totalRepSupply.div(80); // 1.25% of the total rep supply
68-
initialReportMinValue = disputeThresholdForFork.div(3).div(2**18) + 1; // This value will result in a maximum 20 round dispute sequence
68+
initialReportMinValue = disputeThresholdForFork.div(3).div(2**18).add(1); // This value will result in a maximum 20 round dispute sequence
6969
return true;
7070
}
7171

@@ -118,7 +118,7 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
118118
}
119119

120120
function getFeeWindowId(uint256 _timestamp) public view returns (uint256) {
121-
return _timestamp / getDisputeRoundDurationInSeconds();
121+
return _timestamp.div(getDisputeRoundDurationInSeconds());
122122
}
123123

124124
function getDisputeRoundDurationInSeconds() public view returns (uint256) {
@@ -141,11 +141,11 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
141141
}
142142

143143
function getOrCreatePreviousFeeWindow() public onlyInGoodTimes returns (IFeeWindow) {
144-
return getOrCreateFeeWindowByTimestamp(controller.getTimestamp() - getDisputeRoundDurationInSeconds());
144+
return getOrCreateFeeWindowByTimestamp(controller.getTimestamp().sub(getDisputeRoundDurationInSeconds()));
145145
}
146146

147147
function getPreviousFeeWindow() public view onlyInGoodTimes returns (IFeeWindow) {
148-
return getFeeWindowByTimestamp(controller.getTimestamp() - getDisputeRoundDurationInSeconds());
148+
return getFeeWindowByTimestamp(controller.getTimestamp().sub(getDisputeRoundDurationInSeconds()));
149149
}
150150

151151
function getOrCreateCurrentFeeWindow() public onlyInGoodTimes returns (IFeeWindow) {
@@ -157,15 +157,15 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
157157
}
158158

159159
function getOrCreateNextFeeWindow() public onlyInGoodTimes returns (IFeeWindow) {
160-
return getOrCreateFeeWindowByTimestamp(controller.getTimestamp() + getDisputeRoundDurationInSeconds());
160+
return getOrCreateFeeWindowByTimestamp(controller.getTimestamp().add(getDisputeRoundDurationInSeconds()));
161161
}
162162

163163
function getNextFeeWindow() public view onlyInGoodTimes returns (IFeeWindow) {
164-
return getFeeWindowByTimestamp(controller.getTimestamp() + getDisputeRoundDurationInSeconds());
164+
return getFeeWindowByTimestamp(controller.getTimestamp().add(getDisputeRoundDurationInSeconds()));
165165
}
166166

167167
function getOrCreateFeeWindowBefore(IFeeWindow _feeWindow) public onlyInGoodTimes returns (IFeeWindow) {
168-
return getOrCreateFeeWindowByTimestamp(_feeWindow.getStartTime() - 2);
168+
return getOrCreateFeeWindowByTimestamp(_feeWindow.getStartTime().sub(2));
169169
}
170170

171171
function createChildUniverse(uint256[] _parentPayoutNumerators, bool _parentInvalid) public returns (IUniverse) {
@@ -426,7 +426,7 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
426426
}
427427

428428
function getOrCacheMarketCreationCost() public onlyInGoodTimes returns (uint256) {
429-
return getOrCacheValidityBond() + getOrCacheTargetReporterGasCosts();
429+
return getOrCacheValidityBond().add(getOrCacheTargetReporterGasCosts());
430430
}
431431

432432
function getInitialReportStakeSize() public onlyInGoodTimes returns (uint256) {

0 commit comments

Comments
 (0)