trac-msb 0.2.8 → 0.2.10
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.
- package/.github/workflows/acceptance-tests.yml +7 -11
- package/.github/workflows/lint-pr-title.yml +26 -0
- package/.github/workflows/unit-tests.yml +2 -8
- package/CODE_OF_CONDUCT.md +128 -0
- package/README.md +33 -18
- package/docker-compose.yml +1 -0
- package/docs/trac_network_http_api.openapi.yaml +889 -0
- package/msb.mjs +5 -22
- package/package.json +14 -10
- package/proto/network.proto +74 -0
- package/rpc/create_server.js +2 -2
- package/rpc/handlers.js +165 -92
- package/rpc/routes/v1.js +3 -1
- package/rpc/rpc_server.js +4 -4
- package/rpc/rpc_services.js +62 -25
- package/rpc/utils/helpers.js +83 -52
- package/src/config/args.js +46 -0
- package/src/config/config.js +78 -5
- package/src/config/env.js +70 -3
- package/src/core/network/Network.js +34 -70
- package/src/core/network/identity/NetworkWalletFactory.js +2 -2
- package/src/core/network/protocols/LegacyProtocol.js +67 -0
- package/src/core/network/protocols/NetworkMessages.js +48 -0
- package/src/core/network/protocols/ProtocolInterface.js +31 -0
- package/src/core/network/protocols/ProtocolSession.js +59 -0
- package/src/core/network/protocols/V1Protocol.js +64 -0
- package/src/core/network/protocols/legacy/NetworkMessageRouter.js +84 -0
- package/src/core/network/protocols/legacy/handlers/GetRequestHandler.js +53 -0
- package/src/core/network/protocols/legacy/handlers/ResponseHandler.js +37 -0
- package/src/core/network/{messaging → protocols/legacy}/validators/base/BaseResponse.js +2 -3
- package/src/core/network/protocols/shared/handlers/RoleOperationHandler.js +88 -0
- package/src/core/network/protocols/shared/handlers/SubnetworkOperationHandler.js +93 -0
- package/src/core/network/{messaging → protocols/shared}/handlers/TransferOperationHandler.js +17 -16
- package/src/core/network/{messaging → protocols/shared}/handlers/base/BaseOperationHandler.js +10 -15
- package/src/core/network/{messaging → protocols/shared}/validators/PartialBootstrapDeployment.js +2 -2
- package/src/core/network/{messaging → protocols/shared}/validators/PartialRoleAccess.js +5 -5
- package/src/core/network/{messaging → protocols/shared}/validators/PartialTransaction.js +4 -4
- package/src/core/network/{messaging → protocols/shared}/validators/PartialTransfer.js +4 -4
- package/src/core/network/{messaging → protocols/shared}/validators/base/PartialOperation.js +14 -12
- package/src/core/network/protocols/v1/NetworkMessageRouter.js +15 -0
- package/src/core/network/services/ConnectionManager.js +5 -5
- package/src/core/network/services/MessageOrchestrator.js +2 -2
- package/src/core/network/services/TransactionPoolService.js +5 -6
- package/src/core/network/services/TransactionRateLimiterService.js +12 -13
- package/src/core/network/services/ValidatorObserverService.js +5 -6
- package/src/core/state/State.js +3 -5
- package/src/index.js +156 -181
- package/src/messages/network/v1/NetworkMessageBuilder.js +325 -0
- package/src/messages/network/v1/NetworkMessageDirector.js +137 -0
- package/src/messages/network/v1/networkMessageFactory.js +12 -0
- package/src/messages/state/ApplyStateMessageBuilder.js +661 -0
- package/src/messages/state/ApplyStateMessageDirector.js +516 -0
- package/src/messages/state/applyStateMessageFactory.js +12 -0
- package/src/utils/buffer.js +53 -1
- package/src/utils/check.js +1 -1
- package/src/utils/cli.js +0 -8
- package/src/utils/constants.js +33 -30
- package/src/utils/fileUtils.js +13 -0
- package/src/utils/normalizers.js +84 -2
- package/src/utils/protobuf/network.cjs +840 -0
- package/src/utils/protobuf/operationHelpers.js +10 -0
- package/src/utils/type.js +26 -0
- package/tests/acceptance/v1/balance/balance.test.mjs +1 -2
- package/tests/acceptance/v1/broadcast-transaction/broadcast-transaction.test.mjs +26 -30
- package/tests/acceptance/v1/health/health.test.mjs +33 -0
- package/tests/acceptance/v1/rpc.test.mjs +4 -3
- package/tests/acceptance/v1/tx/tx.test.mjs +27 -16
- package/tests/acceptance/v1/tx-details/tx-details.test.mjs +26 -12
- package/tests/fixtures/check.fixtures.js +33 -32
- package/tests/fixtures/networkV1.fixtures.js +85 -0
- package/tests/fixtures/protobuf.fixtures.js +109 -25
- package/tests/helpers/StateNetworkFactory.js +2 -2
- package/tests/helpers/address.js +6 -0
- package/tests/helpers/autobaseTestHelpers.js +2 -1
- package/tests/helpers/config.js +2 -1
- package/tests/helpers/setupApplyTests.js +59 -56
- package/tests/unit/messages/messages.test.js +12 -0
- package/tests/unit/messages/network/NetworkMessageBuilder.test.js +276 -0
- package/tests/unit/messages/network/NetworkMessageDirector.test.js +201 -0
- package/tests/unit/messages/state/applyStateMessageBuilder.complete.test.js +521 -0
- package/tests/unit/messages/state/applyStateMessageBuilder.partial.test.js +233 -0
- package/tests/unit/network/ConnectionManager.test.js +6 -5
- package/tests/unit/network/networkModule.test.js +3 -2
- package/tests/unit/state/apply/addAdmin/addAdminHappyPathScenario.js +10 -6
- package/tests/unit/state/apply/addAdmin/addAdminScenarioHelpers.js +9 -6
- package/tests/unit/state/apply/addAdmin/state.apply.addAdmin.test.js +10 -7
- package/tests/unit/state/apply/addIndexer/addIndexerScenarioHelpers.js +18 -21
- package/tests/unit/state/apply/addWriter/addWriterScenarioHelpers.js +53 -38
- package/tests/unit/state/apply/adminRecovery/adminRecoveryScenarioHelpers.js +46 -35
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistScenarioHelpers.js +13 -16
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js +17 -11
- package/tests/unit/state/apply/banValidator/banValidatorScenarioHelpers.js +11 -12
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentScenarioHelpers.js +9 -7
- package/tests/unit/state/apply/common/commonScenarioHelper.js +15 -14
- package/tests/unit/state/apply/common/payload-structure/initializationDisabledScenario.js +9 -4
- package/tests/unit/state/apply/disableInitialization/disableInitializationScenarioHelpers.js +17 -11
- package/tests/unit/state/apply/removeWriter/removeWriterScenarioHelpers.js +19 -14
- package/tests/unit/state/apply/transfer/transferDoubleSpendAcrossValidatorsScenario.js +37 -29
- package/tests/unit/state/apply/transfer/transferScenarioHelpers.js +9 -7
- package/tests/unit/state/apply/txOperation/txOperationScenarioHelpers.js +11 -9
- package/tests/unit/unit.test.js +1 -1
- package/tests/unit/utils/buffer/buffer.test.js +62 -1
- package/tests/unit/utils/fileUtils/readAddressesFromWhitelistFile.test.js +4 -3
- package/tests/unit/utils/fileUtils/readBalanceMigrationFile.test.js +3 -2
- package/tests/unit/utils/migrationUtils/validateAddressFromIncomingFile.test.js +3 -2
- package/tests/unit/utils/normalizers/normalizers.test.js +469 -0
- package/tests/unit/utils/protobuf/operationHelpers.test.js +120 -2
- package/tests/unit/utils/type/type.test.js +25 -0
- package/tests/unit/utils/utils.test.js +1 -0
- package/docs/networking-dualstack-plan.md +0 -75
- package/docs/networking-layer-redesign.md +0 -155
- package/src/core/network/messaging/NetworkMessages.js +0 -64
- package/src/core/network/messaging/handlers/GetRequestHandler.js +0 -113
- package/src/core/network/messaging/handlers/ResponseHandler.js +0 -107
- package/src/core/network/messaging/handlers/RoleOperationHandler.js +0 -114
- package/src/core/network/messaging/handlers/SubnetworkOperationHandler.js +0 -149
- package/src/core/network/messaging/routes/NetworkMessageRouter.js +0 -98
- package/src/core/network/messaging/validators/AdminResponse.js +0 -58
- package/src/core/network/messaging/validators/CustomNodeResponse.js +0 -46
- package/src/messages/base/StateBuilder.js +0 -25
- package/src/messages/completeStateMessages/CompleteStateMessageBuilder.js +0 -425
- package/src/messages/completeStateMessages/CompleteStateMessageDirector.js +0 -252
- package/src/messages/completeStateMessages/CompleteStateMessageOperations.js +0 -296
- package/src/messages/partialStateMessages/PartialStateMessageBuilder.js +0 -272
- package/src/messages/partialStateMessages/PartialStateMessageDirector.js +0 -137
- package/src/messages/partialStateMessages/PartialStateMessageOperations.js +0 -138
- package/tests/integration/apply/addAdmin/addAdminBasic.test.js +0 -69
- package/tests/integration/apply/addAdmin/addAdminRecovery.test.js +0 -126
- package/tests/integration/apply/addIndexer.test.js +0 -239
- package/tests/integration/apply/addWhitelist.test.js +0 -53
- package/tests/integration/apply/addWriter.test.js +0 -245
- package/tests/integration/apply/apply.test.js +0 -19
- package/tests/integration/apply/banValidator.test.js +0 -116
- package/tests/integration/apply/postTx/invalidSubValues.test.js +0 -103
- package/tests/integration/apply/postTx/postTx.test.js +0 -196
- package/tests/integration/apply/removeIndexer.test.js +0 -132
- package/tests/integration/apply/removeWriter.test.js +0 -168
- package/tests/integration/apply/transfer.test.js +0 -83
- package/tests/integration/integration.test.js +0 -9
- package/tests/unit/messageOperations/assembleAddIndexerMessage.test.js +0 -21
- package/tests/unit/messageOperations/assembleAddWriterMessage.test.js +0 -17
- package/tests/unit/messageOperations/assembleAdminMessage.test.js +0 -68
- package/tests/unit/messageOperations/assembleBanWriterMessage.test.js +0 -17
- package/tests/unit/messageOperations/assemblePostTransaction.test.js +0 -424
- package/tests/unit/messageOperations/assembleRemoveIndexerMessage.test.js +0 -19
- package/tests/unit/messageOperations/assembleRemoveWriterMessage.test.js +0 -17
- package/tests/unit/messageOperations/assembleWhitelistMessages.test.js +0 -59
- package/tests/unit/messageOperations/commonsStateMessageOperationsTest.js +0 -278
- package/tests/unit/messageOperations/stateMessageOperations.test.js +0 -19
- /package/src/core/network/{messaging → protocols/legacy}/validators/ValidatorResponse.js +0 -0
- /package/src/utils/{operations.js → applyOperations.js} +0 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { OperationType } from '../../utils/constants.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Director that orchestrates ApplyStateMessageBuilder for partial and complete messages.
|
|
5
|
+
*/
|
|
6
|
+
class ApplyStateMessageDirector {
|
|
7
|
+
#builder;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {ApplyStateMessageBuilder} builderInstance
|
|
11
|
+
*/
|
|
12
|
+
constructor(builderInstance) {
|
|
13
|
+
this.#builder = builderInstance;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Build a partial add writer payload.
|
|
18
|
+
* @param {string|Buffer} invokerAddress
|
|
19
|
+
* @param {string|Buffer} writingKey
|
|
20
|
+
* @param {string|Buffer} txValidity
|
|
21
|
+
* @param {'json'|'buffer'} output
|
|
22
|
+
* @returns {Promise<object>}
|
|
23
|
+
*/
|
|
24
|
+
async buildPartialAddWriterMessage(invokerAddress, writingKey, txValidity, output) {
|
|
25
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
26
|
+
await this.#builder
|
|
27
|
+
.setPhase('partial')
|
|
28
|
+
.setOutput(output)
|
|
29
|
+
.setOperationType(OperationType.ADD_WRITER)
|
|
30
|
+
.setAddress(invokerAddress)
|
|
31
|
+
.setTxValidity(txValidity)
|
|
32
|
+
.setWriterKey(writingKey)
|
|
33
|
+
.build();
|
|
34
|
+
return this.#builder.getPayload();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Build a partial remove writer payload.
|
|
39
|
+
* @param {string|Buffer} invokerAddress
|
|
40
|
+
* @param {string|Buffer} writerKey
|
|
41
|
+
* @param {string|Buffer} txValidity
|
|
42
|
+
* @param {'json'|'buffer'} output
|
|
43
|
+
* @returns {Promise<object>}
|
|
44
|
+
*/
|
|
45
|
+
async buildPartialRemoveWriterMessage(invokerAddress, writerKey, txValidity, output) {
|
|
46
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
47
|
+
await this.#builder
|
|
48
|
+
.setPhase('partial')
|
|
49
|
+
.setOutput(output)
|
|
50
|
+
.setOperationType(OperationType.REMOVE_WRITER)
|
|
51
|
+
.setAddress(invokerAddress)
|
|
52
|
+
.setTxValidity(txValidity)
|
|
53
|
+
.setWriterKey(writerKey)
|
|
54
|
+
.build();
|
|
55
|
+
return this.#builder.getPayload();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Build a partial admin recovery payload.
|
|
60
|
+
* @param {string|Buffer} invokerAddress
|
|
61
|
+
* @param {string|Buffer} writingKey
|
|
62
|
+
* @param {string|Buffer} txValidity
|
|
63
|
+
* @param {'json'|'buffer'} output
|
|
64
|
+
* @returns {Promise<object>}
|
|
65
|
+
*/
|
|
66
|
+
async buildPartialAdminRecoveryMessage(invokerAddress, writingKey, txValidity, output) {
|
|
67
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
68
|
+
await this.#builder
|
|
69
|
+
.setPhase('partial')
|
|
70
|
+
.setOutput(output)
|
|
71
|
+
.setOperationType(OperationType.ADMIN_RECOVERY)
|
|
72
|
+
.setAddress(invokerAddress)
|
|
73
|
+
.setTxValidity(txValidity)
|
|
74
|
+
.setWriterKey(writingKey)
|
|
75
|
+
.build();
|
|
76
|
+
return this.#builder.getPayload();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Build a partial transaction payload.
|
|
81
|
+
* @param {string|Buffer} invokerAddress
|
|
82
|
+
* @param {string|Buffer} incomingWritingKey
|
|
83
|
+
* @param {string|Buffer} txValidity
|
|
84
|
+
* @param {string|Buffer} contentHash
|
|
85
|
+
* @param {string|Buffer} externalBootstrap
|
|
86
|
+
* @param {string|Buffer} msbBootstrap
|
|
87
|
+
* @param {'json'|'buffer'} output
|
|
88
|
+
* @returns {Promise<object>}
|
|
89
|
+
*/
|
|
90
|
+
async buildPartialTransactionOperationMessage(
|
|
91
|
+
invokerAddress,
|
|
92
|
+
incomingWritingKey,
|
|
93
|
+
txValidity,
|
|
94
|
+
contentHash,
|
|
95
|
+
externalBootstrap,
|
|
96
|
+
msbBootstrap,
|
|
97
|
+
output
|
|
98
|
+
) {
|
|
99
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
100
|
+
await this.#builder
|
|
101
|
+
.setPhase('partial')
|
|
102
|
+
.setOutput(output)
|
|
103
|
+
.setOperationType(OperationType.TX)
|
|
104
|
+
.setAddress(invokerAddress)
|
|
105
|
+
.setTxValidity(txValidity)
|
|
106
|
+
.setWriterKey(incomingWritingKey)
|
|
107
|
+
.setContentHash(contentHash)
|
|
108
|
+
.setExternalBootstrap(externalBootstrap)
|
|
109
|
+
.setMsbBootstrap(msbBootstrap)
|
|
110
|
+
.build();
|
|
111
|
+
return this.#builder.getPayload();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Build a partial bootstrap deployment payload.
|
|
116
|
+
* @param {string|Buffer} invokerAddress
|
|
117
|
+
* @param {string|Buffer} bootstrap
|
|
118
|
+
* @param {string|Buffer} channel
|
|
119
|
+
* @param {string|Buffer} txValidity
|
|
120
|
+
* @param {'json'|'buffer'} output
|
|
121
|
+
* @returns {Promise<object>}
|
|
122
|
+
*/
|
|
123
|
+
async buildPartialBootstrapDeploymentMessage(invokerAddress, bootstrap, channel, txValidity, output) {
|
|
124
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
125
|
+
await this.#builder
|
|
126
|
+
.setPhase('partial')
|
|
127
|
+
.setOutput(output)
|
|
128
|
+
.setOperationType(OperationType.BOOTSTRAP_DEPLOYMENT)
|
|
129
|
+
.setAddress(invokerAddress)
|
|
130
|
+
.setTxValidity(txValidity)
|
|
131
|
+
.setExternalBootstrap(bootstrap)
|
|
132
|
+
.setChannel(channel)
|
|
133
|
+
.build();
|
|
134
|
+
return this.#builder.getPayload();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Build a partial transfer payload.
|
|
139
|
+
* @param {string|Buffer} invokerAddress
|
|
140
|
+
* @param {string|Buffer} recipientAddress
|
|
141
|
+
* @param {string|Buffer} amount
|
|
142
|
+
* @param {string|Buffer} txValidity
|
|
143
|
+
* @param {'json'|'buffer'} output
|
|
144
|
+
* @returns {Promise<object>}
|
|
145
|
+
*/
|
|
146
|
+
async buildPartialTransferOperationMessage(invokerAddress, recipientAddress, amount, txValidity, output) {
|
|
147
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
148
|
+
await this.#builder
|
|
149
|
+
.setPhase('partial')
|
|
150
|
+
.setOutput(output)
|
|
151
|
+
.setOperationType(OperationType.TRANSFER)
|
|
152
|
+
.setAddress(invokerAddress)
|
|
153
|
+
.setTxValidity(txValidity)
|
|
154
|
+
.setIncomingAddress(recipientAddress)
|
|
155
|
+
.setAmount(amount)
|
|
156
|
+
.build();
|
|
157
|
+
return this.#builder.getPayload();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Build a complete add admin payload.
|
|
162
|
+
* @param {string|Buffer} invokerAddress
|
|
163
|
+
* @param {string|Buffer} writingKey
|
|
164
|
+
* @param {string|Buffer} txValidity
|
|
165
|
+
* @returns {Promise<object>}
|
|
166
|
+
*/
|
|
167
|
+
async buildCompleteAddAdminMessage(invokerAddress, writingKey, txValidity) {
|
|
168
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
169
|
+
await this.#builder
|
|
170
|
+
.setPhase('complete')
|
|
171
|
+
.setOutput('buffer')
|
|
172
|
+
.setOperationType(OperationType.ADD_ADMIN)
|
|
173
|
+
.setAddress(invokerAddress)
|
|
174
|
+
.setWriterKey(writingKey)
|
|
175
|
+
.setTxValidity(txValidity)
|
|
176
|
+
.build();
|
|
177
|
+
return this.#builder.getPayload();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Build a complete disable initialization payload.
|
|
182
|
+
* @param {string|Buffer} invokerAddress
|
|
183
|
+
* @param {string|Buffer} writingKey
|
|
184
|
+
* @param {string|Buffer} txValidity
|
|
185
|
+
* @returns {Promise<object>}
|
|
186
|
+
*/
|
|
187
|
+
async buildCompleteDisableInitializationMessage(invokerAddress, writingKey, txValidity) {
|
|
188
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
189
|
+
await this.#builder
|
|
190
|
+
.setPhase('complete')
|
|
191
|
+
.setOutput('buffer')
|
|
192
|
+
.setOperationType(OperationType.DISABLE_INITIALIZATION)
|
|
193
|
+
.setAddress(invokerAddress)
|
|
194
|
+
.setWriterKey(writingKey)
|
|
195
|
+
.setTxValidity(txValidity)
|
|
196
|
+
.build();
|
|
197
|
+
return this.#builder.getPayload();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Build a complete balance initialization payload.
|
|
202
|
+
* @param {string|Buffer} invokerAddress
|
|
203
|
+
* @param {string|Buffer} recipientAddress
|
|
204
|
+
* @param {string|Buffer} amount
|
|
205
|
+
* @param {string|Buffer} txValidity
|
|
206
|
+
* @returns {Promise<object>}
|
|
207
|
+
*/
|
|
208
|
+
async buildCompleteBalanceInitializationMessage(invokerAddress, recipientAddress, amount, txValidity) {
|
|
209
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
210
|
+
await this.#builder
|
|
211
|
+
.setPhase('complete')
|
|
212
|
+
.setOutput('buffer')
|
|
213
|
+
.setOperationType(OperationType.BALANCE_INITIALIZATION)
|
|
214
|
+
.setAddress(invokerAddress)
|
|
215
|
+
.setIncomingAddress(recipientAddress)
|
|
216
|
+
.setAmount(amount)
|
|
217
|
+
.setTxValidity(txValidity)
|
|
218
|
+
.build();
|
|
219
|
+
return this.#builder.getPayload();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Build a complete append whitelist payload.
|
|
224
|
+
* @param {string|Buffer} invokerAddress
|
|
225
|
+
* @param {string|Buffer} incomingAddress
|
|
226
|
+
* @param {string|Buffer} txValidity
|
|
227
|
+
* @returns {Promise<object>}
|
|
228
|
+
*/
|
|
229
|
+
async buildCompleteAppendWhitelistMessage(invokerAddress, incomingAddress, txValidity) {
|
|
230
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
231
|
+
await this.#builder
|
|
232
|
+
.setPhase('complete')
|
|
233
|
+
.setOutput('buffer')
|
|
234
|
+
.setOperationType(OperationType.APPEND_WHITELIST)
|
|
235
|
+
.setAddress(invokerAddress)
|
|
236
|
+
.setTxValidity(txValidity)
|
|
237
|
+
.setIncomingAddress(incomingAddress)
|
|
238
|
+
.build();
|
|
239
|
+
return this.#builder.getPayload();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Build a complete add writer payload.
|
|
244
|
+
* @param {string|Buffer} invokerAddress
|
|
245
|
+
* @param {string|Buffer} txHash
|
|
246
|
+
* @param {string|Buffer} txValidity
|
|
247
|
+
* @param {string|Buffer} incomingWritingKey
|
|
248
|
+
* @param {string|Buffer} incomingNonce
|
|
249
|
+
* @param {string|Buffer} incomingSignature
|
|
250
|
+
* @returns {Promise<object>}
|
|
251
|
+
*/
|
|
252
|
+
async buildCompleteAddWriterMessage(
|
|
253
|
+
invokerAddress,
|
|
254
|
+
txHash,
|
|
255
|
+
txValidity,
|
|
256
|
+
incomingWritingKey,
|
|
257
|
+
incomingNonce,
|
|
258
|
+
incomingSignature
|
|
259
|
+
) {
|
|
260
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
261
|
+
await this.#builder
|
|
262
|
+
.setPhase('complete')
|
|
263
|
+
.setOutput('buffer')
|
|
264
|
+
.setOperationType(OperationType.ADD_WRITER)
|
|
265
|
+
.setAddress(invokerAddress)
|
|
266
|
+
.setTxHash(txHash)
|
|
267
|
+
.setTxValidity(txValidity)
|
|
268
|
+
.setIncomingWriterKey(incomingWritingKey)
|
|
269
|
+
.setIncomingNonce(incomingNonce)
|
|
270
|
+
.setIncomingSignature(incomingSignature)
|
|
271
|
+
.build();
|
|
272
|
+
return this.#builder.getPayload();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Build a complete remove writer payload.
|
|
277
|
+
* @param {string|Buffer} invokerAddress
|
|
278
|
+
* @param {string|Buffer} txHash
|
|
279
|
+
* @param {string|Buffer} txValidity
|
|
280
|
+
* @param {string|Buffer} incomingWritingKey
|
|
281
|
+
* @param {string|Buffer} incomingNonce
|
|
282
|
+
* @param {string|Buffer} incomingSignature
|
|
283
|
+
* @returns {Promise<object>}
|
|
284
|
+
*/
|
|
285
|
+
async buildCompleteRemoveWriterMessage(
|
|
286
|
+
invokerAddress,
|
|
287
|
+
txHash,
|
|
288
|
+
txValidity,
|
|
289
|
+
incomingWritingKey,
|
|
290
|
+
incomingNonce,
|
|
291
|
+
incomingSignature
|
|
292
|
+
) {
|
|
293
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
294
|
+
await this.#builder
|
|
295
|
+
.setPhase('complete')
|
|
296
|
+
.setOutput('buffer')
|
|
297
|
+
.setOperationType(OperationType.REMOVE_WRITER)
|
|
298
|
+
.setAddress(invokerAddress)
|
|
299
|
+
.setTxHash(txHash)
|
|
300
|
+
.setTxValidity(txValidity)
|
|
301
|
+
.setIncomingWriterKey(incomingWritingKey)
|
|
302
|
+
.setIncomingNonce(incomingNonce)
|
|
303
|
+
.setIncomingSignature(incomingSignature)
|
|
304
|
+
.build();
|
|
305
|
+
return this.#builder.getPayload();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Build a complete admin recovery payload.
|
|
310
|
+
* @param {string|Buffer} invokerAddress
|
|
311
|
+
* @param {string|Buffer} txHash
|
|
312
|
+
* @param {string|Buffer} txValidity
|
|
313
|
+
* @param {string|Buffer} incomingWritingKey
|
|
314
|
+
* @param {string|Buffer} incomingNonce
|
|
315
|
+
* @param {string|Buffer} incomingSignature
|
|
316
|
+
* @returns {Promise<object>}
|
|
317
|
+
*/
|
|
318
|
+
async buildCompleteAdminRecoveryMessage(
|
|
319
|
+
invokerAddress,
|
|
320
|
+
txHash,
|
|
321
|
+
txValidity,
|
|
322
|
+
incomingWritingKey,
|
|
323
|
+
incomingNonce,
|
|
324
|
+
incomingSignature
|
|
325
|
+
) {
|
|
326
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
327
|
+
await this.#builder
|
|
328
|
+
.setPhase('complete')
|
|
329
|
+
.setOutput('buffer')
|
|
330
|
+
.setOperationType(OperationType.ADMIN_RECOVERY)
|
|
331
|
+
.setAddress(invokerAddress)
|
|
332
|
+
.setTxHash(txHash)
|
|
333
|
+
.setTxValidity(txValidity)
|
|
334
|
+
.setIncomingWriterKey(incomingWritingKey)
|
|
335
|
+
.setIncomingNonce(incomingNonce)
|
|
336
|
+
.setIncomingSignature(incomingSignature)
|
|
337
|
+
.build();
|
|
338
|
+
return this.#builder.getPayload();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Build a complete add indexer payload.
|
|
343
|
+
* @param {string|Buffer} invokerAddress
|
|
344
|
+
* @param {string|Buffer} incomingAddress
|
|
345
|
+
* @param {string|Buffer} txValidity
|
|
346
|
+
* @returns {Promise<object>}
|
|
347
|
+
*/
|
|
348
|
+
async buildCompleteAddIndexerMessage(invokerAddress, incomingAddress, txValidity) {
|
|
349
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
350
|
+
await this.#builder
|
|
351
|
+
.setPhase('complete')
|
|
352
|
+
.setOutput('buffer')
|
|
353
|
+
.setOperationType(OperationType.ADD_INDEXER)
|
|
354
|
+
.setAddress(invokerAddress)
|
|
355
|
+
.setTxValidity(txValidity)
|
|
356
|
+
.setIncomingAddress(incomingAddress)
|
|
357
|
+
.build();
|
|
358
|
+
return this.#builder.getPayload();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Build a complete remove indexer payload.
|
|
363
|
+
* @param {string|Buffer} invokerAddress
|
|
364
|
+
* @param {string|Buffer} incomingAddress
|
|
365
|
+
* @param {string|Buffer} txValidity
|
|
366
|
+
* @returns {Promise<object>}
|
|
367
|
+
*/
|
|
368
|
+
async buildCompleteRemoveIndexerMessage(invokerAddress, incomingAddress, txValidity) {
|
|
369
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
370
|
+
await this.#builder
|
|
371
|
+
.setPhase('complete')
|
|
372
|
+
.setOutput('buffer')
|
|
373
|
+
.setOperationType(OperationType.REMOVE_INDEXER)
|
|
374
|
+
.setAddress(invokerAddress)
|
|
375
|
+
.setTxValidity(txValidity)
|
|
376
|
+
.setIncomingAddress(incomingAddress)
|
|
377
|
+
.build();
|
|
378
|
+
return this.#builder.getPayload();
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Build a complete ban validator payload.
|
|
383
|
+
* @param {string|Buffer} invokerAddress
|
|
384
|
+
* @param {string|Buffer} incomingAddress
|
|
385
|
+
* @param {string|Buffer} txValidity
|
|
386
|
+
* @returns {Promise<object>}
|
|
387
|
+
*/
|
|
388
|
+
async buildCompleteBanWriterMessage(invokerAddress, incomingAddress, txValidity) {
|
|
389
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
390
|
+
await this.#builder
|
|
391
|
+
.setPhase('complete')
|
|
392
|
+
.setOutput('buffer')
|
|
393
|
+
.setOperationType(OperationType.BAN_VALIDATOR)
|
|
394
|
+
.setAddress(invokerAddress)
|
|
395
|
+
.setTxValidity(txValidity)
|
|
396
|
+
.setIncomingAddress(incomingAddress)
|
|
397
|
+
.build();
|
|
398
|
+
return this.#builder.getPayload();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Build a complete transaction payload.
|
|
403
|
+
* @param {string|Buffer} invokerAddress
|
|
404
|
+
* @param {string|Buffer} txHash
|
|
405
|
+
* @param {string|Buffer} txValidity
|
|
406
|
+
* @param {string|Buffer} incomingWriterKey
|
|
407
|
+
* @param {string|Buffer} incomingNonce
|
|
408
|
+
* @param {string|Buffer} contentHash
|
|
409
|
+
* @param {string|Buffer} incomingSignature
|
|
410
|
+
* @param {string|Buffer} externalBootstrap
|
|
411
|
+
* @param {string|Buffer} msbBootstrap
|
|
412
|
+
* @returns {Promise<object>}
|
|
413
|
+
*/
|
|
414
|
+
async buildCompleteTransactionOperationMessage(
|
|
415
|
+
invokerAddress,
|
|
416
|
+
txHash,
|
|
417
|
+
txValidity,
|
|
418
|
+
incomingWriterKey,
|
|
419
|
+
incomingNonce,
|
|
420
|
+
contentHash,
|
|
421
|
+
incomingSignature,
|
|
422
|
+
externalBootstrap,
|
|
423
|
+
msbBootstrap
|
|
424
|
+
) {
|
|
425
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
426
|
+
await this.#builder
|
|
427
|
+
.setPhase('complete')
|
|
428
|
+
.setOutput('buffer')
|
|
429
|
+
.setOperationType(OperationType.TX)
|
|
430
|
+
.setAddress(invokerAddress)
|
|
431
|
+
.setTxHash(txHash)
|
|
432
|
+
.setTxValidity(txValidity)
|
|
433
|
+
.setIncomingWriterKey(incomingWriterKey)
|
|
434
|
+
.setIncomingNonce(incomingNonce)
|
|
435
|
+
.setContentHash(contentHash)
|
|
436
|
+
.setIncomingSignature(incomingSignature)
|
|
437
|
+
.setExternalBootstrap(externalBootstrap)
|
|
438
|
+
.setMsbBootstrap(msbBootstrap)
|
|
439
|
+
.build();
|
|
440
|
+
return this.#builder.getPayload();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Build a complete bootstrap deployment payload.
|
|
445
|
+
* @param {string|Buffer} invokerAddress
|
|
446
|
+
* @param {string|Buffer} transactionHash
|
|
447
|
+
* @param {string|Buffer} txValidity
|
|
448
|
+
* @param {string|Buffer} externalBootstrap
|
|
449
|
+
* @param {string|Buffer} channel
|
|
450
|
+
* @param {string|Buffer} incomingNonce
|
|
451
|
+
* @param {string|Buffer} incomingSignature
|
|
452
|
+
* @returns {Promise<object>}
|
|
453
|
+
*/
|
|
454
|
+
async buildCompleteBootstrapDeploymentMessage(
|
|
455
|
+
invokerAddress,
|
|
456
|
+
transactionHash,
|
|
457
|
+
txValidity,
|
|
458
|
+
externalBootstrap,
|
|
459
|
+
channel,
|
|
460
|
+
incomingNonce,
|
|
461
|
+
incomingSignature
|
|
462
|
+
) {
|
|
463
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
464
|
+
await this.#builder
|
|
465
|
+
.setPhase('complete')
|
|
466
|
+
.setOutput('buffer')
|
|
467
|
+
.setOperationType(OperationType.BOOTSTRAP_DEPLOYMENT)
|
|
468
|
+
.setAddress(invokerAddress)
|
|
469
|
+
.setTxHash(transactionHash)
|
|
470
|
+
.setTxValidity(txValidity)
|
|
471
|
+
.setExternalBootstrap(externalBootstrap)
|
|
472
|
+
.setChannel(channel)
|
|
473
|
+
.setIncomingNonce(incomingNonce)
|
|
474
|
+
.setIncomingSignature(incomingSignature)
|
|
475
|
+
.build();
|
|
476
|
+
return this.#builder.getPayload();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Build a complete transfer payload.
|
|
481
|
+
* @param {string|Buffer} invokerAddress
|
|
482
|
+
* @param {string|Buffer} transactionHash
|
|
483
|
+
* @param {string|Buffer} txValidity
|
|
484
|
+
* @param {string|Buffer} incomingNonce
|
|
485
|
+
* @param {string|Buffer} recipientAddress
|
|
486
|
+
* @param {string|Buffer} amount
|
|
487
|
+
* @param {string|Buffer} incomingSignature
|
|
488
|
+
* @returns {Promise<object>}
|
|
489
|
+
*/
|
|
490
|
+
async buildCompleteTransferOperationMessage(
|
|
491
|
+
invokerAddress,
|
|
492
|
+
transactionHash,
|
|
493
|
+
txValidity,
|
|
494
|
+
incomingNonce,
|
|
495
|
+
recipientAddress,
|
|
496
|
+
amount,
|
|
497
|
+
incomingSignature
|
|
498
|
+
) {
|
|
499
|
+
if (!this.#builder) throw new Error('Builder has not been set.');
|
|
500
|
+
await this.#builder
|
|
501
|
+
.setPhase('complete')
|
|
502
|
+
.setOutput('buffer')
|
|
503
|
+
.setOperationType(OperationType.TRANSFER)
|
|
504
|
+
.setAddress(invokerAddress)
|
|
505
|
+
.setTxHash(transactionHash)
|
|
506
|
+
.setTxValidity(txValidity)
|
|
507
|
+
.setIncomingNonce(incomingNonce)
|
|
508
|
+
.setIncomingAddress(recipientAddress)
|
|
509
|
+
.setAmount(amount)
|
|
510
|
+
.setIncomingSignature(incomingSignature)
|
|
511
|
+
.build();
|
|
512
|
+
return this.#builder.getPayload();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export default ApplyStateMessageDirector;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ApplyStateMessageDirector from "./ApplyStateMessageDirector.js";
|
|
2
|
+
import ApplyStateMessageBuilder from "./ApplyStateMessageBuilder.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Factory helper to create a director with a builder instance.
|
|
6
|
+
* @param {PeerWallet} wallet
|
|
7
|
+
* @param {object} config
|
|
8
|
+
* @returns {ApplyStateMessageDirector}
|
|
9
|
+
*/
|
|
10
|
+
export const applyStateMessageFactory = (wallet, config) =>{
|
|
11
|
+
return new ApplyStateMessageDirector(new ApplyStateMessageBuilder(wallet, config))
|
|
12
|
+
}
|
package/src/utils/buffer.js
CHANGED
|
@@ -59,4 +59,56 @@ export function deepCopyBuffer(buffer) {
|
|
|
59
59
|
const copy = b4a.alloc(buffer.length);
|
|
60
60
|
buffer.copy(copy);
|
|
61
61
|
return copy;
|
|
62
|
-
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function uint64ToBuffer(value, fieldName) {
|
|
65
|
+
if (typeof value === 'number') {
|
|
66
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
67
|
+
throw new Error(`${fieldName} must be a non-negative safe integer`);
|
|
68
|
+
}
|
|
69
|
+
value = BigInt(value);
|
|
70
|
+
} else if (typeof value !== 'bigint') {
|
|
71
|
+
throw new Error(`${fieldName} must be a number or bigint`);
|
|
72
|
+
}
|
|
73
|
+
if (value < 0n) {
|
|
74
|
+
throw new Error(`${fieldName} must be a non-negative integer`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const buf = b4a.alloc(8);
|
|
78
|
+
buf.writeBigUInt64BE(value);
|
|
79
|
+
return buf;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function timestampToBuffer(timestamp) {
|
|
83
|
+
return uint64ToBuffer(timestamp, 'timestamp');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function idToBuffer(id) {
|
|
87
|
+
if (typeof id !== 'string') {
|
|
88
|
+
throw new Error('id must be a string');
|
|
89
|
+
}
|
|
90
|
+
return b4a.from(id, 'utf8');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
export function encodeCapabilities(capabilities) {
|
|
95
|
+
if (!Array.isArray(capabilities)) {
|
|
96
|
+
throw new Error('Capabilities must be an array');
|
|
97
|
+
}
|
|
98
|
+
const validCapabilities = capabilities.map((capability) => {
|
|
99
|
+
if (typeof capability !== 'string') {
|
|
100
|
+
throw new Error('Capabilities array must contain only strings');
|
|
101
|
+
}
|
|
102
|
+
return capability;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const parts = [];
|
|
106
|
+
for (const capability of validCapabilities.slice().sort()) {
|
|
107
|
+
const capabilityBuffer = b4a.from(capability, 'utf8');
|
|
108
|
+
const bufferLen = b4a.allocUnsafe(2);
|
|
109
|
+
bufferLen.writeUInt16BE(capabilityBuffer.length, 0);
|
|
110
|
+
parts.push(bufferLen, capabilityBuffer);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return parts.length ? b4a.concat(parts) : b4a.alloc(0);
|
|
114
|
+
}
|
package/src/utils/check.js
CHANGED
package/src/utils/cli.js
CHANGED
|
@@ -39,14 +39,6 @@ export async function verifyDag(state, network, wallet, writerKey) {
|
|
|
39
39
|
const wl = await state.getWriterLength();
|
|
40
40
|
console.log('Total Registered Writers:', wl !== null ? wl : 0);
|
|
41
41
|
|
|
42
|
-
console.log("---------- connections stats ----------");
|
|
43
|
-
console.log("Admin Stream:", network.admin_stream ? "Connected" : "Not Connected");
|
|
44
|
-
console.log("Admin Public Key:", network.admin ? network.admin.toString('hex') : "None");
|
|
45
|
-
console.log("Validator Stream:", network.validatorConnectionManager.connectionCount() > 0 ? "Connected" : "Not Connected");
|
|
46
|
-
console.log("Validator Public Key:", network.validator ? network.validator.toString('hex') : "None");
|
|
47
|
-
console.log("Custom Stream:", network.custom_stream ? "Connected" : "Not Connected");
|
|
48
|
-
console.log("Custom Node Address:", network.custom_node ? network.custom_node.toString('hex') : "None");
|
|
49
|
-
|
|
50
42
|
console.log("---------- flags ----------");
|
|
51
43
|
try {
|
|
52
44
|
console.log(`isIndexer: ${state?.isIndexer?.() ?? 'unset'}`);
|
package/src/utils/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { OperationType as
|
|
1
|
+
import { OperationType as ApplyOperationType } from './protobuf/applyOperations.cjs';
|
|
2
|
+
import { MessageType as NetworkMessageType, ResultCode as NetworkResultCode } from './protobuf/network.cjs';
|
|
2
3
|
import b4a from 'b4a'
|
|
3
4
|
// TODO: We are going to have a lot of contstants. It would be good, to separate them into different files.
|
|
4
5
|
|
|
@@ -17,19 +18,37 @@ export const EntryType = Object.freeze({
|
|
|
17
18
|
|
|
18
19
|
//ATTENTION - THIS IS USED IN THE APPLY FUNCTION!
|
|
19
20
|
export const OperationType = Object.freeze({
|
|
20
|
-
ADD_ADMIN:
|
|
21
|
-
DISABLE_INITIALIZATION:
|
|
22
|
-
BALANCE_INITIALIZATION:
|
|
23
|
-
APPEND_WHITELIST:
|
|
24
|
-
ADD_WRITER:
|
|
25
|
-
REMOVE_WRITER:
|
|
26
|
-
ADMIN_RECOVERY:
|
|
27
|
-
ADD_INDEXER:
|
|
28
|
-
REMOVE_INDEXER:
|
|
29
|
-
BAN_VALIDATOR:
|
|
30
|
-
BOOTSTRAP_DEPLOYMENT:
|
|
31
|
-
TX:
|
|
32
|
-
TRANSFER:
|
|
21
|
+
ADD_ADMIN: ApplyOperationType.ADD_ADMIN,
|
|
22
|
+
DISABLE_INITIALIZATION: ApplyOperationType.DISABLE_INITIALIZATION,
|
|
23
|
+
BALANCE_INITIALIZATION: ApplyOperationType.BALANCE_INITIALIZATION,
|
|
24
|
+
APPEND_WHITELIST: ApplyOperationType.APPEND_WHITELIST,
|
|
25
|
+
ADD_WRITER: ApplyOperationType.ADD_WRITER,
|
|
26
|
+
REMOVE_WRITER: ApplyOperationType.REMOVE_WRITER,
|
|
27
|
+
ADMIN_RECOVERY: ApplyOperationType.ADMIN_RECOVERY,
|
|
28
|
+
ADD_INDEXER: ApplyOperationType.ADD_INDEXER,
|
|
29
|
+
REMOVE_INDEXER: ApplyOperationType.REMOVE_INDEXER,
|
|
30
|
+
BAN_VALIDATOR: ApplyOperationType.BAN_VALIDATOR,
|
|
31
|
+
BOOTSTRAP_DEPLOYMENT: ApplyOperationType.BOOTSTRAP_DEPLOYMENT,
|
|
32
|
+
TX: ApplyOperationType.TX,
|
|
33
|
+
TRANSFER: ApplyOperationType.TRANSFER,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const NetworkOperationType = Object.freeze({
|
|
37
|
+
VALIDATOR_CONNECTION_REQUEST: NetworkMessageType.MESSAGE_TYPE_VALIDATOR_CONNECTION_REQUEST,
|
|
38
|
+
VALIDATOR_CONNECTION_RESPONSE: NetworkMessageType.MESSAGE_TYPE_VALIDATOR_CONNECTION_RESPONSE,
|
|
39
|
+
LIVENESS_REQUEST: NetworkMessageType.MESSAGE_TYPE_LIVENESS_REQUEST,
|
|
40
|
+
LIVENESS_RESPONSE: NetworkMessageType.MESSAGE_TYPE_LIVENESS_RESPONSE,
|
|
41
|
+
BROADCAST_TRANSACTION_REQUEST: NetworkMessageType.MESSAGE_TYPE_BROADCAST_TRANSACTION_REQUEST,
|
|
42
|
+
BROADCAST_TRANSACTION_RESPONSE: NetworkMessageType.MESSAGE_TYPE_BROADCAST_TRANSACTION_RESPONSE,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const ResultCode = Object.freeze({
|
|
46
|
+
OK: NetworkResultCode.RESULT_CODE_OK,
|
|
47
|
+
INVALID_PAYLOAD: NetworkResultCode.RESULT_CODE_INVALID_PAYLOAD,
|
|
48
|
+
UNSUPPORTED_VERSION: NetworkResultCode.RESULT_CODE_UNSUPPORTED_VERSION,
|
|
49
|
+
RATE_LIMITED: NetworkResultCode.RESULT_CODE_RATE_LIMITED,
|
|
50
|
+
TIMEOUT: NetworkResultCode.RESULT_CODE_TIMEOUT,
|
|
51
|
+
SIGNATURE_INVALID: NetworkResultCode.RESULT_CODE_SIGNATURE_INVALID,
|
|
33
52
|
});
|
|
34
53
|
|
|
35
54
|
// Role managment constants
|
|
@@ -63,12 +82,6 @@ export const TRAC_NAMESPACE = 'TracNetwork';
|
|
|
63
82
|
export const WHITELIST_SLEEP_INTERVAL = 1_000;
|
|
64
83
|
export const BALANCE_MIGRATION_SLEEP_INTERVAL = 500;
|
|
65
84
|
|
|
66
|
-
// Connectivity constants
|
|
67
|
-
export const MAX_PEERS = 64;
|
|
68
|
-
export const MAX_PARALLEL = 64;
|
|
69
|
-
export const MAX_SERVER_CONNECTIONS = Infinity;
|
|
70
|
-
export const MAX_CLIENT_CONNECTIONS = Infinity;
|
|
71
|
-
export const MAX_WRITERS_FOR_ADMIN_INDEXER_CONNECTION = 10;
|
|
72
85
|
// State
|
|
73
86
|
export const ACK_INTERVAL = 1_000;
|
|
74
87
|
export const AUTOBASE_VALUE_ENCODING = 'binary';
|
|
@@ -95,16 +108,6 @@ export const BOOTSTRAP_HEXSTRING_LENGTH = 64;
|
|
|
95
108
|
|
|
96
109
|
// Pool constants
|
|
97
110
|
export const BATCH_SIZE = 10;
|
|
98
|
-
export const PROCESS_INTERVAL_MS = 50;
|
|
99
|
-
|
|
100
|
-
// Rate limiting constants
|
|
101
|
-
export const CLEANUP_INTERVAL_MS = 120_000;
|
|
102
|
-
export const CONNECTION_TIMEOUT_MS = 60_000;
|
|
103
|
-
export const MAX_TRANSACTIONS_PER_SECOND = 50;
|
|
104
|
-
|
|
105
|
-
// Operation handler constants
|
|
106
|
-
export const MAX_PARTIAL_TX_PAYLOAD_BYTE_SIZE = 3072;
|
|
107
|
-
export const TRANSACTION_POOL_SIZE = 1000;
|
|
108
111
|
|
|
109
112
|
// Network message constants
|
|
110
113
|
export const NETWORK_MESSAGE_TYPES = Object.freeze({
|