-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Tendermint version 0.23.1
I would like to inject my own Public and Private key types because I do not want to use the ED25519 curve.
The embedded doc mentions it is possible to inject its own private validator as long as it implements the types.PrivValidator interface.
Unfortunately, this is currently impossible.
The typesGenesisDocrequires an array of validators which can be bootsrapped using something like
genDoc.Validators = []types.GenesisValidator{{
PubKey: privValidator.GetPubKey(), // <-- this pulls the "new" Public Key
Power: 10,
}}The Node is instantiated using a (massive) NewNode(...) function that attempts to serialize the GenesisDoc in the state DB using a piece of code that does
genDoc, err := loadGenesisDoc(stateDB)
if err != nil {
genDoc, err = genesisDocProvider()
if err != nil {
return nil, err
}
// save genesis doc to prevent a certain class of user errors (e.g. when it
// was changed, accidentally or not). Also good for audit trail.
saveGenesisDoc(stateDB, genDoc) // <---- THE PROBLEMATIC CALL
}To serialize the doc, aminois called.
Unfortunately aminorequires all serializable "concrete" types to be pre-registered and the piece of code that does this is, is located in the wire.go file in the node package in an init() call, namely
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc) // <--- this registers all the types
}As currently written, there is no way to inject custom types either by getting hold of cdc, which is private to the package, or via a provided callback.
I believe this static initialization should be revisited and cdc should be instantiated early and injected in the new node as part of the NewNode function parameters.