Skip to content

Conversation

yondonfu
Copy link
Member

  • Add fundAndApproveSigners() function to wrap funding deposit and penalty escrow and approving signers
  • Add test for separation of ticket redeemer and recipient

The wrapper function atomically funds a sender's deposit and penalty
escrow and also approves a set of signer addresses.
@yondonfu yondonfu requested a review from eladmallel November 26, 2018 21:58
address[] _signers
)
external
checkDepositPenaltyEscrowSplit(_depositAmount, _penaltyEscrowAmount)
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this always fail because it checks against msg.value which won't be sufficient in an ERC20 approach?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right - we actually don't need to check the deposit/penalty escrow split in ERC20TicketBroker since the contract doesn't need to make sure that the correct value is included in the tx. If the user did not approve a sufficient amount of tokens to be transferred by ERC20TicketBroker to cover both the specified deposit and penalty escrow amounts, the ERC20 transferFrom call will fail.

I removed the modifier from ERC20TicketBroker and moved it from TicketBroker into ETHTicketBroker and LivepeerETHTicketBroker in 00f5dfc since the modifier logic does not necessarily apply to all TicketBroker implementations (i.e. ERC20TicketBroker). However, this does introduce duplication of the modifier in LivepeerETHTicketBroker and ETHTicketBroker. Let me know if you have any thoughts on a better approach here.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could just decide to leave the modifier in TicketBroker even though not every broker type needs it, if we choose to prioritize DRY (don't repeat yourself) over maximizing sub-type reuse of super type code.

I'm leaning in that direction.. to sweeten the deal we could rename the modifier to explicitly mention it's using ETH value, to reduce the odds of misuse.

wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have any strong feelings here, so I am happy to leave the modifier in TicketBroker and update its name to reflect that it deals with ETH value.

})
})

describe("fundAndApproveSigners", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add tests that ensure events are emitted?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are already tests for events emitted from the modifiers and approveSigners - since this function just internally calls those modifiers and approveSigners I did not include tests for events emitted in the interest of avoiding additional duplication. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, you did add tests for tracking balances, which is also logic that lives inside the modifiers :) so we're testing one part of the modifiers' behavior but not the other.

I share the sentiment that this is redundant, but find it harder to let go of the inconsistency.

Perhaps we should consider dropping the test for balance tracking?
Or re-discuss how we could design these contracts to achieve more straightforward code reuse that doesn't force us to duplicate a bunch of testing code?

@eladmallel
Copy link
Contributor

@yondonfu notice how we're forced to several identical tests to cover both the ETH broker and the LivepeerETH broker. Perhaps we should further discuss how to get rid of this duplication?

@coveralls
Copy link

coveralls commented Dec 10, 2018

Pull Request Test Coverage Report for Build 575

  • 5 of 5 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 99.609%

Totals Coverage Status
Change from base Build 564: 0.003%
Covered Lines: 708
Relevant Lines: 709

💛 - Coveralls

@yondonfu yondonfu force-pushed the yf/sender-wrapper-function branch from 00f5dfc to c73812c Compare December 10, 2018 19:36
Copy link
Contributor

@eladmallel eladmallel left a comment

Choose a reason for hiding this comment

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

🚢 pending green CI !

@yondonfu yondonfu merged commit 497359d into yf/depositor-signer-separation Dec 10, 2018
@yondonfu yondonfu deleted the yf/sender-wrapper-function branch December 10, 2018 19:57
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.

3 participants