Peergos / nabu

A minimal Java implementation of IPFS
MIT License
66 stars 11 forks source link

Possible bug: Bootstrap connected to 0 nodes close to us. #93

Closed seras42 closed 4 months ago

seras42 commented 5 months ago

Good day, sorry for disturbing this repo again.

It seems to me i have discovered another possible bug. I would like to confirm it with this repo. For some reason, if i fork nabu, it works well and connects to nodes, but if i try to use grade implementation i cannot connect to any sort of peers or nodes. Even tough i use the same code:

Log output:

Gradle implementation: implementation 'com.github.Peergos:nabu:latest.release' INFO: Bootstrap connected to 0 nodes close to us. Fork: v0.7.7 INFO: Bootstrap connected to 14 nodes close to us.

Same code:


     public void init(){
        RecordStore recordStore = new RamRecordStore();
        Blockstore blockStore = new RamBlockstore();

        int portNumber = 10000 + new Random().nextInt(50000);
        List<MultiAddress> swarmAddresses = List.of(new MultiAddress("/ip6/::/tcp/" + portNumber));
        List<MultiAddress> bootstrapNodes = new ArrayList<>(Config.defaultBootstrapNodes);

        HostBuilder builder = new HostBuilder().generateIdentity();
        PrivKey privKey = builder.getPrivateKey();
        PeerId peerId = builder.getPeerId();
        System.out.println("My PeerId:" + peerId.toBase58());
        IdentitySection identitySection = new IdentitySection(privKey.bytes(), peerId);
        BlockRequestAuthoriser authoriser = (c, p, a) -> CompletableFuture.completedFuture(true);

        EmbeddedIpfs embeddedIpfs = EmbeddedIpfs.build(recordStore, blockStore, false,
                swarmAddresses,
                bootstrapNodes,
                identitySection,
                authoriser, Optional.of(SeekerIFS.proxyHandler()));
        embeddedIpfs.start();
    }
ianopolous commented 5 months ago

Do subsequent lines also say "INFO: Bootstrap connected to 0 nodes close to us" or are they greater than 0?

seras42 commented 5 months ago

Yes, its always 0. Even if i use different code, just the Kademelia part. I can't seem to figure out why the gradle implementation doesn't work, but fork does.


May 08, 2024 12:21:22 PM org.peergos.EmbeddedIpfs start
INFO: Node started and listening on [/ip6/::/tcp/45320/p2p/=====================================]
May 08, 2024 12:21:22 PM org.peergos.EmbeddedIpfs start
INFO: Bootstrapping IPFS routing table
May 08, 2024 12:21:23 PM org.peergos.EmbeddedIpfs start
INFO: Bootstrapping IPFS kademlia
May 08, 2024 12:21:23 PM org.peergos.protocol.dht.Kademlia bootstrap
INFO: Bootstrap connected to 0 nodes close to us.
May 08, 2024 12:21:23 PM org.peergos.protocol.dht.Kademlia bootstrap
INFO: Bootstrap connected to 0 nodes close to us.```
ianopolous commented 5 months ago

I can reproduce this in nabu-chat. Not sure what's going on yet.

A work around in the meantime is likely to vendor a locally built nabu jar. That is what we do in Peergos.

ianopolous commented 5 months ago

Ok this should be fixed with v0.7.9. Can you try that?

seras42 commented 4 months ago

Confirmed it works. However i had to add this to the gradle or i would get an error, this was not asked before.

maven {url "https://artifacts.consensys.net/public/maven/maven/"} implementation 'tech.pegasys:noise-java:22.1.0'

If not would get this error:

   > Could not find tech.pegasys:noise-java:22.1.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/tech/pegasys/noise-java/22.1.0/noise-java-22.1.0.pom
       - https://dl.google.com/dl/android/maven2/tech/pegasys/noise-java/22.1.0/noise-java-22.1.0.pom
       - https://jitpack.io/tech/pegasys/noise-java/22.1.0/noise-java-22.1.0.pom
       - https://jcenter.bintray.com/tech/pegasys/noise-java/22.1.0/noise-java-22.1.0.pom
     Required by:
         project :