Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

kadaster-labs/sensrnet-multichain

Repository files navigation

SensRNet Blockchain Application

This is the repo for the blockchain component of the SensrNet application. It features the blockchain component, which can be used to form a network of connected nodes which distribute and validate each others transactions (events).

For more information see our documentation (and especially details about MultiChain).

Running a Node

Two node-variants can be created using the Dockerfile in this repository. Depending on the node variant, either a new chain is started, or an existing chain is joined. The node variant depends on the availability of the MAIN_NODE_HOST environment variable. The node configuration depends on environment variables.

Configuration

  • CHAINNAME: SensRNet (The blockchain name to join / create)
  • NETWORK_PORT: 8571 (The port to connect with the blockchain network)
  • RPC_PORT: 8570 (The port to connect using RPC)
  • RPC_USER: multichainrpc (The user to connect using RPC)
  • RPC_PASSWORD: change-me (The password to connect using RPC)
  • RPC_ALLOW_IP: 0.0.0.0/0.0.0.0 (IP range allowed to connect using RPC)
  • DELAY_INIT: 1 (Whether to wait during node initialization)
  • PARAM_TARGET_BLOCK_SIZE: target-block-time|30
  • PARAM_ANYONE_CAN_CONNECT: anyone-can-connect|true
  • PARAM_ANYONE_CAN_MINE: anyone-can-mine|true
  • PRIVATE_KEY: The private key to initialize the node with. The private key can be set when the node has not yet been initialized. An address / private key pair can be generated using scripts/generate_keypair.js.

Optional

These variables can be set as environment variables:

  • MAIN_NODE_HOST: main-node (The IP-address / hostname of the blockchain node to connect to)
# Basic chain parameters

chain-protocol = multichain             # Chain protocol: multichain (permissions, native assets) or bitcoin
chain-is-testnet = false                # Content of the 'testnet' field of API responses, for compatibility.
target-block-time = 15                  # Target time between blocks (transaction confirmation delay), seconds. (5 - 86400)
maximum-block-size = 1000000            # Maximum block size in bytes. (1000 - 1000000000)

# Global permissions

anyone-can-connect = false              # Anyone can connect, i.e. a publicly readable blockchain.
anyone-can-send = false                 # Anyone can send, i.e. transaction signing not restricted by address.
anyone-can-receive = false              # Anyone can receive, i.e. transaction outputs not restricted by address.
anyone-can-issue = false                # Anyone can issue new native assets.
anyone-can-mine = false                 # Anyone can mine blocks (confirm transactions).
anyone-can-activate = false             # Anyone can grant or revoke connect, send and receive permissions.
anyone-can-admin = false                # Anyone can grant or revoke all permissions.
allow-p2sh-outputs = true               # Allow pay-to-scripthash (P2SH) scripts, often used for multisig.
allow-multisig-outputs = true           # Allow bare multisignature scripts, rarely used but still supported.

# Consensus requirements

setup-first-blocks = 60                 # Length of initial setup phase in blocks, in which mining-diversity,
                                        # admin-consensus-* and mining-requires-peers are not applied. (1 - 31536000)
mining-diversity = 0.3                  # Miners must wait <mining-diversity>*<active miners> between blocks. (0 - 1)
admin-consensus-admin = 0.5             # <admin-consensus-admin>*<active admins> needed to change admin perms. (0 - 1)
admin-consensus-activate = 0.5          # <admin-consensus-activate>*<active admins> to change activate perms. (0 - 1)
admin-consensus-mine = 0.5              # <admin-consensus-mine>*<active admins> to change mining permissions. (0 - 1)
admin-consensus-issue = 0.0             # <admin-consensus-issue>*<active admins> to change issue permissions. (0 - 1)
mining-requires-peers = true            # Default for whether nodes only mine blocks if connected to other nodes.

# Native blockchain currency (likely not required)

initial-block-reward = 0                # Initial block mining reward in raw native currency units. (0 - 1000000000000000000)
first-block-reward = -1                 # Different mining reward for first block only, ignored if negative. (-1 - 1000000000000000000)
reward-halving-interval = 52560000      # Interval for halving of mining rewards, in blocks. (60 - 4294967295)
reward-spendable-delay = 1              # Delay before mining reward can be spent, in blocks. (1 - 100000)
minimum-per-output = 0                  # Minimum native currency per output (anti-dust), in raw units.
                                        # If set to -1, this is calculated from minimum-relay-fee. (-1 - 1000000000)
maximum-per-output = 100000000000000    # Maximum native currency per output, in raw units. (0 - 1000000000000000000)
minimum-relay-fee = 0                   # Minimum transaction fee, in raw units of native currency. (0 - 1000000000)
native-currency-multiple = 100000000    # Number of raw units of native currency per display unit. (0 - 1000000000)

# Advanced mining parameters

skip-pow-check = false                  # Skip checking whether block hashes demonstrate proof of work.
pow-minimum-bits = 16                   # Initial and minimum proof of work difficulty, in leading zero bits. (1 - 32)
target-adjust-freq = 86400              # Interval between proof of work difficulty adjustments, in seconds. (3600 - 4294967295)
allow-min-difficulty-blocks = false     # Allow lower difficulty blocks if none after 2*<target-block-time>.

# Standard transaction definitions

only-accept-std-txs = true              # Only accept and relay transactions which qualify as 'standard'.
max-std-tx-size = 100000                # Maximum size of standard transactions, in bytes. (1024 - 10000000)
max-std-op-return-size = 4096           # Maximum size of OP_RETURN metadata in standard transactions, in bytes. (0 - 8388608)
max-std-op-drops-count = 5              # Maximum number of OP_DROPs per output in standard transactions. (0 - 100)
max-std-element-size = 600              # Maximum size of data elements in standard transactions, in bytes. (128 - 32768)

Example Network

An example network containing a main-node (which creates a chain), and another node (which connects to the main-node) can be brought up using the following command:

$ docker-compose up --build

And stopped:

$ docker-compose stop

Find Us

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Maintainers

Should you have any questions or concerns, please reach out to one of the project's Maintainers.

License

This work is licensed under a EUPL v1.2 license.