Blockchain Forks test: a step-by-step guide
As a popularity of decentralized applications (APPS) and intelligent contract is important. A crucial aspect of this process is a guarantee that a heating THANAGE a blockchain fork is with integrity or stable.
In this article, we will explore the challenges they face from the developers in sending SMS blockchains for forks and providing practices on practical advice on the mandate.
The challenges of the Blockchain fork test *
When it is to test the blockchain forks, it presents itself of several technicians:
- Regtest mode: Bitcoin (BTC) is built on blocks under the regtest model. However, this mode is greater than the following limitations: it cannot create new blocks or update the blockchain.
- Change the Blockchain Code : To effectively test a fork, developers need the UNI-E Bitcoin Code. This can be demanding due to the complexity of the code and the need for precise changes.
Test Regtest mode
To go beyond, we identified two things:
– Ent (eg “Ethereum”). This approach requires significant changes to the basis of Bitcoin Code and can consume the radius.
- Edit the Blockchain Code : Another perspective is to modify while this approach can be opened, raise different concerns:
* Safety risks
: Changeing the Bitcoin Code base can introduce introductory vulnerabilities, can compromise the fork.
* Complexity of tests
: test of a modified code base requires significant effort and competence.
Edit Bitcoind to create test forks in regtest mode
Despite the challenges of Thees, the developers have clung to create forks use Bitcoind. An approach is to modify to be generally blocked with arbitrary. This can be achieved by introducing the header in the block the block in the center of the process.
Here is an example of the thing of the house that can happen:
`c
// Change the Bitcoin-QT code base
VOID Register_New_Block_Function (Int Argc, Char
ARGV, Char Buff) {
// generates a new block with arbitrary metadata
STD :: String New_Block_id = “New-Block-” + STD :: To_string (STD :: Rand ());
STD :: String New_Block_data = “Test Data”;
// Update Blockchain metadata
int new_block_height = argc;
Char* New_Block_Data_hex = std :: Malloc (Strule (New_Block_data.c_str () + 1);
Strcpy (New_Block_Data_hex, New_Block_data.c_st ());
Sparintf (New_Block_Data_hex, “%x%02x”, New_Block_id.c_st (), New_Block_height%10);
// Set the metadata of the new block
New_Block_Medata = New_Block_Data_hex;
// Update the Blockchain state
int new_block_state = argc + 1; // Add a new field
// Call the Regtest to create and manage the news
Regtest_create_New_Block (New_Block_id, New_Block_height, New_Block_data, New_Block_Medata, New_Block_state);
}
// Change the Bitcoind Regtest function
Int Main () {
// Create a new test fork under regtest
in ARGC = 1;
Char ** ARGV = {{“Regtest,” -Newblock “,” New-Block-1234567890ABCDEF “}}}; // generates a new Witata block
Char* buf = {“}; // Initialize the checking data buffer
Regtest_create_new_block (ARGV, ARGC, Buff);
Return 0;
}
``
This example shows that the developers were attached to the forks of the US Bitcoind case.