From 1a2c8ee180f23d207cffa0324a52f7156c20cd02 Mon Sep 17 00:00:00 2001 From: wit liu <765765346@qq.com> Date: Sun, 21 Sep 2025 18:55:13 +0800 Subject: [PATCH] all: fix govet (#1517) Co-authored-by: wit --- .../XDPoS/engines/engine_v2/forensics.go | 20 ++++++++++++++----- core/vm/privacy/bulletproof.go | 6 +++++- core/vm/privacy/ringct.go | 18 ++++++++++++++--- trie/trie.go | 3 ++- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/consensus/XDPoS/engines/engine_v2/forensics.go b/consensus/XDPoS/engines/engine_v2/forensics.go index 5bc621ce63..afadfa1f60 100644 --- a/consensus/XDPoS/engines/engine_v2/forensics.go +++ b/consensus/XDPoS/engines/engine_v2/forensics.go @@ -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 diff --git a/core/vm/privacy/bulletproof.go b/core/vm/privacy/bulletproof.go index addeab7326..8ab3509020 100644 --- a/core/vm/privacy/bulletproof.go +++ b/core/vm/privacy/bulletproof.go @@ -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 { diff --git a/core/vm/privacy/ringct.go b/core/vm/privacy/ringct.go index 91ea3096c1..cc68c5c721 100644 --- a/core/vm/privacy/ringct.go +++ b/core/vm/privacy/ringct.go @@ -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...) } diff --git a/trie/trie.go b/trie/trie.go index da300f9dcb..29157f894f 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -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 {