Skip to content

Fallback for process Redemption and Staking - #60

Merged
jasonklein merged 4 commits into
developfrom
benjaminbollen/gh26/processfallback
Dec 13, 2017
Merged

Fallback for process Redemption and Staking#60
jasonklein merged 4 commits into
developfrom
benjaminbollen/gh26/processfallback

Conversation

@benjaminbollen

Copy link
Copy Markdown
Contributor

contracts, test: introduce fallback for process staking and redemption. fixes #26

this was forgotten to be merged into develop

@benjaminbollen
benjaminbollen force-pushed the benjaminbollen/gh26/processfallback branch from 1dac0e4 to 287ed48 Compare December 12, 2017 17:59

@jasonklein jasonklein left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The description of the PR indicates tests, but testing appears to be incomplete/uneven. Both OpenSTValue and OpenSTUtility update processStaking and processRedeeming tests to not use the registrar, but OpenSTValue has additional testing, of registrar's ability to process staking, that is not replicated in OpenSTUtility for redeeming; and these changes are not tested for the Registrar contract.

address public registrar;
/// registered branded tokens
mapping(bytes32 /* uuid */ => RegisteredToken) public registeredTokens;
mapping(bytes32 /* uuid */ => RegisteredToken) registeredTokens;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why drop the public modifier?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

because it s a struct, and so a public getter cannot be implemented by the compiler (it cannot return a struct, correct?); in exchange we have registeredTokenProperties

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But then I think that should mean we are seeing compiler errors on develop. Also, when I called the public function just now in what's on the develop branch, it returns two (sensible looking) addresses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so then structs can be auto-decomposed by the compiler; there does not need to be both though. Then we should remove likewise functions on OpenSTValue.sol as well; I'll open an issue for it instead, that updates the integration tests that use these getters.

Comment thread contracts/OpenSTUtility.sol Outdated
Redemption storage redemption = redemptions[_redemptionIntentHash];
require(redemption.redeemer == msg.sender);

// note: as processRedemption incurs a cost for the staker, we provide a fallback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this refer to "redeemer"? I see arguments for both ways, so mostly just asking to confirm this is intentional and not simply a copy/paste oversight.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

copy-paste oversight; thx

Comment thread contracts/OpenSTUtility.sol Outdated
Redemption storage redemption = redemptions[_redemptionIntentHash];
require(redemption.redeemer == msg.sender);

// note: as processRedemption incurs a cost for the staker, we provide a fallback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a fair reading of this comment implies that the issue is that there is a cost to the redeemer and the fix is to provide a fallback to mitigate that cost in someway (e.g., if the redeemer were unable to call processRedemption for some reason and problems issuing from that deficiency).

This comment should be reworded to clarify that the issue to address is that the redeemer could avoid certain costs, but that such avoidance is counter to the protocol; and that the fallback is the fix to ensure adherence to the protocol. Same comment for OpenSTValue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

extended explanation to make this point

Comment thread contracts/OpenSTUtilityInterface.sol Outdated
uint256 expirationHeight);

function processRedeeming(
bytes23 _redemptionIntentHash)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bytes32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

noted

Comment thread contracts/Registrar.sol Outdated
// address of OpenSTUtility registry:
OpenSTUtilityInterface _registry,
// OpenSTUtility function:
bytes23 _redemptionIntentHash)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bytes32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

noted

Comment thread test/OpenSTValue.js

it('fails to process when msg.sender != staker', async () => {
await Utils.expectThrow(openSTValue.processStaking(stakingIntentHash, { from: registrar }));
// registrar can additionally as a fallback process staking in v0.9

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The it of this test should be updated to reflect what the comment implies—this tests that a non-staker/non-registrar cannot successfully call the function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed to " fails to process when msg.sender is not staker or registrar"

Comment thread test/OpenSTValue.js Outdated
})
})

describe('ProcessStaking with fallback', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be consistent, the "test stories" at the top should be updated to reflect this addition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated in OpenSTValue.js and OpenSTUtility.js

Comment thread test/OpenSTUtility.js

it('fails to process if msg.sender != redeemer', async () => {
await Utils.expectThrow(openSTUtility.processRedeeming(redemptionIntentHash, { from: accounts[1] }));
await Utils.expectThrow(openSTUtility.processRedeeming(redemptionIntentHash, { from: accounts[5] }));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The it of this test should be updated to reflect what the comment implies—this tests that a non-redeemer/non-registrar cannot successfully call the function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed to "fails to process if msg.sender is not redeemer or registrar"

@benjaminbollen
benjaminbollen force-pushed the benjaminbollen/gh26/processfallback branch from 008357a to a1ea331 Compare December 13, 2017 16:40
@benjaminbollen

Copy link
Copy Markdown
Contributor Author
  1. updated code for review comments and corrections
  2. extended unit test for process redemption by registrar

@jasonklein
jasonklein merged commit 6c99394 into develop Dec 13, 2017
@benjaminbollen
benjaminbollen deleted the benjaminbollen/gh26/processfallback branch December 15, 2017 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

processStaking and processRedemption fallback

2 participants