trac-msb 0.2.4 → 0.2.6
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/.dockerignore +16 -0
- package/.github/workflows/acceptance-tests.yml +7 -0
- package/.github/workflows/publish.yml +40 -0
- package/.github/workflows/{CI.yml → unit-tests.yml} +1 -1
- package/README.md +175 -50
- package/docker-compose.yml +16 -0
- package/dockerfile +41 -0
- package/docs/fee_distribution.md +89 -0
- package/msb.mjs +12 -14
- package/package.json +8 -4
- package/rpc/constants.mjs +4 -1
- package/rpc/handlers.mjs +109 -66
- package/rpc/routes/v1.mjs +3 -1
- package/rpc/rpc_services.js +126 -0
- package/rpc/utils/confirmedParameter.mjs +17 -0
- package/rpc/utils/url.mjs +38 -0
- package/src/core/network/Network.js +27 -10
- package/src/core/network/identity/NetworkWalletFactory.js +78 -0
- package/src/core/network/services/ConnectionManager.js +2 -2
- package/src/core/network/services/ValidatorObserverService.js +7 -4
- package/src/core/state/State.js +28 -22
- package/src/index.js +197 -385
- package/src/utils/cliCommands.js +280 -0
- package/src/utils/constants.js +3 -1
- package/tests/acceptance/v1/account/account.test.mjs +123 -0
- package/tests/acceptance/v1/balance/balance.test.mjs +55 -0
- package/tests/acceptance/v1/broadcast-transaction/broadcast-transaction.test.mjs +111 -0
- package/tests/acceptance/v1/confirmed-length/confirmed-length.test.mjs +19 -0
- package/tests/acceptance/v1/fee/fee.test.mjs +11 -0
- package/tests/acceptance/v1/rpc.test.mjs +62 -291
- package/tests/acceptance/v1/tx/tx.test.mjs +98 -0
- package/tests/acceptance/v1/tx-details/tx-details.test.mjs +195 -0
- package/tests/acceptance/v1/tx-hashes/tx-hashes.test.mjs +72 -0
- package/tests/acceptance/v1/tx-payloads-bulk/tx-payloads-bulk.test.mjs +27 -0
- package/tests/acceptance/v1/txv/txv.test.mjs +11 -0
- package/tests/acceptance/v1/unconfirmed-length/unconfirmed-length.test.mjs +11 -0
- package/tests/helpers/StateNetworkFactory.js +157 -0
- package/tests/helpers/autobaseTestHelpers.js +369 -0
- package/tests/helpers/createTestSignature.js +12 -0
- package/tests/helpers/transactionPayloads.mjs +78 -0
- package/tests/unit/network/NetworkWalletFactory.test.js +156 -0
- package/tests/unit/state/apply/addAdmin/addAdminHappyPathScenario.js +38 -0
- package/tests/unit/state/apply/addAdmin/addAdminScenarioHelpers.js +273 -0
- package/tests/unit/state/apply/addAdmin/adminEntryEncodingFailureScenario.js +30 -0
- package/tests/unit/state/apply/addAdmin/adminEntryExistsScenario.js +78 -0
- package/tests/unit/state/apply/addAdmin/nodeEntryInitializationFailureScenario.js +30 -0
- package/tests/unit/state/apply/addAdmin/nonBootstrapNodeScenario.js +68 -0
- package/tests/unit/state/apply/addAdmin/state.apply.addAdmin.test.js +155 -0
- package/tests/unit/state/apply/addIndexer/addIndexerHappyPathScenario.js +39 -0
- package/tests/unit/state/apply/addIndexer/addIndexerMultipleIndexersInTheNetworkScenario.js +167 -0
- package/tests/unit/state/apply/addIndexer/addIndexerPretenderAlreadyIndexerScenario.js +21 -0
- package/tests/unit/state/apply/addIndexer/addIndexerPretenderNotWriterScenario.js +21 -0
- package/tests/unit/state/apply/addIndexer/addIndexerRemoveAndReAddScenario.js +186 -0
- package/tests/unit/state/apply/addIndexer/addIndexerScenarioHelpers.js +445 -0
- package/tests/unit/state/apply/addIndexer/addIndexerWriterKeyAlreadyRegisteredScenario.js +32 -0
- package/tests/unit/state/apply/addIndexer/state.apply.addIndexer.test.js +297 -0
- package/tests/unit/state/apply/addWriter/addWriterHappyPathScenario.js +41 -0
- package/tests/unit/state/apply/addWriter/addWriterInvalidValidatorSignatureScenario.js +32 -0
- package/tests/unit/state/apply/addWriter/addWriterNewWkScenario.js +149 -0
- package/tests/unit/state/apply/addWriter/addWriterRequesterAlreadyWriterScenario.js +21 -0
- package/tests/unit/state/apply/addWriter/addWriterRequesterBalanceInsufficientScenario.js +21 -0
- package/tests/unit/state/apply/addWriter/addWriterRequesterEntryDecodeFailureScenario.js +19 -0
- package/tests/unit/state/apply/addWriter/addWriterRequesterEntryMissingScenario.js +19 -0
- package/tests/unit/state/apply/addWriter/addWriterRequesterIndexerScenario.js +21 -0
- package/tests/unit/state/apply/addWriter/addWriterRequesterNotWhitelistedScenario.js +21 -0
- package/tests/unit/state/apply/addWriter/addWriterScenarioHelpers.js +757 -0
- package/tests/unit/state/apply/addWriter/addWriterStakeBalanceUpdateFailureScenario.js +50 -0
- package/tests/unit/state/apply/addWriter/addWriterStakeInsufficientBalanceScenario.js +29 -0
- package/tests/unit/state/apply/addWriter/addWriterStakeInvalidBalanceScenario.js +29 -0
- package/tests/unit/state/apply/addWriter/addWriterStakeInvalidEntryScenario.js +21 -0
- package/tests/unit/state/apply/addWriter/addWriterStakeStakedBalanceFailureScenario.js +37 -0
- package/tests/unit/state/apply/addWriter/addWriterStakeSubtractFailureScenario.js +42 -0
- package/tests/unit/state/apply/addWriter/addWriterValidatorRewardScenario.js +105 -0
- package/tests/unit/state/apply/addWriter/addWriterWriterKeyMismatchScenario.js +54 -0
- package/tests/unit/state/apply/addWriter/addWriterWriterKeyOwnershipScenario.js +54 -0
- package/tests/unit/state/apply/addWriter/addWriterZeroWriterKeyScenario.js +29 -0
- package/tests/unit/state/apply/addWriter/state.apply.addWriter.test.js +309 -0
- package/tests/unit/state/apply/adminRecovery/adminRecoveryHappyPathScenario.js +30 -0
- package/tests/unit/state/apply/adminRecovery/adminRecoveryScenarioHelpers.js +866 -0
- package/tests/unit/state/apply/adminRecovery/state.apply.adminRecovery.test.js +439 -0
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistBanAndReapplyScenario.js +78 -0
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistExistingReaderHappyPathScenario.js +98 -0
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistFeeAfterDisableScenario.js +66 -0
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistHappyPathScenario.js +55 -0
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistInsufficientAdminBalanceScenario.js +103 -0
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistNodeAlreadyWhitelistedScenario.js +60 -0
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistScenarioHelpers.js +191 -0
- package/tests/unit/state/apply/appendWhitelist/state.apply.appendWhitelist.test.js +220 -0
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationHappyPathScenario.js +82 -0
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js +106 -0
- package/tests/unit/state/apply/balanceInitialization/invalidAmountScenario.js +45 -0
- package/tests/unit/state/apply/balanceInitialization/nodeEntryBalanceUpdateFailureScenario.js +81 -0
- package/tests/unit/state/apply/balanceInitialization/state.apply.balanceInitialization.test.js +189 -0
- package/tests/unit/state/apply/banValidator/banValidatorBanAndReWhitelistScenario.js +155 -0
- package/tests/unit/state/apply/banValidator/banValidatorHappyPathScenario.js +36 -0
- package/tests/unit/state/apply/banValidator/banValidatorScenarioHelpers.js +534 -0
- package/tests/unit/state/apply/banValidator/banValidatorSequentialBansScenario.js +74 -0
- package/tests/unit/state/apply/banValidator/banValidatorTargetDecodeFailureScenario.js +19 -0
- package/tests/unit/state/apply/banValidator/banValidatorTargetIndexerScenario.js +32 -0
- package/tests/unit/state/apply/banValidator/banValidatorTargetNodeEntryMissingScenario.js +19 -0
- package/tests/unit/state/apply/banValidator/banValidatorTargetRoleUpdateFailureScenario.js +19 -0
- package/tests/unit/state/apply/banValidator/banValidatorWhitelistedNonWriterScenario.js +38 -0
- package/tests/unit/state/apply/banValidator/banValidatorWhitelistedZeroBalanceScenario.js +91 -0
- package/tests/unit/state/apply/banValidator/banValidatorWithdrawFailureScenario.js +19 -0
- package/tests/unit/state/apply/banValidator/state.apply.banValidator.test.js +266 -0
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentDuplicateRegistrationScenario.js +142 -0
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentHappyPathScenario.js +26 -0
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentIncompleteOperationScenario.js +94 -0
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentInvalidDeploymentEntryScenario.js +37 -0
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentMultipleBootstrapScenario.js +86 -0
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentScenarioHelpers.js +344 -0
- package/tests/unit/state/apply/bootstrapDeployment/invalidValidatorNodeEntryScenario.js +57 -0
- package/tests/unit/state/apply/bootstrapDeployment/state.apply.bootstrapDeployment.test.js +429 -0
- package/tests/unit/state/apply/common/access-control/adminConsistencyMismatchScenario.js +119 -0
- package/tests/unit/state/apply/common/access-control/adminEntryDecodeFailureScenario.js +130 -0
- package/tests/unit/state/apply/common/access-control/adminEntryExistsScenario.js +93 -0
- package/tests/unit/state/apply/common/access-control/adminEntryMissingScenario.js +108 -0
- package/tests/unit/state/apply/common/access-control/adminOnlyGuardScenario.js +126 -0
- package/tests/unit/state/apply/common/access-control/adminPublicKeyDecodeFailureScenario.js +120 -0
- package/tests/unit/state/apply/common/access-control/roleAccessOperationValidationScenario.js +50 -0
- package/tests/unit/state/apply/common/adminControlOperationValidationScenario.js +56 -0
- package/tests/unit/state/apply/common/balances/adminEntryUpdateFailureScenario.js +52 -0
- package/tests/unit/state/apply/common/balances/base/requesterBalanceScenarioBase.js +197 -0
- package/tests/unit/state/apply/common/balances/feeDecodeFailureScenario.js +52 -0
- package/tests/unit/state/apply/common/balances/requesterBalanceDecodeFailureScenario.js +15 -0
- package/tests/unit/state/apply/common/balances/requesterBalanceFeeApplicationFailureScenario.js +11 -0
- package/tests/unit/state/apply/common/balances/requesterBalanceInsufficientScenario.js +15 -0
- package/tests/unit/state/apply/common/balances/requesterBalanceUpdateFailureScenario.js +11 -0
- package/tests/unit/state/apply/common/balances/validatorEntryRewardFailureScenario.js +11 -0
- package/tests/unit/state/apply/common/balances/validatorEntryUpdateFailureScenario.js +11 -0
- package/tests/unit/state/apply/common/balances/validatorNodeEntryDecodeFailureScenario.js +40 -0
- package/tests/unit/state/apply/common/base/OperationValidationScenarioBase.js +114 -0
- package/tests/unit/state/apply/common/commonScenarioHelper.js +103 -0
- package/tests/unit/state/apply/common/indexer/indexerNodeEntryDecodeFailureScenario.js +36 -0
- package/tests/unit/state/apply/common/indexer/indexerNodeEntryMissingScenario.js +36 -0
- package/tests/unit/state/apply/common/indexer/indexerRoleUpdateFailureScenario.js +29 -0
- package/tests/unit/state/apply/common/indexer/indexerSequenceStateInvalidScenario.js +66 -0
- package/tests/unit/state/apply/common/invalidMessageComponentValidationScenario.js +84 -0
- package/tests/unit/state/apply/common/nodeEntryInitializationFailureScenario.js +47 -0
- package/tests/unit/state/apply/common/operationAlreadyAppliedScenario.js +85 -0
- package/tests/unit/state/apply/common/payload-structure/addressWithInvalidPublicKeyScenario.js +52 -0
- package/tests/unit/state/apply/common/payload-structure/initializationDisabledScenario.js +49 -0
- package/tests/unit/state/apply/common/payload-structure/invalidAddressValidationScenario.js +73 -0
- package/tests/unit/state/apply/common/payload-structure/invalidHashValidationScenario.js +71 -0
- package/tests/unit/state/apply/common/payload-structure/invalidPayloadValidationScenario.js +31 -0
- package/tests/unit/state/apply/common/payload-structure/invalidSignatureValidationScenario.js +142 -0
- package/tests/unit/state/apply/common/payload-structure/partialOperationValidationScenario.js +87 -0
- package/tests/unit/state/apply/common/requester/requesterNodeEntryBufferMissingScenario.js +70 -0
- package/tests/unit/state/apply/common/requester/requesterNodeEntryDecodeFailureScenario.js +72 -0
- package/tests/unit/state/apply/common/requester/requesterNodeEntryMissingScenario.js +36 -0
- package/tests/unit/state/apply/common/requesterAddressValidationScenario.js +44 -0
- package/tests/unit/state/apply/common/requesterPublicKeyValidationScenario.js +25 -0
- package/tests/unit/state/apply/common/transactionValidityMismatchScenario.js +98 -0
- package/tests/unit/state/apply/common/validatorConsistency/base/validatorConsistencyScenarioBase.js +201 -0
- package/tests/unit/state/apply/common/validatorConsistency/validatorEntryDecodeFailureScenario.js +17 -0
- package/tests/unit/state/apply/common/validatorConsistency/validatorEntryMissingScenario.js +44 -0
- package/tests/unit/state/apply/common/validatorConsistency/validatorInactiveScenario.js +19 -0
- package/tests/unit/state/apply/common/validatorConsistency/validatorWriterKeyMismatchScenario.js +18 -0
- package/tests/unit/state/apply/common/validatorEntryValidation/base/validatorEntryValidationScenarioBase.js +314 -0
- package/tests/unit/state/apply/common/validatorEntryValidation/validatorEntryInvalidBalanceScenario.js +18 -0
- package/tests/unit/state/apply/common/writerKeyExistsValidationScenario.js +43 -0
- package/tests/unit/state/apply/disableInitialization/disableInitializationAlreadyDisabledScenario.js +53 -0
- package/tests/unit/state/apply/disableInitialization/disableInitializationHappyPathScenario.js +24 -0
- package/tests/unit/state/apply/disableInitialization/disableInitializationScenarioHelpers.js +197 -0
- package/tests/unit/state/apply/disableInitialization/state.apply.disableInitialization.test.js +161 -0
- package/tests/unit/state/apply/missing-tests.md +18 -0
- package/tests/unit/state/apply/removeIndexer/removeIndexerHappyPathScenario.js +58 -0
- package/tests/unit/state/apply/removeIndexer/removeIndexerReAddAndRemoveAgainScenario.js +98 -0
- package/tests/unit/state/apply/removeIndexer/removeIndexerRemoveMultipleIndexersScenario.js +167 -0
- package/tests/unit/state/apply/removeIndexer/removeIndexerScenarioHelpers.js +428 -0
- package/tests/unit/state/apply/removeIndexer/removeIndexerTargetNotIndexerScenario.js +22 -0
- package/tests/unit/state/apply/removeIndexer/removeIndexerWriterKeyMissingScenario.js +20 -0
- package/tests/unit/state/apply/removeIndexer/state.apply.removeIndexer.test.js +291 -0
- package/tests/unit/state/apply/removeWriter/removeWriterAndAddWriterAgainScenario.js +87 -0
- package/tests/unit/state/apply/removeWriter/removeWriterHappyPathScenario.js +38 -0
- package/tests/unit/state/apply/removeWriter/removeWriterInvalidValidatorSignatureScenario.js +32 -0
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterBalanceInsufficientScenario.js +21 -0
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterEntryDecodeFailureScenario.js +19 -0
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterEntryMissingScenario.js +19 -0
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterIndexerScenario.js +21 -0
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterNotWriterScenario.js +21 -0
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterRoleUpdateFailureScenario.js +19 -0
- package/tests/unit/state/apply/removeWriter/removeWriterScenarioHelpers.js +344 -0
- package/tests/unit/state/apply/removeWriter/removeWriterThroughWriterValidatorScenario.js +113 -0
- package/tests/unit/state/apply/removeWriter/removeWriterUnstakeFailureScenario.js +33 -0
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyMismatchScenario.js +21 -0
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyOwnershipScenario.js +26 -0
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyRegistryMissingScenario.js +22 -0
- package/tests/unit/state/apply/removeWriter/state.apply.removeWriter.test.js +307 -0
- package/tests/unit/state/apply/state.apply.test.js +24 -0
- package/tests/unit/state/apply/transfer/state.apply.transfer.test.js +819 -0
- package/tests/unit/state/apply/transfer/transferContractSchemaValidationScenario.js +22 -0
- package/tests/unit/state/apply/transfer/transferDoubleSpendAcrossValidatorsScenario.js +137 -0
- package/tests/unit/state/apply/transfer/transferDoubleSpendSameBatchScenario.js +63 -0
- package/tests/unit/state/apply/transfer/transferDoubleSpendSingleValidatorScenario.js +67 -0
- package/tests/unit/state/apply/transfer/transferExistingRecipientAmountScenario.js +31 -0
- package/tests/unit/state/apply/transfer/transferExistingRecipientZeroAmountScenario.js +31 -0
- package/tests/unit/state/apply/transfer/transferHandlerGuardScenarios.js +22 -0
- package/tests/unit/state/apply/transfer/transferHappyPathScenario.js +8 -0
- package/tests/unit/state/apply/transfer/transferInvalidIncomingDataScenario.js +66 -0
- package/tests/unit/state/apply/transfer/transferNewRecipientAmountScenario.js +31 -0
- package/tests/unit/state/apply/transfer/transferNewRecipientZeroAmountScenario.js +31 -0
- package/tests/unit/state/apply/transfer/transferScenarioHelpers.js +1167 -0
- package/tests/unit/state/apply/transfer/transferSelfTransferAmountScenario.js +38 -0
- package/tests/unit/state/apply/transfer/transferSelfTransferZeroAmountScenario.js +38 -0
- package/tests/unit/state/apply/transfer/transferValidatorRecipientAmountScenario.js +38 -0
- package/tests/unit/state/apply/transfer/transferValidatorRecipientZeroAmountScenario.js +38 -0
- package/tests/unit/state/apply/txOperation/state.apply.txOperation.test.js +318 -0
- package/tests/unit/state/apply/txOperation/txOperationBootstrapNotRegisteredScenario.js +70 -0
- package/tests/unit/state/apply/txOperation/txOperationDifferentValidatorCreatorHappyPathScenario.js +23 -0
- package/tests/unit/state/apply/txOperation/txOperationInvalidDeploymentEntryScenario.js +48 -0
- package/tests/unit/state/apply/txOperation/txOperationInvalidFeeAmountScenario.js +39 -0
- package/tests/unit/state/apply/txOperation/txOperationInvalidSubnetCreatorAddressScenario.js +46 -0
- package/tests/unit/state/apply/txOperation/txOperationRequesterCreatorHappyPathScenario.js +21 -0
- package/tests/unit/state/apply/txOperation/txOperationScenarioHelpers.js +429 -0
- package/tests/unit/state/apply/txOperation/txOperationStandardHappyPathScenario.js +21 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddCreatorBalanceFailureScenario.js +26 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddValidatorBalanceFailureScenario.js +25 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddValidatorBonusFailureScenario.js +27 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeCreatorEntryScenario.js +18 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeRequesterEntryScenario.js +17 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeValidatorEntryScenario.js +31 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardBypassScenario.js +49 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardScenarioFactory.js +92 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInsufficientRequesterBalanceScenario.js +28 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidCreatorBalanceScenario.js +29 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidRequesterBalanceScenario.js +28 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidRequesterEntryScenario.js +17 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidValidatorBalanceScenario.js +33 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeMissingCreatorEntryScenario.js +18 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeSubtractFailureScenario.js +25 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateCreatorBalanceFailureScenario.js +26 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateFailureScenario.js +25 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateValidatorBalanceFailureScenario.js +26 -0
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateValidatorBonusFailureScenario.js +27 -0
- package/tests/unit/state/apply/txOperation/txOperationValidatorCreatorHappyPathScenario.js +21 -0
- package/tests/unit/state/stateModule.test.js +1 -0
- package/tests/unit/state/stateTestUtils.js +5 -1
- package/.env +0 -3
package/.dockerignore
ADDED
|
@@ -2,6 +2,11 @@ name: MSB-Acceptance-Tests
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
workflow_dispatch:
|
|
5
|
+
# TODO: re-enable when runners handle acceptance reliably outside local
|
|
6
|
+
# workflow_run:
|
|
7
|
+
# workflows: ["MSB-Unit-Tests"]
|
|
8
|
+
# types:
|
|
9
|
+
# - completed
|
|
5
10
|
|
|
6
11
|
concurrency:
|
|
7
12
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
@@ -11,6 +16,8 @@ jobs:
|
|
|
11
16
|
integration-tests:
|
|
12
17
|
name: Acceptance Tests
|
|
13
18
|
runs-on: ${{ matrix.os }}
|
|
19
|
+
# if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
|
|
20
|
+
if: ${{ github.event_name == 'workflow_dispatch' }}
|
|
14
21
|
strategy:
|
|
15
22
|
matrix:
|
|
16
23
|
node-version: [lts/*]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Publish trac-msb to npm on release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish-npm:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout repo
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Use Node.js
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: '24'
|
|
22
|
+
registry-url: 'https://registry.npmjs.org'
|
|
23
|
+
|
|
24
|
+
- name: Set package.json version from tag
|
|
25
|
+
run: |
|
|
26
|
+
TAG="${GITHUB_REF#refs/tags/}"
|
|
27
|
+
VERSION="${TAG#v}"
|
|
28
|
+
echo "Version from tag: $VERSION"
|
|
29
|
+
npm version "$VERSION" --no-git-tag-version
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: npm ci
|
|
33
|
+
|
|
34
|
+
- name: Run unit tests
|
|
35
|
+
run: npm run test:unit:all
|
|
36
|
+
|
|
37
|
+
- name: Publish to npm
|
|
38
|
+
env:
|
|
39
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_MSB_PUBLISH_TOKEN }}
|
|
40
|
+
run: npm publish
|
package/README.md
CHANGED
|
@@ -2,77 +2,202 @@
|
|
|
2
2
|
|
|
3
3
|
A peer-to-peer crypto validator network to verify and append transactions.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Always follow the guidance in the [Security Policy](SECURITY.md) for release compatibility, upgrade steps, and required follow-up actions.
|
|
6
6
|
|
|
7
|
-
The MSB
|
|
7
|
+
The MSB leverages the [Pear Runtime and Holepunch](https://pears.com/).
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
Node.js is required to run the application. Before installing Node.js, refer to the official [Node.js documentation](https://nodejs.org) for the latest recommended version and installation instructions. For this project, Node.js v24.11.0 (LTS) and npm 11.6.1 or newer are compatible.
|
|
12
|
+
|
|
13
|
+
The Pear Runtime CLI is required to run the application. Before installing Pear, refer to the official [Pear documentation](https://docs.pears.com/guides/getting-started) for the latest recommended version and installation instructions. For this project, the latest Pear CLI is compatible.
|
|
14
|
+
|
|
15
|
+
Install Pear globally:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install -g pear
|
|
19
|
+
which pear
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Docker is optional and only needed for running the containerized RPC node. Before installing Docker, refer to the official [Docker documentation](https://www.docker.com) for the latest recommended version and installation instructions. For running the containerized RPC node, the latest Docker is recommended. Tested with Docker version 28.3.2, build 578ccf6.
|
|
8
23
|
|
|
9
24
|
## Install
|
|
10
25
|
|
|
11
26
|
```shell
|
|
12
|
-
git clone -b
|
|
27
|
+
git clone -b main --single-branch git@github.com:Trac-Systems/main_settlement_bus.git
|
|
28
|
+
cd main_settlement_bus
|
|
29
|
+
npm install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Post-install checklist
|
|
33
|
+
|
|
34
|
+
Before running tests, install bare globally:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install -g bare
|
|
13
38
|
```
|
|
14
39
|
|
|
40
|
+
- ✅ `npm run test:unit:all` – confirms the codebase builds and runs under both supported runtimes.
|
|
41
|
+
- 📋 `npm run test:acceptance` – optional but recommended before upgrades. This suite spins up in-process nodes and may take a few minutes.
|
|
42
|
+
- 🌐 RPC smoke test – start `MSB_STORE=smoke-store MSB_HOST=127.0.0.1 MSB_PORT=5000 npm run env-prod-rpc` in one terminal, then execute `curl -s http://127.0.0.1:5000/v1/fee` from another terminal to verify `/v1` routes respond. Stop the node with `Ctrl+C` once finished.
|
|
43
|
+
|
|
15
44
|
## Usage
|
|
16
45
|
|
|
17
|
-
|
|
46
|
+
Runtime entry points cover CLI-driven runs (`prod`, `prod-rpc`) and `.env`-aware runs (`env-prod`, `env-prod-rpc`). Each section below lists the accepted configuration inputs.
|
|
47
|
+
|
|
48
|
+
### Interactive regular node
|
|
49
|
+
|
|
50
|
+
#### Regular node with .env file
|
|
51
|
+
|
|
52
|
+
This variant reads configuration from `.env`:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
# .env
|
|
56
|
+
MSB_STORE=<store_name>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
then
|
|
18
60
|
|
|
19
|
-
```js
|
|
20
|
-
cd main_settlement_bus
|
|
21
|
-
npm install -g pear
|
|
22
|
-
npm install
|
|
23
61
|
```
|
|
62
|
+
npm run env-prod
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The script sources `.env` before invoking program and falls back to `node-store` when `MSB_STORE` is not defined.
|
|
24
66
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
|
|
67
|
+
#### Inline environment variables
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
MSB_STORE=<store_name> npm run env-prod
|
|
29
71
|
```
|
|
30
72
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
73
|
+
This run persists data under `./stores/${MSB_STORE}` (defaults to `node-store`) and is intended for inline or CLI-supplied configuration.
|
|
74
|
+
|
|
75
|
+
#### CLI flags
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
npm run prod --store=<store_name>
|
|
34
79
|
```
|
|
35
80
|
|
|
36
|
-
|
|
81
|
+
### RPC-enabled node
|
|
82
|
+
|
|
83
|
+
#### RPC with .env file
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
# .env
|
|
87
|
+
MSB_STORE=<store_name>
|
|
88
|
+
MSB_HOST=127.0.0.1
|
|
89
|
+
MSB_PORT=5000
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
npm run env-prod-rpc
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This entry point sources `.env` automatically and defaults to `rpc-node-store`, `127.0.0.1`, and `5000` when variables are not present.
|
|
97
|
+
|
|
98
|
+
#### Inline environment variables
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
MSB_STORE=<store_name> MSB_HOST=<host> MSB_PORT=<port> npm run env-prod-rpc
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Override any combination of `MSB_STORE`, `MSB_HOST`, or `MSB_PORT`. Data is persisted under `./stores/${MSB_STORE}` (default `rpc-node-store` for this script).
|
|
105
|
+
|
|
106
|
+
#### CLI flags
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
npm run prod-rpc --store=<store_name> --host=<host> --port=<port>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Docker usage
|
|
113
|
+
|
|
114
|
+
You can run the RPC node in a containerized environment using the provided `docker-compose.yml` file. The `msb-rpc` service is already wired up. You usually only need to tweak these variables:
|
|
115
|
+
|
|
116
|
+
- `MSB_STORE`: name of the store directory under `./stores`.
|
|
117
|
+
- `MSB_HOST`: host interface to bind (defaults to `127.0.0.1` to avoid exposing everything).
|
|
118
|
+
- `MSB_PORT`: port the RPC server listens on **inside** the container (defaults to `5000`).
|
|
119
|
+
- `MSB_PUBLISH_PORT`: host port to expose (defaults to `MSB_PORT`, so set it only when the host port should differ).
|
|
120
|
+
|
|
121
|
+
Leave `MSB_PORT=5000` if you just want to publish the default RPC port and only bump `MSB_PUBLISH_PORT` when the host side must change. Set both to the same value if you want the RPC server itself to listen on another port.
|
|
122
|
+
|
|
123
|
+
Example (keep container port 5000, expose host port 6000):
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
MSB_STORE=rpc-node-store \
|
|
127
|
+
MSB_HOST=127.0.0.1 \
|
|
128
|
+
MSB_PORT=5000 \
|
|
129
|
+
MSB_PUBLISH_PORT=6000 \
|
|
130
|
+
docker compose up -d msb-rpc
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Running `msb-rpc` with Docker Compose
|
|
134
|
+
|
|
135
|
+
Any of the following launch methods can be applied:
|
|
136
|
+
|
|
137
|
+
1. **Using a `.env` file** – populate `.env`, then start the service:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
docker compose up -d msb-rpc
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
or
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
docker compose --env-file .env up -d msb-rpc
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Add any of the variables listed above to `.env`. When the host port needs to differ from the container port, set `MSB_PUBLISH_PORT` without touching `MSB_PORT`.
|
|
150
|
+
|
|
151
|
+
Example `.env` (publishes host port 1337, keeps the container on 5000):
|
|
152
|
+
|
|
153
|
+
```dotenv
|
|
154
|
+
MSB_STORE=rpc-node-store
|
|
155
|
+
MSB_HOST=127.0.0.1
|
|
156
|
+
MSB_PORT=5000
|
|
157
|
+
MSB_PUBLISH_PORT=1337
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
2. **Passing variables inline** – use this method when environment variables should be provided directly in the command line, without modifying the `.env` file:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
MSB_STORE=<store_name> MSB_HOST=<host> MSB_PORT=<container_port> MSB_PUBLISH_PORT=<host_port> docker compose up -d msb-rpc
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Skip `MSB_PORT` when you just want to keep the container on `5000` and expose a different host port.
|
|
167
|
+
|
|
168
|
+
3. **Reusing an existing store directory** – mount the path that already holds your store and pin the host binding you need:
|
|
37
169
|
|
|
38
|
-
|
|
170
|
+
```sh
|
|
171
|
+
docker compose run -d --name msb-rpc \
|
|
172
|
+
-e MSB_STORE=<store_name> \
|
|
173
|
+
-e MSB_HOST=<host> \
|
|
174
|
+
-e MSB_PORT=<container_port> \
|
|
175
|
+
-e MSB_PUBLISH_PORT=<host_port> \
|
|
176
|
+
-p <host_address>:<host_port>:<container_port> \
|
|
177
|
+
-v /absolute/path/to/your/store_directory:/msb/stores \
|
|
178
|
+
msb-rpc
|
|
179
|
+
```
|
|
39
180
|
|
|
40
|
-
-
|
|
41
|
-
- Copy and backup the seedphrase
|
|
42
|
-
- Copy the "MSB Writer" address
|
|
43
|
-
- With a text editor, open the file msb.mjs in document root
|
|
44
|
-
- Replace the bootstrap address with the copied writer address
|
|
45
|
-
- Choose a channel name (exactly 32 characters)
|
|
46
|
-
- Run again: pear run . store1
|
|
47
|
-
- After the options appear, type /add_admin and hit enter
|
|
48
|
-
- Your instance is now the Bootstrap and admin peer, required to control validators
|
|
49
|
-
- Keep your bootstrap node running
|
|
50
|
-
- Strongly recommended: add a couple of nodes as writers
|
|
181
|
+
Adjust `/absolute/path/to/your/store_directory` to the directory that already contains the persisted store. Once the container exists, bring it back with `docker compose start msb-rpc`. If the container should stay on `5000`, omit `-e MSB_PORT=<container_port>` and just set `MSB_PUBLISH_PORT` plus the matching `-p` flag.
|
|
51
182
|
|
|
52
|
-
|
|
183
|
+
Example with specific values:
|
|
53
184
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
185
|
+
```sh
|
|
186
|
+
docker compose run -d --name msb-rpc \
|
|
187
|
+
-e MSB_STORE=rpc-node-store \
|
|
188
|
+
-e MSB_HOST=127.0.0.1 \
|
|
189
|
+
-e MSB_PORT=5000 \
|
|
190
|
+
-e MSB_PUBLISH_PORT=6000 \
|
|
191
|
+
-p 127.0.0.1:6000:5000 \
|
|
192
|
+
-v /absolute/path/to/your/store_directory:/msb/stores \
|
|
193
|
+
msb-rpc
|
|
194
|
+
```
|
|
61
195
|
|
|
62
|
-
|
|
196
|
+
Stop the service with `docker compose stop msb-rpc`, remove the stack entirely with `docker compose down` when you are finished.
|
|
63
197
|
|
|
64
|
-
|
|
65
|
-
- Copy and backup the seedphrase
|
|
66
|
-
- Copy the "MSB Address" after the screen fully loaded
|
|
67
|
-
- Hand your "MSB Address" over to the MSB admin for whitelisting
|
|
68
|
-
- Wait for the admin to announce the whitelist event
|
|
69
|
-
- In the screen type /add_writer
|
|
70
|
-
- After a few seconds you should see your validator being added as a writer
|
|
198
|
+
> Note: The RPC instance must synchronize with the network after startup, so full readiness may take some time.
|
|
71
199
|
|
|
72
|
-
|
|
200
|
+
## Troubleshooting
|
|
73
201
|
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
- In the MSB screen, enter /add_whitelist
|
|
77
|
-
- Wait for the listto be fully processed
|
|
78
|
-
- Inform your validator community being whitelisted
|
|
202
|
+
- **Dependency install failures** – confirm you are on Node.js v24.11.0 (LTS) and npm ≥ 11.6.1. If packages still fail to build, clear artifacts (`rm -rf node_modules package-lock.json && npm install`) and rerun `npm run test:unit:all`.
|
|
203
|
+
- **Unit tests fail only in one runtime** – run the targeted commands (`npm run test:unit:node` or `npm run test:unit:bare`) to isolate regressions, then inspect `tests/unit/unit.test.js` for the failing cases.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
services:
|
|
2
|
+
msb-rpc:
|
|
3
|
+
build:
|
|
4
|
+
context: .
|
|
5
|
+
dockerfile: dockerfile
|
|
6
|
+
container_name: msb-rpc
|
|
7
|
+
restart: always
|
|
8
|
+
environment:
|
|
9
|
+
MSB_STORE: ${MSB_STORE:-rpc-node-store}
|
|
10
|
+
MSB_HOST: ${MSB_HOST:-127.0.0.1}
|
|
11
|
+
MSB_PORT: ${MSB_PORT:-5000}
|
|
12
|
+
volumes:
|
|
13
|
+
- ./stores:/msb/stores
|
|
14
|
+
ports:
|
|
15
|
+
- "${MSB_HOST:-127.0.0.1}:${MSB_PUBLISH_PORT:-5000}:${MSB_PORT:-5000}"
|
|
16
|
+
read_only: true
|
package/dockerfile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
FROM node:22-bookworm-slim
|
|
2
|
+
|
|
3
|
+
RUN apt-get update \
|
|
4
|
+
&& apt-get install -y --no-install-recommends \
|
|
5
|
+
libatomic1 \
|
|
6
|
+
libgcc-s1 \
|
|
7
|
+
libstdc++6 \
|
|
8
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
9
|
+
|
|
10
|
+
RUN groupadd --system ops \
|
|
11
|
+
&& useradd --system --gid ops --home /home/ops --shell /usr/sbin/nologin ops \
|
|
12
|
+
&& mkdir -p /home/ops \
|
|
13
|
+
&& chown ops:ops /home/ops \
|
|
14
|
+
&& mkdir -p /msb/stores \
|
|
15
|
+
&& chown -R node:ops /msb
|
|
16
|
+
|
|
17
|
+
WORKDIR /msb
|
|
18
|
+
|
|
19
|
+
USER node
|
|
20
|
+
|
|
21
|
+
COPY package*.json ./
|
|
22
|
+
RUN npm ci --omit=dev
|
|
23
|
+
COPY . .
|
|
24
|
+
|
|
25
|
+
USER root
|
|
26
|
+
RUN chown -R node:ops /msb \
|
|
27
|
+
&& chmod -R 0555 /msb \
|
|
28
|
+
&& chown -R node:node /msb/stores \
|
|
29
|
+
&& chmod 0700 /msb/stores
|
|
30
|
+
|
|
31
|
+
USER node
|
|
32
|
+
|
|
33
|
+
ENV MSB_STORE=node-store \
|
|
34
|
+
MSB_HOST=0.0.0.0 \
|
|
35
|
+
MSB_PORT=5000
|
|
36
|
+
|
|
37
|
+
VOLUME ["/msb/stores"]
|
|
38
|
+
EXPOSE 5000
|
|
39
|
+
|
|
40
|
+
ENTRYPOINT ["npm", "run"]
|
|
41
|
+
CMD ["env-prod-rpc-docker"]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Fee distribution (state.js)
|
|
2
|
+
|
|
3
|
+
## Constants
|
|
4
|
+
- `FEE` = 0.03 $TNK base fee.
|
|
5
|
+
- Predefined splits: `PERCENT_75`, `PERCENT_50`, `PERCENT_25`.
|
|
6
|
+
|
|
7
|
+
## Operations (excluding TRANSFER and TX)
|
|
8
|
+
| Operation | Who pays / amount | When charged | Validator | Remainder |
|
|
9
|
+
| --- | --- | --- | --- | --- |
|
|
10
|
+
| AddAdmin | Admin, `0` | One-time during initialization | 0% | n/a (free) |
|
|
11
|
+
| BalanceInitialization | Admin (sender), `0` | While initialization flag is enabled | 0% | n/a (free) |
|
|
12
|
+
| AppendWhitelist | Admin, `FEE` | Only if initialization flag is disabled | 0% | 100% burned (deducted from admin) |
|
|
13
|
+
| AddWriter | Writer candidate, `FEE` | Always charged | 75% | 25% burned |
|
|
14
|
+
| RemoveWriter | Writer being removed, `FEE` | Always charged | 75% | 25% burned |
|
|
15
|
+
| AdminRecovery | Admin, `FEE` | Always charged | 75% | 25% burned |
|
|
16
|
+
| AddIndexer | Admin, `FEE` | Always charged | 0% | 100% burned |
|
|
17
|
+
| RemoveIndexer | Admin, `FEE` | Always charged | 0% | 100% burned |
|
|
18
|
+
| BanValidator | Admin, `FEE` | Always charged | 0% | 100% burned |
|
|
19
|
+
| BootstrapDeployment | Deployment initiator, `FEE` | Always charged | 75% | 25% burned |
|
|
20
|
+
| Transfer | Requester, `FEE` | Always charged | 75% | 25% burned |
|
|
21
|
+
| TX | Requester, `FEE` | Always charged | depends on subnet owner (see TX cases) | depends on subnet owner (see TX cases) |
|
|
22
|
+
|
|
23
|
+
### Operation details
|
|
24
|
+
- **AddAdmin**
|
|
25
|
+
- Payer: admin (network creator), amount: free.
|
|
26
|
+
- Effect: admin receives initial balance `1000 $TNK` and initial staked balance `0.3 $TNK`; admin is set as indexer+validator+whitelisted and admin entry is created. Runs exactly once during bootstrap.
|
|
27
|
+
- **AddWriter**
|
|
28
|
+
- Payer: writer candidate, amount: `FEE`.
|
|
29
|
+
- Split: validator 75%, burned 25%.
|
|
30
|
+
- Effect: role set to writer, staking updated, key registered.
|
|
31
|
+
- **RemoveWriter**
|
|
32
|
+
- Payer: writer being removed, amount: `FEE`.
|
|
33
|
+
- Split: validator 75%, burned 25%.
|
|
34
|
+
- Effect: role set to whitelisted, stake released, writer key unregistered.
|
|
35
|
+
- **AdminRecovery**
|
|
36
|
+
- Payer: admin rotating writer key, amount: `FEE`.
|
|
37
|
+
- Split: validator 75%, burned 25%.
|
|
38
|
+
- Effect: admin writer key swapped, indexer entry updated to the new key.
|
|
39
|
+
- **BootstrapDeployment**
|
|
40
|
+
- Payer: deployment initiator, amount: `FEE`.
|
|
41
|
+
- Split: validator 75%, burned 25%.
|
|
42
|
+
- Effect: deployment entry stored for the bootstrap.
|
|
43
|
+
|
|
44
|
+
## Transfer (OperationType.TRANSFER)
|
|
45
|
+
- Payer: requester (sender).
|
|
46
|
+
- Fee: `FEE` (always charged, in self-transfer only the fee is deducted).
|
|
47
|
+
- Basics:
|
|
48
|
+
- Amount deducted from sender: `transferAmount + FEE`. In self-transfer only the fee is deducted.
|
|
49
|
+
- If the sender lacks full funds for the deduction, the operation is ignored (state unchanged).
|
|
50
|
+
- Fee split: validator 75%, burned 25%.
|
|
51
|
+
- Transfer amount to recipient:
|
|
52
|
+
- Recipient is not a validator: recipient gets `transferAmount` (can be 0). A new recipient is initialized as READER with that balance.
|
|
53
|
+
- Recipient is the validator: validator gets `transferAmount` plus its fee share (75% of `FEE`).
|
|
54
|
+
- Self-transfer: recipient equals sender. Recipient balance is unchanged. Fee still goes 75% to validator, 25% burned.
|
|
55
|
+
|
|
56
|
+
## Subnetwork TX (OperationType.TX)
|
|
57
|
+
- Payer: requester.
|
|
58
|
+
- Fee: `FEE`.
|
|
59
|
+
- Fee split depends on who deployed the subnet (`bootstrapDeployer`):
|
|
60
|
+
1. `bootstrapDeployer = requester`, validator is different:
|
|
61
|
+
- Validator: 50%
|
|
62
|
+
- Bootstrap deployer: 0% (no discount for owning the subnet)
|
|
63
|
+
- Burned: 50%
|
|
64
|
+
2. `bootstrapDeployer = validator`, requester is different:
|
|
65
|
+
- Validator (and deployer): 75% (50% as validator + 25% as deployer)
|
|
66
|
+
- Burned: 25%
|
|
67
|
+
- Requester: 0%
|
|
68
|
+
3. `bootstrapDeployer` is neither requester nor validator:
|
|
69
|
+
- Validator: 50%
|
|
70
|
+
- Bootstrap deployer: 25%
|
|
71
|
+
- Burned: 25%
|
|
72
|
+
- Requester: 0%
|
|
73
|
+
- The fee is deducted from the requester before distribution. Others receive only the shares above.
|
|
74
|
+
|
|
75
|
+
## Zero-fee operations
|
|
76
|
+
- `ADD_ADMIN` (one-time bootstrap, assigns `1000 $TNK` liquid + `0.3 $TNK` staked to admin).
|
|
77
|
+
- `BALANCE_INITIALIZATION` (sender -> recipient top-up) is free while initialization is enabled.
|
|
78
|
+
- `DISABLE_INITIALIZATION` is free, can be used exactly once to turn off balance initialization.
|
|
79
|
+
- AppendWhitelist before initialization is disabled is free (fee appears only after the flag is turned off).
|
|
80
|
+
|
|
81
|
+
## Validator penalties
|
|
82
|
+
- For a batch with invalid operations or an oversized batch: `penalty = FEE * invalidOperations`.
|
|
83
|
+
- The penalty is taken from staked balance, not distributed, and the validator is downgraded to whitelisted. Remaining stake after the penalty returns to the normal balance, so part of the penalty is effectively burned.
|
|
84
|
+
- Each failed operation in a batch (validation errors, unmet conditions, invalid payload) increases the invalid counter and triggers at least one `FEE` worth of penalty.
|
|
85
|
+
|
|
86
|
+
## Note on the `bs` field in TX
|
|
87
|
+
- `bs` identifies the subnet bootstrap, mapped in MSB to the subnet creator address.
|
|
88
|
+
- A TX is valid only if `bs` points to a registered bootstrap.
|
|
89
|
+
- The subnet owner (address tied to `bs`) receives a share of the TX fee only when they are not the requester. If requester or validator is the creator, the creator’s share is folded into their respective percentage as described above.
|
package/msb.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {MainSettlementBus} from './src/index.js';
|
|
1
|
+
import { MainSettlementBus } from './src/index.js';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const pearApp = typeof Pear !== 'undefined' ? (Pear.app ?? Pear.config) : undefined;
|
|
4
|
+
const runtimeArgs = typeof process !== 'undefined' ? process.argv.slice(2) : [];
|
|
5
|
+
const args = pearApp?.args ?? runtimeArgs;
|
|
6
|
+
const runRpc = args.includes('--rpc');
|
|
5
7
|
|
|
6
8
|
const opts = {
|
|
7
|
-
stores_directory
|
|
8
|
-
store_name
|
|
9
|
+
stores_directory: 'stores/',
|
|
10
|
+
store_name: pearApp?.args?.[0] ?? runtimeArgs[0],
|
|
9
11
|
bootstrap: 'acbc3a4344d3a804101d40e53db1dda82b767646425af73599d4cd6577d69685',
|
|
10
12
|
channel: '0000trac0network0msb0mainnet0000',
|
|
11
13
|
enable_role_requester: false,
|
|
@@ -21,14 +23,13 @@ const rpc_opts = {
|
|
|
21
23
|
...opts,
|
|
22
24
|
enable_tx_apply_logs: false,
|
|
23
25
|
enable_error_apply_logs: false,
|
|
26
|
+
enable_wallet: false,
|
|
27
|
+
enable_interactive_mode: false,
|
|
28
|
+
};
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const msb = new MainSettlementBus(args.includes('--rpc') ? rpc_opts : opts);
|
|
30
|
+
const msb = new MainSettlementBus(runRpc ? rpc_opts : opts);
|
|
28
31
|
|
|
29
32
|
msb.ready().then(async () => {
|
|
30
|
-
const runRpc = args.includes('--rpc');
|
|
31
|
-
|
|
32
33
|
if (runRpc) {
|
|
33
34
|
console.log('Starting RPC server...');
|
|
34
35
|
const portIndex = args.indexOf('--port');
|
|
@@ -39,9 +40,6 @@ msb.ready().then(async () => {
|
|
|
39
40
|
const {startRpcServer} = await import('./rpc/rpc_server.mjs');
|
|
40
41
|
startRpcServer(msb, host, port);
|
|
41
42
|
} else {
|
|
42
|
-
|
|
43
|
+
msb.interactiveMode();
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
msb.interactiveMode();
|
|
46
45
|
});
|
|
47
|
-
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trac-msb",
|
|
3
3
|
"main": "msb.mjs",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.6",
|
|
5
5
|
"pear": {
|
|
6
6
|
"name": "trac-msb",
|
|
7
7
|
"type": "terminal"
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "pear run -d .",
|
|
12
|
-
"prod": "NODE_OPTIONS='--max-old-space-size=4096' pear run . ${npm_config_store}",
|
|
13
12
|
"dev-rpc": "pear run -d . ${npm_config_store} --rpc --port ${npm_config_port}",
|
|
14
|
-
"prod
|
|
13
|
+
"prod": "NODE_OPTIONS='--max-old-space-size=4096' pear run . ${npm_config_store}",
|
|
14
|
+
"prod-rpc": "NODE_OPTIONS='--max-old-space-size=4096' pear run . ${npm_config_store} --rpc --host ${npm_config_host} --port ${npm_config_port}",
|
|
15
|
+
"env-prod": "if [ -f .env ]; then set -a; . ./.env; set +a; fi; NODE_OPTIONS='--max-old-space-size=4096' pear run . ${MSB_STORE:-node-store}",
|
|
16
|
+
"env-prod-rpc": "if [ -f .env ]; then set -a; . ./.env; set +a; fi; NODE_OPTIONS='--max-old-space-size=4096' pear run . ${MSB_STORE:-rpc-node-store} --rpc --host ${MSB_HOST:-127.0.0.1} --port ${MSB_PORT:-5000}",
|
|
17
|
+
"env-prod-rpc-docker": "if [ -f .env ]; then set -a; . ./.env; set +a; fi; NODE_OPTIONS='--max-old-space-size=4096' node msb.mjs ${MSB_STORE:-rpc-node-store} --rpc --host 0.0.0.0 --port ${MSB_PORT:-5000}",
|
|
15
18
|
"protobuf": "node scripts/generate-protobufs.js",
|
|
16
|
-
"test:acceptance": "node --experimental-vm-modules node_modules/jest/bin/jest.js --testTimeout=200000 tests/acceptance/",
|
|
19
|
+
"test:acceptance": "node --experimental-vm-modules node_modules/jest/bin/jest.js --testTimeout=200000 tests/acceptance/v1/rpc.test.mjs --runInBand",
|
|
17
20
|
"test:integration": "brittle-node -t 1200000 tests/integration/integration.test.js",
|
|
18
21
|
"test:unit:node": "brittle-node -t 60000 tests/unit/unit.test.js",
|
|
19
22
|
"test:unit:bare": "brittle-bare -t 60000 tests/unit/unit.test.js",
|
|
@@ -30,6 +33,7 @@
|
|
|
30
33
|
"bare-http1": "4.1.5",
|
|
31
34
|
"bare-readline": "1.0.7",
|
|
32
35
|
"bare-tty": "5.0.2",
|
|
36
|
+
"bare-utils": "1.5.1",
|
|
33
37
|
"bech32": "2.0.0",
|
|
34
38
|
"compact-encoding": "2.18.0",
|
|
35
39
|
"corestore": "7.5.0",
|
package/rpc/constants.mjs
CHANGED