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

chore!: update packages #107

Merged
merged 9 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,248 changes: 1,969 additions & 1,279 deletions package-lock.json

Large diffs are not rendered by default.

56 changes: 29 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,24 @@
},
"homepage": "https://github.com/hldb/welo#readme",
"devDependencies": {
"@chainsafe/libp2p-gossipsub": "^8.0.0",
"@chainsafe/libp2p-noise": "^12.0.1",
"@chainsafe/libp2p-yamux": "^4.0.2",
"@helia/interface": "^1.1.1",
"@libp2p/bootstrap": "^8.0.0",
"@chainsafe/libp2p-gossipsub": "^10.1.0",
"@chainsafe/libp2p-noise": "^13.0.3",
"@chainsafe/libp2p-yamux": "^5.0.3",
"@helia/interface": "^2.1.0",
"@libp2p/bootstrap": "^9.0.12",
"@libp2p/interface": "^0.1.6",
"@libp2p/interface-keychain": "^2.0.5",
"@libp2p/interface-keys": "^1.0.8",
"@libp2p/interface-libp2p": "^3.2.0",
"@libp2p/interface-peer-id": "^2.0.2",
"@libp2p/interface-pubsub": "^4.0.1",
"@libp2p/kad-dht": "^9.3.6",
"@libp2p/mplex": "^8.0.4",
"@libp2p/tcp": "^7.0.1",
"@libp2p/webrtc": "^2.0.11",
"@libp2p/kad-dht": "^10.0.15",
"@libp2p/mplex": "^9.0.12",
"@libp2p/tcp": "^8.0.13",
"@libp2p/webrtc": "^3.2.11",
"@libp2p/webrtc-star": "^7.0.0",
"@libp2p/websockets": "^6.0.3",
"@multiformats/multiaddr": "^12.1.3",
"@libp2p/websockets": "^7.0.13",
"@multiformats/multiaddr": "^12.1.10",
"@types/mocha": "^10.0.0",
"aegir": "^38.1.5",
"blockstore-level": "^1.1.0",
Expand All @@ -100,7 +101,7 @@
"interface-datastore": "^8.2.0",
"ipns": "^6.0.0",
"level": "^8.0.0",
"libp2p": "^0.45.3",
"libp2p": "^0.46.21",
"make-dir": "^3.1.0",
"path-browserify": "^1.0.1",
"prettier": "^2.7.1",
Expand All @@ -112,28 +113,29 @@
},
"dependencies": {
"@alanshaw/pail": "^0.3.3",
"@ipld/car": "^5.1.1",
"@ipld/dag-cbor": "^9.0.1",
"@libp2p/crypto": "^1.0.17",
"@ipld/car": "^5.2.4",
"@ipld/dag-cbor": "^9.0.6",
"@libp2p/crypto": "^2.0.8",
"@libp2p/interfaces": "^3.3.2",
"@libp2p/peer-id": "^2.0.3",
"@libp2p/peer-id-factory": "^2.0.3",
"@libp2p/peer-id": "^3.0.6",
"@libp2p/peer-id-factory": "^3.0.8",
"@open-draft/deferred-promise": "^2.1.0",
"@tabcat/zzzync": "^2.0.0",
"datastore-core": "^9.1.1",
"@tabcat/zzzync": "^4.2.0",
"datastore-core": "^9.2.3",
"fission-bloom-filters": "^1.7.1",
"helia": "^1.1.2",
"interface-blockstore": "5.2",
"it-all": "^2.0.0",
"helia": "^2.1.0",
"interface-blockstore": "^5.2.6",
"it-all": "^3.0.4",
"it-concat": "^3.0.1",
"it-drain": "3.0",
"it-length-prefixed": "^9.0.1",
"it-pushable": "^3.2.1",
"it-drain": "^3.0.5",
"it-length-prefixed": "^9.0.3",
"it-pushable": "^3.2.3",
"multiformats": "^11.0.1",
"p-queue": "^7.3.0",
"protons-runtime": "^5.0.1",
"streaming-iterables": "^7.1.0",
"uint8arrays": "^4.0.3",
"remove": "^0.1.5",
"streaming-iterables": "^8.0.1",
"uint8arrays": "^4.0.6",
"w3name": "^1.0.8",
"web3.storage": "^4.5.4"
},
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Helia } from '@helia/interface'
import type { Libp2p, ServiceMap } from '@libp2p/interface-libp2p'
import type { Libp2p, ServiceMap } from '@libp2p/interface'
import type { PubSub } from '@libp2p/interface-pubsub'
import type { Datastore } from 'interface-datastore'
import type { KeyChain } from '@libp2p/interface-keychain'
Expand Down
8 changes: 4 additions & 4 deletions src/replicator/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { DbComponents } from '@/interface.js'
import type { Manifest } from '@/manifest/index.js'
import type { Replica } from '@/replica/index.js'
import type { AccessInstance } from '@/access/interface.js'
import type { Stream, Connection } from '@libp2p/interface-connection'
import type { Stream, Connection } from '@libp2p/interface/connection'
import type { PeerInfo } from '@libp2p/interface-peer-info'
import type { PeerId } from '@libp2p/interface-peer-id'

Expand Down Expand Up @@ -37,7 +37,7 @@ export class BootstrapReplicator extends Playable {
// Handle direct head requests.
await this.libp2p.handle(
this.protocol,
this.handle.bind(this) as (connectionInfo: { stream: Stream, connection: Connection }) => void
this.handle.bind(this) as (data: { stream: Stream, connection: Connection }) => void
)

// Bootstrap the heads
Expand Down Expand Up @@ -150,7 +150,7 @@ export class BootstrapReplicator extends Playable {
if (!reverseSync) {
await pipePromise
he.close()
stream.close()
await stream.close()
return
}

Expand All @@ -174,7 +174,7 @@ export class BootstrapReplicator extends Playable {
}

he.close()
stream.close()
await stream.close()
}
}

Expand Down
39 changes: 15 additions & 24 deletions src/replicator/zzzync/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Web3Storage } from 'web3.storage'
import type { Libp2p } from '@libp2p/interface'
import W3NameService from 'w3name/service'
import { zzzync, type Zzzync, toDcid } from '@tabcat/zzzync'
import { w3name as namer, revisionState, type RevisionState } from '@tabcat/zzzync/namers/w3name'
import { dht as advertiser, CreateEphemeralLibp2p, Libp2pWithDHT } from '@tabcat/zzzync/advertisers/dht'
import { w3Namer as namer, revisionState, type RevisionState } from '@tabcat/zzzync/namers/w3'
import { dhtAdvertiser as advertiser, CreateEphemeralKadDHT } from '@tabcat/zzzync/advertisers/dht'
import { CID } from 'multiformats/cid'
import { CarReader } from '@ipld/car/reader'
import { CarWriter } from '@ipld/car/writer'
Expand All @@ -20,14 +21,10 @@ import type { Blockstore } from 'interface-blockstore'
import { entries as pailEntries } from '@alanshaw/pail'
import { ShardBlockView, ShardFetcher, ShardLink } from '@alanshaw/pail/shard'
import { Datastore, Key } from 'interface-datastore'
// import { CodeError } from '@libp2p/interfaces/errors'
import type { AnyBlock, BlockFetcher } from '@alanshaw/pail/block'
import type { AnyLink } from '@alanshaw/pail/link'
import type { SignedEntry } from '@/entry/basal'
import type { EntryInstance } from '@/entry/interface'
// import { parsedcid } from '@/utils/index.js'
// import all from 'it-all'
import drain from 'it-drain'
import { decodeCbor, encodeCbor } from '@/utils/block.js'

const ipfsNamespace = '/ipfs/'
Expand Down Expand Up @@ -86,11 +83,12 @@ export class ZzzyncReplicator extends Playable {
this.#revisions = options.revisions ?? revisionState(datastore)
this.#lastAdvertised = 0

const libp2p = ipfs.libp2p as unknown as Libp2pWithDHT
const libp2p = ipfs.libp2p as unknown as Libp2p<Awaited<ReturnType<CreateEphemeralKadDHT>>>

this.#zync = zzzync(
namer(this.w3.name, this.#revisions),
advertiser(libp2p, options.createEphemeralLibp2p, { scope: options.scope })
advertiser(libp2p.services.dht, options.createEphemeralLibp2p),
ipfs.blockstore
)

this.#provider = null
Expand Down Expand Up @@ -166,7 +164,7 @@ export class ZzzyncReplicator extends Playable {

const now = Date.now()
if (now > (this.#lastAdvertised + republishInterval)) {
await drain(this.#zync.advertiser.collaborate(this.dcid, this.#provider))
await this.#zync.advertiser.collaborate(this.dcid, this.#provider)
this.#lastAdvertised = now
}
}
Expand All @@ -177,21 +175,14 @@ export class ZzzyncReplicator extends Playable {
}

const providers: Map<string, Ed25519PeerId> = new Map()
for await (const event of this.#zync.advertiser.findCollaborators(this.dcid)) {
if (
event.name === 'PROVIDER' ||
(event.name === 'PEER_RESPONSE' && event.messageName === 'GET_PROVIDERS')
) {
for (const provider of event.providers) {
if (provider.id.type !== 'Ed25519') {
continue
}
const peerIdString = provider.id.toString()
!providers.has(peerIdString) && providers.set(peerIdString, provider.id)
}
// findProviders hangs
break
for await (const provider of this.#zync.advertiser.findCollaborators(this.dcid)) {
if (provider.type !== 'Ed25519') {
continue
}
const peerIdString = provider.toString()
!providers.has(peerIdString) && providers.set(peerIdString, provider)
// findProviders hangs
break
}

const fetchEntry = async (cid: CID): Promise<EntryInstance<SignedEntry>> => {
Expand Down Expand Up @@ -285,7 +276,7 @@ interface W3 {
interface Options {
w3: W3
revisions?: RevisionState
createEphemeralLibp2p: CreateEphemeralLibp2p
createEphemeralLibp2p: CreateEphemeralKadDHT
scope?: 'lan' | 'wan'
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/heads-exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { consume } from 'streaming-iterables'
import { pushable, Pushable } from 'it-pushable'
import type { Uint8ArrayList } from 'uint8arraylist'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { Stream } from '@libp2p/interface-connection'
import type { Stream } from '@libp2p/interface/connection'

const uint8ArrayToBuffer = (a: Uint8Array): ArrayBuffer => a.buffer.slice(a.byteOffset, a.byteLength + a.byteOffset)

Expand Down Expand Up @@ -135,7 +135,7 @@ export class HeadsExchange {
}

async verify (): Promise<boolean> {
if (this.stream.stat.timeline.close != null) {
if (this.stream.timeline.close != null) {
throw new Error('stream is closed')
}

Expand All @@ -155,7 +155,7 @@ export class HeadsExchange {
}

async getHeads (seed?: number): Promise<CID[]> {
if (this.stream.stat.timeline.close != null) {
if (this.stream.timeline.close != null) {
throw new Error('stream is closed')
}

Expand Down
6 changes: 3 additions & 3 deletions test/test-zzzync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { getTestIdentities, getTestIdentity } from './utils/identities.js'
import { basalEntry } from '@/entry/basal/index.js'
import { basalIdentity } from '@/identity/basal/index.js'
import { Web3Storage } from 'web3.storage'
import type { CreateEphemeralKadDHT } from '@tabcat/zzzync/dist/src/advertisers/dht.js'
import type { Ed25519PeerId, PeerId } from '@libp2p/interface-peer-id'
import { createLibp2p, Libp2pOptions } from 'libp2p'
import { createLibp2pOptions } from './utils/libp2p-options.js'
import type { CreateEphemeralLibp2p } from '@tabcat/zzzync/dist/src/advertisers/dht.js'
import { CID } from 'multiformats'
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { isBrowser } from 'wherearewe'
Expand Down Expand Up @@ -145,10 +145,10 @@ _describe(testName, () => {
}

const client = new Web3Storage({ token })
const createEphemeralLibp2p = async (peerId: Ed25519PeerId): ReturnType<CreateEphemeralLibp2p> => {
const createEphemeralLibp2p: CreateEphemeralKadDHT = async (peerId: PeerId) => {
const libp2p = await createLibp2p(await createLibp2pOptions({ peerId }))

return { libp2p }
return libp2p.services
}
const replicator = zzzyncReplicator({ w3: { client }, createEphemeralLibp2p, scope: 'lan' })

Expand Down
8 changes: 4 additions & 4 deletions test/utils/libp2p-services.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

import { gossipsub, type GossipSub } from '@chainsafe/libp2p-gossipsub'
import { gossipsub } from '@chainsafe/libp2p-gossipsub'
import type { PubSub } from '@libp2p/interface-pubsub'
import { kadDHT, type DualKadDHT } from '@libp2p/kad-dht'
saul-jb marked this conversation as resolved.
Show resolved Hide resolved
import { identifyService } from 'libp2p/identify'
import { ipnsSelector } from 'ipns/selector'
import { ipnsValidator } from 'ipns/validator'
import type { ServiceMap } from '@libp2p/interface-libp2p'
import type { ServiceMap } from '@libp2p/interface'
import type { DefaultIdentifyService } from 'libp2p/identify/identify'

export interface Services extends ServiceMap {
identify: DefaultIdentifyService
pubsub: GossipSub
pubsub: PubSub
dht: DualKadDHT
}

Expand Down
2 changes: 1 addition & 1 deletion test/utils/libp2p.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Helia } from '@helia/interface'
import type { Libp2p, ServiceMap } from '@libp2p/interface-libp2p'
import type { Libp2p, ServiceMap } from '@libp2p/interface'

export const getTestLibp2p = async <T extends ServiceMap>(testIpfs: Helia<Libp2p<T>>): Promise<Libp2p<T>> => testIpfs.libp2p
Loading