Skip to content

Commit 5e0e094

Browse files
authored
Merge pull request #521 from AugurProject/initial_reporter_escape_hatch_eth
use cash for gas report bond and send it in the escape hatch
2 parents 120adb5 + 5141ebf commit 5e0e094

File tree

8 files changed

+25
-17
lines changed

8 files changed

+25
-17
lines changed

source/contracts/reporting/IInitialReporter.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ contract IInitialReporter is IReportingParticipant {
1212
function designatedReporterWasCorrect() public view returns (bool);
1313
function getDesignatedReporter() public view returns (address);
1414
function getReportTimestamp() public view returns (uint256);
15-
function depositGasBond() public payable returns (bool);
1615
}

source/contracts/reporting/InitialReporter.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ contract InitialReporter is DelegationTarget, Ownable, Extractable, BaseReportin
2323
return true;
2424
}
2525

26-
function depositGasBond() public payable returns (bool) {
27-
return true;
28-
}
29-
3026
function redeem(address) public returns (bool) {
3127
if (!isDisavowed() && !market.isFinalized()) {
3228
market.finalize();
@@ -57,6 +53,10 @@ contract InitialReporter is DelegationTarget, Ownable, Extractable, BaseReportin
5753

5854
function withdrawInEmergency() public onlyInBadTimes returns (bool) {
5955
reputationToken.transfer(owner, reputationToken.balanceOf(this));
56+
uint256 _cashBalance = cash.balanceOf(this);
57+
if (_cashBalance > 0) {
58+
cash.withdrawEtherTo(owner, _cashBalance);
59+
}
6060
return true;
6161
}
6262

source/contracts/reporting/Market.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
8989
if (_refund > 0) {
9090
require(owner.call.value(_refund)());
9191
}
92-
// Send the reporter gas bond to the initial report contract. It will be paid out only if they are correct.
93-
require(IInitialReporter(participants[0]).depositGasBond.value(reporterGasCostsFeeAttoeth)());
9492
return true;
9593
}
9694

@@ -225,8 +223,10 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
225223
// If the designated reporter showed up return the no show bond to the market creator. Otherwise it will be used as stake in the first report.
226224
if (_reporter == _initialReporter.getDesignatedReporter()) {
227225
_reputationToken.transfer(owner, _repBalance);
226+
marketCreatorMailbox.depositEther.value(reporterGasCostsFeeAttoeth)();
228227
} else {
229228
_reputationToken.transfer(_initialReporter, _repBalance);
229+
cash.depositEtherFor.value(reporterGasCostsFeeAttoeth)(_initialReporter);
230230
}
231231
return true;
232232
}

tests/reporting/test_fee_distribution.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
def test_initial_report_and_participation_fee_collection(localFixture, universe, market, categoricalMarket, scalarMarket, cash, reputationToken):
88
feeWindow = localFixture.applySignature('FeeWindow', market.getFeeWindow())
9+
constants = localFixture.contracts["Constants"]
910

1011
# We cannot purchase participation tokens yet since the window isn't active
1112
with raises(TransactionFailed):
@@ -121,6 +122,7 @@ def test_failed_crowdsourcer_fees(localFixture, universe, market, cash, reputati
121122

122123
def test_one_round_crowdsourcer_fees(localFixture, universe, market, cash, reputationToken):
123124
feeWindow = localFixture.applySignature('FeeWindow', market.getFeeWindow())
125+
constants = localFixture.contracts["Constants"]
124126

125127
# We'll make the window active
126128
localFixture.contracts["Time"].setTimestamp(feeWindow.getStartTime() + 1)
@@ -164,6 +166,8 @@ def test_one_round_crowdsourcer_fees(localFixture, universe, market, cash, reput
164166
assert initialReporter.redeem(tester.a0)
165167

166168
def test_multiple_round_crowdsourcer_fees(localFixture, universe, market, cash, reputationToken):
169+
constants = localFixture.contracts["Constants"]
170+
167171
# Initial Report disputed
168172
proceedToNextRound(localFixture, market, tester.k1, True)
169173
# Initial Report winning

tests/reporting/test_reporting.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_initialReportHappyPath(localFixture, universe, market):
6161
localFixture.contracts["Time"].setTimestamp(feeWindow.getEndTime() + 1)
6262
assert market.finalize()
6363

64-
def test_initialReport_transfer_ownership(localFixture, universe, market, cash):
64+
def test_initialReport_transfer_ownership(localFixture, universe, market, cash, constants):
6565
reputationToken = localFixture.applySignature("ReputationToken", universe.getReputationToken())
6666

6767
# proceed to the initial reporting period
@@ -92,8 +92,11 @@ def test_initialReport_transfer_ownership(localFixture, universe, market, cash):
9292
# When we redeem the initialReporter it goes to the correct party as well
9393
expectedRep = initialReporter.getStake()
9494
owner = initialReporter.getOwner()
95-
with TokenDelta(reputationToken, expectedRep, owner, "Redeeming didn't refund REP"):
96-
assert initialReporter.redeem(owner)
95+
96+
expectedGasBond = 2 * constants.GAS_TO_REPORT() * constants.DEFAULT_REPORTING_GAS_PRICE()
97+
with EtherDelta(expectedGasBond, owner, localFixture.chain, "Initial reporter did not get the reporting gas cost bond"):
98+
with TokenDelta(reputationToken, expectedRep, owner, "Redeeming didn't refund REP"):
99+
assert initialReporter.redeem(owner)
97100

98101
@mark.parametrize('rounds', [
99102
2,
@@ -327,3 +330,7 @@ def localSnapshot(fixture, kitchenSinkSnapshot):
327330
def localFixture(fixture, localSnapshot):
328331
fixture.resetToSnapshot(localSnapshot)
329332
return fixture
333+
334+
@fixture
335+
def constants(localFixture, kitchenSinkSnapshot):
336+
return localFixture.contracts['Constants']

tests/reporting/test_universe_redeem.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def test_redeem_participation_tokens(kitchenSinkFixture, universe, market, cash)
6262

6363
def test_redeem_reporting_participants(kitchenSinkFixture, market, categoricalMarket, scalarMarket, universe, cash):
6464
reputationToken = kitchenSinkFixture.applySignature("ReputationToken", universe.getReputationToken())
65+
constants = kitchenSinkFixture.contracts["Constants"]
6566

6667
# Initial Report
6768
proceedToNextRound(kitchenSinkFixture, market, doGenerateFees = True)
@@ -90,8 +91,8 @@ def test_redeem_reporting_participants(kitchenSinkFixture, market, categoricalMa
9091
expectedRep = long(winningDisputeCrowdsourcer2.getStake() + winningDisputeCrowdsourcer1.getStake())
9192
expectedRep = long(expectedRep + expectedRep / 2)
9293
expectedRep += long(initialReporter.getStake() + initialReporter.getStake() / 2)
94+
expectedGasBond = 2 * constants.GAS_TO_REPORT() * constants.DEFAULT_REPORTING_GAS_PRICE()
9395
with TokenDelta(reputationToken, expectedRep, tester.a0, "Redeeming didn't refund REP"):
94-
with EtherDelta(expectedFees, tester.a0, kitchenSinkFixture.chain, "Redeeming didn't increase ETH correctly"):
95-
with PrintGasUsed(kitchenSinkFixture, "Universe Redeem:", 0):
96-
assert universe.redeemStake([initialReporter.address, winningDisputeCrowdsourcer1.address, winningDisputeCrowdsourcer2.address], [])
96+
with PrintGasUsed(kitchenSinkFixture, "Universe Redeem:", 0):
97+
assert universe.redeemStake([initialReporter.address, winningDisputeCrowdsourcer1.address, winningDisputeCrowdsourcer2.address], [])
9798

tests/reporting_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def generateFees(fixture, universe, market):
114114
completeSets = fixture.contracts['CompleteSets']
115115
cash = fixture.contracts['Cash']
116116
mailbox = fixture.applySignature('Mailbox', market.getMarketCreatorMailbox())
117+
assert mailbox.withdrawEther()
117118

118119
cost = 1000 * market.getNumTicks()
119120
marketCreatorFees = cost / market.getMarketCreatorSettlementFeeDivisor()

tests/solidity_test_helpers/MockInitialReporter.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ contract MockInitialReporter is IInitialReporter {
5858
return reportTimestamp;
5959
}
6060

61-
function depositGasBond() public payable returns (bool) {
62-
return true;
63-
}
64-
6561
function getStake() public view returns (uint256) {
6662
return 0;
6763
}

0 commit comments

Comments
 (0)