diff --git a/signer/file.go b/signer/file.go index 1431e973..b0eae6f6 100644 --- a/signer/file.go +++ b/signer/file.go @@ -201,7 +201,8 @@ func (pv *FilePV) GetPubKey() (crypto.PubKey, error) { } func (pv *FilePV) Sign(block Block) ([]byte, []byte, time.Time, error) { - height, round, step, signBytes, voteExtensionSignBytes := block.Height, int32(block.Round), block.Step, block.SignBytes, block.VoteExtensionSignBytes + height, round, step := block.Height, int32(block.Round), block.Step + signBytes, voteExtensionSignBytes := block.SignBytes, block.VoteExtensionSignBytes lss := pv.LastSignState diff --git a/signer/remote_signer.go b/signer/remote_signer.go index 88ce9ff5..1a675e30 100644 --- a/signer/remote_signer.go +++ b/signer/remote_signer.go @@ -186,7 +186,13 @@ func (rs *ReconnRemoteSigner) handleSignVoteRequest(chainID string, vote *cometp Error: nil, }} - sig, voteExtSig, timestamp, err := signAndTrack(context.TODO(), rs.Logger, rs.privVal, chainID, VoteToBlock(chainID, vote)) + sig, voteExtSig, timestamp, err := signAndTrack( + context.TODO(), + rs.Logger, + rs.privVal, + chainID, + VoteToBlock(chainID, vote), + ) if err != nil { msgSum.SignedVoteResponse.Error = getRemoteSignerError(err) return cometprotoprivval.Message{Sum: msgSum} diff --git a/signer/single_signer_validator.go b/signer/single_signer_validator.go index 23da5d88..33d78de0 100644 --- a/signer/single_signer_validator.go +++ b/signer/single_signer_validator.go @@ -49,7 +49,15 @@ func (pv *SingleSignerValidator) GetPubKey(_ context.Context, chainID string) ([ } // SignVote implements types.PrivValidator -func (pv *SingleSignerValidator) Sign(_ context.Context, chainID string, block Block) ([]byte, []byte, time.Time, error) { +func (pv *SingleSignerValidator) Sign( + _ context.Context, + chainID string, + block Block) ( + []byte, + []byte, + time.Time, + error, +) { chainState, err := pv.loadChainStateIfNecessary(chainID) if err != nil { return nil, nil, block.Timestamp, err diff --git a/signer/single_signer_validator_test.go b/signer/single_signer_validator_test.go index 4ef737b5..721ec234 100644 --- a/signer/single_signer_validator_test.go +++ b/signer/single_signer_validator_test.go @@ -121,6 +121,7 @@ func TestSingleSignerValidator(t *testing.T) { require.True(t, privateKey.PubKey().VerifySignature(block.SignBytes, sig), "signature verification failed") - require.True(t, privateKey.PubKey().VerifySignature(block.VoteExtensionSignBytes, voteExtSig), "vote extension signature verification failed") + require.True(t, privateKey.PubKey().VerifySignature(block.VoteExtensionSignBytes, voteExtSig), + "vote extension signature verification failed") } diff --git a/signer/threshold_validator.go b/signer/threshold_validator.go index 8d954355..ba33dbb1 100644 --- a/signer/threshold_validator.go +++ b/signer/threshold_validator.go @@ -146,7 +146,10 @@ func (pv *ThresholdValidator) mustLoadChainState(chainID string) ChainSignState // sign process if it is greater than the current high watermark. A mutex is used to avoid concurrent // state updates. The disk write is scheduled in a separate goroutine which will perform an atomic write. // pendingDiskWG is used upon termination in pendingDiskWG to ensure all writes have completed. -func (pv *ThresholdValidator) SaveLastSignedStateInitiated(chainID string, block *Block) ([]byte, []byte, time.Time, error) { +func (pv *ThresholdValidator) SaveLastSignedStateInitiated( + chainID string, + block *Block, +) ([]byte, []byte, time.Time, error) { css := pv.mustLoadChainState(chainID) height, round, step := block.Height, block.Round, block.Step @@ -158,7 +161,8 @@ func (pv *ThresholdValidator) SaveLastSignedStateInitiated(chainID string, block } // There was an error saving the last sign state, so check if there is an existing signature for this block. - existingSignature, existingVoteExtSignature, existingTimestamp, sameBlockErr := pv.getExistingBlockSignature(chainID, block) + existingSignature, existingVoteExtSignature, + existingTimestamp, sameBlockErr := pv.getExistingBlockSignature(chainID, block) if _, ok := err.(*SameHRSError); !ok { if sameBlockErr == nil { @@ -208,7 +212,8 @@ func (pv *ThresholdValidator) SaveLastSignedStateInitiated(chainID string, block continue } - existingSignature, existingVoteExtSignature, existingTimestamp, sameBlockErr = pv.compareBlockSignatureAgainstSSC(chainID, block, &ssc) + existingSignature, existingVoteExtSignature, + existingTimestamp, sameBlockErr = pv.compareBlockSignatureAgainstSSC(chainID, block, &ssc) if sameBlockErr == nil { return existingSignature, existingVoteExtSignature, existingTimestamp, nil } @@ -397,7 +402,10 @@ func (pv *ThresholdValidator) LoadSignStateIfNecessary(chainID string) error { // getExistingBlockSignature returns the existing block signature and no error if the signature is valid for the block. // It returns nil signature and nil error if there is no signature and it's okay to sign (fresh or again). // It returns an error if we have already signed a greater block, or if we are still waiting for in in-progress sign. -func (pv *ThresholdValidator) getExistingBlockSignature(chainID string, block *Block) ([]byte, []byte, time.Time, error) { +func (pv *ThresholdValidator) getExistingBlockSignature( + chainID string, + block *Block, +) ([]byte, []byte, time.Time, error) { css := pv.mustLoadChainState(chainID) latestBlock, existingSignature := css.lastSignState.GetFromCache(block.HRSKey()) @@ -615,8 +623,13 @@ func (pv *ThresholdValidator) proxyIfNecessary( return true, signRes.Signature, signRes.VoteExtensionSignature, stamp, nil } -func (pv *ThresholdValidator) Sign(ctx context.Context, chainID string, block Block) ([]byte, []byte, time.Time, error) { - height, round, step, stamp, signBytes, voteExtensionSignBytes := block.Height, block.Round, block.Step, block.Timestamp, block.SignBytes, block.VoteExtensionSignBytes +func (pv *ThresholdValidator) Sign( + ctx context.Context, + chainID string, + block Block, +) ([]byte, []byte, time.Time, error) { + height, round, step, stamp := block.Height, block.Round, block.Step, block.Timestamp + signBytes, voteExtensionSignBytes := block.SignBytes, block.VoteExtensionSignBytes log := pv.logger.With( "chain_id", chainID, diff --git a/signer/threshold_validator_test.go b/signer/threshold_validator_test.go index 7befae6f..05d499d5 100644 --- a/signer/threshold_validator_test.go +++ b/signer/threshold_validator_test.go @@ -607,8 +607,6 @@ func testThresholdValidatorLeaderElection(t *testing.T, threshold, total uint8) if !pubKey.VerifySignature(voteExtSignBytes, voteExtSig) { t.Log("PreCommit vote extension signature verification failed") return - } else { - t.Log("PreCommit vote extension signature verification succeeded") } mu.Lock()