Developers Forum for XinFin XDC Network

Siheng Pan
Siheng Pan

Posted on

XDC Subnet Light Client Smart Contract Performance Analysis

The protocol team has designed and developed the most secure and advanced subnet system for XDC ( Following this design, the XDC network will receive each subnet’s headers and maintain a light client of each subnet. This light client is implemented using Solidity as a smart contract. In this report, we analyze the performance of this smart contract(, which is critical for the productization of the subnet system.

Our evaluation of the subnet smart contract included assessing its runtime and gas consumption. To obtain our measurements, we utilized a laptop with a 2GHz Quad-Core Intel Core i5 processor and 32GB of memory. We created an EVM emulator from XDC node utilities, deployed the subnet contract, and fed it 1798 simulated block headers with varying numbers of signatures. The resulting data is presented in the graphs below.

Subnet Contract Performance Measurement

Our measurements indicate that signature verification (of the subnet headers) is the dominating consumer, as the gas cost and runtime both increase linearly with the number of signatures. In the worst-case scenario where 72 signatures need to be verified (which corresponds to a subnet with 108 master nodes in the same way as the XDC mainnet), the verification of each subnet header requires approximately 3 million gas units. At the current gas price of XDC, this will cost about $0.00003 per header. If we assume a 2-second block time, the annual cost per subnet will be about $473. In addition, the verification runtime for such a block header is roughly 8ms. In comparison, the optimal consensus agreement is set at 2s. These findings demonstrate that the subnet contract's gas cost and execution time are very affordable and sustainable, even for subnets with a large master node committee. Additionally, the contract's execution runtime is negligible, which means that it does not impact the mainnet's normal consensus process. Furthermore, we discovered that multiple headers can be batched together in a single transaction, allowing for greater flexibility in supporting various consensus rates or delayed block submissions. Also it is worth mentioning that the XDC network can host multiple subnets at the same time. Each XDC block has a gas limit of 420 millions, allowing it to carry up to 140 headers from very large subnets, which indicates high scalability.

We welcome feedback and contributions from the community to optimize this light-client-based smart contract further. A potential approach is to update the signature algorithm of the subnet to BLS, so that the signatures can be aggregated. This way, the light client will only need to store and verify one signature, no matter how large the subnet is.

Discussion (0)