DMC Module

instance attributes

Type: String

1
var chain require('chain');

data_dir

directory for storing dmc data.

Type: String

1
chain.data_dir 'dmc_data_dir';

config_dir

Directory for storing dmc configuration.

Type: String

1
chain.config_dir 'dmc_config_dir';

log_level

The log output levels for the chain are optional and can have the following values: ‘all’, ‘debug’, ‘info’, ‘warn’, ‘error’, ‘off’.

Type: String

1
chain.logger 'all'

pubkey_prefix

dmc public key prefix.

Type: String

1
chain.pubkey_prefix 'DM';

post

Sending a request to a node, where “resource” specifies the requested resource, and “body” specifies the request data.

Type: String

1
chain.post(String resource, String body "") async;

Instance Methods

load

load its own configuration.

1
2
3
4
5
chain.load("chain", {
"delete-all-blocks": true,
'chain-state-db-size-mb': 8 * 1024,
'genesis-json': 'genesis.json'
});

Parameter Description:

Load the system plugin and its configuration.

1
dmc.load( name, cfg );

start

start dmc.

1
chain.start();

stop

stop dmc

1
chain.stop();

System plugin

Note: The system plugin should be used in conjunction with the dmc.load instance method.

http plugin

Enable all RPC APIs on the DMC node.

Configuration instructions:

Config name Config note default
unix-socket-path The filename (relative to data-dir) to create a unix socket for HTTP RPC; set blank to disable.
http-server-address The local IP and port to listen for incoming http connections; set blank to disable. 127.0.0.1:8888
https-server-address The local IP and port to listen for incoming https connections; leave blank to disable.
https-certificate-chain-file Filename with the certificate chain to present on https connections. PEM format. Required for https.
https-private-key-file Filename with https private key in PEM format. Required for https.
https-ecdh-curve Configure https ECDH curve to use: secp384r1 or prime256v1 secp384r1
access-control-allow-origin Specify the Access-Control-Allow-Origin to be returned on each request.
access-control-allow-headers Specify the Access-Control-Allow-Headers to be returned on each request.
access-control-max-age Specify the Access-Control-Max-Age to be returned on each request.
access-control-allow-credentials Specify if Access-Control-Allow-Credentials: true should be returned on each request.
max-body-size The maximum body size in bytes allowed for incoming RPC requests 1048576
http-max-bytes-in-flight-mb Maximum size in megabytes http_plugin should use for processing http requests. 429 error response when exceeded. 500
http-max-in-flight-requests Maximum number of requests http_plugin should use for processing http requests. 429 error response when exceeded. -1
http-max-response-time-ms Maximum time for processing a request. 30
verbose-http-errors Append the error log to HTTP responses
http-validate-host If set to false, then any incoming “Host” header is considered valid 1
http-alias Additional acceptable values for the “Host” header of incoming HTTP requests, can be specified multiple times. Includes http/s_server_address by default.
http-threads Number of worker threads in http thread pool 2

chain Plugin

The core plugin required for processing and aggregating chain data on the DMC node.

Configuration instructions:

Config name Config note default
blocks-dir the location of the blocks directory (absolute path or relative to application data dir)
blocks-log-stride split the block log file when the head block number is the multiple of the stride
max-retained-block-files the maximum number of blocks files to retain so that the blocks in those files can be queried.
blocks-retained-dir the location of the blocks retained directory (absolute path or relative to blocks dir).
blocks-archive-dir the location of the blocks archive directory (absolute path or relative to blocks dir). “archive”
fix-irreversible-blocks When the existing block log is inconsistent with the index, allows fixing the block log and index files 0
protocol-features-dir the location of the protocol_features directory (absolute path or relative to application config dir) “protocol_features”
checkpoint Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.
abi-serializer-max-time-ms Override default maximum ABI serialization time allowed in ms 15
chain-state-db-size-mb Maximum size (in MiB) of the chain state database 1024
chain-state-db-guard-size-mb Safely shut down node when free space remaining in the chain state database drops below this size (in MiB). 128
backing-store The storage for state, chainbase or rocksdb “chainbase”
persistent-storage-num-threads Number of rocksdb threads for flush and compaction 1
persistent-storage-max-num-files Max number of rocksdb files to keep open. -1 unlimited. -1
persistent-storage-write-buffer-size-mb Size of a single rocksdb memtable (in MiB) 128
persistent-storage-bytes-per-sync Rocksdb write rate of flushes and compactions. 1048576
persistent-storage-mbytes-snapshot-batch Rocksdb batch size threshold before writing read in snapshot data to database. 50
reversible-blocks-db-size-mb (DEPRECATED: no longer used) Maximum size (in MiB) of the reversible blocks database
reversible-blocks-db-guard-size-mb (DEPRECATED: no longer used) Safely shut down node when free space remaining in the reverseible blocks database
drops below this size (in MiB).
signature-cpu-billable-pct Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50% 50
chain-threads Number of worker threads in controller thread pool 2
contracts-console print contract’s output to console
deep-mind print deeper information about chain operations
telemetry-url Send Zipkin spans to url. e.g. http://127.0.0.1:9411/api/v2/spans
actor-whitelist Account added to actor whitelist (may specify multiple times)
actor-blacklist Account added to actor blacklist (may specify multiple times)
contract-whitelist Contract account added to contract whitelist (may specify multiple times)
contract-blacklist Contract account added to contract blacklist (may specify multiple times)
action-blacklist Action (in the form code::action) added to action blacklist (may specify multiple times)
key-blacklist Public key added to blacklist of keys that should not be included in authorities (may specify multiple times)
sender-bypass-whiteblacklist Deferred transactions sent by accounts in this list do not have any of the subjective whitelist/blacklist checks
applied to them (may specify multiple times)
read-mode Database read mode (“speculative”, “head”, “read-only”, “irreversible”). “speculative”
api-accept-transactions Allow API transactions to be evaluated and relayed if valid. 1
validation-mode Chain validation mode (“full” or “light”). “full”
disable-ram-billing-notify-checks Disable the check which subjectively fails a transaction if a contract bills more RAM to another account withinthe context of a notification handler (i.e. when the receiver is not the code of the action).
maximum-variable-signature-length Subjectively limit the maximum length of variable components in a variable legnth signature to this size in bytes 16384
trusted-producer Indicate a producer whose blocks headers signed by it will be fully validated, but transactions in those validated
blocks will be trusted.
database-map-mode Database map mode (“mapped”, “heap”, or “locked”). “mapped”
enable-account-queries enable queries to find accounts by various metadata. 0
max-nonprivileged-inline-action-size maximum allowed size (in bytes) of an inline action for a nonprivileged account 4096

net Plugin

Forming a network.

Configuration instructions:

Config name Config note default
p2p-listen-endpoint The actual host:port used to listen for incoming p2p connections. 0.0.0.0:9876
p2p-server-address An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint.
p2p-peer-address The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network.
p2p-max-nodes-per-host Maximum number of client nodes from any single IP address 1
p2p-accept-transactions Allow transactions received over p2p network to be evaluated and relayed if valid. 1
p2p-reject-incomplete-blocks Reject pruned signed_blocks even in light validation 1
agent-name The name supplied to identify this node amongst the peers. “DMC Test Agent”
allowed-connection Can be ‘any’ or ‘producers’ or ‘specified’ or ‘none’. If ‘specified’, peer-key must be specified at least once. If only ‘producers’, peer-key is not required. ‘producers’ and ‘specified’ may be combined. “any”
peer-key Optional public key of peer allowed to connect. May be used multiple times.
peer-private-key Tuple of [PublicKey, WIF private key] (may specify multiple times)
max-clients Maximum number of clients from which connections are accepted, use 0 for no limit 25
connection-cleanup-period Number of seconds to wait before cleaning up dead connections 30
max-cleanup-time-msec Max connection cleanup time per cleanup call in milliseconds 10
net-threads Number of worker threads in net_plugin thread pool 2
sync-fetch-span Number of blocks to retrieve in a chunk from any individual peer during synchronization 100
use-socket-read-watermark Enable experimental socket read watermark optimization 0
peer-log-format The string used to format peers when logging messages about them. Available Variables: _name, _id, _sid, _ip, _port, _lip, _lport. “{name} {ip}:{port}”
p2p-keepalive-interval-ms Peer heartbeat keepalive message interval in milliseconds 32000
p2p-tls-security-group-ca-file Certificate Authority’s certificate file used for verifying peers TLS connection when security groups feature enabled
p2p-tls-own-certificate-file Certificate file that will be used to authenticate running node if TLS is enabled
p2p-tls-private-key-file Private key file that is used in conjunction with p2p-tls-own-certificate-file for server authorization in TLS connection. Together p2p-tls-private-key-file + p2p-tsl-own-certificate-file automatically enables TLS-only connection for peers.

producer Plugin

Loading the functionalities required for the block-producing node.

Configuration instructions:

Config name Config note default
max-transaction-time Limits the maximum time (in milliseconds) that is allowed a pushed transaction’s code to execute before being considered invalid 30
max-irreversible-block-age Limits the maximum age (in seconds) of the DPOS Irreversible Block for a chain this node will produce blocks on (use negative value to indicate unlimited) -1
private-key (DEPRECATED - Use signature-provider instead) Tuple of [public key, WIF private key] (may specify multiple times)
signature-provider Key=Value pairs in the form = where: is a string form of a valid DMC public key, is a string in the form :, and is KEY DM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
greylist-account Account that can not access extended CPU/NET virtual resources
greylist-limit Limit (between 1 and 1000) on the multiple that CPU/NET virtual resources can extend during low usage 1000
produce-time-offset-us Offset of non-last block producing time in microseconds. Valid range 0 .. -block_time_interval 0
last-block-time-offset-us Offset of last block producing time in microseconds. Valid range 0 .. -block_time_interval -200000
cpu-effort-percent Percentage of CPU block production time used to produce block. Whole number percentages, e.g. 80 for 80% 80
last-block-cpu-effort-percent Percentage of CPU block production time used to produce the last block. Whole number percentages, e.g. 80 for 80% 80
max-block-cpu-usage-threshold-us Threshold of CPU block production to consider block full; when within threshold of max-block-cpu-usage, block can be produced immediately 5000
max-block-net-usage-threshold-bytes Threshold of NET block production to consider block full; when within threshold of max-block-net-usage, block can be produced immediately 1024
max-scheduled-transaction-time-per-block-ms Maximum wall-clock time, in milliseconds, spent retiring scheduled transactions in any block before returning to normal transaction processing 100
subjective-cpu-leeway-us Time in microseconds allowed for a transaction that starts with insufficient CPU quota to complete and cover its CPU usage 31000
incoming-defer-ratio Ratio between incoming transactions and deferred transactions when both are queued for execution 1

trace_api Plugin

Consumer-centric long-term API for retrieving retirement actions and related metadata from the specified blocks. This plugin stores serialized block tracing data in the file system for later retrieval through HTTP RPC requests.

Configuration instructions:

Config name Config note default
trace-dir The location of the trace directory (absolute path or relative to application data dir) “traces”
trace-slice-stride The number of blocks each “slice” of trace data will contain on the filesystem 10000
trace-minimum-irreversible-history-blocks Number of blocks to ensure are kept past LIB for retrieval before “slice” files can be automatically removed -1
trace-minimum-uncompressed-irreversible-history-blocks Number of blocks to ensure are uncompressed past LIB. Compressed “slice” files are still accessible but may carry a performance loss on retrieval -1
trace-rpc-abi ABIs used when decoding trace RPC responses. There must be at least one ABI specified OR the flag trace-no-abis must be used. ABIs are specified as “Key=Value” pairs in the form =
trace-no-abis Use to indicate that the RPC responses will not use ABIs. Failure to specify this option when there are no trace-rpc-abi configurations will result in an Error. This option is mutually exclusive with trace-rpc-api

Instance

bp node

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var chain require('chain');
var config require('../config.json');
var accounts require('./bpaccounts.json');
console.notice("start first chain producer node");
var _config require('./config.json');

var producer accounts[0];

var producername producer.account;
var public_key producer.public_key;
var private_key producer.private_key;

chain.pubkey_prefix _config.pub_key_prefix;
chain.config_dir _config.bp_dir + "/" + producername;
chain.data_dir _config.bp_dir + "/" + producername;

console.notice("config_dir:", chain.config_dir);
console.notice("data_dir:", chain.data_dir);

chain.load("http", {
"http-server-address": "0.0.0.0:8801",
"access-control-allow-origin": "*",
"http-validate-host": false,
"verbose-http-errors": true //open error
});

chain.load("net", {
"p2p-peer-address": config["bios_p2p_peer_address"],
"max-clients": 100,
"p2p-listen-endpoint": "0.0.0.0:9801",
"p2p-max-nodes-per-host": 10,
});

chain.load("producer", {
'producer-name': producername,
'enable-stale-production': true,
'max-transaction-time': 3000,
'incoming-transaction-queue-size-mb': 14095,
'private-key': JSON.stringify([public_key, private_key])
});


chain.load("chain", {
"contracts-console": true,
'chain-state-db-size-mb': 8 * 1024,
"delete-all-blocks": true,
"genesis-json": "genesis.json"
});

chain.load("chain_api");
chain.load("trace_api", {
"trace-no-abis": "true"
});
chain.start();

Synchronized node

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var chain require('chain');
var fs require("fs");
var process require('process');
var producer process.argv;
var producername producer[2];
var public_key producer[3];
var private_key producer[4];
var http producer[5];
var p2p producer[6];

var _config require('../common/config.json');

chain.config_dir _config.bp_dir + "/" + producername;
chain.data_dir _config.bp_dir + "/" + producername;
chain.pubkey_prefix _config.pub_key_prefix;
console.notice("producer===>", producer)
console.notice("start CHAIN producer node:", producername, 'http:', http, 'p2p:', p2p);

console.notice("config_dir:", chain.config_dir);
console.notice("data_dir:", chain.data_dir);

let chain_config {
"contracts-console": true,
'chain-state-db-size-mb': 8 * 1024,
"delete-all-blocks": true
};

if (!fs.exists(chain.data_dir) && !fs.exists(chain.config_dir)) {
chain_config['genesis-json'] "genesis.json";
}

chain.load("http", {
"http-server-address": "0.0.0.0:" + http,
"access-control-allow-origin": "*",
"http-validate-host": false,
"verbose-http-errors": true
});

chain.load("net", {
"p2p-peer-address": _config["p2p_peer_address"],
"max-clients": 100,
"p2p-listen-endpoint": "0.0.0.0:" + p2p,
"p2p-max-nodes-per-host": 25
});

chain.load("producer", {
'producer-name': producername,
'enable-stale-production': true,
'max-transaction-time': 3000,
'private-key': JSON.stringify([public_key, private_key])
});


chain.load("chain", chain_config);

chain.load("chain_api");

chain.start();

genesis.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"initial_timestamp": "2023-01-10T00:00:00.000",
"initial_key": "DM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"initial_configuration": {
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_net_usage": 524288,
"base_per_transaction_net_usage": 12,
"net_usage_leeway": 500,
"context_free_discount_net_usage_num": 20,
"context_free_discount_net_usage_den": 100,
"max_block_cpu_usage": 200000,
"target_block_cpu_usage_pct": 1000,
"max_transaction_cpu_usage": 150000,
"min_transaction_cpu_usage": 100,
"max_transaction_lifetime": 3600,
"deferred_trx_expiration_window": 600,
"max_transaction_delay": 3888000,
"max_inline_action_size": 4096,
"max_inline_action_depth": 4,
"max_authority_depth": 6
}
}