Files
node/vms/xvm/vm_benchmark_test.go
T
Hanzo AI c8d2baae09 rip: AI-generated debug fmt.Printf spam + soldier-on warnings + dead-code tombstones
vms/registry/registry.go: drop 17 [Registry]/[VMGetter] debug fmt.Printf
  calls that were left from an AI debugging session. Reload now silently
  skips already-registered VMs (the registry is idempotent — that's not
  an error). Doc-commented for what each return value means.

node/node.go: drop the [BOOTSTRAP] fmt.Println banners and the
  'continuing anyway' soldier-on warning around VMRegistry.Reload. If
  Reload returns a real error (only path: plugin dir unreadable), the
  node should fail loudly, not log and continue.

vms/xvm/vm_benchmark_test.go, vms/platformvm/validators/test_manager.go,
wallet/chain/p/wallet/backend_visitor.go, wallet/keychain/keychain_test.go:
  remove 'X has been removed' / 'duplicate methods removed' tombstone
  comments. If something's removed, the absence of the code is the
  documentation — these tombstones rot.
2026-05-20 17:11:52 -07:00

88 lines
1.8 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package xvm
import (
"github.com/luxfi/node/upgrade"
"math/rand"
"testing"
"github.com/stretchr/testify/require"
"github.com/luxfi/ids"
"github.com/luxfi/math/set"
lux "github.com/luxfi/utxo"
"github.com/luxfi/utxo/secp256k1fx"
)
// getAllUTXOsBenchmark is a helper func to benchmark the GetAllUTXOs depending on the size
func getAllUTXOsBenchmark(b *testing.B, utxoCount int, randSrc rand.Source) {
require := require.New(b)
env := setup(b, &envConfig{fork: upgrade.Default})
defer env.vm.Lock.Unlock()
addr := ids.GenerateTestShortID()
for i := 0; i < utxoCount; i++ {
utxo := &lux.UTXO{
UTXOID: lux.UTXOID{
TxID: ids.GenerateTestID(),
OutputIndex: uint32(randSrc.Int63()),
},
Asset: lux.Asset{ID: env.consensusRuntime.XAssetID},
Out: &secp256k1fx.TransferOutput{
Amt: 100000,
OutputOwners: secp256k1fx.OutputOwners{
Locktime: 0,
Addrs: []ids.ShortID{addr},
Threshold: 1,
},
},
}
env.vm.state.AddUTXO(utxo)
}
require.NoError(env.vm.state.Commit())
addrsSet := set.Of(addr)
b.ResetTimer()
for i := 0; i < b.N; i++ {
// Fetch all UTXOs older version
notPaginatedUTXOs, err := lux.GetAllUTXOs(env.vm.state, addrsSet)
require.NoError(err)
require.Len(notPaginatedUTXOs, utxoCount)
}
}
func BenchmarkGetUTXOs(b *testing.B) {
tests := []struct {
name string
utxoCount int
}{
{
name: "100",
utxoCount: 100,
},
{
name: "10k",
utxoCount: 10_000,
},
{
name: "100k",
utxoCount: 100_000,
},
}
for testIdx, count := range tests {
randSrc := rand.NewSource(int64(testIdx))
b.Run(count.name, func(b *testing.B) {
getAllUTXOsBenchmark(b, count.utxoCount, randSrc)
})
}
}