Skip to content

Commit

Permalink
Merge branch 'feat/send-message-limits' into 'dev'
Browse files Browse the repository at this point in the history
feat(rosenet-node): make `sendMessage` code more defensive

Closes #78

See merge request ergo/rosen-bridge/rosenet!38
  • Loading branch information
vorujack committed Sep 24, 2024
2 parents 8ceb3a6 + 34f5a83 commit de119a1
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 198 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-shirts-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/rosenet-node': minor
---

Limit the number of concurrent pending messages, while also applying different timeouts during message sending
117 changes: 7 additions & 110 deletions package-lock.json

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

14 changes: 6 additions & 8 deletions packages/rosenet-node/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ export const RELAY_DISCOVERY_RESTART_INTERVAL = 10_000;
export const ROSENET_DIRECT_PROTOCOL_V1 = '/rosenet/direct/1';
export const DEFAULT_NODE_PORT = 55123;
export const ACK_BYTE = 1;
/**
* Worst inter-continent ping RTT is around 250ms at the time of this commit,
* and an ack requires 1 RTT. We use 2 RTT as the timeout for an ack.
*/
export const ACK_TIMEOUT = 500;
export const MESSAGE_RETRY_ATTEMPTS = 3;
export const MESSAGE_RETRY_EXPONENT = 5;
export const MESSAGE_RETRY_INITIAL_DELAY = 5000;
export const MESSAGE_ROUNDTRIP_TIMEOUT = 1000;
export const MESSAGE_RETRY_ATTEMPTS = 5;
export const MESSAGE_RETRY_INITIAL_DELAY = 2000;
export const MAX_CONCURRENT_ROSENET_DIRECT_MESSAGES_ALLOWED = 1000;
export const MAX_CONCURRENT_ROSENET_DIRECT_MESSAGES_QUEUE_SIZE = 2000;
export const ROSENET_DIRECT_STREAM_CREATION_TIMEOUT = 500;
18 changes: 0 additions & 18 deletions packages/rosenet-node/lib/errors/RoseNetDirectAckError.ts

This file was deleted.

18 changes: 18 additions & 0 deletions packages/rosenet-node/lib/errors/RoseNetDirectError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import RoseNetNodeError from './RoseNetNodeError';

export enum RoseNetDirectErrorType {
Timeout = 'Timeout',
InvalidAckChunks = 'InvalidAckChunks',
InvalidAckByte = 'InvalidAckByte',
}

class RoseNetDirectError extends RoseNetNodeError {
constructor(
message: string,
public type: RoseNetDirectErrorType,
) {
super(message);
}
}

export default RoseNetDirectError;
3 changes: 3 additions & 0 deletions packages/rosenet-node/lib/errors/RoseNetNodeError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ class RoseNetNodeError extends Error {
constructor(
public message: string,
public stack = '',
cause?: unknown,
) {
super(message);

this.cause = cause;

if (stack) {
this.stack = stack;
} else {
Expand Down
Loading

0 comments on commit de119a1

Please sign in to comment.