Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open channel with insufficient ETH balance behaves awkward #1698

Closed
weilbith opened this issue Jun 15, 2020 · 8 comments · Fixed by #1721
Closed

Open channel with insufficient ETH balance behaves awkward #1698

weilbith opened this issue Jun 15, 2020 · 8 comments · Fixed by #1721
Assignees
Labels
bug 🕷️ Something isn't working cli 🔤 Command-line SDK-based Node.js Client issues sdk 🖥

Comments

@weilbith
Copy link
Contributor

Steps to Reproduce

Preparation in the dApp:

  1. Attempt to add new token
  2. Use the mint token button

Become mad in MetaMask:
3. Transfer the full balance (use MAX button) to another account (you
hopefully control)

Create error on SDK

  1. Call openChannel on the SDK for the token just minted initial balance and an active partner (basically make sure that everything on this request is fine)

Expected Result

  • SDK responds/throws error
  • SDK detects the issue (maybe ahead?)
  • SDK does not create the channel object

Actual Result

  • No response/error
  • SDK logs internally error of failing transaction by EthersJS
  • SDK has open channel object what actually can't be used and is a zombie (my interpretation)

Additional Infos (Optional)

This is the log of the SDK:

 action     {
  type: 'token/monitored',
  payload: {
    token: '0x0f84DB873066d53379eC99048609d51b6239c409',
    tokenNetwork: '0xb3bd0c1D08346070662d4181f5837F95bf62FB01',
    fromBlock: 2114501
  }
}
 action     {
  type: 'channel/open/request',
  payload: { settleTimeout: undefined, deposit: BigNumber { _hex: '0x01' } },
  meta: {
    tokenNetwork: '0xb3bd0c1D08346070662d4181f5837F95bf62FB01',
    partner: '0x1F916ab5cf1B30B22f24Ebf435f53Ee665344Acf'
  }
}
 action     { type: 'block/new', payload: { blockNumber: 2877405 } }
 action     { type: 'block/new', payload: { blockNumber: 2877406 } }
 action     {
  type: 'channel/open/success',
  payload: {
    id: 7,
    token: '0x0f84DB873066d53379eC99048609d51b6239c409',
    settleTimeout: 500,
    isFirstParticipant: true,
    txHash: '0x163212e97c89f15c2230613a3395b6739d7fb08e630e5035d48d6548cd676c45',
    txBlock: 2877406,
    confirmed: undefined
  },
  meta: {
    tokenNetwork: '0xb3bd0c1D08346070662d4181f5837F95bf62FB01',
    partner: '0x1F916ab5cf1B30B22f24Ebf435f53Ee665344Acf'
  }
}
 action     {
  type: 'channel/deposit/failure',
  payload: Error: gas required exceeds allowance (8000000) or always failing transaction
      at getResult (/home/thore/projects/brainbot-projects/repositories/raiden/light-client/raiden-ts/node_modules/ethers/providers/json-rpc-provider.js:40:21)
      at exports.XMLHttpRequest.request.onreadystatechange (/home/thore/projects/brainbot-projects/repositories/raiden/light-client/raiden-ts/node_modules/ethers/utils/we
b.js:111:30)
      at exports.XMLHttpRequest.dispatchEvent (/home/thore/projects/brainbot-projects/repositories/raiden/light-client/raiden-ts/node_modules/xmlhttprequest/lib/XMLHttpRe
quest.js:591:25)
      at setState (/home/thore/projects/brainbot-projects/repositories/raiden/light-client/raiden-ts/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
      at IncomingMessage.<anonymous> (/home/thore/projects/brainbot-projects/repositories/raiden/light-client/raiden-ts/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:
447:13)
      at IncomingMessage.emit (events.js:327:22)
      at endReadableNT (_stream_readable.js:1221:12)
      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
    code: -32000,
    data: undefined,
    url: 'https://goerli.infura.io/v3/a23320bce0ea4ddfb6bb6f9f2240e99d',
    body: '{"method":"eth_estimateGas","params":[{"gasPrice":"0x77359400","from":"0xA1a663837b8E53E9d3Da9Eb4A010a5D43B0C31a1","to":"0xb3bd0c1D08346070662d4181f5837F95bf62
FB01","data":"0x63ea01430000000000000000000000000000000000000000000000000000000000000007000000000000000000000000a1a663837b8e53e9d3da9eb4a010a5d43b0c31a1000000000000000000
00000000000000000000000000000000000000000000010000000000000000000000001f916ab5cf1b30b22f24ebf435f53ee665344acf"}],"id":370,"jsonrpc":"2.0"}',
    responseText: '{"jsonrpc":"2.0","id":370,"error":{"code":-32000,"message":"gas required exceeds allowance (8000000) or always failing transaction"}}'
  },
  meta: {
    tokenNetwork: '0xb3bd0c1D08346070662d4181f5837F95bf62FB01',
    partner: '0x1F916ab5cf1B30B22f24Ebf435f53Ee665344Acf'
  },
  error: true
}
@weilbith weilbith added bug 🕷️ Something isn't working sdk 🖥 cli 🔤 Command-line SDK-based Node.js Client issues labels Jun 15, 2020
@kelsos
Copy link
Contributor

kelsos commented Jun 15, 2020

From what I can see in the logs the channel opening transaction was successful, only the deposit failed. These are two different smart contract calls. In general, opening a channel without depositing is still acceptable as far as Raiden is concerned.

Opening a channel with zero deposit won't fail. I would not say the channel is zombie or unusable because you can still receive on even if you have 0 deposit. And as soon as you receive you can also send.

@weilbith
Copy link
Contributor Author

Okay this is awkward. How could the channel have been created?

@weilbith
Copy link
Contributor Author

So I checked Etherscan. There is no other transaction after the one sending the whole balance.

@weilbith
Copy link
Contributor Author

I can redo this again and again for new tokens also with 0 deposit.

@weilbith
Copy link
Contributor Author

And importantly: I don't get a response.

@weilbith
Copy link
Contributor Author

Okay, first things first. I was a big unorganized and mixed my both accounts
I used to transfer the ETH. So I was using the wrong account to do the test. So if there is not enough ETH to pay, I get a valid error. The issue is now only about insufficient token funds. This is what the log above is actually about. I'll adjust the issue tile and description.

@weilbith
Copy link
Contributor Author

So as I understood it now (@andrevmatos please correct) me is the actual issue that the SDK does catch and reject() on a failing gas estimation for the first transfer to open the channel, but not for the deposit one.

@andrevmatos andrevmatos self-assigned this Jun 15, 2020
@andrevmatos
Copy link
Contributor

Yes, the failure channel/deposit/failure you saw is expected (since you didn't have the funds), but since the channel/open/success action went through, it should not prevent your API call to resolve successufully. This happened because the error happened before sending the tx, on estimateGas (which is good, since it saves gas from a tx that would fail anyway), while I catch/handle the failure only for the recipe, i.e. when the transaction is sent but fails on-chain. I'll fix by ensuring we handle both errors and doesn't impact the rest of the chain.
Thank you for the report though, this is some very specific edge condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🕷️ Something isn't working cli 🔤 Command-line SDK-based Node.js Client issues sdk 🖥
Projects
None yet
3 participants