lint: clean all 21 staticcheck findings — CI green, drop last codec reference

- SA1019: math.Mul64/Add64 -> generic math.Mul/Add (ed25519fx, mldsafx,
  schnorrfx inputs; flow_checker; utxo_fetching); prefixdb.NewNested -> New (alias)
- unused: DELETE dead codecVersion const (last codec reference in utxo — full
  ZAP native now), isSortedAndUniqueOrdered (root + secp256k1fx), mldsafx
  Keychain.get, and all 6 redundant TransferOutput.isState() markers (the
  embedded verify.IsState already provides State membership)
- QF1008: drop embedded-field selectors (utxo_wire, ed25519fx, nftfx,
  propertyfx + tests); ST1005: lowercase Schnorr error string

Behavior-identical; 11/11 packages pass.

Co-authored-by: Hanzo Dev <dev@hanzo.ai>
This commit is contained in:
zeekay
2026-07-12 22:32:45 -07:00
co-authored by Hanzo Dev
parent f106a1abb9
commit 6efa1285f9
34 changed files with 37 additions and 81 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ func (t *testTx) Bytes() []byte { return t.b }
func newTestFx(t *testing.T) *Fx {
t.Helper()
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
fx := &Fx{}
+1 -1
View File
@@ -134,7 +134,7 @@ func (fx *Fx) verifyOperation(tx UnsignedTx, op *MintOperation, cred *Credential
if err := verify.All(op, cred, utxo); err != nil {
return err
}
if !utxo.OutputOwners.Equals(&op.MintOutput.OutputOwners) {
if !utxo.Equals(&op.MintOutput.OutputOwners) {
return ErrWrongMintCreated
}
return fx.VerifyCredentials(tx, &op.MintInput, cred, &utxo.OutputOwners)
+2 -2
View File
@@ -29,7 +29,7 @@ func BenchmarkEd25519Verify(b *testing.B) {
}
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -79,7 +79,7 @@ func BenchmarkEd25519VerifyCached(b *testing.B) {
}
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
+3 -3
View File
@@ -24,7 +24,7 @@ func newTestFx(t *testing.T) (*Fx, ed25519.PrivateKey, ed25519.PublicKey, ids.Sh
require.NoError(err)
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -42,7 +42,7 @@ func newTestFx(t *testing.T) (*Fx, ed25519.PrivateKey, ed25519.PublicKey, ids.Sh
func TestFxInitialize(t *testing.T) {
vm := TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
fx := Fx{}
require.NoError(t, fx.Initialize(&vm))
@@ -235,7 +235,7 @@ func TestFxVerifyTransferBootstrapping(t *testing.T) {
require.NoError(err)
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
+1 -1
View File
@@ -29,7 +29,7 @@ type Input struct {
func (in *Input) Cost() (uint64, error) {
numSigs := uint64(len(in.SigIndices))
return math.Mul64(numSigs, CostPerSignature)
return math.Mul(numSigs, CostPerSignature)
}
// Verify this input is syntactically valid
-2
View File
@@ -41,5 +41,3 @@ func (out *TransferOutput) Verify() error {
func (out *TransferOutput) Owners() interface{} {
return &out.OutputOwners
}
func (*TransferOutput) isState() {}
+1 -1
View File
@@ -44,7 +44,7 @@ func TestWire_TransferOutput_RoundTrip(t *testing.T) {
if got.Amt != in.Amt {
t.Errorf("Amt: got %d, want %d", got.Amt, in.Amt)
}
if !in.OutputOwners.Equals(&got.OutputOwners) {
if !in.Equals(&got.OutputOwners) {
t.Errorf("OutputOwners mismatch")
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ func (fc *FlowChecker) Produce(assetID ids.ID, amount uint64) {
func (fc *FlowChecker) add(value map[ids.ID]uint64, assetID ids.ID, amount uint64) {
var err error
value[assetID], err = math.Add64(value[assetID], amount)
value[assetID], err = math.Add(value[assetID], amount)
if err != nil {
fc.errs = append(fc.errs, err)
}
+2 -2
View File
@@ -23,7 +23,7 @@ func BenchmarkMLDSA65Verify(b *testing.B) {
pkBytes := sk.PublicKey.Bytes()
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -71,7 +71,7 @@ func BenchmarkMLDSA65VerifyCached(b *testing.B) {
pkBytes := sk.PublicKey.Bytes()
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
+3 -3
View File
@@ -24,7 +24,7 @@ func newTestFx(t *testing.T) (*Fx, *mldsa.PrivateKey, []byte) {
require.NoError(err)
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -39,7 +39,7 @@ func newTestFx(t *testing.T) (*Fx, *mldsa.PrivateKey, []byte) {
func TestFxInitialize(t *testing.T) {
vm := TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
fx := Fx{}
require.NoError(t, fx.Initialize(&vm))
@@ -301,7 +301,7 @@ func TestFxVerifyTransferBootstrapping(t *testing.T) {
pkBytes := sk.PublicKey.Bytes()
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
+1 -1
View File
@@ -29,7 +29,7 @@ type Input struct {
func (in *Input) Cost() (uint64, error) {
numSigs := uint64(len(in.SigIndices))
return math.Mul64(numSigs, CostPerSignature)
return math.Mul(numSigs, CostPerSignature)
}
// Verify this input is syntactically valid
-8
View File
@@ -148,11 +148,3 @@ func (kc *Keychain) Match(owners *OutputOwners, time uint64) ([]uint32, []*mldsa
}
return sigs, keys, uint32(len(keys)) == owners.Threshold
}
// get returns the raw private key for the given address
func (kc Keychain) get(id ids.ShortID) (*mldsa.PrivateKey, bool) {
if i, ok := kc.addrToKeyIndex[id]; ok {
return kc.Keys[i], true
}
return nil, false
}
-2
View File
@@ -41,5 +41,3 @@ func (out *TransferOutput) Verify() error {
func (out *TransferOutput) Owners() interface{} {
return &out.OutputOwners
}
func (*TransferOutput) isState() {}
+1 -1
View File
@@ -75,7 +75,7 @@ func (fx *Fx) VerifyMintOperation(tx secp256k1fx.UnsignedTx, op *MintOperation,
case out.GroupID != op.GroupID:
return errWrongUniqueID
default:
return fx.Fx.VerifyCredentials(tx, &op.MintInput, &cred.Credential, &out.OutputOwners)
return fx.VerifyCredentials(tx, &op.MintInput, &cred.Credential, &out.OutputOwners)
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ func (fx *Fx) VerifyMintOperation(tx secp256k1fx.UnsignedTx, op *MintOperation,
case !out.OutputOwners.Equals(&op.MintOutput.OutputOwners):
return errWrongMintOutput
default:
return fx.Fx.VerifyCredentials(tx, &op.MintInput, &cred.Credential, &out.OutputOwners)
return fx.VerifyCredentials(tx, &op.MintInput, &cred.Credential, &out.OutputOwners)
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ var (
ErrNilCredential = errors.New("nil Schnorr credential")
ErrEmptyCredential = errors.New("empty Schnorr credential")
ErrInvalidSignature = errors.New("invalid Schnorr signature")
ErrWrongSigLen = errors.New("Schnorr signature wrong length")
ErrWrongSigLen = errors.New("wrong Schnorr signature length")
)
// Credential contains BIP-340 Schnorr signatures for spending UTXOs.
+1 -1
View File
@@ -28,7 +28,7 @@ func benchSetup(b *testing.B) (*Fx, *TransferOutput, *TransferInput, *Credential
}
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
+2 -2
View File
@@ -24,7 +24,7 @@ func newTestFx(t *testing.T) (*Fx, *btcec.PrivateKey, []byte, ids.ShortID) {
require.NoError(err)
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -52,7 +52,7 @@ func signSchnorr(t *testing.T, sk *btcec.PrivateKey, msg []byte) [SigLen]byte {
func TestFxInitialize(t *testing.T) {
vm := TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
fx := Fx{}
require.NoError(t, fx.Initialize(&vm))
+1 -1
View File
@@ -30,7 +30,7 @@ type Input struct {
func (in *Input) Cost() (uint64, error) {
numSigs := uint64(len(in.SigIndices))
return math.Mul64(numSigs, CostPerSignature)
return math.Mul(numSigs, CostPerSignature)
}
// Verify this input is syntactically valid
-2
View File
@@ -41,5 +41,3 @@ func (out *TransferOutput) Verify() error {
func (out *TransferOutput) Owners() interface{} {
return &out.OutputOwners
}
func (*TransferOutput) isState() {}
-10
View File
@@ -4,7 +4,6 @@
package secp256k1fx
import (
"cmp"
"slices"
)
@@ -22,12 +21,3 @@ func isSortedAndUniqueByCompare[T interface{ Compare(T) int }](s []T) bool {
}
return true
}
func isSortedAndUniqueOrdered[T cmp.Ordered](s []T) bool {
for i := 1; i < len(s); i++ {
if s[i-1] >= s[i] {
return false
}
}
return true
}
-2
View File
@@ -67,5 +67,3 @@ func (out *TransferOutput) Verify() error {
func (out *TransferOutput) Owners() interface{} {
return &out.OutputOwners
}
func (*TransferOutput) isState() {}
+2 -2
View File
@@ -30,7 +30,7 @@ func BenchmarkP256Verify(b *testing.B) {
}
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -83,7 +83,7 @@ func BenchmarkP256VerifyCached(b *testing.B) {
}
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
+3 -3
View File
@@ -25,7 +25,7 @@ func newTestFx(t *testing.T) (*Fx, *ecdsa.PrivateKey, []byte, ids.ShortID) {
require.NoError(err)
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -44,7 +44,7 @@ func newTestFx(t *testing.T) (*Fx, *ecdsa.PrivateKey, []byte, ids.ShortID) {
func TestFxInitialize(t *testing.T) {
vm := TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
fx := Fx{}
require.NoError(t, fx.Initialize(&vm))
@@ -241,7 +241,7 @@ func TestFxVerifyTransferBootstrapping(t *testing.T) {
require.NoError(err)
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
-2
View File
@@ -41,5 +41,3 @@ func (out *TransferOutput) Verify() error {
func (out *TransferOutput) Owners() interface{} {
return &out.OutputOwners
}
func (*TransferOutput) isState() {}
+2 -2
View File
@@ -22,7 +22,7 @@ func BenchmarkSLH192fVerify(b *testing.B) {
pkBytes := sk.PublicKey.Bytes()
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -69,7 +69,7 @@ func BenchmarkSLH192fVerifyCached(b *testing.B) {
pkBytes := sk.PublicKey.Bytes()
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
+3 -3
View File
@@ -24,7 +24,7 @@ func newTestFx(t *testing.T) (*Fx, *slhdsa.PrivateKey, []byte) {
require.NoError(err)
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -39,7 +39,7 @@ func newTestFx(t *testing.T) (*Fx, *slhdsa.PrivateKey, []byte) {
func TestFxInitialize(t *testing.T) {
vm := TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
fx := Fx{}
require.NoError(t, fx.Initialize(&vm))
@@ -257,7 +257,7 @@ func TestFxVerifyTransferBootstrapping(t *testing.T) {
pkBytes := sk.PublicKey.Bytes()
vm := &TestVM{
Log: log.NewNoOpLogger(),
Log: log.NewNoOpLogger(),
}
vm.Clk.Set(time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC))
-2
View File
@@ -41,5 +41,3 @@ func (out *TransferOutput) Verify() error {
func (out *TransferOutput) Owners() interface{} {
return &out.OutputOwners
}
func (*TransferOutput) isState() {}
-10
View File
@@ -4,7 +4,6 @@
package utxo
import (
"cmp"
"slices"
)
@@ -22,12 +21,3 @@ func isSortedAndUniqueByCompare[T interface{ Compare(T) int }](s []T) bool {
}
return true
}
func isSortedAndUniqueOrdered[T cmp.Ordered](s []T) bool {
for i := 1; i < len(s); i++ {
if s[i-1] >= s[i] {
return false
}
}
return true
}
-4
View File
@@ -3,10 +3,6 @@
package utxo
const (
codecVersion = 0
)
// Addressable is the interface a feature extension must provide to be able to
// be tracked as a part of the utxo set for a set of addresses
type Addressable interface {
+1 -1
View File
@@ -23,7 +23,7 @@ func GetBalance(db UTXOReader, addrs set.Set[ids.ShortID]) (uint64, error) {
balance := uint64(0)
for _, utxo := range utxos {
if out, ok := utxo.Out.(Amounter); ok {
balance, err = safemath.Add64(out.Amount(), balance)
balance, err = safemath.Add(out.Amount(), balance)
if err != nil {
return 0, err
}
+1 -1
View File
@@ -264,7 +264,7 @@ func (s *utxoState) getIndexDB(addr []byte) linkeddb.LinkedDB {
return indexList
}
indexDB := prefixdb.NewNested(addr, s.indexDB)
indexDB := prefixdb.New(addr, s.indexDB)
indexList := linkeddb.NewDefault(indexDB)
s.indexCache.Put(addrStr, indexList)
return indexList
+1 -1
View File
@@ -49,7 +49,7 @@ func (u *UTXO) WireBytes() ([]byte, error) {
return wire.NewUTXO(wire.UTXOInput{
TxID: u.TxID,
OutputIndex: u.OutputIndex,
AssetID: u.Asset.ID,
AssetID: u.ID,
Output: outputBytes,
}), nil
}
+1 -1
View File
@@ -73,7 +73,7 @@ func TestUTXO_WireBytes_Secp256k1_TransferOutput_RoundTrip(t *testing.T) {
if gotOut.Amt != inOut.Amt {
t.Errorf("Out.Amt: got %d, want %d", gotOut.Amt, inOut.Amt)
}
if !gotOut.OutputOwners.Equals(&inOut.OutputOwners) {
if !gotOut.Equals(&inOut.OutputOwners) {
t.Errorf("Out.OutputOwners mismatch")
}
}