In this tutorial we will create our own blockchain network using cellframe-node software.
Test network name is home21-network (in next part of instruction we create 2nd network home12-network and try move transactions from one network to another)
Linux and Windows configuration files for test network you can download from:
Configuration files is placed in directories:
/opt/cellframe-node – Linux
C:\Users\Public\Documents\cellframe-node – Windows
We create 3 nodes: 1 master and 2 root node. On the picture you can see two shards: cell0 and cell1. We will work with them in the next editions of that manual.
You can use virtual machine for it, created on standard virtualization software (Microsoft Hyper-V, VMware Player\Fusion\Workstation, etc). Every from 3 machine must be configured for TCP\IP network communication.
We need to create configurations files for every node. Network configs consists of many files and folders – configuration files are presented inside archive with distributives. We need change IP-addresses in cellframe-node.cfg (ext_address) and home21-network.cfg (seed_nodes)
Default network config contains next settings:
1 shard (cell)
3 nodes:
node0
node1
node2
5 chains:
poa – consensus DaG-PoA
pos – consensus DaG-PoS
block-poa – consensus block DaG-PoA
block-pos – consensus block DaG-PoS
noconsensus – no consensus
Node supports next crypto algorithms:
sig_bliss - Bliss
sig_picnic - Picnic
sig_dil - Dilithium
Cellframe-node config directory contains next configs:
Global node config – cellframe-node.cfg
Network folders – configs for every network, which are placed in etc/network folder. There is network config on same level with network name, for example home21-network.cfg and folder home21-network with chains config. Chain’s configs can be named arbitrarily, but with cfg extension.
[mempool]::auto_proc parameter is node parameter in cellframe-node.cfg, which allows automatically mempool processing (no need manually datum processing using cellframe-node-cli mempool_proc command)
If you use different consensus type on one local machine, there is no principal differences in their working between each other: only some different configs and additional certificates\wallet. But in network mode you can see more differences.
Variants of network state:
NET_STATE_OFFLINE
NET_STATE_LINKS_PREPARE
NET_STATE_LINKS_CONNECTING
NET_STATE_LINKS_ESTABLISHED
NET_STATE_SYNC_GDB
NET_STATE_SYNC_CHAINS
NET_STATE_ADDR_REQUEST
NET_STATE_ONLINE
More information you can read in wiki pages https://wiki.cellframe.net/en/soft/network_settings
Node consists of 3 binaries:
cellframe-node – main binary
cellframe-node-cli – cmd interface to node
cellframe-node-tool – special tool for executing command for wallet and certificate creation
Node structure:
The simplest example is chain without consensus. You simply emit tokens on your local machine:
cellframe-node-tool cert create home21_cert sig_dil
cellframe-node-cli wallet new -w home21-wallet -sign sig_dil
Wallet 'home21-wallet' (type=sig_dil) successfully created
cellframe-node-cli wallet info -w home21-wallet -net home21-network
wallet: home21-wallet
addr: rMcg8v2uM2b71q9sVWFQgLKqagozgWfq5Q8gGrfcq5VnaVHgCjvfteFeK3HRmjsQe3nfjqxJqV3LX7siMTVaJsz38dQKmYju6TtKPoq8
network: home21-network
balance: 0
cellframe-node-cli token_decl -net home21-network -chain noconsensus -token HOME21TKN -total_supply 5000 -signs_total 1 -signs_emission 1 -certs home21_cert
datum 0xEAE464E0BA9451C9DA7B5D4FCC4097094D8B766A450F0C35AABB698D44B27B9A with token HOME21TKN is placed in datum pool
Process token declaration in mempool (if [mempool]::auto_proc is disabled):
cellframe-node-cli mempool_proc -net home21-network -chain noconsensus -datum 0xEAE464E0BA9451C9DA7B5D4FCC4097094D8B766A450F0C35AABB698D44B27B9A
if [mempool]::auto_proc is enabled, and operation was successful, you see that message, because datum was already automatically processed:
Error! Can't find datum 0xEAE464E0BA9451C9DA7B5D4FCC4097094D8B766A450F0C35AABB698D44B27B9A
cellframe-node-cli token_emit -net home21-network -chain_emission noconsensus -chain_base_tx noconsensus -token HOME21TKN -certs home21_cert -emission_value 123000000000000 -addr rMcg8v2uM2b71q9sVWFQgLKqagozgWfq5Q8gGrfcq5VnaVHgCjvfteFeK3HRmjsQe3nfjqxJqV3LX7siMTVaJsz38dQKmYju6TtKPoq8
datum emission 0x6EA8AB68FF360741C0DCE5147E5EC41A466AB3DD5383DD8A01B0B49A635AEA76 is placed in datum pool
datum tx 0xF9C1ABFB139586112FE8547A80B263BA3A7B7DC17B2B60417A63F5162BC48C26 is placed in datum pool
cellframe-node-cli mempool_proc -net home21-network -chain noconsensus -datum 0x6EA8AB68FF360741C0DCE5147E5EC41A466AB3DD5383DD8A01B0B49A635AEA76
cellframe-node-cli mempool_proc -net home21-network -chain noconsensus -datum 0xF9C1ABFB139586112FE8547A80B263BA3A7B7DC17B2B60417A63F5162BC48C26
cellframe-node-cli wallet info -w home21-wallet -net home21-network
[mempool]::auto_proc disabled:
[mempool]::auto_proc enabled:
Also, you can create token emission with noconsensus chain, which are stored in 3 chains. You need create 3 chain configuration files for it. Take standard nonconsensus file, change file name, chain name, id and storage_dir parameters, it must be unique per node.
noconsensus-token – token declaration is stored
noconsensus-emit – emissions events are stored
noconsensus-tx – transactions event are stored
cellframe-node-cli token_decl -net home21-network -chain noconsensus-token -token TKN_DIL_M -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_sig_dil
datum 0xFE6DCF09946F8EE188517FE97BADAC9B1E57DEBAF3237008050BD44E3D9332AE with token TKN_DIL_M is placed in datum pool
cellframe-node-cli token_emit -net home21-network -chain_emission noconsensus-emit -chain_base_tx noconsensus-tx -token TKN_DIL_M -certs cert_sig_dil -emission_value 15000000000000 -addr rMcg8v2uM2b71q9sVJbmwvqZ6UHwwJTSNyW17LZEQPjt1uX6wcB2cnXXkrn9AWxBRBc1UxKBQTXhtZSm4sXhzUurp6ka69aSvArKEqrw
Datum emission 0xF316263599B4CE1B4A55DFFAB78E0D0DEB919FBACEDC8EA7A3B95DA0BF5D8997 is placed in datum pool
datum tx 0xFDA672745DD85734E76FA7B96510AEE2819B5AD341236A31471847923DB8B95E is placed in datum pool
That kind of consensus needs special wallet for transaction signing. First, we need create it using our local home21 chain without consensus. We will use dilithium alghoritm:
cellframe-node-tool wallet create wallet-pos sig_dil
cellframe-node-tool cert create cert_dil sig_dil
cellframe-node-cli wallet info -w wallet-pos -net home21-network
cellframe-node-cli token_decl -net home21-network -chain noconsensus -token HOME21PS -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_dil
cellframe-node-cli mempool_proc -net home21-network -chain noconsensus -datum 0xF40769CD50415957D51C6C39E61C9D70121841D472493B1A9900148F104A2E34
cellframe-node-cli token_emit -net home21-network -chain_emission noconsensus -chain_base_tx noconsensus -token HOME21PS -certs cert_dil -emission_value 123000000000000 -addr rMcg8v2uM2b71q9sVkzPjRkcHxYM2DsK2WT83SetGVpWjUWasoBwTYgHo3XrNtSxUz7iu7ufAt9oFy8NFB6vhDWwH6S2J8SFwVV4zWLn
datum emission 0xE1B2F22C5141CB728C6BBC01678AD2F46840805ED5632567FF6BE90461142227 is placed in datum pool
datum tx 0x6C5B1B1A1288F721DDCF90F8789CB7D737ED7A837AB18CDFA490BFA34F290C6A is placed in datum pool
config section inside network config (home21-network.cfg):
[dag-pos]
events-sign-wallet= wallet-pos
tokens_hold=[HOME21PS,HOME21PS]
tokens_hold_value=[1000000000,1000000000]
confirmations_minimum=1
We already have certificate and wallet (home21-wallet) therefore starting
DaG-PoS consensus can be configured in "cellframe-node\etc\network\home21-network\chain-pos.cfg":
cellframe-node-cli token_decl -net home21-network -chain pos -token HOME21PS1 -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_dil
datum 0xEC7A892DB8DF3999FAE56E0EE8DAC520A789C6A28E9460DF0CB7089E66ADE313 with token HOME21PLA is placed in datum pool
process it through mempool
Add event id 0x8556291A1610AC8983E8E951183C1E0450E90C80194DB3E1A7DD03836EDEA8C8 to static_genesis_event parameter in chain-pos.cfg
cellframe-node-cli token_emit -net home21-network -chain_emission pos -chain_base_tx pos -token HOME21PS1 -certs cert_dil -emission_value 15550000000 -addr rMcg8v2uM2b71q9sV1cn2EqeoXqeFqHUNBkW63ezA5eUKdihwjwqvPHWzz6bMr1BCm1xcnyu2uk99pQDLjP9eH1hR61qVCV6AyLmMmk6
datum emission 0x912E59E2A6F5D984A13EC69100FE73A960E3F159A922DEC4B2D95F59CF1E1191 is placed in datum pool
datum tx 0xEFD653261C8D3ED0D2AD46B6A82483874124B2E238775D512CC80806CD0F6E87 is placed in datum pool
We can see in cellframe-node log:
process it through mempool
You can configure nodes with different roles:
- unlimited root node
- client node, that can create tokens and require transfer from wallet form root node.
Emission operation on client node is limited. You have two nodes – client and server (technically you can create many client nodes and many server nodes).
cellframe-node-cli token_decl -net home21-network -chain poa -token HOME21POA -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_sig
node log:
write event from console to chain_poa.cfg
Disable seed_mode on root node
cellframe-node-tool wallet create wallet-dil sig_dil
cellframe-node-cli wallet info -w home21wallet -net home21-network
wallet: wallet-dil
addr: rMcg8v2uM2b71q9sUhxaDNBdWrQNC6XAXjjPTrPzZsqiDmAToEughrMSukFYsrDNyYBzWr8dQFrJvXvWaamJa5CWznLoWcYcKuBFUMSy
network: home21-network
balance: 0
cellframe-node-cli token_emit -net home21-network -chain_emission poa -chain_base_tx poa -token HOME21POA -certs cert_dil -emission_value 123000000000000 -addr rMcg8v2uM2b71q9sUhxaDNBdWrQNC6XAXjjPTrPzZsqiDmAToEughrMSukFYsrDNyYBzWr8dQFrJvXvWaamJa5CWznLoWcYcKuBFUMSy
You see messages on root node
Sync client node with server and you can see new balance on your wallet
That kind of consensus supports round verification option. See it description in “node syncing” part of this instruction.
That kind of consensus need seed_mode configuring:
Set general::seed_mode=true in cellframe-node.cfg
Make emission, write DAG event id in chain config
Set general::seed_mode=false
Recommend remove GDB base and chains, before consensus testing. Create event certificates for DaG-PoA consensus:
cellframe-node-tool cert create home21.network.root.0 sig_dil – node0
cellframe-node-tool cert create home21.network.root.1 sig_dil – node1
cellframe-node-tool cert create home21.network.root.2 sig_dil – node2
Copy these certificates to share\ca folder on every node. Rename home21.network.root <num> to cert_event.dcert and placed it in var\lib\ca folder. One certificate for one node.
First, we will test algorithm, for 1 host with 1 node. Technically we can set auth_certs_number to 2,3 and higher.
In Linux config you see /opt/cellframe-node/share/ca
Important, that you have to use same crypto algorithms for public node keys, wallet and sign certificates, or you can get errors with atoms verification.
For transaction token signing you must have to create tokens in signed wallet and tokens for transaction with same names:
No token permissions found for token
If you see this error, simply remove GDB and chains files and repeat token emission operation.
DaG-PoA consensus is used in poa chain. When you start node, you can see messages about DaG-PoA consensus initialization:
cellframe-node-cli token_decl -net home21-network -chain poa -token HOME21PA -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_dil
cellframe-node-cli token_emit -net home21-network -chain_emission poa -chain_base_tx poa -token HOME21PA -certs cert_dil -emission_value 15500000000 -addr rMcg8v2uM2b71q9sV1cn2EqeoXqeFqHUNBkW63ezA5eUKdihwjwqvPHWzz6bMr1BCm1xcnyu2uk99pQDLjP9eH1hR61qVCV6AyLmMmk6
After that you can make emission many times:
You can store token, emissions and transactions in one chain or different chains. Chain name is specified in -chain parameter of command
We can made emission operation on 3 chains
poa_tokens – token declaration is stored
poa_emit – emissions events are stored
poa_tx – transactions event are stored
First, we enable seed_mode on all 3 nodes, then execute:
cellframe-node-cli token_decl -net home21-network -chain poa_emit -token TKN_DIL_M -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_sig_dil
datum 0xFE6DCF09946F8EE188517FE97BADAC9B1E57DEBAF3237008050BD44E3D9332AE with token TKN_DIL_M is placed in datum pool
Process mempool, using command:
cellframe-node-cli mempool_proc -net home21-network -chain poa_token -datum 0xFE6DCF09946F8EE188517FE97BADAC9B1E57DEBAF3237008050BD44E3D9332AE
waiting for round synchronization will be completed
cellframe-node-cli token_emit -net home21-network -chain_emission poa_emit -chain_base_tx poa_tx -token TKN_DIL_M -certs cert_sig_dil -emission_value 15000000000000 -addr rMcg8v2uM2b71q9sVJbmwvqZ6UHwwJTSNyW17LZEQPjt1uX6wcB2cnXXkrn9AWxBRBc1UxKBQTXhtZSm4sXhzUurp6ka69aSvArKEqrw
Datum emission 0xF316263599B4CE1B4A55DFFAB78E0D0DEB919FBACEDC8EA7A3B95DA0BF5D8997 is placed in datum pool
datum tx 0xFDA672745DD85734E76FA7B96510AEE2819B5AD341236A31471847923DB8B95E is placed in datum pool
process datums in mempool one-by-one
cellframe-node-cli mempool_proc -net home21-network -chain poa_emit -datum 0xF316263599B4CE1B4A55DFFAB78E0D0DEB919FBACEDC8EA7A3B95DA0BF5D8997
cellframe-node-cli mempool_proc -net home21-network -chain poa_tx -datum 0xFDA672745DD85734E76FA7B96510AEE2819B5AD341236A31471847923DB8B95E
waiting for synchronization in rounds, and you got emission:
Disable seed_mode on all 3 nodes and write events hash in static_genesis_event parameter
You can see events in three chains:
We will create local Cellframe network with TON consensus based on 2 nodes in local network. One chain with block_ton type will be used. For demo purposes, we make one token emission.
TON chain configuration file:
[chain]
id=0x0000000000000050
shard_id=0x0000000000000000
name=ton
load_priority=2
\# Possible values [token, emission, transaction, ca]
datum_types=[token, emission, transaction, ca]
mempool_auto_types=[all]
consensus=block_ton
[files]
storage_dir=/opt/cellframe-node/var/lib/network/home21-network/ton/
[blocks]
is_celled=false
is_static_genesis_event=true
static_genesis_event=\<event_id\>
[block-ton]
ton_nodes_addrs=[AAAA::0000::0000::0004,AAAA::0000::0000::0001]
auth_certs_prefix=home21.network.root
auth_certs_number=2
stake_tokens=0
stake_tokens_value=0
consensus_debug=true
validators_list_by_stake=false
round_start_sync_timeout=10
round_start_multiple_of=35
allowed_clock_offset=10
session_idle_min=10
round_candidates_max=5
next_candidate_delay=2
round_attempts_max=5
round_attempt_duration=20
first_message_delay=2
my_candidate_attempts_max=2
Specific node settings (cellframe-node.cfg):
Cellframe TON consensus based on Telegram Open Network consensus. It saves information in blocks, not a DAG. Current TON validation mechanism consists of correct datum signing on validators, count of which is more 2/3 from all nodes. Validators makes signing and checking operation. TON synchronization is real-time, doesn’t need additional GDB or chain node synchronization and uses TCP/IP voting channel for it. Nodes, using TON consensus, is sensitivity to time syncing.
Terms:
Candidate – block is called candidate on all of stage of negotiation. It means “candidate to signing”. If block was negotiated on all stage, it will be signed and save to chain
Coordinator – one of validator, that can start voting
Message handler – function or block of functions, that handle specific consensus messages
Validators – nodes, that can permissions for datums signing.
Voting channel – TCP\IP cellframe node channel, which allow transfer data between nodes in real-time.
Consensus initialization proceed in dap_chain_cs_block_ton_init in main.c of cellframe node. Before TON voting channel additionally initialized in dap_stream_ch_chain_voting_init function. It creates additional stream and channel. Also 1 second timer with callback s_packet_in_callback_handler is created. Voting channel supports as individual connection as broadcast connections to all node in network (all messages is sending to all validators using broadcasting now).
After voting channel is created, TON module start initialization in s_callback_new function. It reads config parameters, then creates list of validators – if validators_list_by_stake option is empty, validators list is built from ton_nodes_addrs parameter. Next s_callback_created (l_chain->callback_created) is started on chain stage loading, it load certificate, which is specified in [block-ton]::blocks-sign-cert in home21-network.cfg. Also, this function configures l_session default parameters, starts s_session_timer (only if node has MASTER or ROOT role) and set callback s_session_packet_in for voting channel in dap_stream_ch_chain_voting_in_callback_add.
s_session_packet_in make next verifications:
If all checks are successful message will be processed.
Type of messages:
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_START_SYNC
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_SUBMIT
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_APPROVE
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_REJECT
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_COMMIT_SIGN
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_VOTE
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_VOTE_FOR
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_PRE_COMMIT
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_START_SYNC – forming validators_start list (validators, that take part in block negotiation process)
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_SUBMIT - block stores in GDB, then s_session_atom_validation executed, which is called s_callback_atom_verify from block module (and additional s_callback_block_verify from block_ton module), if verifications successful, message DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_APPROVE will be send to all of node in list through dap_stream_ch_chain_voting_pkt_broadcast.
If TON config has flag_sign_verify option, block has additional verification in s_callback_block_verify
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_APPROVE - verified hash in dap_sign_verify and send DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_VOTE, if option attempt_current_number = 1. Attempt_current_number is stored in session object and changes in handler of DAP_STREAM_CH_CHAIN_SESSION_STATE_CS_PROC message.
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_REJECT - reject packet and stop processing
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_COMMIT_SIGN – check if COMMIT_SIGN messages count is more than 2/3 of the validators, after that round can be finished
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_VOTE - message is sent from DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_APPROVE. If voting message is more than 2/3 of the validators message DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_PRE_COMMIT will be send to nodes in validators_start list.
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_VOTE_FOR - send from DAP_STREAM_CH_CHAIN_SESSION_STATE_CS_PROC message handler, if current node is coordinator.
DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_PRE_COMMIT – if previous stage of messages was success incoming message is signed, after then node send DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_COMMIT_SIGN to all nodes in validators_start list.
Many part of consensus is working in timer-triggered procedure s_session_timer. Its handle different session states:
DAP_STREAM_CH_CHAIN_SESSION_STATE_IDLE – it is default session state after consensus module starting. If all of conditions on time delays
are correct, session will go to DAP_STREAM_CH_CHAIN_SESSION_STATE_WAIT_START, start round, set default parameters for session and load objects from "local.ton.home21-network.ton.store"
If l_startsync_count/l_session->cur_round.validators_count, then session go to DAP_STREAM_CH_CHAIN_SESSION_STATE_WAIT_START state.
DAP_STREAM_CH_CHAIN_SESSION_STATE_WAIT_START – check if validators_start_count is more then 2/3 of all validators, if true set session state to DAP_STREAM_CH_CHAIN_SESSION_STATE_CS_PROC and start round.
DAP_STREAM_CH_CHAIN_SESSION_STATE_WAIT_SIGNS – same actions as DAP_STREAM_CH_CHAIN_SESSION_STATE_CS_PROC.
DAP_STREAM_CH_CHAIN_SESSION_STATE_CS_PROC – in this message handler state block is saved in chain using s_session_candidate_submit->dap_chain_cs_new_block_add_datums (dap_chain_block_new and dap_chain_block_datum_add), after finish send to all validators message DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_SUBMIT. s_session_send_votefor (send message DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_VOTE_FOR to validators) is executed in DAP_STREAM_CH_CHAIN_SESSION_STATE_CS_PROC,.
Coordinator is one of node in validators list. Coordinator calculated from validator’s list using specific algorithm:
l_mod – current round id.
l_validators_count – count of node validators
l_session->attempt_current_number – count of DAP_STREAM_CH_CHAIN_SESSION_STATE_CS_PROC handler calling
When s_session_round_finish session go to DAP_STREAM_CH_CHAIN_SESSION_STATE_IDLE
If all checks are successful, block will be signed using certificate, specified in blocks-sign-cert parameter of network, node send message DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_APPROVE to all nodes in l_session->cur_round.validators_start, check all objects if sign_collected attribute is true (set if dap_sign_verify is success), send it to s_session_candidate_to_chain, which is save atom through a_session->chain->callback_atom_add (s_callback_atom_add from block module) function, then dap_chain_atom_save, finally calling s_session_my_candidate_delete.
If block is not verified, node send DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_REJECT message to validators, if
l_reject_count/l_session->cur_round.validators_count bigger, then 2/3, node remove datum from database.
Certificate scheme is same as DaG-PoA consensus – you need generate certificates for every validator, name it block-sign, then convert it to public certificate, place it in <cellframe-config-dir>\share\ca folder and name it home21.network.root.<node_number>. Node can get certificates for all nodes in network.
Specific TON consensus settings:
[block-ton]
ton_nodes_addrs=[AAAA::0000::0000::0001,AAAA::0000::0000::0004] – list of node address (validators)
auth_certs_prefix=home21.network.root – prefixes of certificate, which are placed in share/ca folder
auth_certs_number=2 – number of signatures for verification
stake_tokens=0 – uses if validators list is taken from stake
stake_tokens_value=0 - uses if validators list is taken from stake
consensus_debug=true – enable debug output in cellframe node console
validators_list_by_stake=false – get validators list form stake. If true it will be read from stake_tokens parameter in l_tokens_hold variable (comma separated)
round_candidates_max=2 – reserved option
my_candidate_attempts_max=2
Different timers:
round_start_sync_timeout=10 – synchronization timeout during 2/3 validators must say, that they can take part in consensus. In other case round is missing.
round_start_multiple_of=35 - Round starting timestamp. Number must be aliquot:
allowed_clock_offset=10 allowable validator divergence time.
session_idle_min=10 - minimum pause between synchronization attempts.
round_attempt_duration=20 – duration of each attempt in sec
first_message_delay=2 – params for s_session_send_startsync repeating. duration of each attempt in seconds
next_candidate_delay=2 – delay option for s_session_candidate_submit calling. delay before offering one's candidate next in the validator's queue in seconds
round_attempts_max=2 – delay option for s_session_round_finish calling. maximum number of candidates participating in the round
For using TON consensus, you need set static node address in home21-network.cfg
node_addr_type=static
node-addr=AAAA::0000::0000::0004
First, we make token declaration in consensus TON. In different from other consensus, all data are placed in blocks, therefore we will be used “block” cellframe-node-cli command for viewing it.
cellframe-node-cli token_decl -net home21-network -chain ton -token tknton -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_sig_dil
Datum 0x30C252B835915D8962AE763425FD97E6FD5D6622260188ADB23CD3A5A1F143A7 with 256bit token tknton is placed in datum pool
cellframe-node-cli mempool_proc -net home21-network -chain ton -datum 0x30C252B835915D8962AE763425FD97E6FD5D6622260188ADB23CD3A5A1F143A7
hash 0x30C252B835915D8962AE763425FD97E6FD5D6622260188ADB23CD3A5A1F143A7: type_id=DATUM_TOKEN_DECL ts_create=Mon May 2 12:46:33 2022
data_size=3880
Datum processed well. Removed datum from mempool.
And waiting for all node will sign blocks. Consensus TON working in real-time synchronization.
We can see messages about block creation:
cellframe-node-cli block list -net home21-network -chain ton
See available wallets:
cellframe-node-cli wallet list -net home21-network
wallet: test_wallet
addr: rMcg8v2uM2b71q9sWfa2UDFgQiPC3XqYpEdsEnW85gwrTu8hE2yQoZu5zcQqkEm3DqLGrZx2GJ7Vjb13VMK2EUnzSRJbKZ322Mubsdnm
Create emission and process datums:
cellframe-node-cli token_emit -net home21-network -chain_emission ton -chain_base_tx ton -token tknton -certs cert_sig_dil -emission_value 123 -addr rMcg8v2uM2b71q9sWfa2UDFgQiPC3XqYpEdsEnW85gwrTu8hE2yQoZu5zcQqkEm3DqLGrZx2GJ7Vjb13VMK2EUnzSRJbKZ322Mubsdnm
Datum 0x0E4CBB89CFDF2BE43F491BF5BCBC027CFF4B4DB899B1DDBB9FC1CBB3FADB67CA with 256bit emission is placed in datum pool
Datum 0x08F6CCE4D509878492CD0F8BC16029AABCCD2FA194FE6FE9ABCF6D2EA09AC264 with 256bit TX is placed in datum pool
cellframe-node-cli mempool_proc -net home21-network -chain ton -datum 0x0E4CBB89CFDF2BE43F491BF5BCBC027CFF4B4DB899B1DDBB9FC1CBB3FADB67CA
hash 0x0E4CBB89CFDF2BE43F491BF5BCBC027CFF4B4DB899B1DDBB9FC1CBB3FADB67CA: type_id=DATUM_TOKEN_EMISSION ts_create=Mon May 2 13:04:50 2022
data_size=3772
Datum processed well. Removed datum from mempool.
See cellframe-node log to make sure for first block signing
See block in block list:
cellframe-node-cli block list -net home21-network -chain ton
home21-network.ton: Have 7 blocks :
0xD05323F50CFF980AE32EC308D46C1342F2BA27446C5A032B2B0B5F7D2F466F02: ts_create=Mon May 2 11:37:54 2022
0xD7F8735D11ED1C2F63D18E22FEEBC542E4B9E47F1501115FE7E4B5010F894EA2: ts_create=Mon May 2 11:41:24 2022
0x6D3AB62B7E5E27097BC944574B2E0C3A3944796635B43D9D790D83D4EE0EB8B3: ts_create=Mon May 2 11:43:44 2022
0x739835FABE69C1923B3E7C3C287BAC70E618EB97F19878AB8519EFBEDCCF220D: ts_create=Mon May 2 12:47:54 2022
0x75E7318F6A331397A230314A5D750C808A36BCF01B7E42FF1932AFA32991FFA3: ts_create=Mon May 2 12:59:34 2022
0x3AA761A3076F70C11C4EDB677E734B2C5FA7F5D15FDE9D5227C47CCA01F2D269: ts_create=Mon May 2 13:01:54 2022
0x57F8A0A15BFE46C1A4F46070851D80E38EABCAFE34B51B80DD465B7E7479E8CB: ts_create=Mon May 2 13:08:54 2022
Process transaction datum in mempool:
cellframe-node-cli mempool_proc -net home21-network -chain ton -datum 0x08F6CCE4D509878492CD0F8BC16029AABCCD2FA194FE6FE9ABCF6D2EA09AC264
hash 0x08F6CCE4D509878492CD0F8BC16029AABCCD2FA194FE6FE9ABCF6D2EA09AC264: type_id=DATUM_TX ts_create=Mon May 2 13:04:50 2022
data_size=3698
Datum processed well. Removed datum from mempool.
Declarate token and create emission is successful:
cellframe-node-cli ledger list coins -net home21-network
Found 2 tokens in home21-network ledger
Token name 'tkn01', type SIMPLE, flags: NO_FLAGS
Supply (current/total) 4877/5000
Auth signs (valid/total) 1/1
Total emissions 1
Token name 'tknton', type SIMPLE, flags: NO_FLAGS
Supply (current/total) 4754/5000
Auth signs (valid/total) 1/1
Total emissions 2
You can see early made emission for token tkn01 and current emission for tknton token.
You see messages about token emission
Finally, see list of blocks:
cellframe-node-cli block list -net home21-network -chain ton
home21-network.ton: Have 8 blocks:
0xD05323F50CFF980AE32EC308D46C1342F2BA27446C5A032B2B0B5F7D2F466F02: ts_create=Mon May 2 11:37:54 2022
0xD7F8735D11ED1C2F63D18E22FEEBC542E4B9E47F1501115FE7E4B5010F894EA2: ts_create=Mon May 2 11:41:24 2022
0x6D3AB62B7E5E27097BC944574B2E0C3A3944796635B43D9D790D83D4EE0EB8B3: ts_create=Mon May 2 11:43:44 2022
0x739835FABE69C1923B3E7C3C287BAC70E618EB97F19878AB8519EFBEDCCF220D: ts_create=Mon May 2 12:47:54 2022
0x75E7318F6A331397A230314A5D750C808A36BCF01B7E42FF1932AFA32991FFA3: ts_create=Mon May 2 12:59:34 2022
0x3AA761A3076F70C11C4EDB677E734B2C5FA7F5D15FDE9D5227C47CCA01F2D269: ts_create=Mon May 2 13:01:54 2022
0x57F8A0A15BFE46C1A4F46070851D80E38EABCAFE34B51B80DD465B7E7479E8CB: ts_create=Mon May 2 13:08:54 2022
0x578F1A936963169A972A967E2AD38597A8BC4AD2B65103DFDF226D02522AFC11: ts_create=Mon May 2 13:14:44 2022
Additionally, you can see detailed information about latest block. You can see block has, transaction detailes, 2 signatures for transaction (nodes addresses is displayed)
Block PoA consensus is same with PoA consensus, but with additional block signing option.
Block PoS consensus is same with PoS consensus, but with additional block signing option.
For node syncing you need more accurate configuration, instead of local environment. All kind of consensus can be used in network mode. But there are additional limitations for network cells.
You need use only one crypto algorithm for all certificates, wallets and token emission operations. If you use different crypto algorithms, you can get some strange blockchain behavior on every stage of that maintenance.
You should carefully initialize it in seed mode.
All nodes have to working TCP/IP communication
Now server node based on Linux OS (Ubuntu), other 2 nodes are based on Windows client OS.
For node network communication you need make initialization one of node in seed mode. This mode is special mode for first DAG event initialization. All events are connected in one chain, one-by-one, but first event is deprived from other.
Public certificates of all nodes are placed in C:\Users\Public\Documents\cellframe-node\share\ca (Linux - /opt/cellframe-node/share/ca) with special prefixes, which are written in auth_certs_prefix chain config. For example, if name of prefix is home21.network.root, names of certificate will be home21.network.root.0, home21.network.root.1, etc, depending of nodes count.
Before placing certificates in share\ca folder we recommend to convert it into public certificates using command:
cellframe-node-tool.exe cert create_cert_pkey home21.network.root.1 home21.network.root.1_pub
Set event_cert certificate inside network config (home21-network.cfg)
events-sign-cert=event_cert
It writing in auth_certs_dir params of chain config.
Steps for seed mode initialization. You need make it for dag-pos (plasma) and dag-poa (zerochain) consensuses
Clear global db and chains (files are placed in <config_dir>\var\lib\global_db and <config_dir>\var\lib\network\<network_name>)
Set general::seed_mode=true in cellframe_node.cfg, set general::auto_online=false
Launch cellframe-node on first node
Run commands for events creation:
cellframe-node-cli token_decl -net home21-network -chain poa -token HOME21CH4 -total_supply 5000 -signs_total 1 -signs_emission 1 -certs cert_tesla
Get event id from node output and place it in poa config [dag] section as static_genesis_event parameter:
cellframe-node-cli tx_create -net home21-network -chain poa -from_wallet wallet-dil -to_addr rMcg8v2uM2b71q9sUrr4qscEu7mtwZhCLAf2Niv4AhEd8psNLsRjeP9M3mPpGWNMqfHK2QgMxZWWJqaM55m9k6MLyv1Q3H4vwJyvGLh1 -token HOME21CH3 -value 1110000000
Copy event from Processing event string to [dag] section of Proof-of-Stake chain config in static_genesis_event parameter.
mempool autoprocessing is auto, therefore you don’t need manually process hash in mempool.
Switch off node
Set seed_mode to false
Launch node1 (on Windows) and node2 (on Linux)
Execute command: cellframe-node-cli net sync all -net home21-network
node is syncing with second node
See synchronization log-output on another node:
Linux node:
You can see additional messages for atoms replication (on client side):
On server side you can see messages about atoms verification.
If you need CA traffic authorization you can configure your network using [auth] section. Set type=ca (certificate) in home21-network.cfg. First, you need:
cellframe-node-tool cert pkey show auth
0x985004576963F6C1686018703FDC5720BD54D86564E0FCC99E2921E122D86535
Wrote in general section of home21-network.cfg
auth_cert=auth
Write hash to [auth] section in home21-network.cfg
You need to create auth.dcert on every node and placed it inside var/lib/ca folder. Get their digest and write to acl_accept_ca_list string array through comma.
You need to initiate node synchronization (cellframe-node-cli net sync all -net home21-network)
for using that function
If you don’t specify certificate, you see messages, that connection can’t be established
If you set certificate correctly you will see standard communication and synchronization messages:
DaG PoA consensus has round syncing option. That’s options are configured in chain configuration file
**[dag_poa]**
auth_certs_number=3
auth_certs_number_verify=3
confirmations_timeout=50
auto_confirmation=true
auto_round_complete=true
wait_sync_before_complete=40
**[dag]**
is_add_directly=false
This option allows to make event matching rounds before events will be placed into DAG automatically. You can use mempool::autoproc only for operation, which uses only one event (token declaration).
confirmations_timeout – sign waiting timeout. Its period of waiting signing events on all nodes.
auto_confirmation - enable auto signing. Function s_callback_event_round_sync is executed without manual action
auto_round_complete – allows execute s_round_event_cs_done in s_callback_event_round_sync of consensus.
wait_sync_before_complete – waiting for rounds syncing