Skip to content

Commit

Permalink
Merge pull request #107 from saul-jb/fix/update-packages
Browse files Browse the repository at this point in the history
chore!: update packages
  • Loading branch information
tabcat authored Nov 22, 2023
2 parents a2e1feb + ad13a3a commit 0472efd
Show file tree
Hide file tree
Showing 26 changed files with 2,058 additions and 1,504 deletions.
3,361 changes: 1,962 additions & 1,399 deletions package-lock.json

Large diffs are not rendered by default.

61 changes: 29 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,19 @@
},
"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",
"@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",
"@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/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 +96,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 +108,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/identity/basal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { keys } from '@libp2p/crypto'
import * as Block from 'multiformats/block'
import * as codec from '@ipld/dag-cbor'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
import type { PrivateKey, PublicKey } from '@libp2p/interface-keys'
import type { PrivateKey, PublicKey } from '@libp2p/interface/keys'
import { Key } from 'interface-datastore'
import type { BlockView } from 'multiformats/interface'
import type { CID } from 'multiformats/cid'
Expand Down
2 changes: 1 addition & 1 deletion src/identity/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { KeyChain } from '@libp2p/interface-keychain'
import type { KeyChain } from '@libp2p/interface/keychain'
import type { BlockView } from 'multiformats/interface'
import type { CID } from 'multiformats/cid'
import type { Datastore } from 'interface-datastore'
Expand Down
8 changes: 4 additions & 4 deletions src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Helia } from '@helia/interface'
import type { Libp2p, ServiceMap } from '@libp2p/interface-libp2p'
import type { PubSub } from '@libp2p/interface-pubsub'
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'
import type { KeyChain } from '@libp2p/interface/keychain'

import type { AccessProtocol } from '@/access/static/protocol.js'
import type { EntryProtocol } from '@/entry/basal/protocol.js'
Expand All @@ -15,7 +15,7 @@ import type { EntryComponent } from '@/entry/interface.js'
import type { StoreInstance, StoreComponent } from '@/store/interface'
import type { Replica } from '@/replica/index.js'
import type { Replicator, ReplicatorModule } from '@/replicator/interface'
import type { Ed25519PeerId } from '@libp2p/interface-peer-id'
import type { Ed25519PeerId } from '@libp2p/interface/peer-id'
import type { Blockstore } from 'interface-blockstore'

export type GossipServiceMap = ServiceMap & { pubsub: PubSub }
Expand Down
4 changes: 2 additions & 2 deletions src/pubsub/direct.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events'
import type { GossipLibp2p } from '@/interface'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { PeerId } from '@libp2p/interface/peer-id'
import type {
Message,
PublishResult,
SubscriptionChangeData,
SignedMessage
} from '@libp2p/interface-pubsub'
} from '@libp2p/interface/pubsub'
import type { Startable } from '@libp2p/interfaces/startable'

import { peerIdString } from '@/utils/index.js'
Expand Down
4 changes: 2 additions & 2 deletions src/pubsub/monitor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events'
import type { GossipLibp2p } from '@/interface'
import type { SubscriptionChangeData } from '@libp2p/interface-pubsub'
import type { SubscriptionChangeData } from '@libp2p/interface/pubsub'
import type { Startable } from '@libp2p/interfaces/startable'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { PeerId } from '@libp2p/interface/peer-id'

import { parsedPeerId, peerIdString } from '@/utils/index.js'

Expand Down
4 changes: 2 additions & 2 deletions src/pubsub/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PubSub } from '@libp2p/interface-pubsub'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { PubSub } from '@libp2p/interface/pubsub'
import type { PeerId } from '@libp2p/interface/peer-id'

export const getPeers = (pubsub: PubSub, topic: string): PeerId[] =>
pubsub.getSubscribers(topic)
Expand Down
12 changes: 6 additions & 6 deletions src/replicator/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ 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 { PeerInfo } from '@libp2p/interface-peer-info'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { Stream, Connection } from '@libp2p/interface/connection'
import type { PeerInfo } from '@libp2p/interface/peer-info'
import type { PeerId } from '@libp2p/interface/peer-id'

export const protocol = `${prefix}he/1.0.0/` as const

Expand All @@ -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
2 changes: 1 addition & 1 deletion src/replicator/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HLDB_PREFIX } from '@/utils/constants.js'
import type { Playable } from '@/utils/playable.js'
import type { Datastore } from 'interface-datastore'
import type { Blockstore } from 'interface-blockstore'
import type { Ed25519PeerId } from '@libp2p/interface-peer-id'
import type { Ed25519PeerId } from '@libp2p/interface/peer-id'

export interface Config {
ipfs: GossipHelia
Expand Down
2 changes: 1 addition & 1 deletion src/replicator/live/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { start, stop } from '@libp2p/interfaces/startable'
import { base32 } from 'multiformats/bases/base32'
import type { GossipHelia } from '@/interface'
import type { CID } from 'multiformats/cid'
import type { SignedMessage, PublishResult } from '@libp2p/interface-pubsub'
import type { SignedMessage, PublishResult } from '@libp2p/interface/pubsub'

import { dagLinks, loadEntry, traverser } from '@/replica/traversal.js'
import { cidstring, parsedcid } from '@/utils/index.js'
Expand Down
2 changes: 1 addition & 1 deletion src/replicator/pubsub/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, ReplicaEvents } from '@/replica/index.js'
import type { AccessInstance } from '@/access/interface.js'
import type { Message, PubSub } from '@libp2p/interface-pubsub'
import type { Message, PubSub } from '@libp2p/interface/pubsub'

export const protocol = `${prefix}pubsub/1.0.0/` as const

Expand Down
41 changes: 16 additions & 25 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 @@ -14,20 +15,16 @@ import type { Replica } from '@/replica/index.js'

import protocol from './protocol.js'
import type { Config, ReplicatorModule } from '../interface.js'
import type { Ed25519PeerId } from '@libp2p/interface-peer-id'
import type { Ed25519PeerId } from '@libp2p/interface/peer-id'
import { Paily } from '@/utils/paily.js'
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
8 changes: 4 additions & 4 deletions src/utils/heads-exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import * as lp from 'it-length-prefixed'
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 { PeerId } from '@libp2p/interface/peer-id'
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
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CID } from 'multiformats/cid'
import { base32 } from 'multiformats/bases/base32'
import { peerIdFromString } from '@libp2p/peer-id'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { PeerId } from '@libp2p/interface/peer-id'

export const cidstring = (cid: CID | string): string => cid.toString(base32)
export const parsedcid = (string: string): CID => CID.parse(string, base32)
Expand Down
2 changes: 1 addition & 1 deletion src/welo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NamespaceDatastore } from 'datastore-core'
import { Key } from 'interface-datastore'
import type { Components, GossipHelia } from '@/interface'
import type { Datastore } from 'interface-datastore'
import type { KeyChain } from '@libp2p/interface-keychain'
import type { KeyChain } from '@libp2p/interface/keychain'

import { Manifest, Address } from '@/manifest/index.js'
import { Playable } from '@/utils/playable.js'
Expand Down
4 changes: 2 additions & 2 deletions test/test-direct.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from 'aegir/chai'
import { EventEmitter } from '@libp2p/interfaces/events'
import { stop } from '@libp2p/interfaces/startable'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { Message } from '@libp2p/interface-pubsub'
import type { PeerId } from '@libp2p/interface/peer-id'
import type { Message } from '@libp2p/interface/pubsub'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { GossipLibp2p, GossipHelia } from '@/interface'

Expand Down
2 changes: 1 addition & 1 deletion test/test-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Helia } from '@helia/interface'
import type { CID } from 'multiformats/cid'
import { base32 } from 'multiformats/bases/base32'
import type { LevelDatastore } from 'datastore-level'
import type { KeyChain } from '@libp2p/interface-keychain'
import type { KeyChain } from '@libp2p/interface/keychain'

import { Entry, basalEntry } from '@/entry/basal/index.js'
import type { EntryData } from '@/entry/interface.js'
Expand Down
Loading

0 comments on commit 0472efd

Please sign in to comment.