mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
feat: clean up dead code, update deps, add xvm genesis/fx and genesis builder
Remove unused bloom filter, test helpers, metrics scaffolding, and linearizable VM wrapper. Trim stale go.sum entries. Add genesis builder helpers and xvm FX/genesis initialization.
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package network
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/network/peer"
|
||||
"github.com/luxfi/node/staking"
|
||||
)
|
||||
|
||||
var (
|
||||
certLock sync.Mutex
|
||||
tlsCerts []*tls.Certificate
|
||||
tlsConfigs []*tls.Config
|
||||
)
|
||||
|
||||
func getTLS(t *testing.T, index int) (ids.NodeID, *tls.Certificate, *tls.Config) {
|
||||
certLock.Lock()
|
||||
defer certLock.Unlock()
|
||||
|
||||
for len(tlsCerts) <= index {
|
||||
cert, err := staking.NewTLSCert()
|
||||
require.NoError(t, err)
|
||||
tlsConfig := peer.TLSConfig(*cert, nil)
|
||||
|
||||
tlsCerts = append(tlsCerts, cert)
|
||||
tlsConfigs = append(tlsConfigs, tlsConfig)
|
||||
}
|
||||
|
||||
tlsCert := tlsCerts[index]
|
||||
nodeID := ids.NodeIDFromCert(&ids.Certificate{
|
||||
Raw: tlsCert.Leaf.Raw,
|
||||
PublicKey: tlsCert.Leaf.PublicKey,
|
||||
})
|
||||
return nodeID, tlsCert, tlsConfigs[index]
|
||||
}
|
||||
@@ -631,7 +631,6 @@ type RNSAnnouncer struct {
|
||||
table map[[endpoints.RNSDestinationLen]byte]*AnnounceEntry
|
||||
handlers []func(dest [endpoints.RNSDestinationLen]byte, entry *AnnounceEntry)
|
||||
gatewayAddr string
|
||||
listener net.Listener
|
||||
}
|
||||
|
||||
// RNSAnnouncerConfig configures the RNS announcer.
|
||||
|
||||
@@ -31,8 +31,6 @@ const (
|
||||
mldsaPublicKeySize = mldsa.MLDSA65PublicKeySize // ~1952 bytes
|
||||
mldsaSignatureSize = mldsa.MLDSA65SignatureSize // ~3309 bytes
|
||||
|
||||
// Hybrid signature size: Ed25519 (64) + ML-DSA-65 (~3309)
|
||||
hybridSignatureSize = ed25519SignatureSize + mldsaSignatureSize
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -81,8 +81,7 @@ type RNSLink struct {
|
||||
|
||||
// Peer information
|
||||
peerDestination [endpoints.RNSDestinationLen]byte
|
||||
peerSigningKey [32]byte
|
||||
peerExchangeKey [32]byte
|
||||
peerSigningKey [32]byte
|
||||
|
||||
// Hybrid peer information (nil if peer is classical-only)
|
||||
peerHybridIdentity *HybridPublicIdentity
|
||||
|
||||
@@ -172,17 +172,6 @@ func newDefaultResourceTracker() tracker.ResourceTracker {
|
||||
|
||||
// noOpConsensusResourceTracker is defined in test_network.go to avoid duplication
|
||||
|
||||
// noOpTracker implements tracker.CPUTracker and tracker.Tracker for testing
|
||||
type noOpTracker struct{}
|
||||
|
||||
func (n *noOpTracker) Usage(nodeID ids.NodeID, t time.Time) float64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (n *noOpTracker) TimeUntilUsage(nodeID ids.NodeID, t time.Time, usage float64) time.Duration {
|
||||
return time.Hour
|
||||
}
|
||||
|
||||
func newTestNetwork(t *testing.T, count int) (*testDialer, []*testListener, []ids.NodeID, []*Config) {
|
||||
var (
|
||||
dialer = newTestDialer()
|
||||
|
||||
@@ -375,7 +375,3 @@ type testRouter struct{}
|
||||
|
||||
func (r *testRouter) HandleInbound(context.Context, message.InboundMessage) {}
|
||||
|
||||
// newTestResourceTracker returns a new test resource tracker
|
||||
func newTestResourceTracker() *testResourceTracker {
|
||||
return &testResourceTracker{}
|
||||
}
|
||||
|
||||
@@ -44,16 +44,6 @@ type rawTestPeer struct {
|
||||
inboundMsgChan <-chan message.InboundMessage
|
||||
}
|
||||
|
||||
// noOpResourceManager implements resource.Manager for testing
|
||||
type noOpResourceManager struct{}
|
||||
|
||||
func (n *noOpResourceManager) CPUUsage() float64 { return 0 }
|
||||
func (n *noOpResourceManager) DiskUsage() float64 { return 0 }
|
||||
func (n *noOpResourceManager) AvailableDiskBytes() uint64 { return 1 << 62 }
|
||||
func (n *noOpResourceManager) TrackProcess(pid int) {}
|
||||
func (n *noOpResourceManager) UntrackProcess(pid int) {}
|
||||
func (n *noOpResourceManager) Shutdown() {}
|
||||
|
||||
// noOpTracker implements tracker.Tracker for testing
|
||||
type noOpTracker struct{}
|
||||
|
||||
|
||||
@@ -153,41 +153,6 @@ func StartTestPeer(
|
||||
return peer, peer.AwaitReady(ctx)
|
||||
}
|
||||
|
||||
// testResourceTracker is a minimal implementation for testing
|
||||
type testResourceTracker struct{}
|
||||
|
||||
func (t *testResourceTracker) CPUTracker() tracker.Tracker {
|
||||
return &testCPUTracker{}
|
||||
}
|
||||
|
||||
func (t *testResourceTracker) DiskTracker() tracker.Tracker {
|
||||
return &testDiskTracker{}
|
||||
}
|
||||
|
||||
func (t *testResourceTracker) StartProcessing(ids.NodeID, time.Time) {}
|
||||
func (t *testResourceTracker) StopProcessing(ids.NodeID, time.Time) {}
|
||||
|
||||
// testCPUTracker is a minimal CPU tracker implementation
|
||||
type testCPUTracker struct{}
|
||||
|
||||
func (t *testCPUTracker) Usage(ids.NodeID, time.Time) float64 { return 0 }
|
||||
func (t *testCPUTracker) TimeUntilUsage(ids.NodeID, time.Time, float64) time.Duration { return 0 }
|
||||
func (t *testCPUTracker) TotalUsage() float64 { return 0 }
|
||||
|
||||
// testTracker is a minimal tracker implementation
|
||||
type testTracker struct{}
|
||||
|
||||
func (t *testTracker) UtilizationTarget() float64 { return 0.8 }
|
||||
func (t *testTracker) CurrentUsage() uint64 { return 0 }
|
||||
func (t *testTracker) TotalUsage() float64 { return 0 }
|
||||
func (t *testTracker) Usage(ids.NodeID, time.Time) float64 { return 0 }
|
||||
func (t *testTracker) TimeUntilUsage(ids.NodeID, time.Time, float64) time.Duration { return 0 }
|
||||
|
||||
// testDiskTracker is a minimal disk tracker implementation
|
||||
type testDiskTracker struct{ testTracker }
|
||||
|
||||
func (t *testDiskTracker) AvailableDiskBytes() uint64 { return 1 << 30 } // 1GB
|
||||
|
||||
// testValidatorManager is a minimal validator manager implementation for testing
|
||||
type testValidatorManager struct{}
|
||||
|
||||
|
||||
@@ -20,12 +20,10 @@ import (
|
||||
validators "github.com/luxfi/validators"
|
||||
"github.com/luxfi/validators/uptime"
|
||||
"github.com/luxfi/constants"
|
||||
"github.com/luxfi/crypto/bls"
|
||||
"github.com/luxfi/crypto/bls/signer/localsigner"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/math/set"
|
||||
consensusset "github.com/luxfi/math/set"
|
||||
"github.com/luxfi/node/message"
|
||||
"github.com/luxfi/node/nets"
|
||||
"github.com/luxfi/node/network/dialer"
|
||||
@@ -231,21 +229,10 @@ type nodeIDConnector struct {
|
||||
nodeID ids.NodeID
|
||||
}
|
||||
|
||||
func newNodeIDConnector(nodeID ids.NodeID) *nodeIDConnector {
|
||||
return &nodeIDConnector{nodeID: nodeID}
|
||||
}
|
||||
|
||||
func (f *nodeIDConnector) IsAllowed(nodeID ids.NodeID, _ bool) bool {
|
||||
return nodeID == f.nodeID
|
||||
}
|
||||
|
||||
// noOpResourceManager is a no-op resource manager for testing
|
||||
type noOpResourceManager struct{}
|
||||
|
||||
func (n *noOpResourceManager) CPUUsage() float64 { return 0 }
|
||||
func (n *noOpResourceManager) DiskUsage() float64 { return 0 }
|
||||
func (n *noOpResourceManager) Shutdown() {}
|
||||
|
||||
// noOpConsensusResourceTracker implements consensus ResourceTracker for testing
|
||||
type noOpConsensusResourceTracker struct{}
|
||||
|
||||
@@ -276,93 +263,3 @@ func (n *noOpConsensusDiskTracker) TimeUntilUsage(nodeID ids.NodeID, now time.Ti
|
||||
}
|
||||
func (n *noOpConsensusDiskTracker) TotalUsage() float64 { return 0 }
|
||||
|
||||
// noOpTargeter is a no-op targeter for testing
|
||||
type noOpTargeter struct {
|
||||
target uint64
|
||||
}
|
||||
|
||||
func (n *noOpTargeter) TargetUsage() uint64 { return n.target }
|
||||
|
||||
// noOpResourceTracker is a no-op resource tracker for testing that implements consensus ResourceTracker
|
||||
type noOpResourceTracker struct{}
|
||||
|
||||
func (n *noOpResourceTracker) StartProcessing(nodeID ids.NodeID, time time.Time) {}
|
||||
func (n *noOpResourceTracker) StopProcessing(nodeID ids.NodeID, time time.Time) {}
|
||||
func (n *noOpResourceTracker) CPUTracker() tracker.Tracker { return &noOpCPUTracker{} }
|
||||
func (n *noOpResourceTracker) DiskTracker() tracker.Tracker { return &noOpDiskTracker{} }
|
||||
|
||||
// noOpCPUTracker is a no-op CPU tracker
|
||||
type noOpCPUTracker struct{}
|
||||
|
||||
func (n *noOpCPUTracker) Usage(nodeID ids.NodeID, now time.Time) float64 { return 0 }
|
||||
func (n *noOpCPUTracker) TimeUntilUsage(nodeID ids.NodeID, now time.Time, value float64) time.Duration {
|
||||
return time.Duration(0)
|
||||
}
|
||||
func (n *noOpCPUTracker) TotalUsage() float64 { return 0 }
|
||||
|
||||
// noOpDiskTracker is a no-op disk tracker
|
||||
type noOpDiskTracker struct{}
|
||||
|
||||
func (n *noOpDiskTracker) Usage(nodeID ids.NodeID, now time.Time) float64 { return 0 }
|
||||
func (n *noOpDiskTracker) TimeUntilUsage(nodeID ids.NodeID, now time.Time, value float64) time.Duration {
|
||||
return time.Duration(0)
|
||||
}
|
||||
func (n *noOpDiskTracker) TotalUsage() float64 { return 0 }
|
||||
|
||||
// noOpValidatorsManager is a no-op validators manager for testing
|
||||
type noOpValidatorsManager struct{}
|
||||
|
||||
func (n *noOpValidatorsManager) GetValidators(netID ids.ID) (validators.Set, error) {
|
||||
return &noOpValidatorSet{}, nil
|
||||
}
|
||||
func (n *noOpValidatorsManager) GetValidator(netID ids.ID, nodeID ids.NodeID) (*validators.GetValidatorOutput, bool) {
|
||||
return nil, false
|
||||
}
|
||||
func (n *noOpValidatorsManager) GetLight(netID ids.ID, nodeID ids.NodeID) uint64 { return 0 }
|
||||
func (n *noOpValidatorsManager) GetWeight(netID ids.ID, nodeID ids.NodeID) uint64 { return 0 }
|
||||
func (n *noOpValidatorsManager) TotalLight(netID ids.ID) (uint64, error) { return 0, nil }
|
||||
func (n *noOpValidatorsManager) TotalWeight(netID ids.ID) (uint64, error) { return 0, nil }
|
||||
func (n *noOpValidatorsManager) AddStaker(netID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error {
|
||||
return nil
|
||||
}
|
||||
func (n *noOpValidatorsManager) AddWeight(netID ids.ID, nodeID ids.NodeID, weight uint64) error {
|
||||
return nil
|
||||
}
|
||||
func (n *noOpValidatorsManager) RemoveWeight(netID ids.ID, nodeID ids.NodeID, weight uint64) error {
|
||||
return nil
|
||||
}
|
||||
func (n *noOpValidatorsManager) GetMap(netID ids.ID) map[ids.NodeID]*validators.GetValidatorOutput {
|
||||
return nil
|
||||
}
|
||||
func (n *noOpValidatorsManager) GetValidatorIDs(netID ids.ID) []ids.NodeID { return nil }
|
||||
func (n *noOpValidatorsManager) NumValidators(netID ids.ID) int { return 0 }
|
||||
func (n *noOpValidatorsManager) NumNets() int { return 0 }
|
||||
func (n *noOpValidatorsManager) SubsetWeight(netID ids.ID, nodeIDs consensusset.Set[ids.NodeID]) (uint64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
func (n *noOpValidatorsManager) Sample(netID ids.ID, size int) ([]ids.NodeID, error) { return nil, nil }
|
||||
func (n *noOpValidatorsManager) Count(netID ids.ID) int { return 0 }
|
||||
func (n *noOpValidatorsManager) RegisterCallbackListener(listener validators.ManagerCallbackListener) {
|
||||
}
|
||||
func (n *noOpValidatorsManager) RegisterSetCallbackListener(netID ids.ID, listener validators.SetCallbackListener) {
|
||||
}
|
||||
|
||||
// noOpValidatorSet is a no-op validator set for testing
|
||||
type noOpValidatorSet struct{}
|
||||
|
||||
func (n *noOpValidatorSet) Has(ids.NodeID) bool { return false }
|
||||
func (n *noOpValidatorSet) Len() int { return 0 }
|
||||
func (n *noOpValidatorSet) List() []validators.Validator { return nil }
|
||||
func (n *noOpValidatorSet) Light() uint64 { return 0 }
|
||||
func (n *noOpValidatorSet) Sample(size int) ([]ids.NodeID, error) { return nil, nil }
|
||||
|
||||
// noOpMetricsFactory is a no-op metrics factory for testing
|
||||
type noOpMetricsFactory struct{}
|
||||
|
||||
func (n *noOpMetricsFactory) New(string) metric.Metrics {
|
||||
return metric.NewNoOp()
|
||||
}
|
||||
|
||||
func (n *noOpMetricsFactory) NewWithRegistry(string, metric.Registry) metric.Metrics {
|
||||
return metric.NewNoOp()
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package tracker
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
@@ -42,7 +41,6 @@ type TargeterConfig struct {
|
||||
|
||||
type targeterImpl struct {
|
||||
targetUsage uint64
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func (t *targeterImpl) TargetUsage() uint64 {
|
||||
|
||||
Reference in New Issue
Block a user