Configuration

Mainsail provides a wide variety of ways to configure how it behaves, what plugins are used, who is forging and more. Each option is documented, so head over to the Mainsail repository and Mainsail Network Config repository. All of this configuration can be found in the app.json, crypto.json, validators.json and peers.json files of the respective network you are using.

Plugins Configuration

Plugins are packages that expose services which expand or alter what a Mainsail node is capable of doing.

{
  "main": [
    {
      "package": "@mainsail/validation"
    },
    {
      "package": "@mainsail/crypto-config"
    },
    {
      "package": "@mainsail/crypto-validation"
    },
    {
      "package": "@mainsail/crypto-hash-bcrypto"
    },
    {
      "package": "@mainsail/crypto-signature-ecdsa"
    },
    {
      "package": "@mainsail/crypto-key-pair-ecdsa"
    },
    {
      "package": "@mainsail/crypto-consensus-bls12-381"
    },
    {
      "package": "@mainsail/crypto-address-base58"
    },
    {
      "package": "@mainsail/crypto-address-keccak256"
    },
    {
      "package": "@mainsail/crypto-wif"
    },
    {
      "package": "@mainsail/blockchain-utils"
    },
    {
      "package": "@mainsail/serializer"
    },
    {
      "package": "@mainsail/crypto-block"
    },
    {
      "package": "@mainsail/evm-service"
    },
    {
      "package": "@mainsail/crypto-transaction"
    },
    {
      "package": "@mainsail/crypto-transaction-evm-call"
    },
    {
      "package": "@mainsail/crypto-worker"
    },
    {
      "package": "@mainsail/logger-pino"
    },
    {
      "package": "@mainsail/snapshot-legacy-importer"
    },
    {
      "package": "@mainsail/state"
    },
    {
      "package": "@mainsail/database"
    },
    {
      "package": "@mainsail/api-database"
    },
    {
      "package": "@mainsail/api-sync"
    },
    {
      "package": "@mainsail/transactions"
    },
    {
      "package": "@mainsail/transaction-pool-worker"
    },
    {
      "package": "@mainsail/crypto-messages"
    },
    {
      "package": "@mainsail/crypto-commit"
    },
    {
      "package": "@mainsail/p2p"
    },
    {
      "package": "@mainsail/evm-api-worker"
    },
    {
      "package": "@mainsail/processor"
    },
    {
      "package": "@mainsail/evm-consensus"
    },
    {
      "package": "@mainsail/validator"
    },
    {
      "package": "@mainsail/consensus-storage"
    },
    {
      "package": "@mainsail/consensus"
    },
    {
      "package": "@mainsail/api-development"
    },
    {
      "package": "@mainsail/webhooks"
    },
    {
      "package": "@mainsail/bootstrap"
    }
  ],
  "crypto-worker": [
    {
      "package": "@mainsail/logger-pino"
    },
    {
      "package": "@mainsail/validation"
    },
    {
      "package": "@mainsail/crypto-config"
    },
    {
      "package": "@mainsail/crypto-validation"
    },
    {
      "package": "@mainsail/crypto-hash-bcrypto"
    },
    {
      "package": "@mainsail/crypto-signature-ecdsa"
    },
    {
      "package": "@mainsail/crypto-key-pair-ecdsa"
    },
    {
      "package": "@mainsail/crypto-consensus-bls12-381"
    },
    {
      "package": "@mainsail/crypto-address-base58"
    },
    {
      "package": "@mainsail/crypto-address-keccak256"
    },
    {
      "package": "@mainsail/crypto-wif"
    },
    {
      "package": "@mainsail/serializer"
    },
    {
      "package": "@mainsail/crypto-block"
    },
    {
      "package": "@mainsail/crypto-transaction"
    },
    {
      "package": "@mainsail/crypto-transaction-evm-call"
    }
  ],
  "transaction-pool": [
    {
      "package": "@mainsail/logger-pino"
    },
    {
      "package": "@mainsail/validation"
    },
    {
      "package": "@mainsail/crypto-config"
    },
    {
      "package": "@mainsail/crypto-validation"
    },
    {
      "package": "@mainsail/crypto-hash-bcrypto"
    },
    {
      "package": "@mainsail/crypto-signature-ecdsa"
    },
    {
      "package": "@mainsail/crypto-key-pair-ecdsa"
    },
    {
      "package": "@mainsail/crypto-consensus-bls12-381"
    },
    {
      "package": "@mainsail/crypto-address-base58"
    },
    {
      "package": "@mainsail/crypto-address-keccak256"
    },
    {
      "package": "@mainsail/crypto-wif"
    },
    {
      "package": "@mainsail/blockchain-utils"
    },
    {
      "package": "@mainsail/serializer"
    },
    {
      "package": "@mainsail/evm-service"
    },
    {
      "package": "@mainsail/crypto-block"
    },
    {
      "package": "@mainsail/crypto-commit"
    },
    {
      "package": "@mainsail/crypto-transaction"
    },
    {
      "package": "@mainsail/crypto-transaction-evm-call"
    },
    {
      "package": "@mainsail/transactions"
    },
    {
      "package": "@mainsail/state"
    },
    {
      "package": "@mainsail/transaction-pool-service"
    },
    {
      "package": "@mainsail/transaction-pool-broadcaster"
    },
    {
      "package": "@mainsail/api-transaction-pool"
    },
    {
      "package": "@mainsail/webhooks"
    }
  ],
  "evm-api": [
    {
      "package": "@mainsail/logger-pino"
    },
    {
      "package": "@mainsail/validation"
    },
    {
      "package": "@mainsail/crypto-config"
    },
    {
      "package": "@mainsail/crypto-validation"
    },
    {
      "package": "@mainsail/crypto-hash-bcrypto"
    },
    {
      "package": "@mainsail/crypto-signature-ecdsa"
    },
    {
      "package": "@mainsail/crypto-key-pair-ecdsa"
    },
    {
      "package": "@mainsail/crypto-consensus-bls12-381"
    },
    {
      "package": "@mainsail/crypto-address-base58"
    },
    {
      "package": "@mainsail/crypto-address-keccak256"
    },
    {
      "package": "@mainsail/crypto-wif"
    },
    {
      "package": "@mainsail/serializer"
    },
    {
      "package": "@mainsail/crypto-block"
    },
    {
      "package": "@mainsail/crypto-messages"
    },
    {
      "package": "@mainsail/crypto-commit"
    },
    {
      "package": "@mainsail/crypto-transaction"
    },
    {
      "package": "@mainsail/crypto-transaction-evm-call"
    },
    {
      "package": "@mainsail/transactions"
    },
    {
      "package": "@mainsail/state"
    },
    {
      "package": "@mainsail/evm-service"
    },
    {
      "package": "@mainsail/database"
    },
    {
      "package": "@mainsail/evm-state"
    },
    {
      "package": "@mainsail/api-evm"
    }
  ]
}

Again the configuration is quite simple. We have a top-level key that serves as a namespace for all of our plugin specific configuration, for each process type ("main", "transaction-pool", "evm-api", "crypto-worker"). Then we see a list of objects that all contain package key and an optional options key.

The package key is used by Mainsail to decide what package should be loaded, this can be either an npm package name or path to a local package.

Plugin options

The options key is used to configure the services that are provided by the plugin. Provided options are merged with default package configuration that is loaded from "default.ts" file inside the package.

Keys that are type of object will be merged with default configuration. String, number, boolean and array keys, will replace default configuration key.

{
    "package": "@mainsail/logger-pino",
    "options": {
        "fileRotator": {
            "interval": "2d"
        }
    }
},

Validator Configuration

The validator configuration is responsible for providing the information that is necessary to know who should be forging on a server. This can either be a list of plaintext bip39 passphrases or a bip38 encrypted passphrase that is protected with a password. Configuration is stored inside validators.json file.

{
  "secrets": ["validator mnemonic"]
}

Peer Configuration

The peer configuration is responsible for providing the information that is necessary to know who the seeds are so that we can retrieve a list of peers from them and start communicating with the network. By default it ships with a list of seeds and an additional list of sources on GitHub which is loaded when Core starts. Configuration is stored in peers.json file.

Environment Configuration

Sometimes it can be beneficial or even necessary to have different configuration values per environment you are working with. An example would be where you are testing a new feature to improve database query or caching performance, in those cases you don't want to be bound to the settings of the production network but run with your own values and modifications.

MAINSAIL_LOG_LEVEL=info
MAINSAIL_LOG_LEVEL_FILE=debug

MAINSAIL_DB_HOST=localhost
MAINSAIL_DB_PORT=5432
MAINSAIL_DB_DATABASE=test_db
MAINSAIL_DB_USERNAME=test_db
MAINSAIL_DB_PASSWORD=password
MAINSAIL_DB_LOGGING_ENABLED=

MAINSAIL_API_SYNC_ENABLED=

MAINSAIL_P2P_HOST=0.0.0.0
MAINSAIL_P2P_PORT=4000

MAINSAIL_WEBHOOKS_HOST=0.0.0.0
MAINSAIL_WEBHOOKS_PORT=4004

MAINSAIL_API_DEV_ENABLED=true
MAINSAIL_API_DEV_HOST=0.0.0.0
MAINSAIL_API_DEV_PORT=4006

MAINSAIL_API_EVM_DISABLED=
MAINSAIL_API_EVM_HOST=0.0.0.0
MAINSAIL_API_EVM_PORT=4008

MAINSAIL_API_TRANSACTION_POOL_DISABLED=
MAINSAIL_API_TRANSACTION_POOL_HOST=0.0.0.0
MAINSAIL_API_TRANSACTION_POOL_PORT=4007

MAINSAIL_CRYPTO_WORKER_COUNT=2
MAINSAIL_CRYPTO_WORKER_LOGGING_ENABLED=

Those are just a few of the possible environment variables, check the Environment Variables to get a full list of available environment variables and make sure to check out dotenv and sindresorhus/env-paths to get a better understanding of what is happening under the hood.