trac-msb 0.2.17 → 0.2.19
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/README.md +62 -2
- package/SECURITY.md +9 -6
- package/cli/commandHandler.js +272 -0
- package/cli/handlers.js +210 -0
- package/cli/interactive.js +182 -0
- package/msb.mjs +7 -8
- package/package.json +33 -11
- package/rpc/create_server.js +44 -44
- package/rpc/handlers.js +43 -56
- package/rpc/routes/index.js +8 -8
- package/rpc/rpc_server.js +6 -2
- package/rpc/utils/helpers.js +46 -66
- package/scripts/pear-runner.js +170 -0
- package/src/config/args.js +60 -13
- package/src/config/config.js +163 -14
- package/src/config/env.js +57 -25
- package/src/core/network/Network.js +121 -56
- package/src/core/network/protocols/LegacyProtocol.js +21 -11
- package/src/core/network/protocols/NetworkMessages.js +38 -17
- package/src/core/network/protocols/ProtocolInterface.js +15 -3
- package/src/core/network/protocols/ProtocolSession.js +144 -17
- package/src/core/network/protocols/V1Protocol.js +37 -18
- package/src/core/network/protocols/connectionPolicies.js +174 -0
- package/src/core/network/protocols/legacy/NetworkMessageRouter.js +26 -20
- package/src/core/network/protocols/{shared/handlers/base/BaseOperationHandler.js → legacy/handlers/BaseStateOperationHandler.js} +25 -14
- package/src/core/network/protocols/legacy/handlers/{GetRequestHandler.js → LegacyGetRequestHandler.js} +9 -9
- package/src/core/network/protocols/legacy/handlers/LegacyResponseHandler.js +23 -0
- package/src/core/network/protocols/{shared/handlers/RoleOperationHandler.js → legacy/handlers/LegacyRoleOperationHandler.js} +19 -12
- package/src/core/network/protocols/{shared/handlers/SubnetworkOperationHandler.js → legacy/handlers/LegacySubnetworkOperationHandler.js} +29 -18
- package/src/core/network/protocols/{shared/handlers/TransferOperationHandler.js → legacy/handlers/LegacyTransferOperationHandler.js} +18 -12
- package/src/core/network/protocols/legacy/validators/base/BaseResponse.js +7 -10
- package/src/core/network/protocols/shared/validators/{PartialBootstrapDeployment.js → PartialBootstrapDeploymentValidator.js} +9 -4
- package/src/core/network/protocols/shared/validators/{base/PartialOperation.js → PartialOperationValidator.js} +53 -31
- package/src/core/network/protocols/shared/validators/{PartialRoleAccess.js → PartialRoleAccessValidator.js} +51 -17
- package/src/core/network/protocols/shared/validators/{PartialTransaction.js → PartialTransactionValidator.js} +21 -7
- package/src/core/network/protocols/shared/validators/{PartialTransfer.js → PartialTransferValidator.js} +32 -14
- package/src/core/network/protocols/v1/NetworkMessageRouter.js +91 -7
- package/src/core/network/protocols/v1/V1ProtocolError.js +27 -0
- package/src/core/network/protocols/v1/handlers/V1BaseOperationHandler.js +66 -0
- package/src/core/network/protocols/v1/handlers/V1BroadcastTransactionOperationHandler.js +272 -0
- package/src/core/network/protocols/v1/handlers/V1LivenessOperationHandler.js +88 -0
- package/src/core/network/protocols/v1/handlers/broadcastTransaction/BroadcastTransactionErrorMapper.js +84 -0
- package/src/core/network/protocols/v1/handlers/broadcastTransaction/BroadcastTransactionOperationStrategies.js +128 -0
- package/src/core/network/protocols/v1/handlers/broadcastTransaction/BroadcastTransactionPayloadUtils.js +26 -0
- package/src/core/network/protocols/v1/validators/V1BaseOperation.js +212 -0
- package/src/core/network/protocols/v1/validators/V1BroadcastTransactionRequest.js +28 -0
- package/src/core/network/protocols/v1/validators/V1BroadcastTransactionResponse.js +260 -0
- package/src/core/network/protocols/v1/validators/V1LivenessRequest.js +15 -0
- package/src/core/network/protocols/v1/validators/V1LivenessResponse.js +17 -0
- package/src/core/network/protocols/v1/validators/V1ValidationSchema.js +210 -0
- package/src/core/network/services/ConnectionManager.js +149 -96
- package/src/core/network/services/MessageOrchestrator.js +197 -37
- package/src/core/network/services/PendingRequestService.js +175 -0
- package/src/core/network/services/TransactionCommitService.js +149 -0
- package/src/core/network/services/TransactionPoolService.js +129 -18
- package/src/core/network/services/TransactionRateLimiterService.js +57 -35
- package/src/core/network/services/ValidatorHealthCheckService.js +127 -0
- package/src/core/network/services/ValidatorObserverService.js +400 -121
- package/src/core/state/State.js +259 -156
- package/src/core/state/utils/address.js +4 -9
- package/src/core/state/utils/balance.js +7 -7
- package/src/core/state/utils/roles.js +1 -1
- package/src/index.js +320 -278
- package/src/messages/network/v1/NetworkMessageBuilder.js +71 -100
- package/src/messages/network/v1/NetworkMessageDirector.js +16 -50
- package/src/messages/network/v1/networkMessageFactory.js +1 -1
- package/src/messages/state/ApplyStateMessageBuilder.js +6 -6
- package/src/messages/state/applyStateMessageFactory.js +1 -1
- package/src/utils/Scheduler.js +0 -8
- package/src/utils/buffer.js +1 -1
- package/src/utils/check.js +12 -13
- package/src/utils/constants.js +78 -5
- package/src/utils/deepEqualApplyPayload.js +40 -0
- package/src/utils/errors.js +20 -0
- package/src/utils/fileUtils.js +12 -3
- package/src/utils/helpers.js +10 -1
- package/src/utils/logger.js +25 -0
- package/src/utils/migrationUtils.js +3 -3
- package/src/utils/normalizers.js +38 -0
- package/src/utils/protobuf/networkV1.generated.cjs +2460 -0
- package/src/utils/protobuf/operationHelpers.js +24 -3
- package/.dockerignore +0 -16
- package/.github/workflows/acceptance-tests.yml +0 -38
- package/.github/workflows/lint-pr-title.yml +0 -26
- package/.github/workflows/publish.yml +0 -33
- package/.github/workflows/unit-tests.yml +0 -34
- package/CODE_OF_CONDUCT.md +0 -128
- package/docker-compose.yml +0 -17
- package/dockerfile +0 -41
- package/docs/fee_distribution.md +0 -89
- package/docs/trac_network_http_api.openapi.yaml +0 -889
- package/migration/.gitkeep +0 -0
- package/proto/applyOperations.proto +0 -117
- package/proto/network.proto +0 -74
- package/rpc/rpc_services.js +0 -163
- package/scripts/generate-protobufs.js +0 -42
- package/src/core/network/identity/NetworkWalletFactory.js +0 -77
- package/src/core/network/protocols/legacy/handlers/ResponseHandler.js +0 -37
- package/src/utils/cli.js +0 -130
- package/src/utils/cliCommands.js +0 -280
- package/src/utils/protobuf/network.cjs +0 -840
- package/tests/acceptance/v1/account/account.test.mjs +0 -123
- package/tests/acceptance/v1/balance/balance.test.mjs +0 -54
- package/tests/acceptance/v1/broadcast-transaction/broadcast-transaction.test.mjs +0 -116
- package/tests/acceptance/v1/confirmed-length/confirmed-length.test.mjs +0 -19
- package/tests/acceptance/v1/fee/fee.test.mjs +0 -11
- package/tests/acceptance/v1/health/health.test.mjs +0 -33
- package/tests/acceptance/v1/rpc.test.mjs +0 -95
- package/tests/acceptance/v1/tx/tx.test.mjs +0 -111
- package/tests/acceptance/v1/tx-details/tx-details.test.mjs +0 -213
- package/tests/acceptance/v1/tx-hashes/tx-hashes.test.mjs +0 -72
- package/tests/acceptance/v1/tx-payloads-bulk/tx-payloads-bulk.test.mjs +0 -27
- package/tests/acceptance/v1/txv/txv.test.mjs +0 -11
- package/tests/acceptance/v1/unconfirmed-length/unconfirmed-length.test.mjs +0 -11
- package/tests/fixtures/apply.fixtures.js +0 -77
- package/tests/fixtures/assembleMessage.fixtures.js +0 -41
- package/tests/fixtures/check.fixtures.js +0 -428
- package/tests/fixtures/networkV1.fixtures.js +0 -85
- package/tests/fixtures/protobuf.fixtures.js +0 -388
- package/tests/helpers/StateNetworkFactory.js +0 -155
- package/tests/helpers/address.js +0 -6
- package/tests/helpers/autobaseTestHelpers.js +0 -419
- package/tests/helpers/config.js +0 -4
- package/tests/helpers/createTestSignature.js +0 -13
- package/tests/helpers/regexHelper.js +0 -3
- package/tests/helpers/setupApplyTests.js +0 -587
- package/tests/helpers/transactionPayloads.mjs +0 -92
- package/tests/helpers/wrapper.js +0 -28
- package/tests/unit/messages/messages.test.js +0 -12
- package/tests/unit/messages/network/NetworkMessageBuilder.test.js +0 -276
- package/tests/unit/messages/network/NetworkMessageDirector.test.js +0 -201
- package/tests/unit/messages/state/applyStateMessageBuilder.complete.test.js +0 -525
- package/tests/unit/messages/state/applyStateMessageBuilder.partial.test.js +0 -237
- package/tests/unit/network/ConnectionManager.test.js +0 -191
- package/tests/unit/network/NetworkWalletFactory.test.js +0 -156
- package/tests/unit/network/networkModule.test.js +0 -10
- package/tests/unit/state/State.test.js +0 -80
- package/tests/unit/state/apply/addAdmin/addAdminHappyPathScenario.js +0 -42
- package/tests/unit/state/apply/addAdmin/addAdminScenarioHelpers.js +0 -276
- package/tests/unit/state/apply/addAdmin/adminEntryEncodingFailureScenario.js +0 -30
- package/tests/unit/state/apply/addAdmin/adminEntryExistsScenario.js +0 -78
- package/tests/unit/state/apply/addAdmin/nodeEntryInitializationFailureScenario.js +0 -30
- package/tests/unit/state/apply/addAdmin/nonBootstrapNodeScenario.js +0 -68
- package/tests/unit/state/apply/addAdmin/state.apply.addAdmin.test.js +0 -159
- package/tests/unit/state/apply/addIndexer/addIndexerHappyPathScenario.js +0 -39
- package/tests/unit/state/apply/addIndexer/addIndexerMultipleIndexersInTheNetworkScenario.js +0 -167
- package/tests/unit/state/apply/addIndexer/addIndexerPretenderAlreadyIndexerScenario.js +0 -21
- package/tests/unit/state/apply/addIndexer/addIndexerPretenderNotWriterScenario.js +0 -21
- package/tests/unit/state/apply/addIndexer/addIndexerRemoveAndReAddScenario.js +0 -186
- package/tests/unit/state/apply/addIndexer/addIndexerScenarioHelpers.js +0 -443
- package/tests/unit/state/apply/addIndexer/addIndexerWriterKeyAlreadyRegisteredScenario.js +0 -32
- package/tests/unit/state/apply/addIndexer/state.apply.addIndexer.test.js +0 -297
- package/tests/unit/state/apply/addWriter/addWriterHappyPathScenario.js +0 -41
- package/tests/unit/state/apply/addWriter/addWriterInvalidValidatorSignatureScenario.js +0 -32
- package/tests/unit/state/apply/addWriter/addWriterNewWkScenario.js +0 -149
- package/tests/unit/state/apply/addWriter/addWriterRequesterAlreadyWriterScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterRequesterBalanceInsufficientScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterRequesterEntryDecodeFailureScenario.js +0 -19
- package/tests/unit/state/apply/addWriter/addWriterRequesterEntryMissingScenario.js +0 -19
- package/tests/unit/state/apply/addWriter/addWriterRequesterIndexerScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterRequesterNotWhitelistedScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterScenarioHelpers.js +0 -766
- package/tests/unit/state/apply/addWriter/addWriterStakeBalanceUpdateFailureScenario.js +0 -50
- package/tests/unit/state/apply/addWriter/addWriterStakeInsufficientBalanceScenario.js +0 -29
- package/tests/unit/state/apply/addWriter/addWriterStakeInvalidBalanceScenario.js +0 -29
- package/tests/unit/state/apply/addWriter/addWriterStakeInvalidEntryScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterStakeStakedBalanceFailureScenario.js +0 -37
- package/tests/unit/state/apply/addWriter/addWriterStakeSubtractFailureScenario.js +0 -42
- package/tests/unit/state/apply/addWriter/addWriterValidatorRewardScenario.js +0 -106
- package/tests/unit/state/apply/addWriter/addWriterWriterKeyMismatchScenario.js +0 -54
- package/tests/unit/state/apply/addWriter/addWriterWriterKeyOwnershipScenario.js +0 -54
- package/tests/unit/state/apply/addWriter/addWriterZeroWriterKeyScenario.js +0 -29
- package/tests/unit/state/apply/addWriter/state.apply.addWriter.test.js +0 -309
- package/tests/unit/state/apply/adminRecovery/adminRecoveryHappyPathScenario.js +0 -30
- package/tests/unit/state/apply/adminRecovery/adminRecoveryScenarioHelpers.js +0 -881
- package/tests/unit/state/apply/adminRecovery/state.apply.adminRecovery.test.js +0 -435
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistBanAndReapplyScenario.js +0 -78
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistExistingReaderHappyPathScenario.js +0 -98
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistFeeAfterDisableScenario.js +0 -66
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistHappyPathScenario.js +0 -55
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistInsufficientAdminBalanceScenario.js +0 -103
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistNodeAlreadyWhitelistedScenario.js +0 -60
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistScenarioHelpers.js +0 -189
- package/tests/unit/state/apply/appendWhitelist/state.apply.appendWhitelist.test.js +0 -220
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationHappyPathScenario.js +0 -82
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js +0 -111
- package/tests/unit/state/apply/balanceInitialization/invalidAmountScenario.js +0 -45
- package/tests/unit/state/apply/balanceInitialization/nodeEntryBalanceUpdateFailureScenario.js +0 -82
- package/tests/unit/state/apply/balanceInitialization/state.apply.balanceInitialization.test.js +0 -189
- package/tests/unit/state/apply/banValidator/banValidatorBanAndReWhitelistScenario.js +0 -156
- package/tests/unit/state/apply/banValidator/banValidatorHappyPathScenario.js +0 -36
- package/tests/unit/state/apply/banValidator/banValidatorScenarioHelpers.js +0 -531
- package/tests/unit/state/apply/banValidator/banValidatorSequentialBansScenario.js +0 -74
- package/tests/unit/state/apply/banValidator/banValidatorTargetDecodeFailureScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/banValidatorTargetIndexerScenario.js +0 -32
- package/tests/unit/state/apply/banValidator/banValidatorTargetNodeEntryMissingScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/banValidatorTargetRoleUpdateFailureScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/banValidatorWhitelistedNonWriterScenario.js +0 -38
- package/tests/unit/state/apply/banValidator/banValidatorWhitelistedZeroBalanceScenario.js +0 -91
- package/tests/unit/state/apply/banValidator/banValidatorWithdrawFailureScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/state.apply.banValidator.test.js +0 -266
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentDuplicateRegistrationScenario.js +0 -143
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentHappyPathScenario.js +0 -26
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentIncompleteOperationScenario.js +0 -94
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentInvalidDeploymentEntryScenario.js +0 -37
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentMultipleBootstrapScenario.js +0 -86
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentScenarioHelpers.js +0 -347
- package/tests/unit/state/apply/bootstrapDeployment/invalidValidatorNodeEntryScenario.js +0 -57
- package/tests/unit/state/apply/bootstrapDeployment/state.apply.bootstrapDeployment.test.js +0 -429
- package/tests/unit/state/apply/common/access-control/adminConsistencyMismatchScenario.js +0 -120
- package/tests/unit/state/apply/common/access-control/adminEntryDecodeFailureScenario.js +0 -130
- package/tests/unit/state/apply/common/access-control/adminEntryExistsScenario.js +0 -93
- package/tests/unit/state/apply/common/access-control/adminEntryMissingScenario.js +0 -108
- package/tests/unit/state/apply/common/access-control/adminOnlyGuardScenario.js +0 -126
- package/tests/unit/state/apply/common/access-control/adminPublicKeyDecodeFailureScenario.js +0 -121
- package/tests/unit/state/apply/common/access-control/roleAccessOperationValidationScenario.js +0 -50
- package/tests/unit/state/apply/common/adminControlOperationValidationScenario.js +0 -56
- package/tests/unit/state/apply/common/balances/adminEntryUpdateFailureScenario.js +0 -52
- package/tests/unit/state/apply/common/balances/base/requesterBalanceScenarioBase.js +0 -198
- package/tests/unit/state/apply/common/balances/feeDecodeFailureScenario.js +0 -52
- package/tests/unit/state/apply/common/balances/requesterBalanceDecodeFailureScenario.js +0 -15
- package/tests/unit/state/apply/common/balances/requesterBalanceFeeApplicationFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/requesterBalanceInsufficientScenario.js +0 -15
- package/tests/unit/state/apply/common/balances/requesterBalanceUpdateFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/validatorEntryRewardFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/validatorEntryUpdateFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/validatorNodeEntryDecodeFailureScenario.js +0 -40
- package/tests/unit/state/apply/common/base/OperationValidationScenarioBase.js +0 -114
- package/tests/unit/state/apply/common/commonScenarioHelper.js +0 -103
- package/tests/unit/state/apply/common/indexer/indexerNodeEntryDecodeFailureScenario.js +0 -36
- package/tests/unit/state/apply/common/indexer/indexerNodeEntryMissingScenario.js +0 -36
- package/tests/unit/state/apply/common/indexer/indexerRoleUpdateFailureScenario.js +0 -29
- package/tests/unit/state/apply/common/indexer/indexerSequenceStateInvalidScenario.js +0 -66
- package/tests/unit/state/apply/common/invalidMessageComponentValidationScenario.js +0 -84
- package/tests/unit/state/apply/common/nodeEntryInitializationFailureScenario.js +0 -47
- package/tests/unit/state/apply/common/operationAlreadyAppliedScenario.js +0 -85
- package/tests/unit/state/apply/common/payload-structure/addressWithInvalidPublicKeyScenario.js +0 -52
- package/tests/unit/state/apply/common/payload-structure/initializationDisabledScenario.js +0 -54
- package/tests/unit/state/apply/common/payload-structure/invalidAddressValidationScenario.js +0 -73
- package/tests/unit/state/apply/common/payload-structure/invalidHashValidationScenario.js +0 -71
- package/tests/unit/state/apply/common/payload-structure/invalidPayloadValidationScenario.js +0 -31
- package/tests/unit/state/apply/common/payload-structure/invalidSignatureValidationScenario.js +0 -142
- package/tests/unit/state/apply/common/payload-structure/partialOperationValidationScenario.js +0 -87
- package/tests/unit/state/apply/common/requester/requesterNodeEntryBufferMissingScenario.js +0 -71
- package/tests/unit/state/apply/common/requester/requesterNodeEntryDecodeFailureScenario.js +0 -73
- package/tests/unit/state/apply/common/requester/requesterNodeEntryMissingScenario.js +0 -36
- package/tests/unit/state/apply/common/requesterAddressValidationScenario.js +0 -44
- package/tests/unit/state/apply/common/requesterPublicKeyValidationScenario.js +0 -25
- package/tests/unit/state/apply/common/transactionValidityMismatchScenario.js +0 -98
- package/tests/unit/state/apply/common/validatorConsistency/base/validatorConsistencyScenarioBase.js +0 -202
- package/tests/unit/state/apply/common/validatorConsistency/validatorEntryDecodeFailureScenario.js +0 -17
- package/tests/unit/state/apply/common/validatorConsistency/validatorEntryMissingScenario.js +0 -44
- package/tests/unit/state/apply/common/validatorConsistency/validatorInactiveScenario.js +0 -19
- package/tests/unit/state/apply/common/validatorConsistency/validatorWriterKeyMismatchScenario.js +0 -18
- package/tests/unit/state/apply/common/validatorEntryValidation/base/validatorEntryValidationScenarioBase.js +0 -315
- package/tests/unit/state/apply/common/validatorEntryValidation/validatorEntryInvalidBalanceScenario.js +0 -18
- package/tests/unit/state/apply/common/writerKeyExistsValidationScenario.js +0 -43
- package/tests/unit/state/apply/disableInitialization/disableInitializationAlreadyDisabledScenario.js +0 -53
- package/tests/unit/state/apply/disableInitialization/disableInitializationHappyPathScenario.js +0 -24
- package/tests/unit/state/apply/disableInitialization/disableInitializationScenarioHelpers.js +0 -204
- package/tests/unit/state/apply/disableInitialization/state.apply.disableInitialization.test.js +0 -161
- package/tests/unit/state/apply/missing-tests.md +0 -18
- package/tests/unit/state/apply/removeIndexer/removeIndexerHappyPathScenario.js +0 -58
- package/tests/unit/state/apply/removeIndexer/removeIndexerReAddAndRemoveAgainScenario.js +0 -98
- package/tests/unit/state/apply/removeIndexer/removeIndexerRemoveMultipleIndexersScenario.js +0 -167
- package/tests/unit/state/apply/removeIndexer/removeIndexerScenarioHelpers.js +0 -429
- package/tests/unit/state/apply/removeIndexer/removeIndexerTargetNotIndexerScenario.js +0 -22
- package/tests/unit/state/apply/removeIndexer/removeIndexerWriterKeyMissingScenario.js +0 -20
- package/tests/unit/state/apply/removeIndexer/state.apply.removeIndexer.test.js +0 -291
- package/tests/unit/state/apply/removeWriter/removeWriterAndAddWriterAgainScenario.js +0 -87
- package/tests/unit/state/apply/removeWriter/removeWriterHappyPathScenario.js +0 -38
- package/tests/unit/state/apply/removeWriter/removeWriterInvalidValidatorSignatureScenario.js +0 -32
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterBalanceInsufficientScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterEntryDecodeFailureScenario.js +0 -19
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterEntryMissingScenario.js +0 -19
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterIndexerScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterNotWriterScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterRoleUpdateFailureScenario.js +0 -19
- package/tests/unit/state/apply/removeWriter/removeWriterScenarioHelpers.js +0 -348
- package/tests/unit/state/apply/removeWriter/removeWriterThroughWriterValidatorScenario.js +0 -113
- package/tests/unit/state/apply/removeWriter/removeWriterUnstakeFailureScenario.js +0 -33
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyMismatchScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyOwnershipScenario.js +0 -26
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyRegistryMissingScenario.js +0 -22
- package/tests/unit/state/apply/removeWriter/state.apply.removeWriter.test.js +0 -307
- package/tests/unit/state/apply/state.apply.test.js +0 -24
- package/tests/unit/state/apply/transfer/state.apply.transfer.test.js +0 -819
- package/tests/unit/state/apply/transfer/transferContractSchemaValidationScenario.js +0 -22
- package/tests/unit/state/apply/transfer/transferDoubleSpendAcrossValidatorsScenario.js +0 -146
- package/tests/unit/state/apply/transfer/transferDoubleSpendSameBatchScenario.js +0 -63
- package/tests/unit/state/apply/transfer/transferDoubleSpendSingleValidatorScenario.js +0 -67
- package/tests/unit/state/apply/transfer/transferExistingRecipientAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferExistingRecipientZeroAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferHandlerGuardScenarios.js +0 -22
- package/tests/unit/state/apply/transfer/transferHappyPathScenario.js +0 -8
- package/tests/unit/state/apply/transfer/transferInvalidIncomingDataScenario.js +0 -66
- package/tests/unit/state/apply/transfer/transferNewRecipientAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferNewRecipientZeroAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferScenarioHelpers.js +0 -1170
- package/tests/unit/state/apply/transfer/transferSelfTransferAmountScenario.js +0 -38
- package/tests/unit/state/apply/transfer/transferSelfTransferZeroAmountScenario.js +0 -38
- package/tests/unit/state/apply/transfer/transferValidatorRecipientAmountScenario.js +0 -38
- package/tests/unit/state/apply/transfer/transferValidatorRecipientZeroAmountScenario.js +0 -38
- package/tests/unit/state/apply/txOperation/state.apply.txOperation.test.js +0 -318
- package/tests/unit/state/apply/txOperation/txOperationBootstrapNotRegisteredScenario.js +0 -70
- package/tests/unit/state/apply/txOperation/txOperationDifferentValidatorCreatorHappyPathScenario.js +0 -23
- package/tests/unit/state/apply/txOperation/txOperationInvalidDeploymentEntryScenario.js +0 -48
- package/tests/unit/state/apply/txOperation/txOperationInvalidFeeAmountScenario.js +0 -39
- package/tests/unit/state/apply/txOperation/txOperationInvalidSubnetCreatorAddressScenario.js +0 -46
- package/tests/unit/state/apply/txOperation/txOperationRequesterCreatorHappyPathScenario.js +0 -21
- package/tests/unit/state/apply/txOperation/txOperationScenarioHelpers.js +0 -432
- package/tests/unit/state/apply/txOperation/txOperationStandardHappyPathScenario.js +0 -21
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddCreatorBalanceFailureScenario.js +0 -26
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddValidatorBalanceFailureScenario.js +0 -25
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddValidatorBonusFailureScenario.js +0 -27
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeCreatorEntryScenario.js +0 -18
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeRequesterEntryScenario.js +0 -17
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeValidatorEntryScenario.js +0 -31
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardBypassScenario.js +0 -49
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardScenarioFactory.js +0 -93
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInsufficientRequesterBalanceScenario.js +0 -28
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidCreatorBalanceScenario.js +0 -29
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidRequesterBalanceScenario.js +0 -28
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidRequesterEntryScenario.js +0 -17
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidValidatorBalanceScenario.js +0 -33
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeMissingCreatorEntryScenario.js +0 -18
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeSubtractFailureScenario.js +0 -25
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateCreatorBalanceFailureScenario.js +0 -26
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateFailureScenario.js +0 -25
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateValidatorBalanceFailureScenario.js +0 -26
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateValidatorBonusFailureScenario.js +0 -27
- package/tests/unit/state/apply/txOperation/txOperationValidatorCreatorHappyPathScenario.js +0 -21
- package/tests/unit/state/stateModule.test.js +0 -23
- package/tests/unit/state/stateTestUtils.js +0 -32
- package/tests/unit/state/utils/address.test.js +0 -63
- package/tests/unit/state/utils/adminEntry.test.js +0 -52
- package/tests/unit/state/utils/balance.test.js +0 -320
- package/tests/unit/state/utils/lengthEntry.test.js +0 -54
- package/tests/unit/state/utils/nodeEntry.test.js +0 -298
- package/tests/unit/state/utils/roles.test.js +0 -44
- package/tests/unit/unit.test.js +0 -14
- package/tests/unit/utils/amountSerialization/amountSerialization.test.js +0 -237
- package/tests/unit/utils/buffer/buffer.test.js +0 -251
- package/tests/unit/utils/check/adminControlOperation.test.js +0 -156
- package/tests/unit/utils/check/balanceInitializationOperation.test.js +0 -54
- package/tests/unit/utils/check/bootstrapDeploymentOperation.test.js +0 -104
- package/tests/unit/utils/check/check.test.js +0 -17
- package/tests/unit/utils/check/common.test.js +0 -419
- package/tests/unit/utils/check/coreAdminOperation.test.js +0 -95
- package/tests/unit/utils/check/roleAccessOperation.test.js +0 -255
- package/tests/unit/utils/check/transactionOperation.test.js +0 -107
- package/tests/unit/utils/check/transferOperation.test.js +0 -102
- package/tests/unit/utils/fileUtils/readAddressesFromWhitelistFile.test.js +0 -95
- package/tests/unit/utils/fileUtils/readBalanceMigrationFile.test.js +0 -149
- package/tests/unit/utils/helpers/helpers.test.js +0 -11
- package/tests/unit/utils/helpers/isHexString.test.js +0 -12
- package/tests/unit/utils/helpers/normalizeHex.test.js +0 -82
- package/tests/unit/utils/migrationUtils/validateAddressFromIncomingFile.test.js +0 -100
- package/tests/unit/utils/normalizers/normalizers.test.js +0 -469
- package/tests/unit/utils/protobuf/applyOperations.test.js +0 -91
- package/tests/unit/utils/protobuf/operationHelpers.test.js +0 -305
- package/tests/unit/utils/protobuf/protobuf.test.js +0 -12
- package/tests/unit/utils/type/type.test.js +0 -25
- package/tests/unit/utils/utils.test.js +0 -20
- package/whitelist/.gitkeep +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import tracCryptoApi from 'trac-crypto-api';
|
|
2
2
|
import b4a from 'b4a';
|
|
3
3
|
import {createMessage, safeWriteUInt32BE, idToBuffer, timestampToBuffer} from "../../../utils/buffer.js";
|
|
4
4
|
import {NetworkOperationType, ResultCode} from '../../../utils/constants.js';
|
|
5
|
-
import {
|
|
5
|
+
import {isAddressValid} from "../../../core/state/utils/address.js";
|
|
6
6
|
import {encodeCapabilities} from "../../../utils/buffer.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Builder for v1 internal network protocol messages.
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {IWallet} wallet
|
|
11
11
|
* @param {Config} config
|
|
12
12
|
*/
|
|
13
13
|
class NetworkMessageBuilder {
|
|
@@ -16,16 +16,17 @@ class NetworkMessageBuilder {
|
|
|
16
16
|
#capabilities;
|
|
17
17
|
#id;
|
|
18
18
|
#timestamp;
|
|
19
|
-
#issuerAddress;
|
|
20
19
|
#resultCode;
|
|
21
20
|
#data;
|
|
21
|
+
#proof;
|
|
22
|
+
#timestamp_ledger;
|
|
22
23
|
#header;
|
|
23
24
|
#payloadKey;
|
|
24
25
|
#body;
|
|
25
26
|
#config;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
* @param {
|
|
29
|
+
* @param {IWallet} wallet
|
|
29
30
|
* @param {Config} config
|
|
30
31
|
*/
|
|
31
32
|
constructor(wallet, config) {
|
|
@@ -50,14 +51,6 @@ class NetworkMessageBuilder {
|
|
|
50
51
|
return this;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
setIssuerAddress(issuerAddress) {
|
|
54
|
-
if (!isAddressValid(issuerAddress, this.#config.addressPrefix)) {
|
|
55
|
-
throw new Error('Issuer TRAC address must be valid.');
|
|
56
|
-
}
|
|
57
|
-
this.#issuerAddress = issuerAddress;
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
54
|
setCapabilities(capabilities = []) {
|
|
62
55
|
if (!Array.isArray(capabilities) || !capabilities.every(capability => typeof capability === 'string')) {
|
|
63
56
|
throw new Error('Capabilities must be a string array.');
|
|
@@ -85,6 +78,9 @@ class NetworkMessageBuilder {
|
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
setData(data) {
|
|
81
|
+
// case when response have to be empty.
|
|
82
|
+
if (data === undefined || data === null) data = b4a.alloc(0);
|
|
83
|
+
|
|
88
84
|
if (!b4a.isBuffer(data)) {
|
|
89
85
|
throw new Error(`Data must be a buffer.`);
|
|
90
86
|
}
|
|
@@ -92,6 +88,30 @@ class NetworkMessageBuilder {
|
|
|
92
88
|
return this;
|
|
93
89
|
}
|
|
94
90
|
|
|
91
|
+
setProof(proof) {
|
|
92
|
+
if (proof === undefined || proof === null) proof = b4a.alloc(0);
|
|
93
|
+
if (!b4a.isBuffer(proof)) {
|
|
94
|
+
throw new Error(`Proof must be a buffer.`);
|
|
95
|
+
}
|
|
96
|
+
this.#proof = proof;
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setTimestampLedger(timestamp) {
|
|
101
|
+
if (timestamp === undefined || timestamp === null) {
|
|
102
|
+
this.#timestamp_ledger = null;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const value = timestamp instanceof Date ? timestamp.getTime() : timestamp;
|
|
107
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
108
|
+
throw new Error('timestamp must be a non-negative safe integer or Date.');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.#timestamp_ledger = value;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
95
115
|
#setHeader() {
|
|
96
116
|
if (!this.#type) throw new Error('Header requires type to be set');
|
|
97
117
|
if (!this.#id) throw new Error('Header requires id to be set');
|
|
@@ -107,78 +127,8 @@ class NetworkMessageBuilder {
|
|
|
107
127
|
return this;
|
|
108
128
|
}
|
|
109
129
|
|
|
110
|
-
async #buildValidatorConnectionRequestPayload() {
|
|
111
|
-
const issuer = this.#issuerAddress
|
|
112
|
-
if (!isAddressValid(issuer, this.#config.addressPrefix)) {
|
|
113
|
-
throw new Error('Issuer address must be a valid TRAC address');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (this.#issuerAddress !== this.#wallet.address) {
|
|
117
|
-
throw new Error('Issuer address must be the signer address');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const nonce = PeerWallet.generateNonce();
|
|
121
|
-
const tsBuf = timestampToBuffer(this.#timestamp);
|
|
122
|
-
const idBuf = idToBuffer(this.#id);
|
|
123
|
-
const message = createMessage(
|
|
124
|
-
this.#type,
|
|
125
|
-
idBuf,
|
|
126
|
-
tsBuf,
|
|
127
|
-
addressToBuffer(issuer, this.#config.addressPrefix),
|
|
128
|
-
nonce,
|
|
129
|
-
encodeCapabilities(this.#capabilities),
|
|
130
|
-
);
|
|
131
|
-
const hash = await PeerWallet.blake3(message);
|
|
132
|
-
const signature = this.#wallet.sign(hash);
|
|
133
|
-
|
|
134
|
-
this.#payloadKey = 'validator_connection_request';
|
|
135
|
-
this.#body = {
|
|
136
|
-
issuer_address: issuer,
|
|
137
|
-
nonce,
|
|
138
|
-
signature
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async #buildValidatorConnectionResponsePayload() {
|
|
143
|
-
const issuer = this.#issuerAddress
|
|
144
|
-
if (!isAddressValid(issuer, this.#config.addressPrefix)) {
|
|
145
|
-
throw new Error('Issuer address must be a valid TRAC address');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (this.#issuerAddress === this.#wallet.address) {
|
|
149
|
-
throw new Error('Issuer address must be the different than the signer address');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (this.#resultCode === null || this.#resultCode === undefined) {
|
|
153
|
-
throw new Error('Result code must be set before building validator connection response');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const nonce = PeerWallet.generateNonce();
|
|
157
|
-
const tsBuf = timestampToBuffer(this.#timestamp);
|
|
158
|
-
const idBuf = idToBuffer(this.#id);
|
|
159
|
-
const message = createMessage(
|
|
160
|
-
this.#type,
|
|
161
|
-
idBuf,
|
|
162
|
-
tsBuf,
|
|
163
|
-
addressToBuffer(issuer, this.#config.addressPrefix),
|
|
164
|
-
nonce,
|
|
165
|
-
safeWriteUInt32BE(this.#resultCode, 0),
|
|
166
|
-
encodeCapabilities(this.#capabilities),
|
|
167
|
-
);
|
|
168
|
-
const hash = await PeerWallet.blake3(message);
|
|
169
|
-
const signature = this.#wallet.sign(hash);
|
|
170
|
-
|
|
171
|
-
this.#payloadKey = 'validator_connection_response';
|
|
172
|
-
this.#body = {
|
|
173
|
-
issuer_address: issuer,
|
|
174
|
-
nonce,
|
|
175
|
-
signature,
|
|
176
|
-
result: this.#resultCode
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
130
|
async #buildLivenessRequestPayload() {
|
|
181
|
-
const nonce =
|
|
131
|
+
const nonce = tracCryptoApi.nonce.generate();
|
|
182
132
|
const tsBuf = timestampToBuffer(this.#timestamp);
|
|
183
133
|
const idBuf = idToBuffer(this.#id);
|
|
184
134
|
const message = createMessage(
|
|
@@ -188,7 +138,7 @@ class NetworkMessageBuilder {
|
|
|
188
138
|
nonce,
|
|
189
139
|
encodeCapabilities(this.#capabilities),
|
|
190
140
|
);
|
|
191
|
-
const hash = await
|
|
141
|
+
const hash = await tracCryptoApi.hash.blake3(message);
|
|
192
142
|
const signature = this.#wallet.sign(hash);
|
|
193
143
|
|
|
194
144
|
this.#payloadKey = 'liveness_request';
|
|
@@ -203,7 +153,7 @@ class NetworkMessageBuilder {
|
|
|
203
153
|
throw new Error('Result code must be set before building liveness response');
|
|
204
154
|
}
|
|
205
155
|
|
|
206
|
-
const nonce =
|
|
156
|
+
const nonce = tracCryptoApi.nonce.generate();
|
|
207
157
|
const tsBuf = timestampToBuffer(this.#timestamp);
|
|
208
158
|
const idBuf = idToBuffer(this.#id);
|
|
209
159
|
const message = createMessage(
|
|
@@ -214,7 +164,7 @@ class NetworkMessageBuilder {
|
|
|
214
164
|
safeWriteUInt32BE(this.#resultCode, 0),
|
|
215
165
|
encodeCapabilities(this.#capabilities),
|
|
216
166
|
);
|
|
217
|
-
const hash = await
|
|
167
|
+
const hash = await tracCryptoApi.hash.blake3(message);
|
|
218
168
|
const signature = this.#wallet.sign(hash);
|
|
219
169
|
|
|
220
170
|
this.#payloadKey = 'liveness_response';
|
|
@@ -229,7 +179,7 @@ class NetworkMessageBuilder {
|
|
|
229
179
|
if (!b4a.isBuffer(this.#data)) {
|
|
230
180
|
throw new Error('Data must be set before building broadcast transaction request');
|
|
231
181
|
}
|
|
232
|
-
const nonce =
|
|
182
|
+
const nonce = tracCryptoApi.nonce.generate();
|
|
233
183
|
const tsBuf = timestampToBuffer(this.#timestamp);
|
|
234
184
|
const idBuf = idToBuffer(this.#id);
|
|
235
185
|
const message = createMessage(
|
|
@@ -240,7 +190,7 @@ class NetworkMessageBuilder {
|
|
|
240
190
|
nonce,
|
|
241
191
|
encodeCapabilities(this.#capabilities),
|
|
242
192
|
);
|
|
243
|
-
const hash = await
|
|
193
|
+
const hash = await tracCryptoApi.hash.blake3(message);
|
|
244
194
|
const signature = this.#wallet.sign(hash);
|
|
245
195
|
|
|
246
196
|
this.#payloadKey = 'broadcast_transaction_request';
|
|
@@ -255,24 +205,53 @@ class NetworkMessageBuilder {
|
|
|
255
205
|
if (this.#resultCode === null || this.#resultCode === undefined) {
|
|
256
206
|
throw new Error('Result code must be set before building broadcast transaction response');
|
|
257
207
|
}
|
|
258
|
-
const nonce =
|
|
208
|
+
const nonce = tracCryptoApi.nonce.generate();
|
|
259
209
|
const tsBuf = timestampToBuffer(this.#timestamp);
|
|
260
210
|
const idBuf = idToBuffer(this.#id);
|
|
211
|
+
const proof = b4a.isBuffer(this.#proof) ? this.#proof : b4a.alloc(0);
|
|
212
|
+
const hasProof = proof.length > 0;
|
|
213
|
+
const timestamp = Number.isSafeInteger(this.#timestamp_ledger) ? this.#timestamp_ledger : 0;
|
|
214
|
+
const hasTimestamp = timestamp > 0;
|
|
215
|
+
|
|
216
|
+
if (this.#resultCode === ResultCode.OK) {
|
|
217
|
+
if (!hasProof || !hasTimestamp) {
|
|
218
|
+
throw new Error('Result code OK requires non-empty proof and timestamp > 0.');
|
|
219
|
+
}
|
|
220
|
+
} else if (this.#resultCode === ResultCode.TX_ACCEPTED_PROOF_UNAVAILABLE) {
|
|
221
|
+
if (hasProof) {
|
|
222
|
+
throw new Error('Result code TX_ACCEPTED_PROOF_UNAVAILABLE requires empty proof.');
|
|
223
|
+
}
|
|
224
|
+
if (!hasTimestamp) {
|
|
225
|
+
throw new Error('Result code TX_ACCEPTED_PROOF_UNAVAILABLE requires timestamp > 0.');
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
if (hasProof) {
|
|
229
|
+
throw new Error('Non-OK result code requires empty proof.');
|
|
230
|
+
}
|
|
231
|
+
if (timestamp !== 0) {
|
|
232
|
+
throw new Error('Non-OK result code requires timestamp to be 0, except TX_ACCEPTED_PROOF_UNAVAILABLE.');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
261
236
|
const message = createMessage(
|
|
262
237
|
this.#type,
|
|
263
238
|
idBuf,
|
|
264
239
|
tsBuf,
|
|
265
240
|
nonce,
|
|
241
|
+
proof,
|
|
242
|
+
timestampToBuffer(timestamp),
|
|
266
243
|
safeWriteUInt32BE(this.#resultCode, 0),
|
|
267
244
|
encodeCapabilities(this.#capabilities),
|
|
268
245
|
);
|
|
269
|
-
const hash = await PeerWallet.blake3(message);
|
|
270
|
-
const signature = this.#wallet.sign(hash);
|
|
271
246
|
|
|
247
|
+
const hash = await tracCryptoApi.hash.blake3(message);
|
|
248
|
+
const signature = this.#wallet.sign(hash);
|
|
272
249
|
this.#payloadKey = 'broadcast_transaction_response';
|
|
273
250
|
this.#body = {
|
|
274
251
|
nonce,
|
|
275
252
|
signature,
|
|
253
|
+
proof,
|
|
254
|
+
timestamp: timestamp,
|
|
276
255
|
result: this.#resultCode
|
|
277
256
|
};
|
|
278
257
|
}
|
|
@@ -281,14 +260,6 @@ class NetworkMessageBuilder {
|
|
|
281
260
|
this.#setHeader();
|
|
282
261
|
|
|
283
262
|
switch (this.#type) {
|
|
284
|
-
case NetworkOperationType.VALIDATOR_CONNECTION_REQUEST: {
|
|
285
|
-
await this.#buildValidatorConnectionRequestPayload();
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
case NetworkOperationType.VALIDATOR_CONNECTION_RESPONSE: {
|
|
289
|
-
await this.#buildValidatorConnectionResponsePayload();
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
263
|
case NetworkOperationType.LIVENESS_REQUEST: {
|
|
293
264
|
await this.#buildLivenessRequestPayload();
|
|
294
265
|
break;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {NetworkOperationType} from '../../../utils/constants.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Director for v1 internal network protocol messages.
|
|
@@ -13,47 +13,6 @@ class NetworkMessageDirector {
|
|
|
13
13
|
this.#builder = builderInstance;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Build a validator connection request message.
|
|
18
|
-
* @param {string} id
|
|
19
|
-
* @param {string} issuerAddress
|
|
20
|
-
* @param {string[]} capabilities
|
|
21
|
-
* @returns {Promise<object>}
|
|
22
|
-
*/
|
|
23
|
-
async buildValidatorConnectionRequest(id, issuerAddress, capabilities) {
|
|
24
|
-
await this.#builder
|
|
25
|
-
.setType(NetworkOperationType.VALIDATOR_CONNECTION_REQUEST)
|
|
26
|
-
.setId(id)
|
|
27
|
-
.setTimestamp()
|
|
28
|
-
.setIssuerAddress(issuerAddress)
|
|
29
|
-
.setCapabilities(capabilities)
|
|
30
|
-
.buildPayload()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return this.#builder.getResult();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Build a validator connection response message.
|
|
38
|
-
* @param {string} id
|
|
39
|
-
* @param {string} issuerAddress
|
|
40
|
-
* @param {string[]} capabilities
|
|
41
|
-
* @param {number} statusCode
|
|
42
|
-
* @returns {Promise<object>}
|
|
43
|
-
*/
|
|
44
|
-
async buildValidatorConnectionResponse(id, issuerAddress, capabilities, statusCode) {
|
|
45
|
-
await this.#builder
|
|
46
|
-
.setType(NetworkOperationType.VALIDATOR_CONNECTION_RESPONSE)
|
|
47
|
-
.setId(id)
|
|
48
|
-
.setTimestamp()
|
|
49
|
-
.setIssuerAddress(issuerAddress)
|
|
50
|
-
.setCapabilities(capabilities)
|
|
51
|
-
.setResultCode(statusCode)
|
|
52
|
-
.buildPayload()
|
|
53
|
-
|
|
54
|
-
return this.#builder.getResult();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
16
|
/**
|
|
58
17
|
* Build a liveness request message.
|
|
59
18
|
* @param {string} id
|
|
@@ -61,12 +20,11 @@ class NetworkMessageDirector {
|
|
|
61
20
|
* @param {string[]} capabilities
|
|
62
21
|
* @returns {Promise<object>}
|
|
63
22
|
*/
|
|
64
|
-
async buildLivenessRequest(id,
|
|
23
|
+
async buildLivenessRequest(id, capabilities) {
|
|
65
24
|
await this.#builder
|
|
66
25
|
.setType(NetworkOperationType.LIVENESS_REQUEST)
|
|
67
26
|
.setId(id)
|
|
68
27
|
.setTimestamp()
|
|
69
|
-
.setData(data)
|
|
70
28
|
.setCapabilities(capabilities)
|
|
71
29
|
.buildPayload();
|
|
72
30
|
|
|
@@ -76,17 +34,15 @@ class NetworkMessageDirector {
|
|
|
76
34
|
/**
|
|
77
35
|
* Build a liveness response message.
|
|
78
36
|
* @param {string} id
|
|
79
|
-
* @param {Buffer} data
|
|
80
37
|
* @param {string[]} capabilities
|
|
81
38
|
* @param {number} statusCode
|
|
82
39
|
* @returns {Promise<object>}
|
|
83
40
|
*/
|
|
84
|
-
async buildLivenessResponse(id,
|
|
41
|
+
async buildLivenessResponse(id, capabilities, statusCode) {
|
|
85
42
|
await this.#builder
|
|
86
43
|
.setType(NetworkOperationType.LIVENESS_RESPONSE)
|
|
87
44
|
.setId(id)
|
|
88
45
|
.setTimestamp()
|
|
89
|
-
.setData(data)
|
|
90
46
|
.setCapabilities(capabilities)
|
|
91
47
|
.setResultCode(statusCode)
|
|
92
48
|
.buildPayload();
|
|
@@ -115,18 +71,28 @@ class NetworkMessageDirector {
|
|
|
115
71
|
|
|
116
72
|
/**
|
|
117
73
|
* Build a broadcast transaction response message.
|
|
74
|
+
*
|
|
75
|
+
* Allowed payload variants:
|
|
76
|
+
* 1) resultCode === OK - proof must be non-empty and timestamp must be > 0.
|
|
77
|
+
* 2) resultCode === TX_ACCEPTED_PROOF_UNAVAILABLE - proof must be empty and timestamp must be > 0.
|
|
78
|
+
* 3) resultCode !== OK and resultCode !== TX_ACCEPTED_PROOF_UNAVAILABLE - proof must be empty and timestamp must be 0.
|
|
79
|
+
*
|
|
118
80
|
* @param {string} id
|
|
119
81
|
* @param {string[]} capabilities
|
|
120
|
-
* @param {number}
|
|
82
|
+
* @param {number} resultCode
|
|
83
|
+
* @param {Buffer|null|undefined} proof
|
|
84
|
+
* @param {number|Date|null|undefined} timestamp - When transaction has been appended by the validator
|
|
121
85
|
* @returns {Promise<object>}
|
|
122
86
|
*/
|
|
123
|
-
async buildBroadcastTransactionResponse(id, capabilities,
|
|
87
|
+
async buildBroadcastTransactionResponse(id, capabilities, resultCode, proof = null, timestamp = null) {
|
|
124
88
|
await this.#builder
|
|
125
89
|
.setType(NetworkOperationType.BROADCAST_TRANSACTION_RESPONSE)
|
|
126
90
|
.setId(id)
|
|
127
91
|
.setTimestamp()
|
|
128
92
|
.setCapabilities(capabilities)
|
|
129
|
-
.
|
|
93
|
+
.setProof(proof)
|
|
94
|
+
.setTimestampLedger(timestamp)
|
|
95
|
+
.setResultCode(resultCode)
|
|
130
96
|
.buildPayload();
|
|
131
97
|
|
|
132
98
|
return this.#builder.getResult();
|
|
@@ -3,7 +3,7 @@ import NetworkMessageBuilder from "./NetworkMessageBuilder.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Factory helper to create a director with a fresh builder instance.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {IWallet} wallet
|
|
7
7
|
* @param {object} config
|
|
8
8
|
* @returns {NetworkMessageDirector}
|
|
9
9
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import
|
|
2
|
+
import tracCryptoApi from 'trac-crypto-api';
|
|
3
3
|
|
|
4
4
|
import { createMessage } from '../../utils/buffer.js';
|
|
5
5
|
import { OperationType } from '../../utils/constants.js';
|
|
@@ -22,7 +22,7 @@ import { isHexString } from '../../utils/helpers.js';
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Builder for partial/complete ApplyState messages.
|
|
25
|
-
* @param {
|
|
25
|
+
* @param {IWallet} wallet
|
|
26
26
|
* @param {Config} config
|
|
27
27
|
*/
|
|
28
28
|
class ApplyStateMessageBuilder {
|
|
@@ -257,7 +257,7 @@ class ApplyStateMessageBuilder {
|
|
|
257
257
|
throw new Error(`Operation type ${this.#operationType} is not supported for partial build.`);
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
const nonce =
|
|
260
|
+
const nonce = tracCryptoApi.nonce.generate();
|
|
261
261
|
let msg;
|
|
262
262
|
|
|
263
263
|
switch (this.#operationType) {
|
|
@@ -329,7 +329,7 @@ class ApplyStateMessageBuilder {
|
|
|
329
329
|
throw new Error(`Unsupported operation type: ${this.#operationType}`);
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
const tx = await
|
|
332
|
+
const tx = await tracCryptoApi.hash.blake3(msg);
|
|
333
333
|
const signature = this.#wallet.sign(tx);
|
|
334
334
|
|
|
335
335
|
if (isBootstrapDeployment(this.#operationType)) {
|
|
@@ -378,7 +378,7 @@ class ApplyStateMessageBuilder {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
async #buildCompleteBody() {
|
|
381
|
-
const nonce =
|
|
381
|
+
const nonce = tracCryptoApi.nonce.generate();
|
|
382
382
|
let msg;
|
|
383
383
|
|
|
384
384
|
switch (this.#operationType) {
|
|
@@ -503,7 +503,7 @@ class ApplyStateMessageBuilder {
|
|
|
503
503
|
throw new Error(`Unsupported operation type: ${this.#operationType}`);
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
const tx = await
|
|
506
|
+
const tx = await tracCryptoApi.hash.blake3(msg);
|
|
507
507
|
const signature = this.#wallet.sign(tx);
|
|
508
508
|
const validatorAddress = addressToBuffer(this.#wallet.address, this.#config.addressPrefix);
|
|
509
509
|
|
|
@@ -3,7 +3,7 @@ import ApplyStateMessageBuilder from "./ApplyStateMessageBuilder.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Factory helper to create a director with a builder instance.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {IWallet} wallet
|
|
7
7
|
* @param {object} config
|
|
8
8
|
* @returns {ApplyStateMessageDirector}
|
|
9
9
|
*/
|
package/src/utils/Scheduler.js
CHANGED
|
@@ -42,14 +42,6 @@ class Scheduler {
|
|
|
42
42
|
return this.#defaultInterval;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
get timer() {
|
|
46
|
-
return this.#timer;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get currentWorkerRun() {
|
|
50
|
-
return this.#currentWorkerRun;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
45
|
static #validateDelay(delayMs, scope = 'delayMs') {
|
|
54
46
|
const ms = Number(delayMs);
|
|
55
47
|
if (!Number.isFinite(ms) || ms < 0) {
|
package/src/utils/buffer.js
CHANGED
package/src/utils/check.js
CHANGED
|
@@ -41,7 +41,7 @@ class Check {
|
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
43
|
const isBuffer = b4a.isBuffer;
|
|
44
|
-
this.#validator.add("buffer", function ({ schema, messages },
|
|
44
|
+
this.#validator.add("buffer", function ({ schema, messages }, _path, _context) {
|
|
45
45
|
return {
|
|
46
46
|
source:
|
|
47
47
|
`
|
|
@@ -50,11 +50,11 @@ class Check {
|
|
|
50
50
|
}
|
|
51
51
|
if (value.length !== ${schema.length}) {
|
|
52
52
|
${this.makeError({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
type: "bufferLength",
|
|
54
|
+
expected: schema.length,
|
|
55
|
+
actual: "value.length",
|
|
56
|
+
messages
|
|
57
|
+
})}
|
|
58
58
|
}
|
|
59
59
|
let isEmpty = true;
|
|
60
60
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -71,7 +71,7 @@ class Check {
|
|
|
71
71
|
};
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
this.#validator.add("buffer_amount", function ({ schema, messages },
|
|
74
|
+
this.#validator.add("buffer_amount", function ({ schema, messages }, _path, _context) {
|
|
75
75
|
return {
|
|
76
76
|
source:
|
|
77
77
|
`
|
|
@@ -80,11 +80,11 @@ class Check {
|
|
|
80
80
|
}
|
|
81
81
|
if (value.length !== ${schema.length}) {
|
|
82
82
|
${this.makeError({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
type: "bufferLength",
|
|
84
|
+
expected: schema.length,
|
|
85
|
+
actual: "value.length",
|
|
86
|
+
messages
|
|
87
|
+
})}
|
|
88
88
|
}
|
|
89
89
|
return value;
|
|
90
90
|
`
|
|
@@ -523,4 +523,3 @@ class Check {
|
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
export default Check;
|
|
526
|
-
|
package/src/utils/constants.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { OperationType as ApplyOperationType } from './protobuf/applyOperations.cjs';
|
|
2
|
-
import
|
|
2
|
+
import networkV1Generated from './protobuf/networkV1.generated.cjs';
|
|
3
3
|
import b4a from 'b4a'
|
|
4
4
|
// TODO: We are going to have a lot of contstants. It would be good, to separate them into different files.
|
|
5
5
|
|
|
6
|
+
const { MessageType: NetworkMessageType, ResultCode: NetworkResultCode } = networkV1Generated.network.v1;
|
|
7
|
+
|
|
6
8
|
//ATTENTION - THIS IS USED IN THE APPLY FUNCTION!
|
|
7
9
|
export const EntryType = Object.freeze({
|
|
8
10
|
ADMIN: 'admin',
|
|
@@ -34,8 +36,6 @@ export const OperationType = Object.freeze({
|
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
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
39
|
LIVENESS_REQUEST: NetworkMessageType.MESSAGE_TYPE_LIVENESS_REQUEST,
|
|
40
40
|
LIVENESS_RESPONSE: NetworkMessageType.MESSAGE_TYPE_LIVENESS_RESPONSE,
|
|
41
41
|
BROADCAST_TRANSACTION_REQUEST: NetworkMessageType.MESSAGE_TYPE_BROADCAST_TRANSACTION_REQUEST,
|
|
@@ -43,12 +43,68 @@ export const NetworkOperationType = Object.freeze({
|
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
export const ResultCode = Object.freeze({
|
|
46
|
+
UNSPECIFIED: NetworkResultCode.RESULT_CODE_UNSPECIFIED,
|
|
46
47
|
OK: NetworkResultCode.RESULT_CODE_OK,
|
|
47
48
|
INVALID_PAYLOAD: NetworkResultCode.RESULT_CODE_INVALID_PAYLOAD,
|
|
48
|
-
UNSUPPORTED_VERSION: NetworkResultCode.RESULT_CODE_UNSUPPORTED_VERSION,
|
|
49
49
|
RATE_LIMITED: NetworkResultCode.RESULT_CODE_RATE_LIMITED,
|
|
50
|
-
TIMEOUT: NetworkResultCode.RESULT_CODE_TIMEOUT,
|
|
51
50
|
SIGNATURE_INVALID: NetworkResultCode.RESULT_CODE_SIGNATURE_INVALID,
|
|
51
|
+
UNEXPECTED_ERROR: NetworkResultCode.RESULT_CODE_UNEXPECTED_ERROR,
|
|
52
|
+
TIMEOUT: NetworkResultCode.RESULT_CODE_TIMEOUT,
|
|
53
|
+
NODE_HAS_NO_WRITE_ACCESS: NetworkResultCode.RESULT_CODE_NODE_HAS_NO_WRITE_ACCESS,
|
|
54
|
+
TX_ACCEPTED_PROOF_UNAVAILABLE: NetworkResultCode.RESULT_CODE_TX_ACCEPTED_PROOF_UNAVAILABLE,
|
|
55
|
+
NODE_OVERLOADED: NetworkResultCode.RESULT_CODE_NODE_OVERLOADED,
|
|
56
|
+
TX_ALREADY_PENDING: NetworkResultCode.RESULT_CODE_TX_ALREADY_PENDING,
|
|
57
|
+
OPERATION_TYPE_UNKNOWN: NetworkResultCode.RESULT_CODE_OPERATION_TYPE_UNKNOWN,
|
|
58
|
+
SCHEMA_VALIDATION_FAILED: NetworkResultCode.RESULT_CODE_SCHEMA_VALIDATION_FAILED,
|
|
59
|
+
REQUESTER_ADDRESS_INVALID: NetworkResultCode.RESULT_CODE_REQUESTER_ADDRESS_INVALID,
|
|
60
|
+
REQUESTER_PUBLIC_KEY_INVALID: NetworkResultCode.RESULT_CODE_REQUESTER_PUBLIC_KEY_INVALID,
|
|
61
|
+
TX_HASH_MISMATCH: NetworkResultCode.RESULT_CODE_TX_HASH_MISMATCH,
|
|
62
|
+
TX_SIGNATURE_INVALID: NetworkResultCode.RESULT_CODE_TX_SIGNATURE_INVALID,
|
|
63
|
+
TX_EXPIRED: NetworkResultCode.RESULT_CODE_TX_EXPIRED,
|
|
64
|
+
TX_ALREADY_EXISTS: NetworkResultCode.RESULT_CODE_TX_ALREADY_EXISTS,
|
|
65
|
+
OPERATION_ALREADY_COMPLETED: NetworkResultCode.RESULT_CODE_OPERATION_ALREADY_COMPLETED,
|
|
66
|
+
REQUESTER_NOT_FOUND: NetworkResultCode.RESULT_CODE_REQUESTER_NOT_FOUND,
|
|
67
|
+
INSUFFICIENT_FEE_BALANCE: NetworkResultCode.RESULT_CODE_INSUFFICIENT_FEE_BALANCE,
|
|
68
|
+
EXTERNAL_BOOTSTRAP_EQUALS_MSB_BOOTSTRAP: NetworkResultCode.RESULT_CODE_EXTERNAL_BOOTSTRAP_EQUALS_MSB_BOOTSTRAP,
|
|
69
|
+
SELF_VALIDATION_FORBIDDEN: NetworkResultCode.RESULT_CODE_SELF_VALIDATION_FORBIDDEN,
|
|
70
|
+
ROLE_NODE_ENTRY_NOT_FOUND: NetworkResultCode.RESULT_CODE_ROLE_NODE_ENTRY_NOT_FOUND,
|
|
71
|
+
ROLE_NODE_ALREADY_WRITER: NetworkResultCode.RESULT_CODE_ROLE_NODE_ALREADY_WRITER,
|
|
72
|
+
ROLE_NODE_NOT_WHITELISTED: NetworkResultCode.RESULT_CODE_ROLE_NODE_NOT_WHITELISTED,
|
|
73
|
+
ROLE_NODE_NOT_WRITER: NetworkResultCode.RESULT_CODE_ROLE_NODE_NOT_WRITER,
|
|
74
|
+
ROLE_NODE_IS_INDEXER: NetworkResultCode.RESULT_CODE_ROLE_NODE_IS_INDEXER,
|
|
75
|
+
ROLE_ADMIN_ENTRY_MISSING: NetworkResultCode.RESULT_CODE_ROLE_ADMIN_ENTRY_MISSING,
|
|
76
|
+
ROLE_INVALID_RECOVERY_CASE: NetworkResultCode.RESULT_CODE_ROLE_INVALID_RECOVERY_CASE,
|
|
77
|
+
ROLE_UNKNOWN_OPERATION: NetworkResultCode.RESULT_CODE_ROLE_UNKNOWN_OPERATION,
|
|
78
|
+
ROLE_INVALID_WRITER_KEY: NetworkResultCode.RESULT_CODE_ROLE_INVALID_WRITER_KEY,
|
|
79
|
+
ROLE_INSUFFICIENT_FEE_BALANCE: NetworkResultCode.RESULT_CODE_ROLE_INSUFFICIENT_FEE_BALANCE,
|
|
80
|
+
MSB_BOOTSTRAP_MISMATCH: NetworkResultCode.RESULT_CODE_MSB_BOOTSTRAP_MISMATCH,
|
|
81
|
+
EXTERNAL_BOOTSTRAP_NOT_DEPLOYED: NetworkResultCode.RESULT_CODE_EXTERNAL_BOOTSTRAP_NOT_DEPLOYED,
|
|
82
|
+
EXTERNAL_BOOTSTRAP_TX_MISSING: NetworkResultCode.RESULT_CODE_EXTERNAL_BOOTSTRAP_TX_MISSING,
|
|
83
|
+
EXTERNAL_BOOTSTRAP_MISMATCH: NetworkResultCode.RESULT_CODE_EXTERNAL_BOOTSTRAP_MISMATCH,
|
|
84
|
+
BOOTSTRAP_ALREADY_EXISTS: NetworkResultCode.RESULT_CODE_BOOTSTRAP_ALREADY_EXISTS,
|
|
85
|
+
TRANSFER_RECIPIENT_ADDRESS_INVALID: NetworkResultCode.RESULT_CODE_TRANSFER_RECIPIENT_ADDRESS_INVALID,
|
|
86
|
+
TRANSFER_RECIPIENT_PUBLIC_KEY_INVALID: NetworkResultCode.RESULT_CODE_TRANSFER_RECIPIENT_PUBLIC_KEY_INVALID,
|
|
87
|
+
TRANSFER_AMOUNT_TOO_LARGE: NetworkResultCode.RESULT_CODE_TRANSFER_AMOUNT_TOO_LARGE,
|
|
88
|
+
TRANSFER_SENDER_NOT_FOUND: NetworkResultCode.RESULT_CODE_TRANSFER_SENDER_NOT_FOUND,
|
|
89
|
+
TRANSFER_INSUFFICIENT_BALANCE: NetworkResultCode.RESULT_CODE_TRANSFER_INSUFFICIENT_BALANCE,
|
|
90
|
+
TRANSFER_RECIPIENT_BALANCE_OVERFLOW: NetworkResultCode.RESULT_CODE_TRANSFER_RECIPIENT_BALANCE_OVERFLOW,
|
|
91
|
+
TX_HASH_INVALID_FORMAT: NetworkResultCode.RESULT_CODE_TX_HASH_INVALID_FORMAT,
|
|
92
|
+
INTERNAL_ENQUEUE_VALIDATION_FAILED: NetworkResultCode.RESULT_CODE_INTERNAL_ENQUEUE_VALIDATION_FAILED,
|
|
93
|
+
TX_COMMITTED_RECEIPT_MISSING: NetworkResultCode.RESULT_CODE_TX_COMMITTED_RECEIPT_MISSING,
|
|
94
|
+
VALIDATOR_RESPONSE_TX_TYPE_INVALID: NetworkResultCode.RESULT_CODE_VALIDATOR_RESPONSE_TX_TYPE_INVALID,
|
|
95
|
+
VALIDATOR_RESPONSE_TX_TYPE_UNKNOWN: NetworkResultCode.RESULT_CODE_VALIDATOR_RESPONSE_TX_TYPE_UNKNOWN,
|
|
96
|
+
VALIDATOR_RESPONSE_TX_TYPE_UNSUPPORTED: NetworkResultCode.RESULT_CODE_VALIDATOR_RESPONSE_TX_TYPE_UNSUPPORTED,
|
|
97
|
+
VALIDATOR_RESPONSE_SCHEMA_INVALID: NetworkResultCode.RESULT_CODE_VALIDATOR_RESPONSE_SCHEMA_INVALID,
|
|
98
|
+
PENDING_REQUEST_MISSING_TX_DATA: NetworkResultCode.RESULT_CODE_PENDING_REQUEST_MISSING_TX_DATA,
|
|
99
|
+
PROOF_PAYLOAD_MISMATCH: NetworkResultCode.RESULT_CODE_PROOF_PAYLOAD_MISMATCH,
|
|
100
|
+
VALIDATOR_WRITER_KEY_NOT_REGISTERED: NetworkResultCode.RESULT_CODE_VALIDATOR_WRITER_KEY_NOT_REGISTERED,
|
|
101
|
+
VALIDATOR_ADDRESS_MISMATCH: NetworkResultCode.RESULT_CODE_VALIDATOR_ADDRESS_MISMATCH,
|
|
102
|
+
VALIDATOR_NODE_ENTRY_NOT_FOUND: NetworkResultCode.RESULT_CODE_VALIDATOR_NODE_ENTRY_NOT_FOUND,
|
|
103
|
+
VALIDATOR_NODE_NOT_WRITER: NetworkResultCode.RESULT_CODE_VALIDATOR_NODE_NOT_WRITER,
|
|
104
|
+
VALIDATOR_WRITER_KEY_MISMATCH: NetworkResultCode.RESULT_CODE_VALIDATOR_WRITER_KEY_MISMATCH,
|
|
105
|
+
VALIDATOR_TX_OBJECT_INVALID: NetworkResultCode.RESULT_CODE_VALIDATOR_TX_OBJECT_INVALID,
|
|
106
|
+
VALIDATOR_VA_MISSING: NetworkResultCode.RESULT_CODE_VALIDATOR_VA_MISSING,
|
|
107
|
+
TX_INVALID_PAYLOAD: NetworkResultCode.RESULT_CODE_TX_INVALID_PAYLOAD
|
|
52
108
|
});
|
|
53
109
|
|
|
54
110
|
// Role managment constants
|
|
@@ -61,6 +117,7 @@ export const EventType = Object.freeze({
|
|
|
61
117
|
WARNING: 'warning',
|
|
62
118
|
VALIDATOR_CONNECTION_READY: 'validator-connection-ready',
|
|
63
119
|
VALIDATOR_CONNECTION_TIMEOUT: 'validator-connection-timeout',
|
|
120
|
+
VALIDATOR_HEALTH_CHECK: 'validator-health-check',
|
|
64
121
|
});
|
|
65
122
|
|
|
66
123
|
// Role managment constants
|
|
@@ -109,6 +166,13 @@ export const BOOTSTRAP_HEXSTRING_LENGTH = 64;
|
|
|
109
166
|
// Pool constants
|
|
110
167
|
export const BATCH_SIZE = 10;
|
|
111
168
|
|
|
169
|
+
// Operation handler constants
|
|
170
|
+
export const MAX_PARTIAL_TX_PAYLOAD_BYTE_SIZE = 3072;
|
|
171
|
+
export const V1_PROTOCOL_PAYLOAD_MAX_SIZE = 4096;
|
|
172
|
+
|
|
173
|
+
// Transaction Commit Service
|
|
174
|
+
export const TRANSACTION_COMMIT_SERVICE_BUFFER_SIZE = 1500;
|
|
175
|
+
|
|
112
176
|
// Network message constants
|
|
113
177
|
export const NETWORK_MESSAGE_TYPES = Object.freeze({
|
|
114
178
|
GET: {
|
|
@@ -123,3 +187,12 @@ export const NETWORK_MESSAGE_TYPES = Object.freeze({
|
|
|
123
187
|
NODE: 'nodeResponse'
|
|
124
188
|
},
|
|
125
189
|
});
|
|
190
|
+
|
|
191
|
+
export const NETWORK_CAPABILITIES = Object.freeze(["protocols:v1:legacy"]);
|
|
192
|
+
|
|
193
|
+
// Network tryConnect status constants
|
|
194
|
+
export const CONNECTION_STATUS = Object.freeze({
|
|
195
|
+
CONNECTED: 0,
|
|
196
|
+
PENDING: 1,
|
|
197
|
+
IGNORED: 2
|
|
198
|
+
});
|