-
Notifications
You must be signed in to change notification settings - Fork 44
Remove MultiSend, move activeApps to FreeBalanceState, upgrade protocols, and more #1774
Conversation
Maybe we should wait to merge in Joels fixes before merging this, or anything else, in? |
I'm going to split it up into multiple smaller PRs I think, consider this a draft atm |
import { NetworkContext } from "@counterfactual/types"; | ||
import { ContractFactory, Wallet } from "ethers"; | ||
|
||
export async function configureNetworkContext(wallet: Wallet) { | ||
export type NetworkContextForTestSuite = NetworkContext & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate PR
packages/node/src/methods/app-instance/propose-install-virtual/operation.ts
Outdated
Show resolved
Hide resolved
packages/node/src/methods/app-instance/propose-install-virtual/operation.ts
Outdated
Show resolved
Hide resolved
packages/node/src/methods/app-instance/propose-install-virtual/operation.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides separating into different PRs, lgtm
@@ -55,7 +58,7 @@ beforeAll(async () => { | |||
/** | |||
* @summary Set up a StateChannel and then install a new AppInstance into it. | |||
* | |||
* @description We re-use the ETHBucket App (which is the app ETH Free Balance uses) | |||
* @description We re-use the FreeBalanceApp App (which is the app ETH Free Balance uses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is ETH Free Balance
in this case?
defaultAbiCoder.encode( | ||
["uint256"], | ||
[freeBalanceETH.coinTransferInterpreterParams!.limit] | ||
["tuple(uint256 limit)"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This encoding should be defined in one place and used throughout the rest of the codebase.
packages/simple-hub-server/src/middlewares/validate-signature.ts
Outdated
Show resolved
Hide resolved
57d3870
to
d297618
Compare
This pull request contains several changes rolled into one. They are:
Major
Removing
MultiSend
Previously we used the
MultiSend
contract for the purposes of atomically updating the free balance state and signing a multisignature wallet delegatecall transaction. We needed this atomicity because we had a design goal of one-round-trip per protocol execution. We've relaxed this design goal and are okay with the protocols requiring multiple round trips, now.Add
activeApps
to the Free Balance stateInstead of using
uninstallKey
parameters on the pre-signed transaction made to anAppInstance
to validate if it is in fact a funded App or not, we instead rely on a master list of "active" (a.k.a. funded) apps. This is an array on the state of the free balance. You can see how this logic plays out here:monorepo/packages/contracts/contracts/ConditionalTransactionDelegateTarget.sol
Lines 73 to 86 in ec25b2c
This means the
UninstallKeyRegistry
is also removed.Updating protocols to manage effected changes
The following protocols have been upgraded:
In the case of the installation protocols, they now have an extra round trip per user involved. This is because to make an installation secure you need to first see the unanimously signed conditional transaction (the call to the
ConditionalTransactionDelegateTarget
) and then you feel OK with signing the update to the Free Balance (bothactiveApps
and the relevant balance updates).In the case of the uninstall, instead of setting a bit on the
UninstallKeyRegistry
now we set the state of the Free Balance object and remove the app from theactiveApps
list.Minor
Extend
FreeBalanceState
monorepo/packages/node/src/models/free-balance.ts
Lines 36 to 41 in ec25b2c
Now it includes
balancesIndexedByToken
andactiveAppsBloomFilter
whereas previously it was just this:Introduce
ConditionalTransaction
This is a new commitment type which represents a multisignature wallet delegatecall function call to the
ConditionalTransactionDelegateTarget
. Previously this was encoded inside the "install commitment". See here:Remove
TwoPartyVirtualEthAsLump.sol
We had a special case contract that handled virtual app agreement interpretation in a hard-coded way for
TwoPartyFixedOutcome
outcome types. Instead, now we re-useConditionalTransactionDelegateTarget
as we do for all AppInstances but the clientside code is now hard-coded to theTwoPartyFixedOutcomeETHInterpreter
for now instead.Introduce
IdentityApp
For test scenarios this is a nice app. It is an app whose
computeOutcome
return value is itsencodedState
.Rename
TwoPartyEthAsLump
toTwoPartyFixedOutcomeETHInterpreter
This name was also confusing and so now it references the exact outcome type and asset class it is meant to be an interpreter for. Additionally, the virtual equivalent
TwoPartyVirtualEthAsLump
which manages the distribution of assets between an endpoint and an intermediary was renamed toTwoPartyFixedOutcomeFromVirtualAppETHInterpreter
.Rename
ETHBucket
toFreeBalanceApp
Since the Free Balance is taking on a larger role, I decided to give it a more unique name.
Removing
rollup
from@counterfactual/chain
The only consumers of this package were internal to the codebase and didn't require anything other than access to the TypeScript source code, so I removed the rollup dependency and build step.
Miscellaneous Code Cleanup
latestversionNumber
tolatestVersionNumber
free-balance.ts
functional instead of imperativevalidateSignature
torequireValidSignatureOrThrowError