counterfactual / monorepo

Home for all packages related to the Counterfactual project
https://counterfactual.com
MIT License
187 stars 44 forks source link

[wallet-ui] User is not receiving funds upon withdraw #2025

Open spersico opened 5 years ago

spersico commented 5 years ago

From the wallet, we manage to execute a withdraw action, MM asks us permission to charge to our wallet the fee (reasonable), and the transaction seems to run just fine. The CF wallet loses the requested amount, the fee is charged to the user's wallet, BUT the withdrawn amount of ETH is never received by the user's wallet.

This has been tested in this branch of prototypal/MM and in master upon this PR

Screenshots of the issue: The user and CF wallets balances, MM prompt, and the data sent (I verified that the node.iife.js is receiving that same data (except the node address)). pre-aproval

The user and CF wallets balances, and the data recieved after The response has inside:

{
"recipient":"0xd6e26d8acfd2948c06098c6de386c89b12e0f916"
"txHash":"0x7bd7caaba6dd530a023e2d84b9cfdfa9cda19784f19f9827b0431900eed02d49"
}

From the walletUI we execute the event with this: https://github.com/counterfactual/monorepo/blob/fb4cfe54f0b43cf5c55a989330801627f77ee528/packages/wallet-ui/src/utils/counterfactual.ts#L57-L67

Inside of MM, the call to the node is handled by the counterfactualMiddleware like this: https://github.com/prototypal/metamask-extension/blob/e0aa337b32e3f1876d94c3ba509fcf05c39ded02/app/scripts/plugins/counterfactualMiddleware.js#L29-L30

on counterfactual.js like this

https://github.com/prototypal/metamask-extension/blob/e0aa337b32e3f1876d94c3ba509fcf05c39ded02/app/scripts/plugins/counterfactual.js#L150-L166

LayneHaber commented 5 years ago

I'm noticing the same issue, here are some (ideally helpul) logs of helpful accounts:

********** PRE WITHDRAW BALANCES: {
  "multisigBalance": "34989569600000000000",
  "recipientBalance": "64999160000000000000",
  "accountBalance": "6559280000000000",
  "userFreeBalance": "4998856960000000000"
}

info: [ConnextListener] Emitted withdrawalStartedEvent
********** STARTED WITHDRAW: 0
// withdrawal confirmed seems to be emitted twice, once without
// any data, and once with data that i have hardcoded into a local cf
logger.js:53 info: [ConnextListener] Emitted withdrawalConfirmedEvent
************ data undefined
data.recipientBalance null
data.multisigBalance null

************ data {recipientBalance: v, multisigBalance: v}
data.recipientBalance 64999160000000000000
data.multisigBalance 34989569600000000000
logger.js:53 info: [WithdrawalController] Withdraw Response: {
  "recipient": "0x2932b7A2355D6fecc4b5c0B6BD44cC31df247a2e",
  "txHash": "0x12009037ce311ea1af9a98ec7fe9dd840962320f3c66dc6abacdc53a5abdfe3a"
}

********** POST WITHDRAW BALANCES: {
  "multisigBalance": "34989569600000000000",
  "recipientBalance": "64999160000000000000",
  "accountBalance": "5858240000000000", // accounts[0]
  "userFreeBalance": "0"
}

Also logged the transaction information:

{
  "to": "0x35936CD28231e22fB68fB556e8121191abdCEEb5", // multisig address
  "from": "0xe838a8C673F46F2B1a9f69dB8368ee65e5cf9123", // accounts[0]
  "contractAddress": null,
  "transactionIndex": 0,
  "gasUsed": {
    "_hex": "0x88ec"
  },
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "blockHash": "0x062640bd861d050d93493480d0bda2b4c59e5678b5b4d2ea7568ca16eef55298",
  "transactionHash": "0x12009037ce311ea1af9a98ec7fe9dd840962320f3c66dc6abacdc53a5abdfe3a",
  "logs": [],
  "blockNumber": 38,
  "confirmations": 1,
  "cumulativeGasUsed": {
    "_hex": "0x88ec"
  },
  "status": 1,
  "byzantium": true
}
LayneHaber commented 5 years ago

the full transaction object:

{
  "hash": "0x5809dd0cce631e75d4dfba72c9727247be89c1bfacad37be3f3cc6c2656c28c1",
  "blockHash": "0x7b7fab5d193c1fd12c0b20654448168f37adb8eedef4172989f250bca6191dce",
  "blockNumber": 44,
  "transactionIndex": 0,
  "confirmations": 1,
  "from": "0xe838a8C673F46F2B1a9f69dB8368ee65e5cf9123",
  "gasPrice": {
    "_hex": "0x4a817c800"
  },
  "gasLimit": {
    "_hex": "0x493e0"
  },
  "to": "0x35936CD28231e22fB68fB556e8121191abdCEEb5",
  "value": {
    "_hex": "0x0"
  },
  "nonce": 11,
  "data": "0x58cb5e5a0000000000000000000000002932b7a2355d6fecc4b5c0b6bd44cc31df247a2e000000000000000000000000000000000000000000000000455f83158dbc000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000417b8641f9fc2284d9065178a354fa2e478d4bf027447e8644fef1f881cd00a49a1aa2a62510a75dd39f9a1e73c536e7aa950917baca5c0827fe892aff08e31b401b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000414014f6b92346e6a142f113311e8a692820b1c63e7474c62ec35c367073a5d4085b3e48efcbb0db2d35e2889195ea488aae825c1986c03c9bcc5338903944e4c31c00000000000000000000000000000000000000000000000000000000000000",
  "r": "0xc4b7bf9fa2a3ddfa224c5586398980728cd76c4177637e0586f2973c3c80b470",
  "s": "0x399f2c51d936b0931474011893a464cc2d26c924b6d774a798778296a50bd731",
  "v": 8930,
  "creates": null,
  "raw": "0xf9028d0b8504a817c800830493e09435936cd28231e22fb68fb556e8121191abdceeb580b9022458cb5e5a0000000000000000000000002932b7a2355d6fecc4b5c0b6bd44cc31df247a2e000000000000000000000000000000000000000000000000455f83158dbc000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000417b8641f9fc2284d9065178a354fa2e478d4bf027447e8644fef1f881cd00a49a1aa2a62510a75dd39f9a1e73c536e7aa950917baca5c0827fe892aff08e31b401b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000414014f6b92346e6a142f113311e8a692820b1c63e7474c62ec35c367073a5d4085b3e48efcbb0db2d35e2889195ea488aae825c1986c03c9bcc5338903944e4c31c000000000000000000000000000000000000000000000000000000000000008222e2a0c4b7bf9fa2a3ddfa224c5586398980728cd76c4177637e0586f2973c3c80b470a0399f2c51d936b0931474011893a464cc2d26c924b6d774a798778296a50bd731",
  "networkId": 4447
}
joelalejandro commented 5 years ago

@cf19drofxots has confirmed that the Node isn't the cause of this behavior. @spersico we'll need to double down on our efforts and figure out what we're doing with the multisigAddress parameter. We might be routing money to an address without the necessary contract code to actually process and redirect the funds to the user.