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

channel balance (raiden) #1051

Closed
offerm opened this issue Jun 21, 2019 · 6 comments · Fixed by #1066
Closed

channel balance (raiden) #1051

offerm opened this issue Jun 21, 2019 · 6 comments · Fixed by #1066
Assignees
Labels
bug Something isn't working P1 top priority

Comments

@offerm
Copy link
Contributor

offerm commented Jun 21, 2019

I have two tokens defined (WETH, DAI) and one channel with another node. The channel balance is 1e18.

When I use xucli channelbalance I see the balance reported for both tokens.

xud@xud-test-1:~/scripts/raiden/exchange$ xucli channelbalance
{
  "balancesMap": [
    [
      "BTC",
      {
        "balance": 3750157448,
        "pendingOpenBalance": 0
      }
    ],
    [
      "DAI",
      {
        "balance": 1000000000000000000,
        "pendingOpenBalance": 0
      }
    ],
    [
      "LTC",
      {
        "balance": 226339963038,
        "pendingOpenBalance": 0
      }
    ],
    [
      "WETH",
      {
        "balance": 1000000000000000000,
        "pendingOpenBalance": 0
      }
    ]
  ]
}
@kilrau kilrau added the bug Something isn't working label Jun 22, 2019
@offerm
Copy link
Contributor Author

offerm commented Jun 22, 2019

In case both channels have balance, there is a different problem:

xud@xud-test-1:~/raiden$ curl http://localhost:5001/api/v1/channels|jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   734  100   734    0     0  52954      0 --:--:-- --:--:-- --:--:-- 56461
[
  {
    "total_deposit": 1.5e+20,
    "token_address": "0x9F50cEA29307d7D91c5176Af42f3aB74f0190dD3",
    "token_network_identifier": "0x23a7036a025FEF30A38f1f3464FFbe2b02a5a627",
    "reveal_timeout": 50,
    "balance": 1.5e+20,
    "settle_timeout": 500,
    "state": "opened",
    "channel_identifier": 1,
    "partner_address": "0x2B88992DEd5C96aa7Eaa9CFE1AE52350df7dc5DF"
  },
  {
    "total_deposit": 7e+20,
    "token_address": "0x76671A2831Dc0aF53B09537dea57F1E22899655d",
    "token_network_identifier": "0x52878c603046eC04647bEc9729c132FD1b72Ec6B",
    "reveal_timeout": 50,
    "balance": 7e+20,
    "settle_timeout": 500,
    "state": "opened",
    "channel_identifier": 1,
    "partner_address": "0x2B88992DEd5C96aa7Eaa9CFE1AE52350df7dc5DF"
  }
]
xud@xud-test-1:~/raiden$ xucli channelbalance
Error: 13 INTERNAL: Assertion failed

@kilrau
Copy link
Contributor

kilrau commented Jun 22, 2019

Summary of bugs to be fixed:

  1. if two raiden token network (e.g. weth) have a channel with balance, xucli channelbalance shows both token networks with the sum of both channel balances.
  2. if all registered token networks have a channel with balance, xucli channelbalance throws Error: 13 INTERNAL: Assertion failed

@offerm
Copy link
Contributor Author

offerm commented Jun 23, 2019

I see assertion failed also with a single channel

xud@xud-test-3:~$ curl  http://localhost:5001/api/v1/channels|jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   347  100   347    0     0  25458      0 --:--:-- --:--:-- --:--:-- 26692
[
  {
    "balance": 1.8e+20,
    "token_network_identifier": "0x52878c603046eC04647bEc9729c132FD1b72Ec6B",
    "token_address": "0x76671A2831Dc0aF53B09537dea57F1E22899655d",
    "settle_timeout": 500,
    "state": "opened",
    "reveal_timeout": 50,
    "total_deposit": 0,
    "partner_address": "0x7ed0299Fa1ADA71D10536B866231D447cDFa48b9",
    "channel_identifier": 4
  }
]
xud@xud-test-3:~$ xucli channelbalance
Error: 13 INTERNAL: Assertion failed

@kilrau
Copy link
Contributor

kilrau commented Jun 25, 2019

Bump up to 1.0.0-testnet P1 since this makes it very hard to figure out what's going on and prove for bug bounty hunters that money was stolen.

@kilrau kilrau added the P1 top priority label Jun 25, 2019
@sangaman sangaman assigned sangaman and unassigned ghost Jun 25, 2019
sangaman added a commit that referenced this issue Jun 25, 2019
This modifies the logic around querying raiden for channel balances.
Rather than summing up all balances across all tokens, it allows for
specifying a currency and retrieving only the balance for that
currency. Calling `ChannelBalance` without specifying a currency will
return each currency separately.

Closes #1051.
sangaman added a commit that referenced this issue Jun 25, 2019
This modifies the logic around querying raiden for channel balances.
Rather than summing up all balances across all tokens, it allows for
specifying a currency and retrieving only the balance for that
currency. Calling `ChannelBalance` without specifying a currency will
return each currency separately.

It also scales the balance returned by raiden to satoshis (10^-8). This
is because the default units of 10^-18 for currencies such as WETH can
exceed the maximum value of a `uint64` used by the gRPC layer.

Closes #1051.
@sangaman
Copy link
Collaborator

I believe the Assertion Failed errors are happening because we wind up with numbers greater than the max for uint64. With each whole unit being 10^18 it can add up pretty quickly. In #1066 I'm standardizing the balances returned to satoshi units, in a future PR for the cli I can modify it to print whole units, so the balance prints like 1.5 WETH instead of 15 and a bunch of zeros.

@kilrau
Copy link
Contributor

kilrau commented Jun 25, 2019

@sangaman Pls give this a manual test

sangaman added a commit that referenced this issue Jul 1, 2019
This modifies the logic around querying raiden for channel balances.
Rather than summing up all balances across all tokens, it allows for
specifying a currency and retrieving only the balance for that
currency. Calling `ChannelBalance` without specifying a currency will
return each currency separately.

It also scales the balance returned by raiden to satoshis (10^-8). This
is because the default units of 10^-18 for currencies such as WETH can
exceed the maximum value of a `uint64` used by the gRPC layer.

Closes #1051.
sangaman added a commit that referenced this issue Jul 6, 2019
This modifies the logic around querying raiden for channel balances.
Rather than summing up all balances across all tokens, it allows for
specifying a currency and retrieving only the balance for that
currency. Calling `ChannelBalance` without specifying a currency will
return each currency separately.

It also scales the balance returned by raiden to satoshis (10^-8). This
is because the default units of 10^-18 for currencies such as WETH can
exceed the maximum value of a `uint64` used by the gRPC layer.

Closes #1051.
sangaman added a commit that referenced this issue Jul 8, 2019
This modifies the logic around querying raiden for channel balances.
Rather than summing up all balances across all tokens, it allows for
specifying a currency and retrieving only the balance for that
currency. Calling `ChannelBalance` without specifying a currency will
return each currency separately.

It also scales the balance returned by raiden to satoshis (10^-8). This
is because the default units of 10^-18 for currencies such as WETH can
exceed the maximum value of a `uint64` used by the gRPC layer.

Closes #1051.
@ghost ghost closed this as completed in #1066 Jul 9, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 top priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants