-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending the Toolkit to support shadow fork tool #6136
Comments
A question about 'Write new balance for new addresses', Where are the new addresses from during shadow fork? |
@GrothenDI It is similar to a faucet. The developers can modify the balance for their addresses for testing. |
part (1) 1.Network Isolation: Ethereum's shadow fork testnet operates in complete isolation to ensure test activities do not affect the mainnet. Has the TRON proposal considered sufficient isolation measures to prevent test network behavior from leaking to mainnet? 2.Security and Testing Standards: Ethereum implements strict security testing standards and specifications during shadow fork testing. Does the TRON proposal include clear security testing standards and processes, and how will these standards be enforced? 3.Post-Test Data Management: After Ethereum shadow fork testing concludes, test network data is typically discarded. Does the TRON proposal provide clear guidance on handling post-test data, and how to ensure test environment rollback and cleanup? |
part (2)
|
It seems like private network with real transaction data |
How about making it easier to add other fullnodes? |
Hi, @endiaoekoe, thank you for your suggestions. Here are some explains:
|
Yeah, it is private network with mainnet state data. But what do mean to add other fullnodes? As described above, If other 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. Then they can form a ordinary local testnet, which can sync and produce blocks. |
The current proposal for enabling fork testing with Tron RPC nodes revolves around enabling syncing historical state, which seems to be the missing functionality preventing us from fork testing with Foundry currently. Given that many development teams—including ours—already use frameworks like Hardhat and Foundry for testing and simulation, we’re curious about the decision to build a separate implementation specific to Tron toolkits rather than designing the functionality to integrate with these more widely adopted tools. Could you share more about the rationale behind this approach and whether there are plans to enable fork test compatibility with Hardhat or Foundry in the future? It seems like such compatibility could significantly lower the barrier to adoption for developers and accelerate broader ecosystem development for Tron. |
@blockketten Considering the difference between TRON and Ethereum, we believe the best choice to implement the shadow fork is within the Toolkit currently. We will do more investigation later and try to implement the shadow fork function compatible with Hardhat and Foundry. |
@Federico2014 After the node's syncing completes at certain height, you should backup the database like this:
Once the database is written, it cannot be rolled back. And you may need to test multiple times. The backup precedure only cost several seconds. And you can also stop service of StatisticManager to skip missing check. So you don't need to write latest timestamp. |
@317787106 Thank you for your suggestions. Backup is quite necessary. For the fullnode data, it may take up too much space. The developers should decide whether to backup the database. |
@Federico2014 This backup is not same as |
@Federico2014 , I second @blockketten proposal; we have to make this as compatible as possible with other tools. Otherwise, we are limiting TRON's interoperability. Thanks for following up on this :) |
@simbadMarino Compatibility with existing tools is undoubtedly the best choice, but it is indeed a challenge. The basic tests for Hardhat and Foundry compatibility with the TRON network are still not feasible, not to mention the shadow fork test. Due to the differences in transaction data structure and storage model between the TRON network and Ethereum, achieving complete compatibility would require a groundbreaking upgrade to the TRON network, which may lead to unpredictable consequences. We will conduct a more thorough analysis of the differences later and evaluate the feasibility of implementing compatibility. Thank you so much for your suggestions. |
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.shutdown
option 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
latesteBlockHeaderTimestamp
to avoid the delay in producing blocksset the new
maintenanceTimeInterval
andnextMaintenanceTime
if needed.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.Here is a brief introduction to the shadow fork scheme. We are willing to implement this feature and contribute to it.
The text was updated successfully, but these errors were encountered: