Skip to content

How to start Marmara PoS chain

dimxy edited this page Aug 9, 2019 · 12 revisions

How to start a new Marmara PoS chain

The way of starting Marmara proof-of-stake basic two-node chain is similar to running conventional Komodo PoS chains (described here: https://developers.komodoplatform.com/basic-docs/antara/antara-setup/antara-customizations.html#ac-staked) But as Marmara chains have customized staking features starting of a Marmara chain differs in preparing utxos splitting for the initial chain lifetime.

The start process begins with starting two-nodes and creation of nodes' pubkeys

The first chain node will be the PoS node and the second node will be the PoW node. Run only the first node with Marmara staking parameters (-ac_marmara=1 -ac_staked=75) and with no '-gen' parameter, example:

./komodod -ac_name=MARMARA1 -ac_supply=100000 -ac_cc=2 -bind='first-node-port' -port='first-node-port' -addressindex=1 -spentindex=1 -ac_marmara=1 -ac_staked=75 -ac_reward=100000000 -debug=marmara-1 &

(parameter '-debug=marmara-1' allows to trace marmara error, info and debug of level 1 log messages, you may remove or change it)

Create a new pubkey for the first node:

./komodo-cli -ac_name=MARMARA1 getnewaddress

The command outputs 'new-address'. Run validateaddress command that returns the pubkey

./komodo-cli -ac_name=MARMARA1 validateaddress 'new-address'

Find the pubkey in the output and restart the first node with 'pubkey':

./komodo-cli -ac_name=MARMARA1 stop

./komodod -ac_name=MARMARA1 -ac_supply=100000 -ac_cc=2 -bind='first-node-ip' -port='first-node-port' -addressindex=1 -spentindex=1 -ac_marmara=1 -ac_staked=75 -ac_reward=100000000 -debug=marmara-1 -pubkey='pubkey' &

Run the second node also with no -gen parameter:

./komodod -ac_name=MARMARA1 -ac_supply=100000 -ac_cc=2 -addnode='first-node-ip' -port='first-node-port' -addressindex=1 -spentindex=1  -ac_marmara=1 -ac_staked=75 -ac_reward=100000000 -debug=marmara-1 &

For the second node also obtain a pubkey with getnewaddress and validateaddress komodo-cli commands and re-run the second node with -pubkey='second-node-pubkey'.

./komodo-cli -ac_name=MARMARA1 getnewaddress

output: 'new-address'

./komodo-cli -ac_name=MARMARA1 validateaddress 'new-address'

output: address values including 'pubkey'

./komodod -ac_name=MARMARA1 -ac_supply=100000 -ac_cc=2 -addnode='first-node-ip' -port='first-node-port' -addressindex=1 -spentindex=1  -ac_marmara=1 -ac_staked=75 -ac_reward=100000000 -debug=marmara-1 -pubkey='pubkey' &

Now both of the nodes are running but not generating coins.

Run generation of some normal coins on the first node

Run setgenerate on the first node, wait for 2-3 blocks to generate and stop it:

./komodo-cli -ac_name=MARMARA1 setgenerate true 1

Wait until 2-3 blocks are created (watch komodod output on the first node).

./komodo-cli -ac_name=MARMARA1 setgenerate false
./komodo-cli -ac_name=MARMARA1 listaddressgroupings

Ensure listaddressgroupings returns an address with some coins

Create activated coins and split them on 64 segids for staking to work

Run marmaralock64 command with coins amount you want to reserve for stake. You do not need to have big amount even for production network as this is needed only for initial chain running stage, while number of users is small and not all segids are covered by user addresses.

./komodo-cli -ac_name=MARMARA1 marmaralock64 6.4 1

This will generate 64 addresses for each segid with one utxo of 0.01 coin on each. The command also returns a big transaction in hexademical encoding. Scroll its output and accurately copy hex value into clipboard. Send the transaction to the chain with sendrawtransaction command:

./komodo-cli -ac_name=MARMARA1 sendrawtransaction 'tx-in-hex'

Run again ./komodo-cli -ac_name=MARMARA1 setgenerate true 1 and wait until the tx is mined by checking that the mempool is empty with ./komodo-cli -ac_name=MARMARA1 getrawmempool. Ensure the activated addresses have been generated correctly with the command ./komodo-cli -ac_name=MARMARA1 marmaralistactivatedaddresses. You should see 64 addresses with the split amount on them.

Stop both the nodes and restart them with the parameters for PoS and PoW

The first node komodod command:

./komodod -ac_name=MARMARA1 -ac_supply=100000 -ac_cc=2 -bind='first-node-ip' -port='first-node-port' -addressindex=1 -spentindex=1 -ac_marmara=1 -ac_staked=75 -ac_reward=100000000 -debug=marmara-1 -pubkey='pubkey' -gen -genproclimit=0 &

The second node komodod command:

./komodod -ac_name=MARMARA1 -ac_supply=100000 -ac_cc=2 -addnode='first-node-ip' -port='first-node-port' -addressindex=1 -spentindex=1  -ac_marmara=1 -ac_staked=75 -ac_reward=100000000 -debug=marmara-1 -pubkey='pubkey' -gen -genproclimit=$(nproc) &

Now your PoS Marmara chain is running and operational.


Important notes:

  • For Marmara chains for the initial stage, while user's number is low, you need to split some activated coins on 64 segids. A 'segid' is some function (like hash) derived from the coin address value and is used in staking.
  • This splitting is done with marmara rpc call 'marmaralock64'.
  • The splitting is done only on PoS nodes in a Marmara chain.
  • If all 64 segids in a Marmara PoS chain are not covered with activated utxos the chain might be working unstable (long delays in block generation).
Clone this wiki locally