Incorrect or no genesis block found. Wrong datadir for network?

+1 vote
I'm generating a new blockchain in a master container, then after the params.dat gets transferred to the peer container (through connecting), it is served to another container with multichain cold and my public API inside. Once the params are written to the correct directory it attempts to start multichain cold.

Sometimes I get the error "Incorrect or no genesis block found. Wrong datadir for network?". Sometimes it starts correctly. I don't see how it can be a race condition in writing the params, because I have verified with hashes that the params have been copied correctly before I start the daemon.

Can you give me more information on this error? Why is multichain cold looking for a genesis block? Why is it looking for a datadir when it has no networking capabilities, so should be basically stateless right?

I'm sorry I ask so many questions but I am working on a big multichain project, so I'm constantly running into stuff.

This is my code so you should see that the params are written before I try to start the cold daemon (there is no concurrency or deferred functions in the GetParams method):

if err := app.GetParams(); err != nil { panic(err) }

cmd := exec.Command("multichaind-cold", CONST_CHAIN_NAME, "-http")

cmd.Stdout = os.Stdout

cmd.Stderr = os.Stderr

fmt.Println("Running multichaind-cold and waiting for it to finish...")

err := cmd.Run()

fmt.Printf("Command finished with error: %v\n", err)

 

Thanks
asked Sep 11, 2018 by alexb

1 Answer

0 votes

The cold version of MultiChain still needs a datadir, even if it is not connecting to the network, because it is a relatively minimal fork of the main MultiChain codebase and we haven't rewritten any more logic than was necessary.

Having said that, if there's no race condition (you could introduce a 2 second delay just to make sure) this problem should not be occurring. What version of MultiChain are you using here?

answered Sep 12, 2018 by MultiChain
MultiChain 2.0 alpha 4 Offline Daemon (latest protocol 20003)

I added a 2 sec delay between writing the params file and starting multichaind-cold.

It's working about 30% of the time, and that error persists for the other 70% of attempts restarting the container. I completely remove all of the local persistent volumes servicing the containers before I restart docker-compose every time.

I think there is a high probability of this being a bug in multichain.
Also can you please tell me why decoderawtransaction is not available on the cold node? This is a big inconvenience because it's an extra network hop to decode a transaction on a hot node. Unnecessary latency :(
Thanks for the extra information. We'll treat this as a bug report for MultiChain 2.0 and look into it for the next release.

As for decoderawtransaction on the cold node, this is not possible, because the raw transaction description could reference assets and streams, whose creation are not know about by the cold node.
This error occurs in case of mismatch between params.dat and other files in the multichaind-cold directory, which were created  using other version of params.dat.


The most likely scenario for this error is:
1. chain with name  "chain" was created
2. params.dat was copied to multichain-cold directory
3. multichain-cold started normally
4. another chain with the same name "chain" was created
5. params.dat was copied to multichain-cold directory
6. multichain-cold returns error.

Please confirm this is not a case.

If yes, please make sure multichaind-cold directory is empty before copying params.dat
Thanks for your reply.
I'm pretty sure that was not the case.
I'm not experiencing the issue anymore after switching from docker to habitat.
...