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

feat: create separate enr package #267

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 10,
project: "./tsconfig.json"
project: "./tsconfig.json",
sourceType: "module"
},
plugins: [
"@typescript-eslint",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
release-type: node
package-name: release-please-action
bump-minor-pre-major: false
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'

- uses: actions/checkout@v3
Expand All @@ -62,7 +62,7 @@ jobs:
- run: yarn build
if: ${{ steps.release.outputs.release_created }}

- run: yarn publish
- run: yarn run publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
4 changes: 4 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"packages/discv5": "5.1.2",
"packages/enr": "1.0.0"
}
46 changes: 5 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,8 @@
# discv5
# discv5 monorepo

![ES Version](https://img.shields.io/badge/ES-2020-yellow)
![Node Version](https://img.shields.io/badge/node-18.x-green)
This monorepo contains code related to the typescript implementation of [discv5](https://github.com/ethereum/devp2p/blob/master/discv5/discv5.md)

A TypeScript implementation of the [DiscV5](https://github.com/ethereum/devp2p/blob/master/discv5/discv5.md) protocol
## Packages

## Libp2p compatibility

![Peer Discovery Compatible](https://github.com/libp2p/js-libp2p-interfaces/raw/master/src/peer-discovery/img/badge.png)

Included is a libp2p peer-discovery compatibility module.

#### Example

```typescript
import { Discv5Discovery, ENR } from "@chainsafe/discv5";
import Libp2p from "libp2p";
import PeerId from "peer-id";

const myPeerId: PeerId = ...;

const bootstrapEnrs: ENR[] = [...];

const libp2p = new Libp2p({
peerId: myPeerId,
modules: {
peerDiscovery: [Discv5Discovery],
},
config: {
discv5: {
enr: ENR.createFromPeerId(myPeerInfo.id),
bindAddr: "/ip4/0.0.0.0/udp/9000",
bootstrapEnrs: bootstrapEnrs,
searchInterval: 30000, // wait 30s between searches
},
},
});

```

## License

Apache-2.0
- [@chainsafe/enr](./packages/enr/README.md)
- [@chainsafe/discv5](./packages/discv5/README.md)
19 changes: 0 additions & 19 deletions bench/enr/index.bench.ts

This file was deleted.

16 changes: 0 additions & 16 deletions bench/keypair/index.bench.ts

This file was deleted.

5 changes: 5 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.0.0",
"npmClient": "yarn"
}
93 changes: 13 additions & 80 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,82 +1,29 @@
{
"name": "@chainsafe/discv5",
"version": "5.1.2",
"description": "Discovery V5",
"name": "discv5-monorepo",
"private": true,
"version": "0.0.0",
"description": "Discovery V5 monorepo",
"type": "module",
"files": [
"lib"
],
"exports": {
".": {
"import": "./lib/index.js"
},
"./enr": {
"import": "./lib/enr/index.js"
},
"./kademlia": {
"import": "./lib/kademlia/index.js"
},
"./keypair": {
"import": "./lib/keypair/index.js"
},
"./libp2p": {
"import": "./lib/libp2p/index.js"
},
"./packet": {
"import": "./lib/packet/index.js"
},
"./util": {
"import": "./lib/util/index.js"
}
},
"typesVersions": {
"*": {
"*": [
"*",
"lib/*",
"lib/*/index"
]
}
},
"types": "./lib/index.d.ts",
"workspaces": ["packages/*"],
"scripts": {
"check-types": "tsc --noEmit",
"build": "tsc -p tsconfig.build.json",
"check-types": "lerna run check-types",
"build": "lerna run build",
"lint": "lerna run lint",
"prepublishOnly": "yarn build",
"lint": "eslint --color --ext .ts src/ test/",
"test": "yarn test:unit && yarn test:e2e",
"test:unit": "mocha 'test/unit/**/*.test.ts'",
"test:e2e": "mocha 'test/e2e/**/*.test.ts'"
"publish": "lerna run publish",
"test": "lerna run test",
"test:unit": "lerna run test:unit",
"test:e2e": "lerna run test:e2e"
},
"pre-push": [
"lint"
],
"repository": {
"type": "git",
"url": "git+https://github.com/ChainSafe/discv5.git"
},
"keywords": [
"discovery",
"discv5",
"ethereum",
"p2p"
],
"leadMaintainer": "Cayman Nava <caymannava@gmail.com>",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/ChainSafe/discv5/issues"
},
"homepage": "https://github.com/ChainSafe/discv5#readme",
"devDependencies": {
"@chainsafe/eslint-plugin-node": "^11.2.3",
"@dapplion/benchmark": "^0.1.6",
"@libp2p/peer-id-factory": "^3.0.1",
"@types/bn.js": "^4.11.5",
"@types/chai": "^4.2.0",
"@types/debug": "^4.1.5",
"@types/eslint": "^6.1.3",
"@types/lru-cache": "^5.1.1",
"@types/mocha": "^8.0.3",
"@types/node": "^20.6.0",
"@typescript-eslint/eslint-plugin": "^5.27.1",
Expand All @@ -85,25 +32,11 @@
"eslint": "^8.17.0",
"eslint-plugin-prettier": "^4.0.0",
"karma": "^4.3.0",
"lerna": "^7.4.2",
"mocha": "^10.0.0",
"nyc": "^14.1.1",
"prettier": "^2.6.2",
"ts-node": "^10.8.1",
"typescript": "^4.7.3"
},
"dependencies": {
"@libp2p/crypto": "^2.0.0",
"@libp2p/interface": "^0.1.2",
"@libp2p/peer-id": "^3.0.1",
"@multiformats/multiaddr": "^12.1.3",
"base64url": "^3.0.1",
"bcrypto": "^5.4.0",
"bigint-buffer": "^1.1.5",
"debug": "^4.3.1",
"err-code": "^3.0.1",
"lru-cache": "^6.0.0",
"rlp": "^2.2.6",
"strict-event-emitter-types": "^2.0.0",
"uint8-varint": "^2.0.1"
}
}
5 changes: 5 additions & 0 deletions packages/discv5/.mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
colors: true
exit: true
extension: ["ts"]
node-option:
- loader=ts-node/esm
Loading
Loading