Background
Shadow Fork is a technique that allows developers to create and test new blockchain protocols or modifications without affecting the main chain. It can be seen as a sandbox environment that simulates the current state of the main chain, enabling developers to experiment and validate changes in custom settings. This approach provides a more realistic testing environment than launching a new testnet. As a result, we can obtain performance metrics in real-world conditions without impacting the operation of the standard network.
Shadow forks are important tools for web3 developers. As explained here, Ethereum has conducted the Merge upgrade testing through the shadow fork. Many of the development tools in the Ethereum ecosystem have supported the shadow fork, such as the Hardhat network, and Foundry Anvil. There are also other relevant projects. Shadow can implement advanced on-chain data retrieval through shadow fork. BuildBear has built a professional Dapp development and testing platform with a shadow fork sandbox environment.
However, there are no relevant shadow fork tools in TRON ecosystem, which may negatively influence developers, as shown in the #6126 . So it will be necessary to design the shadow fork tool for the TRON network.
Rationale
Shadow fork tool can bring many potential benefits to protocol and application developers, especially for testing in the simulated production environment. The use cases include:
-
Testnet or Mainnet upgrade testing
-
Smart contracts testing against the production environment
-
Integrating with existing tools, such as Tronbox
-
Local development testing with mainnet state
Specification
To implement the shadow fork tool in the TRON network, the base idea is:
-
Obtain the current state of the chain, through node syncing or downloading the archived data
-
Use the shadow fork tool to modify the SR and other data of the current state to produce blocks locally
-
Launch the fullnode against the modified state to execute the development and testing
Test Specification
The test should guarantee the tool can complete the shadow fork successfully.
Scope Of Impact
The feature is to implement the shadow fork within the Toolkit and does not influence the FullNode.
Implementation
As shown in the following figure, we have designed an explicit scheme to implement the state fork tool in the TRON network. The main steps are:
- Obtain the state data of the main chain. There are three possible ways:
-
Download the light node state data, and then sync to the specified block number;
-
Download the full node state data, and then sync to the specified block number;
-
Sync to the specified block number directly.
We can modify the node.shutdown option to make the fullnode sync to the specified block number.

- Run the DBFork tool in the Toolkit to modify some data to launch the node and produce blocks locally. The modified data includes:
-
erase the historical witnesses and active witnesses
-
Write new witnesses to the state and update new active witnesses
-
Write new balance for new addresses
-
set the new latesteBlockHeaderTimestamp to avoid the delay in producing blocks
-
set the new maintenanceTimeInterval and nextMaintenanceTime if needed.
- Launch the full node against the modified state. To launch the node smoothly, we may need to change some parameters:
needSyncCheck = false
minParticipation = 0
node.p2p.versioon != 11111
To produce the blocks, we also need to configure the private key of the witness and run the fullnode with the --witness parameter, which is similar to the mainnet.
- If another node wants to join the shadow fork network, it must execute the above steps or copy the state data from the first shadow fork node directly.
Here is a brief introduction to the shadow fork scheme. We are willing to implement this feature and contribute to it.
Background
Shadow Fork is a technique that allows developers to create and test new blockchain protocols or modifications without affecting the main chain. It can be seen as a sandbox environment that simulates the current state of the main chain, enabling developers to experiment and validate changes in custom settings. This approach provides a more realistic testing environment than launching a new testnet. As a result, we can obtain performance metrics in real-world conditions without impacting the operation of the standard network.
Shadow forks are important tools for web3 developers. As explained here, Ethereum has conducted the Merge upgrade testing through the shadow fork. Many of the development tools in the Ethereum ecosystem have supported the shadow fork, such as the Hardhat network, and Foundry Anvil. There are also other relevant projects. Shadow can implement advanced on-chain data retrieval through shadow fork. BuildBear has built a professional Dapp development and testing platform with a shadow fork sandbox environment.
However, there are no relevant shadow fork tools in TRON ecosystem, which may negatively influence developers, as shown in the #6126 . So it will be necessary to design the shadow fork tool for the TRON network.
Rationale
Shadow fork tool can bring many potential benefits to protocol and application developers, especially for testing in the simulated production environment. The use cases include:
Testnet or Mainnet upgrade testing
Smart contracts testing against the production environment
Integrating with existing tools, such as Tronbox
Local development testing with mainnet state
Specification
To implement the shadow fork tool in the TRON network, the base idea is:
Obtain the current state of the chain, through node syncing or downloading the archived data
Use the shadow fork tool to modify the SR and other data of the current state to produce blocks locally
Launch the fullnode against the modified state to execute the development and testing
Test Specification
The test should guarantee the tool can complete the shadow fork successfully.
Scope Of Impact
The feature is to implement the shadow fork within the Toolkit and does not influence the FullNode.
Implementation
As shown in the following figure, we have designed an explicit scheme to implement the state fork tool in the TRON network. The main steps are:
Download the light node state data, and then sync to the specified block number;
Download the full node state data, and then sync to the specified block number;
Sync to the specified block number directly.
We can modify the
node.shutdownoption to make the fullnode sync to the specified block number.erase the historical witnesses and active witnesses
Write new witnesses to the state and update new active witnesses
Write new balance for new addresses
set the new
latesteBlockHeaderTimestampto avoid the delay in producing blocksset the new
maintenanceTimeIntervalandnextMaintenanceTimeif needed.To produce the blocks, we also need to configure the private key of the witness and run the fullnode with the
--witnessparameter, which is similar to the mainnet.Here is a brief introduction to the shadow fork scheme. We are willing to implement this feature and contribute to it.