all: fix govet (#1517)

Co-authored-by: wit <wit765765346@gmail>
This commit is contained in:
wit liu 2025-09-21 18:55:13 +08:00 committed by GitHub
parent 185e28ad14
commit 1a2c8ee180
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 10 deletions

View file

@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"reflect"
"strconv"
"strings"
"github.com/XinFinOrg/XDPoSChain/common"
@ -80,14 +79,16 @@ func (f *Forensics) SetCommittedQCs(headers []types.Header, incomingQC types.Quo
return nil
}
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error {
return nil
}
/*
Entry point for processing forensics.
Triggered once processQC is successfully.
Forensics runs in a separate go routine as its no system critical
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/97878029/Forensics+Diagram+flow
*/
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error {
return nil
log.Debug("Received a QC in forensics", "QC", incomingQC)
// Clone the values to a temporary variable
highestCommittedQCs := f.HighestCommittedQCs
@ -126,6 +127,7 @@ func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_
return nil
}
*/
// Last step of forensics which sends out detailed proof to report service.
func (f *Forensics) SendForensicProof(chain consensus.ChainReader, engine *XDPoS_v2, firstQc types.QuorumCert, secondQc types.QuorumCert) error {
@ -388,14 +390,16 @@ func generateVoteEquivocationId(signer common.Address, round1, round2 types.Roun
return fmt.Sprintf("%x:%d:%d", signer, round1, round2)
}
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error {
return nil
}
/*
Entry point for processing vote equivocation.
Triggered once handle vote is successfully.
Forensics runs in a separate go routine as its no system critical
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/99516417/Vote+Equivocation+detection+specification
*/
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error {
return nil
log.Debug("Received a vote in forensics", "vote", incomingVote)
// Clone the values to a temporary variable
highestCommittedQCs := f.HighestCommittedQCs
@ -449,6 +453,7 @@ func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine
return nil
}
*/
func (f *Forensics) isExtendingFromAncestor(blockChainReader consensus.ChainReader, currentBlock *types.BlockInfo, ancestorBlock *types.BlockInfo) (bool, error) {
blockNumDiff := int(big.NewInt(0).Sub(currentBlock.Number, ancestorBlock.Number).Int64())
@ -487,6 +492,10 @@ func (f *Forensics) isVoteBlamed(chain consensus.ChainReader, highestCommittedQC
func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool) {
return
}
/*
func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool) {
poolKey := vote.PoolKey()
votePoolKeys := votePool.PoolObjKeysList()
signer, err := GetVoteSignerAddresses(vote)
@ -523,6 +532,7 @@ func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *uti
}
}
}
*/
func (f *Forensics) SendVoteEquivocationProof(vote1, vote2 *types.Vote, signer common.Address) error {
smallerRoundVote := vote1

View file

@ -35,7 +35,11 @@ type ECPoint struct {
}
func (p *ECPoint) toECPubKey() *ecdsa.PublicKey {
return &ecdsa.PublicKey{curve, p.X, p.Y}
return &ecdsa.PublicKey{
Curve: curve,
X: p.X,
Y: p.Y,
}
}
func toECPoint(key *ecdsa.PublicKey) *ECPoint {

View file

@ -111,7 +111,11 @@ func DeserializeCompressed(curve elliptic.Curve, b []byte) *ecdsa.PublicKey {
if ybit != isOdd(y) {
return nil
}
return &ecdsa.PublicKey{curve, x, y}
return &ecdsa.PublicKey{
Curve: curve,
X: x,
Y: y,
}
}
// bytes returns the public key ring as a byte slice.
@ -426,13 +430,21 @@ func Sign(m [32]byte, rings []Ring, privkeys []*ecdsa.PrivateKey, s int) (*RingS
// start at secret index s/PI
// compute L_s = u*G
l_x, l_y := curve.ScalarBaseMult(PadTo32Bytes(alpha[i].Bytes()))
L[i][s] = &ecdsa.PublicKey{curve, l_x, l_y}
L[i][s] = &ecdsa.PublicKey{
Curve: curve,
X: l_x,
Y: l_y,
}
lT := append(PadTo32Bytes(l_x.Bytes()), PadTo32Bytes(l_y.Bytes())...)
l = append(l, lT...)
// compute R_s = u*H_p(P[s])
h_x, h_y := HashPoint(pubkeys[i])
r_x, r_y := curve.ScalarMult(h_x, h_y, PadTo32Bytes(alpha[i].Bytes()))
R[i][s] = &ecdsa.PublicKey{curve, r_x, r_y}
R[i][s] = &ecdsa.PublicKey{
Curve: curve,
X: r_x,
Y: r_y,
}
rT := append(PadTo32Bytes(r_x.Bytes()), PadTo32Bytes(r_y.Bytes())...)
l = append(l, rT...)
}

View file

@ -320,6 +320,7 @@ func (t *Trie) TryGetAllLeftKeyAndValue(limit []byte) ([][]byte, [][]byte, error
}
return keys, values, err
}
func (t *Trie) tryGetAllLeftKeyAndValue(origNode node, prefix []byte, limit []byte) (keys [][]byte, values [][]byte, newnode node, didResolve bool, err error) {
switch n := (origNode).(type) {
case nil:
@ -370,8 +371,8 @@ func (t *Trie) tryGetAllLeftKeyAndValue(origNode node, prefix []byte, limit []by
default:
return nil, nil, nil, false, fmt.Errorf("%T: invalid Node: %v", origNode, origNode)
}
return nil, nil, nil, false, fmt.Errorf("%T: invalid Node: %v", origNode, origNode)
}
func (t *Trie) TryGetBestRightKeyAndValue() ([]byte, []byte, error) {
key, value, newroot, didResolve, err := t.tryGetBestRightKeyAndValue(t.root, []byte{})
if err == nil && didResolve {