Removed assertion that protocol fee != 0 from staking contract.

This commit is contained in:
Greg Hysen 2019-10-22 11:53:00 -07:00
parent 9ac715f99d
commit c44e16a88f
6 changed files with 16 additions and 35 deletions

View File

@ -5,6 +5,14 @@
{ {
"note": "Add more overflow safeguards to `LibFixedMath`", "note": "Add more overflow safeguards to `LibFixedMath`",
"pr": 2255 "pr": 2255
},
{
"note": "Refactored finalization state.",
"pr": 2276
},
{
"note": "Removed protocol fee != 0 assertion.",
"pr": 2278
} }
] ]
}, },

View File

@ -166,7 +166,6 @@ contract MixinExchangeFees is
if (msg.value != protocolFeePaid && msg.value != 0) { if (msg.value != protocolFeePaid && msg.value != 0) {
LibRichErrors.rrevert( LibRichErrors.rrevert(
LibStakingRichErrors.InvalidProtocolFeePaymentError( LibStakingRichErrors.InvalidProtocolFeePaymentError(
LibStakingRichErrors.ProtocolFeePaymentErrorCodes.MismatchedFeeAndPayment,
protocolFeePaid, protocolFeePaid,
msg.value msg.value
) )

View File

@ -29,10 +29,6 @@ library LibStakingRichErrors {
CanOnlyDecreaseOperatorShare CanOnlyDecreaseOperatorShare
} }
enum ProtocolFeePaymentErrorCodes {
MismatchedFeeAndPayment
}
enum InitializationErrorCodes { enum InitializationErrorCodes {
MixinSchedulerAlreadyInitialized, MixinSchedulerAlreadyInitialized,
MixinParamsAlreadyInitialized MixinParamsAlreadyInitialized
@ -103,9 +99,9 @@ library LibStakingRichErrors {
bytes4 internal constant INVALID_PARAM_VALUE_ERROR_SELECTOR = bytes4 internal constant INVALID_PARAM_VALUE_ERROR_SELECTOR =
0xfc45bd11; 0xfc45bd11;
// bytes4(keccak256("InvalidProtocolFeePaymentError(uint8,uint256,uint256)")) // bytes4(keccak256("InvalidProtocolFeePaymentError(uint256,uint256)"))
bytes4 internal constant INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR = bytes4 internal constant INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR =
0xefd6cb33; 0x31d7a505;
// bytes4(keccak256("PreviousEpochNotFinalizedError(uint256,uint256)")) // bytes4(keccak256("PreviousEpochNotFinalizedError(uint256,uint256)"))
bytes4 internal constant PREVIOUS_EPOCH_NOT_FINALIZED_ERROR_SELECTOR = bytes4 internal constant PREVIOUS_EPOCH_NOT_FINALIZED_ERROR_SELECTOR =
@ -251,7 +247,6 @@ library LibStakingRichErrors {
} }
function InvalidProtocolFeePaymentError( function InvalidProtocolFeePaymentError(
ProtocolFeePaymentErrorCodes errorCodes,
uint256 expectedProtocolFeePaid, uint256 expectedProtocolFeePaid,
uint256 actualProtocolFeePaid uint256 actualProtocolFeePaid
) )
@ -261,7 +256,6 @@ library LibStakingRichErrors {
{ {
return abi.encodeWithSelector( return abi.encodeWithSelector(
INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR, INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR,
errorCodes,
expectedProtocolFeePaid, expectedProtocolFeePaid,
actualProtocolFeePaid actualProtocolFeePaid
); );

View File

@ -90,21 +90,6 @@ blockchainTests('Protocol Fees unit tests', env => {
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
it('should revert if `protocolFeePaid` is zero with zero value sent', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
ZERO_AMOUNT,
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.ZeroProtocolFeePaid,
ZERO_AMOUNT,
ZERO_AMOUNT,
);
return expect(tx).to.revertWith(expectedError);
});
it('should revert if `protocolFeePaid` is zero with non-zero value sent', async () => { it('should revert if `protocolFeePaid` is zero with non-zero value sent', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress, makerAddress,
@ -113,7 +98,6 @@ blockchainTests('Protocol Fees unit tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
); );
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.ZeroProtocolFeePaid,
ZERO_AMOUNT, ZERO_AMOUNT,
DEFAULT_PROTOCOL_FEE_PAID, DEFAULT_PROTOCOL_FEE_PAID,
); );
@ -128,7 +112,6 @@ blockchainTests('Protocol Fees unit tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) }, { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) },
); );
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.MismatchedFeeAndPayment,
DEFAULT_PROTOCOL_FEE_PAID, DEFAULT_PROTOCOL_FEE_PAID,
DEFAULT_PROTOCOL_FEE_PAID.minus(1), DEFAULT_PROTOCOL_FEE_PAID.minus(1),
); );
@ -143,7 +126,6 @@ blockchainTests('Protocol Fees unit tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) }, { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) },
); );
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.MismatchedFeeAndPayment,
DEFAULT_PROTOCOL_FEE_PAID, DEFAULT_PROTOCOL_FEE_PAID,
DEFAULT_PROTOCOL_FEE_PAID.plus(1), DEFAULT_PROTOCOL_FEE_PAID.plus(1),
); );

View File

@ -113,6 +113,10 @@
{ {
"note": "Renamed `OnlyCallableByPoolOperatorOrMakerError` to `OnlyCallableByPoolOperatorError`.", "note": "Renamed `OnlyCallableByPoolOperatorOrMakerError` to `OnlyCallableByPoolOperatorError`.",
"pr": 2250 "pr": 2250
},
{
"note": "Removed protocol fee != 0 error.",
"pr": 2278
} }
], ],
"timestamp": 1570135330 "timestamp": 1570135330

View File

@ -14,11 +14,6 @@ export enum OperatorShareErrorCodes {
CanOnlyDecreaseOperatorShare, CanOnlyDecreaseOperatorShare,
} }
export enum ProtocolFeePaymentErrorCodes {
ZeroProtocolFeePaid,
MismatchedFeeAndPayment,
}
export enum InvalidParamValueErrorCodes { export enum InvalidParamValueErrorCodes {
InvalidCobbDouglasAlpha, InvalidCobbDouglasAlpha,
InvalidRewardDelegatedStakeWeight, InvalidRewardDelegatedStakeWeight,
@ -144,14 +139,13 @@ export class InvalidParamValueError extends RevertError {
export class InvalidProtocolFeePaymentError extends RevertError { export class InvalidProtocolFeePaymentError extends RevertError {
constructor( constructor(
errorCode?: ProtocolFeePaymentErrorCodes,
expectedProtocolFeePaid?: BigNumber | number | string, expectedProtocolFeePaid?: BigNumber | number | string,
actualProtocolFeePaid?: BigNumber | number | string, actualProtocolFeePaid?: BigNumber | number | string,
) { ) {
super( super(
'InvalidProtocolFeePaymentError', 'InvalidProtocolFeePaymentError',
'InvalidProtocolFeePaymentError(uint8 errorCode, uint256 expectedProtocolFeePaid, uint256 actualProtocolFeePaid)', 'InvalidProtocolFeePaymentError(uint256 expectedProtocolFeePaid, uint256 actualProtocolFeePaid)',
{ errorCode, expectedProtocolFeePaid, actualProtocolFeePaid }, { expectedProtocolFeePaid, actualProtocolFeePaid },
); );
} }
} }