Skip to content

Commit

Permalink
Merge branch 'feat/hole-punching' into 'dev'
Browse files Browse the repository at this point in the history
feat: DCUtR (hole punching protocol)

Closes #75

See merge request ergo/rosen-bridge/rosenet!35
  • Loading branch information
vorujack committed Sep 13, 2024
2 parents 9ba8cd6 + a2b827e commit eee9978
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/modern-donuts-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rosen-bridge/rosenet-relay': minor
'@rosen-bridge/rosenet-node': minor
---

Enable DCUtR service
36 changes: 29 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/rosenet-node/lib/createRoseNetNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { noise } from '@chainsafe/libp2p-noise';
import { yamux } from '@chainsafe/libp2p-yamux';
import { bootstrap } from '@libp2p/bootstrap';
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2';
import { dcutr } from '@libp2p/dcutr';
import { identify } from '@libp2p/identify';
import { PeerId } from '@libp2p/interface';
import { pubsubPeerDiscovery } from '@libp2p/pubsub-peer-discovery';
Expand Down Expand Up @@ -129,6 +130,7 @@ const createRoseNetNode = async ({
*/
maxInboundDataLength: 170_000_000, // 170MB
}),
dcutr: dcutr(),
restartRelayDiscovery,
},
logger: libp2pLoggerFactory(logger, config.debug?.libp2pComponents ?? []),
Expand Down
1 change: 1 addition & 0 deletions packages/rosenet-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@chainsafe/libp2p-yamux": "^6.0.2",
"@libp2p/bootstrap": "^10.1.5",
"@libp2p/circuit-relay-v2": "^1.1.5",
"@libp2p/dcutr": "^1.1.5",
"@libp2p/identify": "^2.1.5",
"@libp2p/interface": "^1.7.0",
"@libp2p/interface-internal": "^1.3.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/rosenet-relay/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const DEFAULT_LISTEN_HOST = '0.0.0.0';
export const RESERVATION_DATA_LIMIT = 1_000_000_000n; // 1GB
export const RESERVATION_DURATION_LIMIT = 60 * 60_000; // 1 hour
15 changes: 11 additions & 4 deletions packages/rosenet-relay/lib/createRoseNetRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {

import { RoseNetRelayError } from './errors';

import { DEFAULT_LISTEN_HOST } from './constants';
import {
DEFAULT_LISTEN_HOST,
RESERVATION_DATA_LIMIT,
RESERVATION_DURATION_LIMIT,
} from './constants';

import packageJson from '../package.json' with { type: 'json' };

Expand Down Expand Up @@ -74,9 +78,12 @@ const createRoseNetRelay = async ({
circuitRelay: circuitRelayServer({
reservations: {
maxReservations: config.maxReservations,
defaultDurationLimit: 0,
defaultDataLimit: 0n,
applyDefaultLimit: false,
/**
* Ideally we want the connection to upgrade through DCUtR, but for
* edge cases we keep these limits a reasonably large number
*/
defaultDurationLimit: RESERVATION_DURATION_LIMIT,
defaultDataLimit: RESERVATION_DATA_LIMIT,
},
}),
pubsub: gossipsub({
Expand Down

0 comments on commit eee9978

Please sign in to comment.