Pollux Private Chain

To construct a private chain, it is imperative to deploy at least one full node operating under Pollux to generate blocks, and any quantity of full nodes to synchronize blocks and broadcast transactions. In this instance, only one Pollux node and one full node are arranged.

Preparation

  • Poxchain JDK 1.8

  • Generate a minimum of two Pollux network addresses and securely store both the address and private key. You can utilize pox chain web, wallet-cli, or Poxc hain to initiate the address creation process.

Deployment Guide

The process of establishing a node on a private chain mirrors that on the mainnet. The distinction lies in the content of the node configuration file. A pivotal aspect of constructing a private chain involves adjusting the configuration parameters within the file. This ensures that the nodes can collectively create a private network for tasks such as node discovery, block synchronization, and broadcasting transactions.

  1. Create deployment directory Create deployment directory, it is recommended to put the two full nodes in different directories.

$ mkdir SR $ mkdir FullNode
  1. Obtain Full Node.jar, then put it into the SR and Full Node directories respectively.

$ cp FullNode.jar ./SR
$ cp FullNode.jar ./FullNode
  1. Obtain the node's config file private_net_config.conf, and put it into the SR and Full Node directories respectively, and modify the file names respectively to super node.conf, full node.conf.

$ cp private_net_config.conf ./SR/supernode.conf
$ cp private_net_config.conf ./FullNode/fullnode.conf
  1. Modify the configuration file of each node

    Certainly! Here's the rewritten content in table form with the specified replacements:

    Config ItemSR FullnodeFullNodeDescription

    localwitness

    The private key of witness address

    Please do not fill in data

    Generating blocks requires signing with a private key

    genesis.block.witnesses

    Witness address

    The same as PRC node's

    Genesis block related configuration

    genesis.block.Assets

    Preset PRC for specific accounts. Add the pre-prepared address to the end and specify its PRC balance as needed

    The same as PRC node's

    Genesis block related configuration

    p2p.version

    any positive integer except for 11111

    the same as PRC node's

    Only nodes of the same p2p version can shake hands successfully

    seed.node

    Please do not fill in data

    Change the seed.node ip.list in the configuration file to the IP address and the port (listen.port) of the PRC

    Enables fullnode to establish connection with PRC node and synchronize data

    needSyncCheck

    false

    true

    Set the first PRC’s needSyncCheck to false, other PRCs true

    node.discovery.enable

    true

    true

    If it is false, the current node will not be discovered by other nodes

    block.proposalExpireTime

    600000

    The same as PRC node's

    The default proposal effective time is 3 days: 259200000 (ms), if you want to quickly pass the proposal, you can set this item to a smaller value, such as 10 minutes, that is, 600000ms

    block.maintenanceTimeInterval

    300000

    The same as PRC node's

    The default maintenance time interval is 6 hours: 21600000 (ms), if you want to pass the proposal quickly, you can set this item to a smaller value, such as five minutes, that is, 300000ms

    committee.allowSameTokenName

    1

    1

    Allow same token name

    committee.allowTvmTransferTrc10

    1

    1

    Allow tvm transfer PRC10

  2. Modify the port in the configuration file, and configure the SR and Full Node with different port numbers. Note that this step is required if SR and Full Node are running on the same machine, otherwise, this step can be skipped.

  • listen.port: p2p listen port

  • http port: Http listen port

  • rpc port: rpc listen port

  1. Startup the node

Full node that produces blocks

$ java -Xmx6g -XX:+HeapDumpOnOutOfMemoryError -jar FullNode.jar  --witness  -c supernode.conf

Full node

$ java -Xmx6g -XX:+HeapDumpOnOutOfMemoryError -jar FullNode.jar  -c fullnode.conf
  1. Modify the dynamic parameters of the private chain

    In order to align with the main network environment, the dynamic parameters of the private chain need to be adjusted to match those of the main network. The adjustment of dynamic parameters can be accomplished through proposals. The PRC account can utilize pox chain or wallet-cli or full node http API wallet/proposal create to generate proposals, wallet/proposal approve to endorse proposals.

    Here are the dynamic parameters and values organized based on the proposals approved by the mainnet consecutively. PRC can directly employ the following commands to initiate proposals and complete the modification of all dynamic parameters for the private chain. Considering the dependencies among some parameters, and in accordance with the current parameter values on the main network, the modification of all private chain parameters can be split into two proposals. In the initial step, PRC creates and casts votes for the first proposal using the code provided below:

javascript=

var PolluxWeb = require('polluxweb');
var polluxWeb = new PolluxWeb({
    fullHost: 'http://localhost:16887',
    privateKey: 'c741f5c0224020d7ccaf4617a33cc099ac13240f150cf35f496db5bfc7d220dc'
});

// First proposal: "key":30 and "key":70 must be modified first
var parametersForProposal1 = [{"key":9,"value":1},{"key":10,"value":1},{"key":11,"value":420},{"key":19,"value":90000000000},{"key":15,"value":1},{"key":18,"value":1},{"key":16,"value":1},{"key":20,"value":1},{"key":26,"value":1},{"key":30,"value":1},{"key":5,"value":16000000},{"key":31,"value":160000000},{"key":32,"value":1},{"key":39,"value":1},{"key":41,"value":1},{"key":3,"value":1000},{"key":47,"value":10000000000},{"key":49,"value":1},{"key":13,"value":80},{"key":7,"value":1000000},{"key":61,"value":600},{"key":63,"value":1},{"key":65,"value":1},{"key":66,"value":1},{"key":67,"value":1},{"key":68,"value":1000000},{"key":69,"value":1},{"key":70,"value":14},{"key":71,"value":1},{"key":76,"value":1}];
var parametersForProposal2 = [{"key":47,"value":15000000000},{"key":59,"value":1},{"key":72,"value":1},{"key":73,"value":3000000000},{"key":74,"value":2000},{"key":75,"value":12000},{"key":77,"value":1},{"key":78,"value":864000}];

async function modifyChainParameters(parameters, proposalID) {
    parameters.sort((a, b) => {
        return a.key.toString() > b.key.toString() ? 1 : a.key.toString() === b.key.toString() ? 0 : -1;
    });
    var unsignedProposal1Txn = await polluxWeb.transactionBuilder.createProposal(parameters, "41D0B69631440F0A494BB51F7EEE68FF5C593C00F0");
    var signedProposal1Txn = await polluxWeb.trx.sign(unsignedProposal1Txn);
    var receipt1 = await polluxWeb.trx.sendRawTransaction(signedProposal1Txn);

    setTimeout(async function() {
        console.log(receipt1);
        console.log("Vote proposal 1 !");
        var unsignedVoteP1Txn = await polluxWeb.transactionBuilder.voteProposal(proposalID, true, polluxWeb.defaultAddress.hex);
        var signedVoteP1Txn = await polluxWeb.trx.sign(unsignedVoteP1Txn);
        var rtn1 = await polluxWeb.trx.sendRawTransaction(signedVoteP1Txn);
    }, 1000);
}

modifyChainParameters(parametersForProposal1, 1);

After generating the proposal through the above code, you can inquire about the proposal's effective time: "expiration_time" via the http://127.0.0.1:xxxx/wallet/listproposals interface. The timestamp is in milliseconds. Once the effective time has elapsed, if the "state" in the return value of the interface is "APPROVED," it indicates that the proposal has been approved. You can then proceed to the next stage and create the second proposal. The sample code is as follows:

modifyChainParameters(parametersForProposal2, 2)

After the proposal takes effect, the dynamic parameters of the private chain will be consistent with the main network. You can query the chain parameters through the /wallet/getchainparameters API.

Last updated