Conversation
|
This cleans it up a lot. :-) What is the purpose of Couldn't we remove the Signer interface and just let the client implement I am wondering though how it would work with moving the signing logic into a Thales HSM. |
|
I'm wary though how people would use different signers. Ideally wanting to use a NanoLedger or Thales shouldn't require you to fork Tendermint Core. Either we have a finite list of supported signers hardcoded in Core and then try to figure out which one to use through a config option or Core expects a signer to be available behind some socket so that way in the config you can specify a socket address and Tendermint Core will just send the bytes to sign that way. |
I'm not quite following the full idea with |
A place to store the actual priv key, so eg. it can be encrypted on disk. This might go away though.
CarefulSigner is the thing that prevents double signing. In this issue, Silas mentioned a
Possibly, but at least for now that would spoil CarefulSigner
The HSM would implement Signer and CarefulSigner
Both of these sounds pretty good. Let's start with a list of supported things (unencrypted, encrypted, ledger, thales) and then open it up to a socket. |
state/execution.go
Outdated
| power := v.Power | ||
| if power < 0 { | ||
| return fmt.Errorf("Power (%d) overflows int64", v.Power) | ||
| return fmt.Errorf("Power (%d) must be positive int64", v.Power) |
| // or else generates a new one and saves it to the filePath. | ||
| func LoadOrGenDefaultPrivValidator(filePath string, store PrivValidatorStore) *DefaultPrivValidator { | ||
| var pv *DefaultPrivValidator | ||
| if _, err := os.Stat(filePath); err == nil { |
| privVal.Save() | ||
| addr := privVal.GetAddress() | ||
| privVal.CarefulSigner.(*LastSignedInfo).LastHeight = height | ||
| privVal.CarefulSigner.(*LastSignedInfo).saveFn(privVal.CarefulSigner) |
There was a problem hiding this comment.
this is harder to read&understand comparing to privVal.Save()
types/priv_validator/signer.go
Outdated
|
|
||
| //----------------------------------------------------------------- | ||
|
|
||
| // DefaultSigner implements Signer. |
There was a problem hiding this comment.
how about a check: var _ Signer = (*DefaultSigner)(nil)
types/priv_validator/types.go
Outdated
| return stepPrecommit | ||
| default: | ||
| cmn.PanicSanity("Unknown vote type") | ||
| return 0 |
types/validator.go
Outdated
| return val, privVal | ||
| } | ||
|
|
||
| type Signer interface { |
There was a problem hiding this comment.
2 Signer interfaces. Wont this be confusing?
There was a problem hiding this comment.
yes this one is just for testing tho. problem of circular imports ...
There was a problem hiding this comment.
I'll change it to TestSigner
|
How about calling it |
|
It's not just a Verifier though - at the least its a VerifyAndSigner. And it's also something that's expected to have mutable internal state if its going to keep track of things to not double sign. So it seemed CarefulSigner was a good fit for a name. The CarefulSigner interface isn't actually being used in any useful way right now, but I think it's useful to have, especially for cases where the LastSignedInfo is on disk but the Signer is an HSM. The goal is for the DefaultPrivValidator to just use Signer and CarefulSigner interfaces directly, but we need to be able to unmarshall into those, so I'm waiting on changes to go-wire to make that work nicely. In the meantime, it should be a very small amount of code to add a new priv validator - the only thing is you have to handle your own marshal/unmarshal for saving/loading from disk. Once the new wire changes are in, everyone can just use the DefaultPrivValidator, and provide the Signer and CarefulSigner they like :) |
Codecov Report
@@ Coverage Diff @@
## develop #1044 +/- ##
===========================================
- Coverage 59.66% 59.52% -0.14%
===========================================
Files 116 119 +3
Lines 10667 10772 +105
===========================================
+ Hits 6364 6412 +48
- Misses 3725 3779 +54
- Partials 578 581 +3 |
|
Ok - I went through this again and simplified. Please take a look at the ADR and the new simplified code. Dropped the CarefulSigner and just put those methods on the LastSignedInfo. Shouldn't be any lost functionality really. Tendermint will jsut support PrivValidatorUnencrypted and PrivValidatorSocket. Folks will still be able to override in-process if they want with their own PrivValidator, and should be able to easily use the LastSignedInfo. |
| power := v.Power | ||
| if power < 0 { | ||
| return fmt.Errorf("Power (%d) overflows int64", v.Power) | ||
| return fmt.Errorf("Power (%d) must be positive int64", power) |
There was a problem hiding this comment.
let's add address here too: "Power (%d) of validator %X must be positive int64", power, address
| vote1 := makeVote(val, chainID, 0, 10, 2, 1, blockID) | ||
| badVote := makeVote(val, chainID, 0, 10, 2, 1, blockID) | ||
| badVote.Signature = val2.PrivKey.Sign(SignBytes(chainID, badVote)) | ||
| badVote.Signature, _ = val2.Sign(SignBytes(chainID, badVote)) |
There was a problem hiding this comment.
it's better not ignore errors. why not do require.NoError(t, err)
| "github.com/tendermint/tendermint/types" | ||
| ) | ||
|
|
||
| // TODO: type ? |
There was a problem hiding this comment.
step is exposed in LastSignedInfo, so don't think this is a good idea because of that
|
|
||
| // TODO: type ? | ||
| const ( | ||
| stepNone int8 = 0 // Used to distinguish the initial state |
| func (info *LastSignedInfo) Reset() { | ||
| info.Height = 0 | ||
| info.Round = 0 | ||
| info.Step = 0 |
|
Closing in favor of fresh new PR without the integrations #1203 |
#673
Hard to see the changes because I busted up the file into its own package, but it should be much easier to read through now.
@silasdavis @wrl @ethanfrey @adrianbrink @melekes