snet-daemon icon indicating copy to clipboard operation
snet-daemon copied to clipboard

Bug : Channels with the same channel_id but differnt nonce stored in channel state in Daemon

Open anandrgitnirman opened this issue 4 years ago • 5 comments

snetd --config snetd_8011.json list channels

What ever is shown in bold and italized should not have happened , irrescpective of any client calls on control_service , need to investigate this

@vsbogd @raamb , need to pick your brains on how this could have happened ,!

233: {ChannelID: 233, Nonce: 1, State: Open, Sender: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, Recipient: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, GroupId: LAX4UqwS0gIWz6yFwYTqXQIeUAgrgYu4RqvvjWIg2C0=, FullAmount: 97, Expiration: 7790405, Signer: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, AuthorizedAmount: 4, Signature: lyVj1kn1XmEUgJAcJLQ7wOCOa3wtaimj4wSp92IdwDNq/tHr4vTGGFmaVyJAj8kE32Vy6UVmrJya4XGLW8nAsBw= 234: {ChannelID: 234, Nonce: 0, State: Open, Sender: 0x3Bb9b2499c283cec176e7C707Ecb495B7a961ebf, Recipient: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, GroupId: LAX4UqwS0gIWz6yFwYTqXQIeUAgrgYu4RqvvjWIg2C0=, FullAmount: 3, Expiration: 9826735, Signer: 0x3Bb9b2499c283cec176e7C707Ecb495B7a961ebf, AuthorizedAmount: 1, Signature: e6HmQ+tClKienhy9zDMUtkwUqxU2pPIdI7ZXh8YxPPlQvUhkUf5IsYPJRHw+HfaglXE/JxkW4nO/xwFeGHa8kxw= 233: {ChannelID: 233, Nonce: 0, State: Open, Sender: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, Recipient: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, GroupId: LAX4UqwS0gIWz6yFwYTqXQIeUAgrgYu4RqvvjWIg2C0=, FullAmount: 100, Expiration: 7740959, Signer: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, AuthorizedAmount: 1, Signature: wnhmP7oKN7IvzxWsmaaNfUQiP7WQEqgCzgiyylWat2BvqeZSYzgxbz3/Yz5/sXIh33X3OpNwrD+XQsFSRVEkhxw=

Daemon config

json
"ipfs_end_point": "http://ipfs.singularitynet.io:80",
  "blockchain_network_selected": "ropsten",
  "organization_id": "singnet",
  "service_id": "do_not_edit",
  "authentication_addresses": [
    "0x94d04332C4f5273feF69c4a52D24f42a3aF1F207"
  ],
  "passthrough_endpoint": "http://localhost:7003",
  "daemon_end_point":"0.0.0.0:8011",
  "blockchain_enabled": true,
  "passthrough_enabled": true,
  "metering_end_point": "https://ropsten-marketplace.singularitynet.io",

anandrgitnirman avatar Apr 16 '20 12:04 anandrgitnirman

@anandrgitnirman , what is the version of daemon?

vsbogd avatar Apr 16 '20 14:04 vsbogd

I looked at code to recall :-) It is a feature. Each channel state is kept in storage and key is pair { channelId, nonce }. So when channel is claimed new state is put with key { channelId, nonce + 1 }, but old state is not removed. So list channel command shows all nonces.

What does seems strange to me is that channel 233, nonce 0 has full amount: 100 and authorized amount 1. And channel 233, nonce 1 has full amount: 97. But its amount should be 100 - 1 = 99. Do you have logs of the daemon?

vsbogd avatar Apr 16 '20 14:04 vsbogd

@anandrgitnirman , what is the version of daemon?

latest 3.1.6

anandrgitnirman avatar Apr 16 '20 19:04 anandrgitnirman

I looked at code to recall :-) It is a feature. Each channel state is kept in storage and key is pair { channelId, nonce }. So when channel is claimed new state is put with key { channelId, nonce + 1 }, but old state is not removed. So list channel command shows all nonces.

What does seems strange to me is that channel 233, nonce 0 has full amount: 100 and authorized amount 1. And channel 233, nonce 1 has full amount: 97. But its amount should be 100 - 1 = 99. Do you have logs of the daemon?

I rechecked this with a brand new org and service , I dont see the channel with old nonce come up at all , on the list channels command

  "ipfs_end_point": "http://ipfs.singularitynet.io:80",
  "blockchain_network_selected": "ropsten",

  "authentication_addresses": [
    "0x94d04332C4f5273feF69c4a52D24f42a3aF1F207"
  ],
  "passthrough_endpoint": "http://localhost:7003",
  "daemon_end_point":"0.0.0.0:8030",
  "blockchain_enabled": true,
  "passthrough_enabled": true,
  "metering_end_point": "https://ropsten-marketplace.singularitynet.io",
  "payment_channel_cert_path": "/home/anand/anand-home/conf_auth/client.pem",
  "payment_channel_ca_path": "/home/anand/anand-home/conf_auth/ca.pem",
  "payment_channel_key_path": "/home/anand/anand-home/conf_auth/client-key.pem",
  "ssl_cert":"/etc/letsencrypt/live/example-service-a.singularitynet.io/fullchain.pem",
  "ssl_key":"/etc/letsencrypt/live/example-service-a.singularitynet.io/privkey.pem",
   "ipfs_end_point": "http://ipfs.singularitynet.io:80",
  "blockchain_network_selected": "ropsten",
  "organization_id": "anand_wed",
  "service_id": "anand_wed",
  "metering_end_point": "https://ropsten-marketplace.singularitynet.io",
  "authentication_addresses": [
    "0x94d04332C4f5273feF69c4a52D24f42a3aF1F207"
  ],
  "blockchain_enabled": true,
  "passthrough_enabled": true
}

see this

snetd --config snetd_8030.json list channels
236: {ChannelID: 236, Nonce: 1, State: Open, Sender: 0x501e8c58E6C16081c0AbCf80Ce2ABb6b3f91E717, Recipient: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, GroupId: yKcFbyUlpWfOuTn0WpICpKtQATrU6gxz6Wn9zAB1kxo=, FullAmount: 998, Expiration: 7791599, Signer: 0x501e8c58E6C16081c0AbCf80Ce2ABb6b3f91E717, AuthorizedAmount: 2, Signature: H2hVAdAjPbQ2Q+2i7izDvPJMRi6XZXxqE0iHMwQ7bTEwXSFiHx8RNJRiB0oojZeRDe0qDfnxjpIESm1lotqbRhs=

238: {ChannelID: 238, Nonce: 1, State: Open, Sender: 0xB18aac9DE3852F988147287daBD19dF2791C2e0f, Recipient: 0x94d04332C4f5273feF69c4a52D24f42a3aF1F207, GroupId: yKcFbyUlpWfOuTn0WpICpKtQATrU6gxz6Wn9zAB1kxo=, FullAmount: 999, Expiration: 7791685, Signer: 0xB18aac9DE3852F988147287daBD19dF2791C2e0f, AuthorizedAmount: 3, Signature: T/p9fbEdAd1VKzbkvNuSUYP6xUCA6gA7QXL+KHHxp3lMQFcG/UvrcqGIVCaTCLrzF8LyIQpS2myeUQmqbamspxs=

we lost the logs sadly :(

anandrgitnirman avatar Apr 16 '20 19:04 anandrgitnirman

  1. But its amo

I looked at code to recall :-) It is a feature. Each channel state is kept in storage and key is pair { channelId, nonce }. So when channel is claimed new state is put with key { channelId, nonce + 1 }, but old state is not removed. So list channel command shows all nonces.

What does seems strange to me is that channel 233, nonce 0 has full amount: 100 and authorized amount 1. And channel 233, nonce 1 has full amount: 97. But its amount should be 100 - 1 = 99. Do you have logs of the daemon?

there was a claim done with Auth Amount = 3 , when channel nonce was zero ! ..( this I am pretty sure)

anandrgitnirman avatar Apr 16 '20 19:04 anandrgitnirman