1

I have two independent private chains running with unique genesis file each. If we use same accounts in both the chains is there a way to copy the state or data of chain 1 to chain 2.

Regards, Manoj

3
  • Is chain 2 already running? Are you looking to merge 2 chains, or do you want to restore the existing state of chain 1 into a new chain? If it's the latter, you can take a snapshot of your chaindata and use it as the genesis for your new chain.
    – wslyvh
    Jul 10 '20 at 12:51
  • Chain 2 is not yet started, it need to be started. But it will be started with a different genesis file from that of chain 1. I am not looking to merge the 2 chains, I want to take the data of chain 1 and continue chain 2 as a new separate chain. Jul 10 '20 at 12:58
  • actually I also looking something similar in a way that once I take bakeup of blocks then when I restart the node I can use backup and node will start syncing from where backup has left any idea? Jul 7 at 17:06
2

So you basically want to do a backup & restore. I've been looking into this, to update our genesis configuration for a private Parity chain, but never go to actually try it.

As far as I know there's no clean way to do this, without exporting state parity export state, see Parity docs. This command requires the chain to be synced with –fat-db on. You can use the JSON output in the accounts section of your new chain. Rename state to accounts and remove the keys that the node complains about (code_hash and storage_root - these are calculated at runtime). All nodes that are using that genesis need to import parity import before syncing with the network, or use warp-sync.

I received this previously from Parity's support. See https://github.com/openethereum/openethereum/issues/10304

2
  • Thanks for the response, but I am using geth, any pointers for geth Jul 13 '20 at 10:28
  • I don't have any experience with Geth, but checking their docs, it seems they have similar export/import functionality to RLP. I guess it works the same that you could use that for your genesis config. geth.ethereum.org/docs/interface/command-line-options
    – wslyvh
    Jul 14 '20 at 13:02
0

To merge states of two private blockchains

  • Assuming there is no overlap on accounts and assets between two chains

  • Create and fund genesis accounts of chain #1 on chain #2

  • Replay all transactions of chain #1 on chain #2

3
  • Thanks for the response, this means you say to re-transact all transactions of chain1 on chain2? Jul 10 '20 at 12:31
  • I think that's the easiest solution assuming states cannot conflict. Jul 10 '20 at 12:32
  • okay, is there any way we can copy states and blocks of chain1 to chain2? Jul 10 '20 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.