trac-msb 0.2.16 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/.github/workflows/acceptance-tests.yml +38 -0
  2. package/.github/workflows/lint-pr-title.yml +26 -0
  3. package/.github/workflows/publish.yml +33 -0
  4. package/.github/workflows/unit-tests.yml +34 -0
  5. package/package.json +4 -9
  6. package/proto/network.proto +74 -0
  7. package/rpc/rpc_services.js +4 -22
  8. package/scripts/generate-protobufs.js +12 -37
  9. package/src/config/config.js +5 -26
  10. package/src/config/env.js +11 -25
  11. package/src/core/network/Network.js +36 -73
  12. package/src/core/network/protocols/LegacyProtocol.js +11 -21
  13. package/src/core/network/protocols/NetworkMessages.js +17 -38
  14. package/src/core/network/protocols/ProtocolInterface.js +2 -14
  15. package/src/core/network/protocols/ProtocolSession.js +17 -144
  16. package/src/core/network/protocols/V1Protocol.js +18 -37
  17. package/src/core/network/protocols/legacy/NetworkMessageRouter.js +19 -25
  18. package/src/core/network/protocols/legacy/handlers/{LegacyGetRequestHandler.js → GetRequestHandler.js} +6 -6
  19. package/src/core/network/protocols/legacy/handlers/ResponseHandler.js +37 -0
  20. package/src/core/network/protocols/{legacy/handlers/LegacyRoleOperationHandler.js → shared/handlers/RoleOperationHandler.js} +11 -18
  21. package/src/core/network/protocols/{legacy/handlers/LegacySubnetworkOperationHandler.js → shared/handlers/SubnetworkOperationHandler.js} +17 -28
  22. package/src/core/network/protocols/{legacy/handlers/LegacyTransferOperationHandler.js → shared/handlers/TransferOperationHandler.js} +11 -17
  23. package/src/core/network/protocols/{legacy/handlers/BaseStateOperationHandler.js → shared/handlers/base/BaseOperationHandler.js} +12 -23
  24. package/src/core/network/protocols/shared/validators/{PartialBootstrapDeploymentValidator.js → PartialBootstrapDeployment.js} +4 -9
  25. package/src/core/network/protocols/shared/validators/{PartialRoleAccessValidator.js → PartialRoleAccess.js} +17 -51
  26. package/src/core/network/protocols/shared/validators/{PartialTransactionValidator.js → PartialTransaction.js} +7 -21
  27. package/src/core/network/protocols/shared/validators/{PartialTransferValidator.js → PartialTransfer.js} +9 -26
  28. package/src/core/network/protocols/shared/validators/{PartialOperationValidator.js → base/PartialOperation.js} +25 -47
  29. package/src/core/network/protocols/v1/NetworkMessageRouter.js +7 -91
  30. package/src/core/network/services/ConnectionManager.js +94 -146
  31. package/src/core/network/services/MessageOrchestrator.js +27 -151
  32. package/src/core/network/services/TransactionPoolService.js +18 -129
  33. package/src/core/network/services/TransactionRateLimiterService.js +34 -52
  34. package/src/core/network/services/ValidatorObserverService.js +26 -18
  35. package/src/core/state/State.js +19 -70
  36. package/src/index.js +4 -5
  37. package/src/messages/network/v1/NetworkMessageBuilder.js +79 -59
  38. package/src/messages/network/v1/NetworkMessageDirector.js +50 -16
  39. package/src/utils/Scheduler.js +8 -0
  40. package/src/utils/constants.js +5 -71
  41. package/src/utils/helpers.js +1 -10
  42. package/src/utils/normalizers.js +0 -38
  43. package/src/utils/protobuf/network.cjs +840 -0
  44. package/src/utils/protobuf/operationHelpers.js +3 -24
  45. package/tests/acceptance/v1/account/account.test.mjs +2 -8
  46. package/tests/acceptance/v1/tx/tx.test.mjs +1 -23
  47. package/tests/acceptance/v1/tx-details/tx-details.test.mjs +6 -34
  48. package/tests/fixtures/networkV1.fixtures.js +28 -2
  49. package/tests/helpers/transactionPayloads.mjs +2 -2
  50. package/tests/unit/messages/network/NetworkMessageBuilder.test.js +79 -239
  51. package/tests/unit/messages/network/NetworkMessageDirector.test.js +77 -223
  52. package/tests/unit/network/ConnectionManager.test.js +191 -0
  53. package/tests/unit/network/networkModule.test.js +1 -4
  54. package/tests/unit/unit.test.js +2 -2
  55. package/tests/unit/utils/protobuf/operationHelpers.test.js +4 -2
  56. package/tests/unit/utils/utils.test.js +0 -1
  57. package/proto/network/v1/enums/message_type.proto +0 -16
  58. package/proto/network/v1/enums/result_code.proto +0 -84
  59. package/proto/network/v1/messages/broadcast_transaction_request.proto +0 -9
  60. package/proto/network/v1/messages/broadcast_transaction_response.proto +0 -13
  61. package/proto/network/v1/messages/liveness_request.proto +0 -8
  62. package/proto/network/v1/messages/liveness_response.proto +0 -11
  63. package/proto/network/v1/network_message.proto +0 -22
  64. package/src/core/network/protocols/connectionPolicies.js +0 -88
  65. package/src/core/network/protocols/legacy/handlers/LegacyResponseHandler.js +0 -23
  66. package/src/core/network/protocols/shared/errors/SharedValidatorRejectionError.js +0 -27
  67. package/src/core/network/protocols/v1/V1ProtocolError.js +0 -91
  68. package/src/core/network/protocols/v1/handlers/V1BaseOperationHandler.js +0 -65
  69. package/src/core/network/protocols/v1/handlers/V1BroadcastTransactionOperationHandler.js +0 -389
  70. package/src/core/network/protocols/v1/handlers/V1LivenessOperationHandler.js +0 -87
  71. package/src/core/network/protocols/v1/validators/V1BaseOperation.js +0 -211
  72. package/src/core/network/protocols/v1/validators/V1BroadcastTransactionRequest.js +0 -26
  73. package/src/core/network/protocols/v1/validators/V1BroadcastTransactionResponse.js +0 -276
  74. package/src/core/network/protocols/v1/validators/V1LivenessRequest.js +0 -15
  75. package/src/core/network/protocols/v1/validators/V1LivenessResponse.js +0 -17
  76. package/src/core/network/protocols/v1/validators/V1ValidationSchema.js +0 -210
  77. package/src/core/network/services/PendingRequestService.js +0 -172
  78. package/src/core/network/services/TransactionCommitService.js +0 -149
  79. package/src/core/network/services/ValidatorHealthCheckService.js +0 -127
  80. package/src/utils/deepEqualApplyPayload.js +0 -40
  81. package/src/utils/logger.js +0 -25
  82. package/src/utils/protobuf/networkV1.generated.cjs +0 -2460
  83. package/tests/unit/network/LegacyNetworkMessageRouter.test.js +0 -54
  84. package/tests/unit/network/ProtocolSession.test.js +0 -127
  85. package/tests/unit/network/services/ConnectionManager.test.js +0 -450
  86. package/tests/unit/network/services/MessageOrchestrator.test.js +0 -445
  87. package/tests/unit/network/services/PendingRequestService.test.js +0 -431
  88. package/tests/unit/network/services/TransactionCommitService.test.js +0 -246
  89. package/tests/unit/network/services/TransactionPoolService.test.js +0 -489
  90. package/tests/unit/network/services/TransactionRateLimiterService.test.js +0 -139
  91. package/tests/unit/network/services/ValidatorHealthCheckService.test.js +0 -115
  92. package/tests/unit/network/services/services.test.js +0 -17
  93. package/tests/unit/network/utils/v1TestUtils.js +0 -153
  94. package/tests/unit/network/v1/NetworkMessageRouterV1.test.js +0 -151
  95. package/tests/unit/network/v1/V1BaseOperation.test.js +0 -356
  96. package/tests/unit/network/v1/V1BroadcastTransactionOperationHandler.test.js +0 -129
  97. package/tests/unit/network/v1/V1BroadcastTransactionRequest.test.js +0 -53
  98. package/tests/unit/network/v1/V1BroadcastTransactionResponse.test.js +0 -512
  99. package/tests/unit/network/v1/V1LivenessRequest.test.js +0 -32
  100. package/tests/unit/network/v1/V1LivenessResponse.test.js +0 -45
  101. package/tests/unit/network/v1/V1ResultCode.test.js +0 -84
  102. package/tests/unit/network/v1/V1ValidationSchema.test.js +0 -13
  103. package/tests/unit/network/v1/connectionPolicies.test.js +0 -49
  104. package/tests/unit/network/v1/handlers/V1BaseOperationHandler.test.js +0 -284
  105. package/tests/unit/network/v1/handlers/V1BroadcastTransactionOperationHandler.test.js +0 -794
  106. package/tests/unit/network/v1/handlers/V1LivenessOperationHandler.test.js +0 -193
  107. package/tests/unit/network/v1/v1.handlers.test.js +0 -15
  108. package/tests/unit/network/v1/v1.test.js +0 -19
  109. package/tests/unit/network/v1/v1ValidationSchema/broadcastTransactionRequest.test.js +0 -119
  110. package/tests/unit/network/v1/v1ValidationSchema/broadcastTransactionResponse.test.js +0 -136
  111. package/tests/unit/network/v1/v1ValidationSchema/common.test.js +0 -308
  112. package/tests/unit/network/v1/v1ValidationSchema/livenessRequest.test.js +0 -90
  113. package/tests/unit/network/v1/v1ValidationSchema/livenessResponse.test.js +0 -133
  114. package/tests/unit/utils/deepEqualApplyPayload/deepEqualApplyPayload.test.js +0 -102
@@ -0,0 +1,38 @@
1
+ name: MSB-Acceptance-Tests
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_run:
6
+ workflows: ["MSB-Unit-Tests"]
7
+ types:
8
+ - completed
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ integration-tests:
16
+ name: Acceptance Tests
17
+ runs-on: [self-hosted, Linux, X64]
18
+ if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
19
+ strategy:
20
+ matrix:
21
+ node-version: [ lts/* ]
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - name: Use Node.js ${{ matrix.node-version }}
27
+ uses: actions/setup-node@v3
28
+ with:
29
+ node-version: ${{ matrix.node-version }}
30
+
31
+ - name: Install dependencies
32
+ run: npm ci
33
+
34
+ - name: Install bare
35
+ run: npm i -g bare
36
+
37
+ - name: Run Integration Tests
38
+ run: npm run test:acceptance
@@ -0,0 +1,26 @@
1
+ name: Lint PR title
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [opened, reopened, edited, synchronize]
6
+
7
+ jobs:
8
+ main:
9
+ name: Validate PR title convention
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ pull-requests: read
13
+ steps:
14
+ - uses: amannn/action-semantic-pull-request@v6.1.1
15
+ env:
16
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17
+ with:
18
+ # Allow optional scopes like feat(ui): ...
19
+ # By default scopes are allowed (no restriction) and are optional.
20
+ requireScope: false
21
+
22
+ # Optional: require a non-empty subject after ": "
23
+ subjectPattern: ^.+$
24
+ subjectPatternError: |
25
+ The pull request title must have a non-empty subject after ": ".
26
+ Example: "feat: add new command"
@@ -0,0 +1,33 @@
1
+ name: Publish trac-msb to npm on release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write # Required for OIDC
9
+ contents: read
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout release tag
16
+ uses: actions/checkout@v4
17
+ with:
18
+ ref: ${{ github.event.release.tag_name }}
19
+
20
+ - name: Use Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: '24'
24
+ registry-url: 'https://registry.npmjs.org'
25
+ - name: Install dependencies
26
+ run: npm ci
27
+
28
+ # unit tests are temporarily disabled because they lost stability on GH runners.
29
+ #- name: Run unit tests
30
+ # run: npm run test:unit:all
31
+
32
+ - name: Publish to npm
33
+ run: npm publish --access public
@@ -0,0 +1,34 @@
1
+ name: MSB-Unit-Tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+ workflow_dispatch:
11
+
12
+ concurrency:
13
+ group: ${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ tests:
18
+ runs-on: [self-hosted, Linux, X64]
19
+
20
+ strategy:
21
+ matrix:
22
+ node-version: [lts/*]
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - name: Use Node.js ${{ matrix.node-version }}
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: ${{ matrix.node-version }}
29
+ - name: Install dependencies
30
+ run: npm ci
31
+ - name: Install bare
32
+ run: npm i -g bare
33
+ - name: Run all tests
34
+ run: npm run test:unit:all
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "msb.mjs",
4
- "version": "0.2.16",
4
+ "version": "0.2.17",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
@@ -18,9 +18,9 @@
18
18
  "test:integration": "brittle-node -t 1200000 tests/integration/integration.test.js",
19
19
  "test:unit:node": "brittle-node -t 60000 tests/unit/unit.test.js",
20
20
  "test:unit:bare": "brittle-bare -t 60000 tests/unit/unit.test.js",
21
- "test:unit:pear": "BRITTLE='-t 60000' brittle-pear tests/unit/unit.test.js",
22
21
  "test:unit:all": "(npm run test:unit:node && npm run test:unit:bare) || exit 1",
23
- "test:unit:node:cov": "brittle-node -c -t 60000 tests/unit/unit.test.js"
22
+ "test:unit:node:cov": "brittle-node -c -t 60000 tests/unit/unit.test.js",
23
+ "test:unit:bare:cov": "brittle-bare -c -t 60000 tests/unit/unit.test.js"
24
24
  },
25
25
  "dependencies": {
26
26
  "autobase": "7.20.1",
@@ -35,7 +35,6 @@
35
35
  "compact-encoding": "2.18.0",
36
36
  "corestore": "7.5.0",
37
37
  "crypto": "npm:bare-node-crypto",
38
- "denque": "^2.1.0",
39
38
  "fastest-validator": "1.19.0",
40
39
  "http": "npm:bare-node-http",
41
40
  "hyperbee": "2.26.5",
@@ -44,8 +43,6 @@
44
43
  "hyperdht": "6.27.0",
45
44
  "hyperswarm": "4.14.2",
46
45
  "lodash": "^4.17.23",
47
- "p-queue": "^9.1.0",
48
- "protobufjs": "^7.5.4",
49
46
  "protocol-buffers-encodings": "1.2.0",
50
47
  "protomux": "3.10.1",
51
48
  "protomux-wakeup": "2.4.0",
@@ -57,13 +54,11 @@
57
54
  "uuid": "^13.0.0"
58
55
  },
59
56
  "devDependencies": {
60
- "bare-module": "^6.1.3",
61
57
  "bare-os": "^3.6.1",
62
58
  "bip39-mnemonic": "^2.4.0",
63
- "brittle": "^3.19.1",
59
+ "brittle": "^3.17.1",
64
60
  "esmock": "^2.7.2",
65
61
  "jest": "^30.1.3",
66
- "protobufjs-cli": "^1.2.0",
67
62
  "protocol-buffers": "^4.2.0",
68
63
  "sinon": "^21.0.0",
69
64
  "supertest": "^7.1.4"
@@ -0,0 +1,74 @@
1
+ syntax = "proto3";
2
+
3
+ package network.v1;
4
+
5
+ enum MessageType {
6
+ MESSAGE_TYPE_UNSPECIFIED = 0;
7
+ MESSAGE_TYPE_VALIDATOR_CONNECTION_REQUEST = 1;
8
+ MESSAGE_TYPE_VALIDATOR_CONNECTION_RESPONSE = 2;
9
+ MESSAGE_TYPE_LIVENESS_REQUEST = 3;
10
+ MESSAGE_TYPE_LIVENESS_RESPONSE = 4;
11
+ MESSAGE_TYPE_BROADCAST_TRANSACTION_REQUEST = 5;
12
+ MESSAGE_TYPE_BROADCAST_TRANSACTION_RESPONSE = 6;
13
+ }
14
+
15
+ enum ResultCode {
16
+ RESULT_CODE_UNSPECIFIED = 0;
17
+ RESULT_CODE_OK = 1;
18
+ RESULT_CODE_INVALID_PAYLOAD = 2;
19
+ RESULT_CODE_UNSUPPORTED_VERSION = 3;
20
+ RESULT_CODE_RATE_LIMITED = 4;
21
+ RESULT_CODE_TIMEOUT = 5;
22
+ RESULT_CODE_SIGNATURE_INVALID = 6;
23
+ }
24
+
25
+ message ValidatorConnectionRequest {
26
+ string issuer_address = 1;
27
+ bytes nonce = 2;
28
+ bytes signature = 3;
29
+ }
30
+
31
+ message ValidatorConnectionResponse {
32
+ string issuer_address = 1;
33
+ bytes nonce = 2;
34
+ bytes signature = 3;
35
+ ResultCode result = 4;
36
+ }
37
+
38
+ message LivenessRequest {
39
+ bytes nonce = 1;
40
+ bytes signature = 2;
41
+ }
42
+
43
+ message LivenessResponse {
44
+ bytes nonce = 1;
45
+ bytes signature = 2;
46
+ ResultCode result = 3;
47
+ }
48
+
49
+ message BroadcastTransactionRequest {
50
+ bytes data = 1; // binary encoded payload
51
+ bytes nonce = 2;
52
+ bytes signature = 3;
53
+ }
54
+
55
+ message BroadcastTransactionResponse {
56
+ bytes nonce = 1;
57
+ bytes signature = 2;
58
+ ResultCode result = 3;
59
+ }
60
+
61
+ message MessageHeader {
62
+ MessageType type = 1;
63
+ string id = 2;
64
+ uint64 timestamp = 3;
65
+ oneof field {
66
+ ValidatorConnectionRequest validator_connection_request = 4;
67
+ ValidatorConnectionResponse validator_connection_response = 5;
68
+ LivenessRequest liveness_request = 6;
69
+ LivenessResponse liveness_response = 7;
70
+ BroadcastTransactionRequest broadcast_transaction_request = 8;
71
+ BroadcastTransactionResponse broadcast_transaction_response = 9;
72
+ }
73
+ repeated string capabilities = 10;
74
+ }
@@ -6,23 +6,10 @@ import {
6
6
  } from "../src/utils/normalizers.js";
7
7
  import { get_confirmed_tx_info, get_unconfirmed_tx_info } from "../src/utils/cli.js";
8
8
  import { OperationType } from "../src/utils/constants.js";
9
- import { sleep } from "../src/utils/helpers.js";
10
9
  import b4a from "b4a";
10
+ import PartialTransaction from "../src/core/network/protocols/shared/validators/PartialTransaction.js";
11
+ import PartialTransfer from "../src/core/network/protocols/shared/validators/PartialTransfer.js";
11
12
  import { ValidationError, BroadcastError, NotFoundError } from "./utils/helpers.js";
12
- import PartialTransactionValidator from "../src/core/network/protocols/shared/validators/PartialTransactionValidator.js";
13
- import PartialTransferValidator from "../src/core/network/protocols/shared/validators/PartialTransferValidator.js";
14
-
15
- // This was added because V1 is not waiting for signed/unsigned state. So to include reverse compatibility
16
- // we need to slow down v1 to legacy case.
17
- const waitForUnconfirmedTx = async (state, txHash, config) => {
18
- const startedAt = Date.now();
19
- while ((Date.now() - startedAt) < config.messageValidatorResponseTimeout) {
20
- const payload = await state.get(txHash);
21
- if (payload) return true;
22
- await sleep(100);
23
- }
24
- return false;
25
- };
26
13
 
27
14
  export async function getBalance(msbInstance, address, confirmed) {
28
15
  const state = msbInstance.state;
@@ -67,8 +54,8 @@ export async function broadcastTransaction(msbInstance, config, payload) {
67
54
  let isValid = false;
68
55
  let hash;
69
56
 
70
- const partialTransferValidator = new PartialTransferValidator(msbInstance.state, null , config);
71
- const partialTransactionValidator = new PartialTransactionValidator(msbInstance.state, null , config);
57
+ const partialTransferValidator = new PartialTransfer(msbInstance.state, null, config);
58
+ const partialTransactionValidator = new PartialTransaction(msbInstance.state, null, config);
72
59
 
73
60
  if (payload.type === OperationType.TRANSFER) {
74
61
  normalizedPayload = normalizeTransferOperation(payload, config);
@@ -90,11 +77,6 @@ export async function broadcastTransaction(msbInstance, config, payload) {
90
77
  throw new BroadcastError("Failed to broadcast transaction after multiple attempts.");
91
78
  }
92
79
 
93
- const isConfirmed = await waitForUnconfirmedTx(msbInstance.state, hash, config);
94
- if (!isConfirmed) {
95
- throw new BroadcastError("Failed to broadcast transaction after multiple attempts.");
96
- }
97
-
98
80
  const signedLength = msbInstance.state.getSignedLength();
99
81
  const unsignedLength = msbInstance.state.getUnsignedLength();
100
82
 
@@ -2,10 +2,10 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
4
  import { fileURLToPath } from 'url';
5
- import { execFileSync } from 'child_process';
5
+ import { execSync } from 'child_process';
6
6
 
7
7
  function generateCJSFromProto(inputPath, outputPath) {
8
- execFileSync('protocol-buffers', [inputPath, '-o', outputPath]);
8
+ execSync(`protocol-buffers "${inputPath}" -o "${outputPath}"`);
9
9
  console.log(`${outputPath} has been generated.`);
10
10
  }
11
11
 
@@ -17,51 +17,26 @@ function transformToUseB4a(outputPath) {
17
17
  console.log(`${outputPath} has been modified to use b4a.`);
18
18
  }
19
19
 
20
- function generatePbjsModule(pbjsPath, protoRootPath, entryPath, outputPath) {
21
- execFileSync(pbjsPath, [
22
- '-t', 'static-module',
23
- '-w', 'commonjs',
24
- '--keep-case',
25
- '-p', protoRootPath,
26
- '-o', outputPath,
27
- entryPath
28
- ]);
29
- console.log(`${outputPath} has been generated.`);
30
- }
31
-
32
- function transformPbjsForBare(outputPath) {
33
- let content = fs.readFileSync(outputPath, 'utf-8');
34
- const shim = `if (typeof globalThis !== 'undefined' && typeof globalThis.self === 'undefined') {\n globalThis.self = globalThis;\n}\n`;
35
- const strictDirective = '"use strict";';
36
-
37
- if (content.includes(strictDirective)) {
38
- content = content.replace(strictDirective, `${strictDirective}\n${shim}`);
39
- } else {
40
- content = `${strictDirective}\n${shim}${content}`;
41
- }
42
-
43
- fs.writeFileSync(outputPath, content, 'utf-8');
44
- console.log(`${outputPath} has been modified for bare-compatible protobufjs runtime.`);
45
- }
46
20
 
47
21
  function main() {
48
22
  const directoryName = path.dirname(fileURLToPath(import.meta.url));
49
23
 
50
24
  const inputDir = path.join(directoryName, '../proto');
51
25
  const outputDir = path.join(directoryName, '../src/utils/protobuf');
52
- const pbjsPath = path.join(directoryName, '../node_modules/.bin/pbjs');
53
- const applyInputPath = path.join(inputDir, 'applyOperations.proto');
54
- const applyOutputPath = path.join(outputDir, 'applyOperations.cjs');
55
- const networkEntryPath = path.join(inputDir, 'network/v1/network_message.proto');
56
- const generatedNetworkOutputPath = path.join(outputDir, 'networkV1.generated.cjs');
57
26
 
58
27
  fs.mkdirSync(outputDir, { recursive: true });
59
28
 
60
- generateCJSFromProto(applyInputPath, applyOutputPath);
61
- transformToUseB4a(applyOutputPath);
29
+ const files = fs.readdirSync(inputDir).filter(f => f.endsWith('.proto'));
62
30
 
63
- generatePbjsModule(pbjsPath, inputDir, networkEntryPath, generatedNetworkOutputPath);
64
- transformPbjsForBare(generatedNetworkOutputPath);
31
+ for (const file of files) {
32
+ const name = path.basename(file, '.proto');
33
+ const inputPath = path.join(inputDir, file);
34
+ const outputPath = path.join(outputDir, `${name}.cjs`);
35
+
36
+ generateCJSFromProto(inputPath, outputPath);
37
+ transformToUseB4a(outputPath);
38
+ }
65
39
  }
66
40
 
67
41
  main();
42
+
@@ -133,6 +133,11 @@ export class Config {
133
133
  return this.#config.processIntervalMs
134
134
  }
135
135
 
136
+ get maxPartialTxPayloadByteSize() {
137
+ if (this.#isOverriden('maxPartialTxPayloadByteSize')) return this.#options.maxPartialTxPayloadByteSize
138
+ return this.#config.maxPartialTxPayloadByteSize
139
+ }
140
+
136
141
  get transactionPoolSize() {
137
142
  if (this.#isOverriden('transactionPoolSize')) return this.#options.transactionPoolSize
138
143
  return this.#config.transactionPoolSize
@@ -193,31 +198,6 @@ export class Config {
193
198
  if (this.#isOverriden('rateLimitMaxTransactionsPerSecond')) return this.#options.rateLimitMaxTransactionsPerSecond
194
199
  return this.#config.rateLimitMaxTransactionsPerSecond
195
200
  }
196
-
197
- get pendingRequestTimeout() {
198
- return this.#config.pendingRequestTimeout
199
- }
200
-
201
- get txCommitTimeout() {
202
- return this.#config.txCommitTimeout
203
- }
204
-
205
- get txPoolSize() {
206
- return this.#config.txPoolSize
207
- }
208
-
209
- get validatorHealthCheckInterval() {
210
- if (this.#isOverriden('validatorHealthCheckInterval')) return this.#options.validatorHealthCheckInterval
211
- return this.#config.validatorHealthCheckInterval
212
- }
213
-
214
- get maxPendingRequestsInPendingRequestsService() {
215
- return this.#config.maxPendingRequestsInPendingRequestsService
216
- }
217
-
218
- get debug() {
219
- return this.#config.debug
220
- }
221
201
 
222
202
  // Most of these properties are boolean
223
203
  #isOverriden(prop) {
@@ -231,5 +211,4 @@ export class Config {
231
211
  );
232
212
  }
233
213
  }
234
-
235
214
  }
package/src/config/env.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { TRAC_NETWORK_MSB_MAINNET_PREFIX, TRAC_NETWORK_MSB_TESTNET1_PREFIX } from 'trac-wallet/constants.js';
2
+ import { Config } from './config.js';
2
3
  import { TRAC_NETWORK_TESTNET_ID, TRAC_NETWORK_MAINNET_ID } from 'trac-crypto-api/constants.js';
3
4
  import { address } from 'trac-crypto-api';
4
- import { Config } from './config.js';
5
5
 
6
6
  export const ENV = {
7
7
  MAINNET: 'mainnet',
8
8
  DEVELOPMENT: 'development',
9
9
  TESTNET1: 'testnet1'
10
10
  }
11
+ // TODO: CREATE TEST ENV CONFIG SIMILAR TO MAINNET AND USE IT IN TESTS.
11
12
 
12
13
  const configData = {
13
14
  [ENV.TESTNET1]: {
14
- debug: false,
15
15
  addressLength: 67,
16
16
  addressPrefix: TRAC_NETWORK_MSB_TESTNET1_PREFIX,
17
17
  addressPrefixLength: TRAC_NETWORK_MSB_TESTNET1_PREFIX.length,
@@ -27,9 +27,9 @@ const configData = {
27
27
  enableTxApplyLogs: true,
28
28
  enableValidatorObserver: true,
29
29
  enableWallet: true,
30
- maxValidators: 50,
31
- maxRetries: 3,
32
- messageThreshold: 3,
30
+ maxValidators: 6,
31
+ maxRetries: 1,
32
+ messageThreshold: 1000,
33
33
  messageValidatorRetryDelay: 1000, //How long to wait before retrying (ms) MESSAGE_VALIDATOR_RETRY_DELAY_MS
34
34
  messageValidatorResponseTimeout: 3 * 3 * 1000, //Overall timeout for sending a message (ms). This is 3 * maxRetries * messageValidatorRetryDelay;
35
35
  host: 'localhost',
@@ -41,20 +41,15 @@ const configData = {
41
41
  maxClientConnections: Infinity, // Connectivity constants
42
42
  maxWritersForAdminIndexerConnection: 10, // Connectivity constants
43
43
  processIntervalMs: 50, // Pool constants
44
+ maxPartialTxPayloadByteSize: 3072, // Operation handler constants
44
45
  transactionPoolSize: 1000, // Operation handler constants
45
46
  rateLimitCleanupIntervalMs: 120_000, // Rate limiting constants
46
47
  rateLimitConnectionTimeoutMs: 60_000, // Rate limiting constants
47
48
  rateLimitMaxTransactionsPerSecond: 50, // Rate limiting constants
48
- maxPendingRequestsInPendingRequestsService: 50_000, // Maximum number of pending requests in PendingRequestService (This value should not exceed 256MB)
49
- pendingRequestTimeout: 3000, // constant after which time the transaction will be considered invalid
50
- txCommitTimeout: 2200,
51
- txPoolSize: 1000, // size of transaction pool
52
- validatorHealthCheckInterval: 5 * 60 * 1000, // How often to check validator health (ms)
53
- storesDirectory: 'stores/',
49
+ storesDirectory : 'stores/',
54
50
  storeName: 'testnet',
55
51
  },
56
52
  [ENV.MAINNET]: {
57
- debug: false,
58
53
  addressLength: 63,
59
54
  addressPrefix: TRAC_NETWORK_MSB_MAINNET_PREFIX,
60
55
  addressPrefixLength: TRAC_NETWORK_MSB_MAINNET_PREFIX.length,
@@ -84,20 +79,15 @@ const configData = {
84
79
  maxClientConnections: Infinity, // Connectivity constants
85
80
  maxWritersForAdminIndexerConnection: 10, // Connectivity constants
86
81
  processIntervalMs: 50, // Pool constants
82
+ maxPartialTxPayloadByteSize: 3072, // Operation handler constants
87
83
  transactionPoolSize: 1000, // Operation handler constants
88
84
  rateLimitCleanupIntervalMs: 120_000, // Rate limiting constants
89
85
  rateLimitConnectionTimeoutMs: 60_000, // Rate limiting constants
90
86
  rateLimitMaxTransactionsPerSecond: 50, // Rate limiting constants
91
- maxPendingRequestsInPendingRequestsService: 50_000, // Maximum number of pending requests in PendingRequestService (This value should not exceed 256MB)
92
- pendingRequestTimeout: 3000, // constant after which time the transaction will be considered invalid
93
- txCommitTimeout: 2200,
94
- txPoolSize: 1000, // size of transaction pool
95
- validatorHealthCheckInterval: 5 * 60 * 1000, // How often to check validator health (ms)
96
87
  storesDirectory: 'stores/',
97
88
  storeName: 'mainnet',
98
89
  },
99
90
  [ENV.DEVELOPMENT]: {
100
- debug: true,
101
91
  addressLength: 63,
102
92
  addressPrefix: TRAC_NETWORK_MSB_MAINNET_PREFIX,
103
93
  addressPrefixLength: TRAC_NETWORK_MSB_MAINNET_PREFIX.length,
@@ -114,7 +104,7 @@ const configData = {
114
104
  enableValidatorObserver: true,
115
105
  enableWallet: true,
116
106
  maxValidators: 6,
117
- maxRetries: 3,
107
+ maxRetries: 0,
118
108
  messageThreshold: 1000,
119
109
  messageValidatorRetryDelay: 1000, //How long to wait before retrying (ms) MESSAGE_VALIDATOR_RETRY_DELAY_MS
120
110
  messageValidatorResponseTimeout: 3 * 3 * 1000, //Overall timeout for sending a message (ms). This is 3 * maxRetries * messageValidatorRetryDelay;
@@ -127,16 +117,12 @@ const configData = {
127
117
  maxClientConnections: Infinity, // Connectivity constants
128
118
  maxWritersForAdminIndexerConnection: 10, // Connectivity constants
129
119
  processIntervalMs: 50, // Pool constants
120
+ maxPartialTxPayloadByteSize: 3072, // Operation handler constants
130
121
  transactionPoolSize: 1000, // Operation handler constants
131
122
  rateLimitCleanupIntervalMs: 120_000, // Rate limiting constants
132
123
  rateLimitConnectionTimeoutMs: 60_000, // Rate limiting constants
133
124
  rateLimitMaxTransactionsPerSecond: 50, // Rate limiting constants
134
- maxPendingRequestsInPendingRequestsService: 50_000, // Maximum number of pending requests in PendingRequestService (This value should not exceed 256MB)
135
- pendingRequestTimeout: 3000, // constant after which time the transaction will be considered invalid
136
- txCommitTimeout: 2200,
137
- txPoolSize: 1000, // size of transaction pool
138
- validatorHealthCheckInterval: 5 * 60 * 1000, // How often to check validator health (ms)
139
- storesDirectory: 'stores/',
125
+ storesDirectory : 'stores/',
140
126
  storeName: 'development',
141
127
  }
142
128
  }