Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

[monorepo] replace Transfer.sol mechanism with Interpreters #1263

Merged
merged 14 commits into from
May 13, 2019
Merged

Conversation

ldct
Copy link
Member

@ldct ldct commented Apr 11, 2019

This PR refactors the contracts and node and fixes: #1222, #1157, #1442

The design is as follows. App Definition resolve functions now return unstructured data which is to be consumed by an "interpreter" contract which runs in the multisig context and handles state deposit payouts in dispute scenarios. App Definitions are classified by "resolve type", e.g.,

  • TwoPartyOutcome: the app is some kind of 2-party game, and the resolve function returns a uint256 in the set {0, 1, 2} which means "player 1 won, player 2 won, draw" respectively
  • ETHTransfer: the resolve functions returns a list of (to, value) tuples

State deposits constrain what apps they can be used with: for instance, a deposit of ETH can be used for apps of resolve type ETHTransfer or TwoPartyOutcome, but a deposit of two ERC721 NFTs can only be used for TwoPartyOutcome.

hard-coded assumptions

  • virtual apps always resolve to type 2-party outcome

temporary hacks to be removed in the future

  • A resolveType function is introduced in all app definitions. This is used by the uninstall protocol to determine how to update the free balance during uninstall.
  • A limitOrTotal field is added to the AppInstance class. For app instances interpreted by ETHInterpreter, this represents a limit on the total ETH; for those interpreted by TwoPartyEthAsLump, this represents the total funds committed to the app.
  • The ttt bot assumes that it is player 2
  • interpreterHash is computed but not checked in StateChannelTransaction

@ldct ldct force-pushed the ldct/transfer branch 3 times, most recently from 13e793d to 7129182 Compare April 13, 2019 00:55
packages/apps/waffle.js Outdated Show resolved Hide resolved
@alxiong
Copy link
Collaborator

alxiong commented Apr 13, 2019

@IIIIllllIIIIllllIIIIllllIIIIllllIIIIll two extra comments:

  1. better comments would help. (e.g. I don't really know what am I supposed to feed into resolution and interpreterParams
  2. in the future, it would be more friendly if we provide a predefined set of interpreter options (i.e. preset) for most use case such that developers can just choose one (from an enum, which contains a list of common interpreters) by specifying a number, or they can customize their own for more complicated app.

in general, I do think current change is great and will support coinshuffle app requirement. Great work!

@ldct ldct force-pushed the ldct/transfer branch 7 times, most recently from 894e000 to 59245be Compare April 22, 2019 03:55
@ldct
Copy link
Member Author

ldct commented Apr 22, 2019

might be blocked on duaraghav8/Ethlint#261

@ldct ldct force-pushed the ldct/transfer branch 5 times, most recently from 23cb32c to f6cef5e Compare April 25, 2019 03:58
@ldct ldct force-pushed the ldct/transfer branch 3 times, most recently from e72f164 to 3b1f744 Compare May 10, 2019 13:37
@ldct ldct force-pushed the ldct/transfer branch 2 times, most recently from f8fcb35 to b8bc4d2 Compare May 10, 2019 21:58
@ldct ldct force-pushed the ldct/transfer branch from 3d58ecd to a916b19 Compare May 12, 2019 02:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transfers are forced to use the same token for all beneficiaries
4 participants