Effects of a nil Sha256Checksum
in a ChecksummedGenesisDoc
#2938
Labels
bug
Something isn't working
documentation
Improvements or additions to documentation
P:integrator-experience
Priority: Improve experience for integrators
The
GenesisDocProvider
is a type alias for a funccometbft/node/setup.go
Line 55 in ce68e90
When the logic was implemented, I believe that the expectation was that this
GenesisDocProvider
was going to be 'provided' usingDefaultGenesisDocProviderFunc
, which calculates the sha256 checksum from the jsonBlob of the genesis file contentcometbft/node/setup.go
Line 59 in ce68e90
The problem is that this provider could come from a custom provider. For example, the Cosmos-SDK has a different genesis signature and it needs to pass it's own provider logic, something like:
which returns a
func() (ChecksummedGenesisDoc, error)
that can be used in anode.NewNode()
as theGenesisDocProvider
, e.g.but this might cause issues in
cometbft/node/setup.go
Line 573 in ce68e90
because the
Sha256Checksum
field is not validated (look at the example above (return node.ChecksummedGenesisDoc{GenesisDoc: gen}
) so it will be nil.It will fail when trying to save it in the
stateDB
here because anil
value cannot be saved on the databasecometbft/node/setup.go
Line 606 in ce68e90
and there is other logic in this function that relies on a
Sha256Checksum
, so in my opinion, we might need to account for that in the code or at least add more tests. I agree that in part this is caused by a integrator not adding the checksum (maybe we need to add some more information to the docs to say that is expected), but at the same time as a defensive measure we might need to ensure we can handle this scenario and that it will not cause other issues in the future.The text was updated successfully, but these errors were encountered: