Add a replica node to the network
A Chromia replica node plays a vital role in the Chromia blockchain ecosystem. Its main duty is to maintain a complete copy of a decentralized application's (dapp) dedicated blockchain. This process ensures data redundancy, security, and availability by replicating all transactions, blocks, and state data from the primary node. These nodes strengthen the network's resilience, allowing other participants to access blockchain data and engage in the consensus process, thus supporting the decentralized operation and scaling of Chromia dapps.
Steps to register a replica node in the network
Step 1: Add provider
To register a node in the network, you need to possess an identity of any tier. Provide your ChromaWay contact with your
public key.
Step 2: Download genesis config to start your node
Create a folder in your working directory called system_chains
. Then run the following command:
curl -s <https://system.chromaway.com:7740/config/7E5BE539EF62E48DDA7035867E67734A70833A69D2F162C457282C319AA58AE4?height=0> > system_chains/dc.xml
Step 3: Start the PostgreSQL database
Run the following command to start PostgreSQL:
docker run --name postgres -e POSTGRES_USER=postchain -e POSTGRES_PASSWORD=<password of your choice> -p 5432:5432 -d postgres:16.3-alpine3.20
Step 4: Start the node
To start the node, create two folders: logs
and node_config
. Mount these folders to the node. Inside the
node_config
folder, create a node.properties
file. Fill in the following fields in this properties file:
messaging.privkey
messaging.pubkey
database.password
To generate values for messaging.privkey
and messaging.pubkey
, run:
pmc keygen -n -s node_identity
Copy these values into the properties file. The password should match the one you used in Step 3.
Content of the node.properties
file:
# Postchain configuration
messaging.privkey= <node privkey – different from the provider privkey from Step 1>
messaging.pubkey= <node pubkey – different from the provider pubkey from Step 1>
messaging.port=9870
genesis.pubkey=037434C8D4F2B7B7DE44E80486A814676DC3D898FD4488E10E1940B1C4C5837200
genesis.host=system.chromaway.com
genesis.port=9870
api.port=7740
database.driverclass=org.postgresql.Driver
database.username=postchain
database.password=<password from Step 3>
database.url=jdbc:postgresql://172.17.0.1:5432/postchain
database.schema=postchain0
infrastructure=net.postchain.d1.D1InfrastructureFactory
api.enable_tls=false
metrics.prometheus.port=9190
configuration.provider.node=managed
container.postgres_max_locks_per_transaction=1024
database.blockBuilderWriteConcurrency=100
database.readConcurrency=100
Command to start the node:
docker run --name postchain \
--volume /var/run/docker.sock:/var/run/docker.sock \
--mount type=bind,source="$(pwd)/node_config",target=/config,readonly \
--mount type=bind,source="$(pwd)/logs",target=/opt/chromaway/postchain/logs \
-e POSTCHAIN_DEBUG=true \
-p 9874:9870/tcp \
-p 9884:9881/tcp \
-p 7744:7740/tcp \
-p 7754:7750/tcp \
-p 50055:50051/tcp \
registry.gitlab.com/chromaway/postchain-chromia/chromaway/chromia-server:3.19.6 \
run-server --node-config /config/node.properties
Step 5: Register the node
Register the node as an unknown host:
pmc node register-replica --pubkey <value of messaging.pubkey in the properties file>
Step 6: Start the management chain
This step starts your node so that it begins syncing with the target network:
docker run --rm \
--mount type=bind,source="$(pwd)"/system_chains/,target=/opt/chromaway/postchain/system_chains,readonly \
registry.gitlab.com/chromaway/postchain-chromia/chromaway/chromia-server:3.19.6 \
admin blockchain initialize -t 172.17.0.1:50055 -cid 0 -bc ./system_chains/dc.xml
Step 7: Add replication of other chains
You can only perform this step once the node has fully synced the system chains from the previous step. Check against the height in a block explorer for the chains:
- Management chain: 15C0CA99BEE60A3B23829968771C50E491BD00D2E3AE448580CD48A8D71E7BBA
- System anchoring chain: B497391373BB74944193205EB37C84B0520D474F491E2EF4743F16F670DB289B :::
To verify full synchronization, run:
pmc blockchain replica add -brid <Target chain brid> --pubkey <value of messaging.pubkey in the properties file>
The brid
for the economy chain is 15C0CA99BEE60A3B23829968771C50E491BD00D2E3AE448580CD48A8D71E7BBA
. :::
To gracefully start or stop a node, use the following command:
docker run --rm \
registry.gitlab.com/chromaway/postchain-chromia/chromaway/chromia-server:3.19.6 \
admin blockchain start -t 172.17.0.1:50055 -cid 0