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

bug: Bitswap not recording 'Bytes sent' #3875

Closed
dgrisham opened this issue Apr 24, 2017 · 3 comments
Closed

bug: Bitswap not recording 'Bytes sent' #3875

dgrisham opened this issue Apr 24, 2017 · 3 comments
Labels
kind/bug A bug in existing code (including security flaws) topic/bitswap Topic bitswap

Comments

@dgrisham
Copy link
Member

dgrisham commented Apr 24, 2017

Version information:

go-ipfs version: 0.4.9-dev-9dc5883a
Repo version: 5
System version: amd64/linux
Golang version: go1.8.1

This bug was also observed in version 0.4.8-dev.

Type: Bug

Severity: Medium

Description:

When sending blocks to another user, the number of bytes sent to that user is not recorded in the corresponding Bitswap ledger (the receiving peer does record the number of bytes they receive, however).

Steps to reproduce:

  1. (Optional) Initialize 2 peers to be connected to only each other.
    • On both peers: ipfs init, ipfs bootstrap rm all, ipfs bootstrap add <other_peer_multiaddr>
    • Run ipfs daemon, then ipfs swarm peers to ensure connections are established.
  2. Add file to IPFS on one of the peers, then get the file on the other peer.
    a. Peer 1: head -c 1000 /dev/urandom | base64 > /tmp/file && ipfs add -q /tmp/file
    b. Peer 2: ipfs get <file_hash>
  3. Check Bitswap ledgers with ipfs bitswap ledger <peer_id>

After I run those steps, the result on the sending peer is:

Ledger for <peer.ID XLhkey>
Debt ratio:     0.000000
Exchanges:      0
Bytes sent:     0
Bytes received: 0

And on the receiving peer:

Ledger for <peer.ID PipTao>
Debt ratio:     0.000000
Exchanges:      1
Bytes sent:     0
Bytes received: 1365

If I then swap the roles and have the second peer upload a file that the first peer downloads, the first ledger changes to:

Ledger for <peer.ID XLhkey>
Debt ratio:     0.000000
Exchanges:      1
Bytes sent:     0
Bytes received: 1365

and the second ledger is unchanged from the one above.

I'm going to look into this myself, but I thought I'd post it here in case anyone has an immediate idea as to why this is happening.

Thanks!

@Kubuxu Kubuxu added topic/bitswap Topic bitswap kind/bug A bug in existing code (including security flaws) labels Apr 24, 2017
@dgrisham
Copy link
Member Author

It looks like the function MessageSent, which updates the ledger just like MessageReceived when a message is received, wasn't actually called anywhere. I was able to fix it by adding a call to MessageSent where it seemed to make the most sense and have verified that the update works as expected, I'm about to submit a pull request with the change. Let me know if there are any other checks or changes I can make to this update, or if I completely missed the reason for this issue and my change was unnecessary.

@whyrusleeping
Copy link
Member

@dgrisham make sure to add a test or two for this in exchange/bitswap/bitswap_test.go :)

@dgrisham
Copy link
Member Author

@whyrusleeping Gotcha, will do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) topic/bitswap Topic bitswap
Projects
None yet
Development

No branches or pull requests

3 participants