Developers Forum for XinFin XDC Network

ruslan wing
ruslan wing

Posted on

XinFin XDC Network full node vs. archive node

Overview

If the XDC network is to be seen as a globally distributed computer, then nodes provide computational power and resources to this computer. In this guide, we’ll understand more about XinFin full nodes and archive nodes, then explore the difference between them.

What is a node in XDC Network?

In an ordinary non-technical context, a node can be defined as a connection point that joins or connects different branches. Any device connected to the network can be considered a node on the Internet. The same goes for a blockchain network. Any computer that has a downloaded copy of the blockchain and participates in the network is generally regarded as a node. The XinFin blockchain is a network of computers constantly communicating with each other. They are taking in and sending out information to other computers, which all work together to verify transactions and verify the common blockchain database known as a ledger. A node receives data from the network and broadcasts it to the network so that all the nodes have the same information at any given time. As the number of nodes on the network increases, it becomes resilient and less vulnerable to attacks.

Here is a brief breakdown of commonly recognized types of nodes in XinFin :

  • Archive nodes — Has data since genesis block.

  • Full nodes — Receive copies of transactions. Has the current state of the blockchain.full node, useful for low memory and computational devices.

  • Masternodes — Masternodes verify transactions and add them to the blocks. They then mine those blocks and secure the blockchain with XinFin Delegated Proof of Stake

What is a XinFin full node?

Full nodes are the nodes that copy and verify transactions on the blockchain and help maintain the blockchain state. Whenever a transaction is added to the blockchain, full nodes verify that the transaction complies with the XinFin specification, and maintain the current state of the blockchain by doing this. Transactions and blocks that do not comply with the XinFin specification are discarded. For example, if person A has sent a transfer transaction of 100 XDC to person B, but person A has zero XDC in their account, the Full node verifying transactions, will mark this transaction as invalid and drop it. Full nodes also execute all the instructions on the smart contract whenever there is a smart contract transaction. It checks if the smart contract execution is giving the desired output or not. A full node stores the state of the most recent 128 blocks (or only 64 if you’re using fast/snap sync) and about one week of trace data updated as soon as the new block comes in. if you would like to setup a full node check out https://github.com/XinFinOrg/XinFin-Node

For more details check out https://xinfin.org/setup-masternode

What is an XinFin archive node?

Archive nodes are full nodes running with a special option known as “archive mode”. Archive nodes have all the historical data of the blockchain since the genesis block. If you have a need for data from blocks before the last 128 blocks, you’ll want to access an archive node. For example, to use calls like eth_getBalance of an ancient address will only be possible with an archive node, to interact with smart contracts deployed much earlier in the XinFin blockchain, etc. if you would like to setup archive node please check out https://github.com/XinFinOrg/Local_DPoS_Setup

Full node vs. Archive node

Let’s try to understand the above difference by trying to use the XinFin RPC to get some information. We’ll query the balance of an account at block 1 of the XinFin blockchain address xdc092dd15c2eccd1a7d436f384dc54f12ad023b837 received about 1K XDC in the genesis block.

First, let’s make the request to an archive node. To get the full archive capability, we’ll get a FullNode and an archive node.

Now running the following command with archive node

$ curl — data ‘{“method”:”eth_getBalance”,”params”:[“xdce5Fb31A5CaEE6a96de393bdBF89FBe65fe125Bb3”, “0x1”],”id”:1,”jsonrpc”:”2.0"}’ -H “Content-Type: application/json” -X POST QUICKNODE_WITH_ARCHIVE_ADD_ON
Enter fullscreen mode Exit fullscreen mode

Output:

{
“id” : 1,
“rpc” : “2.0”,
“result” : “0x3635c9adc5dea00000”
}
Enter fullscreen mode Exit fullscreen mode

Now running the following command with full node

$ curl — data ‘{“method”:”eth_getBalance”,”params”:[“xdce5Fb31A5CaEE6a96de393bdBF89FBe65fe125Bb3”, “0x1”],”id”:1,”jsonrpc”:”2.0"}’ -H “Content-Type: application/json” -X POST QUICKNODE_WITHOUT_ARCHIVE_ADD_ON
Enter fullscreen mode Exit fullscreen mode

Output:

{
“error” : {
“code” : -32000,
“message” : “missing trie node d67e4d450343046425ae4271474353857ab860dbc0a1dde64b41b5cd3a532bf3 (path )”
},
“id” : 1,
“rpc” : “2.0”
}
Enter fullscreen mode Exit fullscreen mode

As you can see, the call errored, which shows the need for archive functionality.

Conclusion

Here we got some understanding of XinFin full and archive nodes. Nodes can take a significant amount of time to sync the whole blockchain data and require constant maintenance. If you need older data from the blockchain, you don’t really have a choice — you have to use an archive node.

If you have any questions regarding the XDC Network please feel free to post it at https://xdc.dev

Discussion (0)