The much awaited feature of the XDC network, the Subnets, is here.!
Blockchain technology has revolutionized the way we envision decentralized systems, enabling trust, security, and transparency. However, as the popularity of blockchain platforms grows, challenges related to scalability, speed, and efficiency have become more pronounced. To tackle these issues, various projects are exploring innovative solutions. One such solution is the XinFin XDC Network and its unique feature: XDC Subnets. In this blog, we will dive into the concept of XDC Subnets, their significance, and how they contribute to overcoming scalability limitations.
The link provides a good understanding of XDC subnets and its importance.
https://xinfinorg.github.io/xdc-subnet-docs/introduction/intro
XDC Subnets can be understood as individual sidechains within the XinFin XDC Network ecosystem. These subnets operate independently while remaining interconnected to the main XDC Network through the use of Relayers and checkpoint smart contracts. Each XDC Subnet can have its own tokenomics, and governance rules, making it a highly customizable and flexible solution.
Benefits of XDC Subnets
Scalability: One of the most significant challenges facing many blockchain platforms is scalability. As the number of users and transactions increases, the main network can become congested, leading to slower transaction processing times and higher fees. XDC Subnets address this issue by allowing transactions to be processed on separate sidechains, thus significantly increasing the network's capacity to handle more transactions simultaneously.
Efficiency: XDC Subnets enable improved resource allocation. Different use cases can be allocated to different subnets, preventing resource contention and enhancing overall network efficiency. This means that applications with specific requirements, such as high throughput or privacy, can be catered to more effectively.
Customization: Each XDC Subnet can have its own set of rules, and even tokens. This flexibility allows enterprises and developers to create tailored solutions that suit their specific requirements. For instance, one subnet might focus on supply chain management, while another might be optimized for decentralized finance (DeFi) applications.
Interoperability: While XDC Subnets operate as separate entities, they can still interact with each other and the main XDC Network through Relayers and smart contracts. This interoperability allows for the seamless transfer of assets across different subnets, creating a unified ecosystem.
XDC subnet-mainnet checkpointing is light-client based and the relayer cannot foul anyone. This is much more secure than the common bridge, which is controlled by a third-party which has to be trusted.
Reduced Transaction Costs: With increased scalability and optimized resource allocation, XDC Subnets can potentially lead to lower transaction costs compared to traditional blockchain networks, making it more feasible for both individuals and enterprises to participate.
Privacy:: Only consensus info (i.e., headers) of the subnets are checkpointed to XDC mainnet,the parent chain, so there is no exposure of subnet transactions to the public.
XDC Subnets represent a pioneering solution to the challenges of scalability and efficiency that have long plagued traditional blockchain networks. By offering a customizable, interconnected, and scalable ecosystem, XinFin's XDC Network paves the way for a new generation of blockchain applications. As the technology continues to evolve, XDC Subnets could play a pivotal role in transforming industries and driving the widespread adoption of blockchain solutions.
XDC Subnets Deployment Guide
Prerequisites:
docker - 20.10.25
docker compose - v2.12.2
OS - Linux. Only Linux is supported right now, due to docker network limitation
For manual installation of docker compose V2 please refer to: https://docs.docker.com/compose/install/linux
Steps:
Clone the repo
git clone https://github.com/XinFinOrg/XinFin-Node.git
cd XinFin-Node/subnet/deployment-generator/
Create a new environment file
cp docker.env.example docker.env
Update the below params in the env file
CONFIG_PATH= (~/XinFin-Node/subnet/deployment-generator)
NETWORK_NAME=CUSTOM_NAME (xdcsubnet)
NUM_MACHINE=1
NUM_SUBNET=3
MAIN_IP=IP_OF_THE_BOOT_SERVER <1.11.111.111>
PARENTCHAIN=devnet
PARENTCHAIN_WALLET=Wallet address
PARENTCHAIN_WALLET_PK=Wallet private key
Pull the latest subnet-generator image
docker pull xinfinorg/subnet-generator:latest
Run the below command while will generate all the required files in the generated directory
docker run --env-file docker.env -v $(pwd)/generated:/app/generated xinfinorg/subnet-generator:latest && cd generated
Follow the generated commands (machine1) in commands.txt file as below to start Subnet Nodes and make sure they are mining
To check if new blocks are being mined use the below commands (8545,8546 and 8547 for 3 subnets) and see if the block number is increasing.
Below commands will update the block numbers when new blocks are being mined.
Each subnet will have its own genesis block and the block numbers will be different.
One subnet cannot be able to communicate with the other subnets and only the parent chain has a checkpoint smart contract for each subnet.
curl --location 'http://localhost:8545' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"XDPoS_getV2BlockByNumber","params":["latest"],"id":1}'
Deploy subnet on machine1
cd ~/.XinFin-Node/subnet/deployment-generator/generated
docker compose --env-file docker-compose.env --profile machine1 pull
docker compose --env-file docker-compose.env --profile machine1 up -d
Deploy checkpoint smart contract (please be mindful of docker image tag if you are not using 'latest')
cd ~/.XinFin-Node/subnet/deployment-generator
docker run --env-file docker.env \
-v $(pwd)/generated/deployment.json:/app/generated/deployment.json \
--entrypoint 'bash' xinfinorg/subnet-generator:latest ./deploy_csc.sh
make an edit to ./config/common.env to include values for CHECKPOINT_CONTRACT which is generated in the above step
Start services and frontend
docker compose --env-file docker-compose.env --profile services pull
docker compose --env-file docker-compose.env --profile services up -d
Use the docker ps -a
command and check if the below processes are running and check the logs with docker logs <container_id>
.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3a8dfd10ec75 xinfinorg/subnet-frontend:v0.1.1 "docker-entrypoint.s…" 21 hours ago Up 20 hours 0.0.0.0:5000->5000/tcp generated-frontend-1
8460ad3ea79f xinfinorg/subnet-stats-service:v0.1.1 "docker-entrypoint.s…" 21 hours ago Up 20 hours 443/tcp, 0.0.0.0:3000->3000/tcp generated-stats-1
7bd263401024 xinfinorg/xdc-relayer:v0.1.1 "docker-entrypoint.s…" 21 hours ago Up 20 hours 3000/tcp generated-relayer-1
23c154f2568e xinfinorg/xdcsubnets:latest "bash /work/start.sh" 23 hours ago Up 23 hours generated-subnet1-1
a50de921728d xinfinorg/xdcsubnets:latest "bash /work/start.sh" 23 hours ago Up 23 hours generated-subnet3-1
5cd389701cfd xinfinorg/xdcsubnets:latest "bash /work/start-bo…" 23 hours ago Up 23 hours 8545/tcp, 8555/tcp, 30301/tcp, 30303/tcp, 0.0.0.0:20301->20301/tcp, 0.0.0.0:20301->20301/udp, 30301/udp generated-bootnode-1
And finally check out the Subnet UI at :5000
We can see from the above image that the Relayer pushes the blocks from the Subnets to the parent chain at a specific interval which is configurable.
And an interesting thing is that there are two ways in which a Subnet can be setup.
-> Fully isolated network which will not use the parent chain to checkpoint (Private network)
-> Subnets on top of the parent XDC chain which uses checkpoint smart contract to confirm the transactions (Hybrid network)
A Relayer is used for this purpose to relay the transactions from the Subnets to the parent chain. The Relayer component can be turned on/off as required and it makes sure all the blocks are broadcasted to the parent chain once it is turned on.
This gives the flexibility for institutions to have the subnets completely isolated from the parent chain as and when required.
For removing the subnet and debugging and other instructions below link can be referred
Lets harness the real power of Subnets with the XDC network.!! Keep building.
#BuildOnXDC
Discussion (1)
Thanks Satheesh! I would love to see how this gets utilised in the nascent projects, as much as the established EVM projects.