Replace Subnet terminology with Net

Updated all references from Subnet to Net throughout the test suite:
- NewTmpnetSubnet → NewTmpnetNet
- tmpnet.Subnet → tmpnet.Net
- network.GetSubnet → network.GetNet
- Subnets field → Nets field

This aligns with the Lux rebranding to drop 'Sub' language.
This commit is contained in:
2025-11-22 21:44:40 -08:00
parent ce9940081d
commit 4da0e49e63
10 changed files with 43 additions and 42 deletions
+4 -3
View File
@@ -239,9 +239,10 @@ func (c *ChainIndexer) eventLoop(currentHeader *types.Header, events chan ChainH
// TODO(karalabe, zsfelfoldi): This seems a bit brittle, can we detect this case explicitly?
if rawdb.ReadCanonicalHash(c.chainDb, prevHeader.Number.Uint64()) != prevHash {
if h := rawdb.FindCommonAncestor(c.chainDb, prevHeader, header); h != nil {
c.newHead(h.Number.Uint64(), true)
}
// FindCommonAncestor is not available in luxfi/geth rawdb
// For now, we trigger a reorg from the previous header height
// This is safe but may reindex more blocks than strictly necessary
c.newHead(prevHeader.Number.Uint64(), true)
}
}
c.newHead(header.Number.Uint64(), false)
+3 -3
View File
@@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/luxfi/consensus"
consensuscontext "github.com/luxfi/consensus/context"
luxvalidators "github.com/luxfi/consensus/validator"
"github.com/luxfi/database"
validators "github.com/luxfi/evm/plugin/evm/validators/state"
@@ -115,8 +115,8 @@ func (m *manager) sync(ctx context.Context) error {
now := time.Now()
log.Debug("performing validator sync")
// get current validator set
validatorState := consensus.GetValidatorState(m.chainCtx)
subnetID := consensus.GetSubnetID(m.chainCtx)
validatorState := consensuscontext.GetValidatorState(m.chainCtx)
subnetID := consensuscontext.GetSubnetID(m.chainCtx)
currentHeight, err := validatorState.GetCurrentHeight(ctx)
if err != nil {
return fmt.Errorf("failed to get current height: %w", err)
+2 -2
View File
@@ -11,7 +11,7 @@ import (
"path/filepath"
"time"
"github.com/luxfi/consensus"
consensuscontext "github.com/luxfi/consensus/context"
luxdatabase "github.com/luxfi/database"
"github.com/luxfi/database/factory"
"github.com/luxfi/database/prefixdb"
@@ -51,7 +51,7 @@ type DatabaseConfig struct {
func (vm *VM) initializeDBs(avaDB luxdatabase.Database) error {
db := avaDB
// skip standalone database initialization if we are running in unit tests
if consensus.GetNetworkID(vm.ctx) != constants.UnitTestID {
if consensuscontext.GetNetworkID(vm.ctx) != constants.UnitTestID {
// first initialize the accepted block database to check if we need to use a standalone database
acceptedDB := prefixdb.New(acceptedPrefix, avaDB)
useStandAloneDB, err := vm.useStandaloneDatabase(acceptedDB)
+7 -7
View File
@@ -64,21 +64,21 @@ var _ = ginkgo.Describe("[Load Simulator]", ginkgo.Ordered, func() {
"evm-small-load",
nodes,
tmpnet.FlagsMap{},
utils.NewTmpnetSubnet(subnetAName, genesisPath, utils.DefaultChainConfig, nodes...),
utils.NewTmpnetNet(subnetAName, genesisPath, utils.DefaultChainConfig, nodes...),
),
)
})
ginkgo.It("basic subnet load test", ginkgo.Label("load"), func() {
ginkgo.It("basic net load test", ginkgo.Label("load"), func() {
network := env.GetNetwork()
subnet := network.GetSubnet(subnetAName)
require.NotNil(subnet)
blockchainID := subnet.Chains[0].ChainID
net := network.GetNet(subnetAName)
require.NotNil(net)
blockchainID := net.Chains[0].ChainID
nodeURIs := env.GetNodeURIs()
validatorIDs := set.NewSet[ids.NodeID](len(subnet.ValidatorIDs))
validatorIDs.Add(subnet.ValidatorIDs...)
validatorIDs := set.NewSet[ids.NodeID](len(net.ValidatorIDs))
validatorIDs.Add(net.ValidatorIDs...)
rpcEndpoints := make([]string, 0, len(nodeURIs))
for _, nodeURI := range nodeURIs {
if !validatorIDs.Contains(nodeURI.NodeID) {
+6 -6
View File
@@ -30,7 +30,7 @@ func NewTmpnetNodes(count int) []*tmpnet.Node {
return nodes
}
func NewTmpnetNetwork(owner string, nodes []*tmpnet.Node, flags tmpnet.FlagsMap, subnets ...*tmpnet.Subnet) *tmpnet.Network {
func NewTmpnetNetwork(owner string, nodes []*tmpnet.Node, flags tmpnet.FlagsMap, nets ...*tmpnet.Net) *tmpnet.Network {
defaultFlags := tmpnet.FlagsMap{}
defaultFlags.SetDefaults(flags)
defaultFlags.SetDefaults(tmpnet.FlagsMap{
@@ -40,15 +40,15 @@ func NewTmpnetNetwork(owner string, nodes []*tmpnet.Node, flags tmpnet.FlagsMap,
Owner: owner,
DefaultFlags: defaultFlags,
Nodes: nodes,
Subnets: subnets,
Nets: nets,
}
}
// Create the configuration that will enable creation and access to a
// subnet created on a temporary network.
func NewTmpnetSubnet(name string, genesisPath string, chainConfig map[string]any, nodes ...*tmpnet.Node) *tmpnet.Subnet {
// net created on a temporary network.
func NewTmpnetNet(name string, genesisPath string, chainConfig map[string]any, nodes ...*tmpnet.Node) *tmpnet.Net {
if len(nodes) == 0 {
panic("a subnet must be validated by at least one node")
panic("a net must be validated by at least one node")
}
validatorIDs := make([]ids.NodeID, len(nodes))
@@ -66,7 +66,7 @@ func NewTmpnetSubnet(name string, genesisPath string, chainConfig map[string]any
panic(err)
}
return &tmpnet.Subnet{
return &tmpnet.Net{
Name: name,
Chains: []*tmpnet.Chain{
{
+2 -2
View File
@@ -102,8 +102,8 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
"evm-warp-e2e",
nodes,
tmpnet.FlagsMap{},
utils.NewTmpnetSubnet(subnetAName, genesisPath, utils.DefaultChainConfig, nodes...),
utils.NewTmpnetSubnet(subnetBName, genesisPath, utils.DefaultChainConfig, nodes...),
utils.NewTmpnetNet(subnetAName, genesisPath, utils.DefaultChainConfig, nodes...),
utils.NewTmpnetNet(subnetBName, genesisPath, utils.DefaultChainConfig, nodes...),
),
)
+1 -1
View File
@@ -744,7 +744,7 @@ func (db *Database) Scheme() string {
// Reader retrieves a node reader belonging to the given state root.
// An error will be returned if the requested state is not available.
func (db *Database) Reader(root common.Hash) (database.Reader, error) {
func (db *Database) Reader(root common.Hash) (database.StateReader, error) {
if _, err := db.node(root); err != nil {
return nil, fmt.Errorf("state %#x is not available, %v", root, err)
}
+9 -9
View File
@@ -7,7 +7,7 @@ import (
"context"
"testing"
"github.com/luxfi/consensus"
consensuscontext "github.com/luxfi/consensus/context"
"github.com/luxfi/consensus/test/helpers"
"github.com/luxfi/consensus/validator"
"github.com/luxfi/consensus/validator/validatorstest"
@@ -17,7 +17,7 @@ import (
// SubnetEVMTestChainID is a evm specific chain ID for testing
var SubnetEVMTestChainID = ids.GenerateTestID()
// testValidatorState wraps validatorstest.State to implement consensus.ValidatorState
// testValidatorState wraps validatorstest.State to implement consensuscontext.ValidatorState
type testValidatorState struct {
*validatorstest.State
}
@@ -54,7 +54,7 @@ func (t *testValidatorState) GetNetID(chainID ids.ID) (ids.ID, error) {
// @TODO: This should eventually be replaced by a more robust solution, or alternatively, the presence of nil
// validator states shouldn't be depended upon by tests
func NewTestValidatorState() consensus.ValidatorState {
func NewTestValidatorState() consensuscontext.ValidatorState {
state := &validatorstest.State{
GetCurrentHeightF: func(context.Context) (uint64, error) {
return 0, nil
@@ -77,8 +77,8 @@ func NewTestValidatorState() consensus.ValidatorState {
// NewTestValidatorStateFromBase creates a testValidatorState that wraps an existing validatorstest.State
// This is useful when you need to use a specific validatorstest.State with custom functions
// but still implement the consensus.ValidatorState interface.
func NewTestValidatorStateFromBase(baseState *validatorstest.State) consensus.ValidatorState {
// but still implement the consensuscontext.ValidatorState interface.
func NewTestValidatorStateFromBase(baseState *validatorstest.State) consensuscontext.ValidatorState {
return &testValidatorState{State: baseState}
}
@@ -101,9 +101,9 @@ func NewTestConsensusContext(t testing.TB) context.Context {
consensusCtx := consensustest.Context(t, SubnetEVMTestChainID)
// Create a standard context and add the consensus context to it
ctx := context.Background()
ctx = consensus.WithContext(ctx, consensusCtx)
ctx = consensuscontext.WithContext(ctx, consensusCtx)
// Add validator state to the context
return consensus.WithValidatorState(ctx, NewTestValidatorState())
return consensuscontext.WithValidatorState(ctx, NewTestValidatorState())
}
// NewTestConsensusContextWithChainID returns a context.Context with validator state properly configured for testing
@@ -112,7 +112,7 @@ func NewTestConsensusContextWithChainID(t testing.TB, chainID ids.ID) context.Co
consensusCtx := consensustest.Context(t, chainID)
// Create a standard context and add the consensus context to it
ctx := context.Background()
ctx = consensus.WithContext(ctx, consensusCtx)
ctx = consensuscontext.WithContext(ctx, consensusCtx)
// Add validator state to the context
return consensus.WithValidatorState(ctx, NewTestValidatorState())
return consensuscontext.WithValidatorState(ctx, NewTestValidatorState())
}
+5 -5
View File
@@ -8,7 +8,7 @@ import (
"errors"
"fmt"
"github.com/luxfi/consensus"
consensuscontext "github.com/luxfi/consensus/context"
"github.com/luxfi/geth/common/hexutil"
"github.com/luxfi/geth/log"
"github.com/luxfi/ids"
@@ -81,8 +81,8 @@ func (a *API) GetBlockAggregateSignature(ctx context.Context, blockID ids.ID, qu
if err != nil {
return nil, err
}
chainID := consensus.GetChainID(a.chainContext)
unsignedMessage, err := luxWarp.NewUnsignedMessage(consensus.GetNetworkID(a.chainContext), chainID[:], blockHashPayload.Bytes())
chainID := consensuscontext.GetChainID(a.chainContext)
unsignedMessage, err := luxWarp.NewUnsignedMessage(consensuscontext.GetNetworkID(a.chainContext), chainID[:], blockHashPayload.Bytes())
if err != nil {
return nil, err
}
@@ -91,7 +91,7 @@ func (a *API) GetBlockAggregateSignature(ctx context.Context, blockID ids.ID, qu
}
func (a *API) aggregateSignatures(ctx context.Context, unsignedMessage *luxWarp.UnsignedMessage, quorumNum uint64, subnetIDStr string) (hexutil.Bytes, error) {
subnetID := consensus.GetSubnetID(a.chainContext)
subnetID := consensuscontext.GetSubnetID(a.chainContext)
if len(subnetIDStr) > 0 {
sid, err := ids.FromString(subnetIDStr)
if err != nil {
@@ -99,7 +99,7 @@ func (a *API) aggregateSignatures(ctx context.Context, unsignedMessage *luxWarp.
}
subnetID = sid
}
validatorState := consensus.GetValidatorState(a.chainContext)
validatorState := consensuscontext.GetValidatorState(a.chainContext)
pChainHeight, err := validatorState.GetCurrentHeight(ctx)
if err != nil {
return nil, err
+4 -4
View File
@@ -6,18 +6,18 @@ package validators
import (
"context"
"github.com/luxfi/consensus"
consensuscontext "github.com/luxfi/consensus/context"
"github.com/luxfi/consensus/validator"
"github.com/luxfi/ids"
)
// ConsensusStateWrapper wraps consensus.ValidatorState to implement validators.State
// ConsensusStateWrapper wraps consensuscontext.ValidatorState to implement validators.State
type ConsensusStateWrapper struct {
vs consensus.ValidatorState
vs consensuscontext.ValidatorState
}
// NewConsensusStateWrapper creates a new wrapper
func NewConsensusStateWrapper(vs consensus.ValidatorState) *ConsensusStateWrapper {
func NewConsensusStateWrapper(vs consensuscontext.ValidatorState) *ConsensusStateWrapper {
return &ConsensusStateWrapper{vs: vs}
}