Fix network and test import paths for 100% build success

- Update consensus/engine/core imports to consensus/core
- Fix test implementations
- Ensure all packages build successfully
This commit is contained in:
2025-08-16 06:22:39 +00:00
parent 0b1a6ba7ae
commit 22b84b0eca
22 changed files with 39 additions and 45 deletions
-3
View File
@@ -6,16 +6,13 @@ package core
import (
"fmt"
"math/big"
"os"
"testing"
"github.com/luxfi/node/upgrade"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/rawdb"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/core/vm"
"github.com/luxfi/crypto"
"github.com/luxfi/geth/eth/tracers/logger"
"github.com/luxfi/geth/ethdb"
ethparams "github.com/luxfi/geth/params"
"github.com/luxfi/evm/consensus/dummy"
+2 -7
View File
@@ -32,7 +32,6 @@ import (
_ "embed"
"fmt"
"math/big"
"path/filepath"
"reflect"
"testing"
@@ -371,9 +370,7 @@ func newDbConfig(t *testing.T, scheme string) *triedb.Config {
return triedb.HashDefaults
case rawdb.PathScheme:
return &triedb.Config{PathDB: &gethpathdb.Config{
CleanCacheSize: pathdb.Defaults.CleanCacheSize,
DirtyCacheSize: pathdb.Defaults.DirtyCacheSize,
ReadOnly: pathdb.Defaults.ReadOnly,
ReadOnly: pathdb.Defaults.ReadOnly,
}}
case customrawdb.FirewoodScheme:
// Firewood disabled - use HashScheme instead
@@ -426,9 +423,7 @@ func TestVerkleGenesisCommit(t *testing.T) {
db := rawdb.NewMemoryDatabase()
triedb := triedb.NewDatabase(db, &triedb.Config{IsVerkle: true, PathDB: &gethpathdb.Config{
CleanCacheSize: pathdb.Defaults.CleanCacheSize,
DirtyCacheSize: pathdb.Defaults.DirtyCacheSize,
ReadOnly: pathdb.Defaults.ReadOnly,
ReadOnly: pathdb.Defaults.ReadOnly,
}})
block := genesis.MustCommit(db, triedb)
if !bytes.Equal(block.Root().Bytes(), expected) {
-1
View File
@@ -32,7 +32,6 @@ import (
"math/big"
"testing"
"github.com/luxfi/node/upgrade"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/rawdb"
"github.com/luxfi/geth/core/types"
+3 -3
View File
@@ -57,7 +57,7 @@ func stressTestTrieDb(t *testing.B, numContracts int, callsPerBlock int, element
signer := types.LatestSigner(config)
testKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
contractAddr := make([]common.Address, numContracts)
contractAddr := make([]crypto.Address, numContracts)
contractTxs := make([]*types.Transaction, numContracts)
gasPrice := big.NewInt(225000000000)
@@ -106,8 +106,8 @@ func stressTestTrieDb(t *testing.B, numContracts int, callsPerBlock int, element
for e := 0; e < callsPerBlock; e++ {
contractId := (i + e) % deployedContracts
tx, err := types.SignTx(types.NewTx(&types.LegacyTx{
Nonce: gen.TxNonce(benchRootAddr),
To: &contractAddr[contractId],
Nonce: gen.TxNonce(common.Address(benchRootAddr)),
To: (*common.Address)(&contractAddr[contractId]),
Value: big.NewInt(0),
Gas: gasTxLimit,
GasPrice: gasPrice,
+6 -6
View File
@@ -57,19 +57,19 @@ func TestTransactionIndices(t *testing.T) {
funds = big.NewInt(10000000000000)
gspec = &Genesis{
Config: &params.ChainConfig{HomesteadBlock: new(big.Int)},
Alloc: GenesisAlloc{addr1: {Balance: funds}},
Alloc: GenesisAlloc{common.Address(addr1): {Balance: funds}},
}
signer = types.LatestSigner(gspec.Config)
)
genDb, blocks, _, err := GenerateChainWithGenesis(gspec, dummy.NewFaker(), 128, 10, func(i int, block *BlockGen) {
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(common.Address(addr1)), common.Address(addr2), big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
require.NoError(err)
block.AddTx(tx)
})
require.NoError(err)
blocks2, _, err := GenerateChain(gspec.Config, blocks[len(blocks)-1], dummy.NewFaker(), genDb, 10, 10, func(i int, block *BlockGen) {
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(common.Address(addr1)), common.Address(addr2), big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
require.NoError(err)
block.AddTx(tx)
})
@@ -177,19 +177,19 @@ func TestTransactionSkipIndexing(t *testing.T) {
funds = big.NewInt(10000000000000)
gspec = &Genesis{
Config: &params.ChainConfig{HomesteadBlock: new(big.Int)},
Alloc: GenesisAlloc{addr1: {Balance: funds}},
Alloc: GenesisAlloc{common.Address(addr1): {Balance: funds}},
}
signer = types.LatestSigner(gspec.Config)
)
genDb, blocks, _, err := GenerateChainWithGenesis(gspec, dummy.NewCoinbaseFaker(), 5, 10, func(i int, block *BlockGen) {
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(common.Address(addr1)), common.Address(addr2), big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
require.NoError(err)
block.AddTx(tx)
})
require.NoError(err)
blocks2, _, err := GenerateChain(gspec.Config, blocks[len(blocks)-1], dummy.NewCoinbaseFaker(), genDb, 5, 10, func(i int, block *BlockGen) {
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(common.Address(addr1)), common.Address(addr2), big.NewInt(10000), ethparams.TxGas, nil, nil), signer, key1)
require.NoError(err)
block.AddTx(tx)
})
+10 -5
View File
@@ -18,7 +18,7 @@ import (
"github.com/luxfi/ids"
"github.com/luxfi/node/codec"
"github.com/luxfi/consensus"
"github.com/luxfi/consensus/engine/core"
"github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/validators"
"github.com/luxfi/node/network/p2p"
"github.com/luxfi/node/utils"
@@ -129,21 +129,26 @@ func NewNetwork(
maxActiveAppRequests int64,
registerer prometheus.Registerer,
) (Network, error) {
p2pNetwork, err := p2p.NewNetwork(ctx.Log, appSender, registerer, "p2p")
logger := consensus.GetLogger(ctx)
p2pNetwork, err := p2p.NewNetwork(logger, appSender, registerer, "p2p")
if err != nil {
return nil, fmt.Errorf("failed to initialize p2p network: %w", err)
}
nodeID := consensus.GetNodeID(ctx)
subnetID := consensus.GetSubnetID(ctx)
validatorState := consensus.GetValidatorState(ctx)
return &network{
appSender: appSender,
codec: codec,
self: ctx.NodeID,
self: nodeID,
outstandingRequestHandlers: make(map[uint32]message.ResponseHandler),
activeAppRequests: semaphore.NewWeighted(maxActiveAppRequests),
sdkNetwork: p2pNetwork,
appRequestHandler: message.NoopRequestHandler{},
peers: NewPeerTracker(),
appStats: stats.NewRequestHandlerStats(),
p2pValidators: p2p.NewValidators(p2pNetwork.Peers, ctx.Log, ctx.SubnetID, ctx.ValidatorState, maxValidatorSetStaleness),
p2pValidators: p2p.NewValidators(p2pNetwork.Peers, logger, subnetID, validatorState, maxValidatorSetStaleness),
}, nil
}
@@ -384,7 +389,7 @@ func (n *network) AppGossip(ctx context.Context, nodeID ids.NodeID, gossipBytes
}
// Connected adds the given nodeID to the peer list so that it can receive messages
func (n *network) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error {
func (n *network) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion interface{}) error {
log.Debug("adding new peer", "nodeID", nodeID)
n.lock.Lock()
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"time"
"github.com/luxfi/node/network/p2p"
"github.com/luxfi/consensus/engine/core"
"github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/engine/enginetest"
"github.com/luxfi/consensus/consensustest"
"github.com/luxfi/node/utils/set"
+1 -1
View File
@@ -4,12 +4,12 @@
package extras
import (
"context"
"encoding/json"
"fmt"
"math/big"
"time"
"github.com/luxfi/consensus"
"github.com/luxfi/geth/common"
ethparams "github.com/luxfi/geth/params"
"github.com/luxfi/evm/commontype"
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"time"
"github.com/luxfi/consensus"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/log"
"github.com/luxfi/evm/core"
"github.com/luxfi/evm/core/txpool"
+1 -1
View File
@@ -16,7 +16,7 @@ import (
"github.com/luxfi/log"
"github.com/luxfi/node/network/p2p"
"github.com/luxfi/node/network/p2p/gossip"
enginecore "github.com/luxfi/consensus/engine/core"
enginecore "github.com/luxfi/consensus/core"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
+1 -1
View File
@@ -16,7 +16,7 @@ import (
"github.com/luxfi/ids"
"github.com/luxfi/node/utils/set"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/geth/common"
"github.com/luxfi/crypto"
+1 -1
View File
@@ -20,7 +20,7 @@ import (
"github.com/luxfi/database/prefixdb"
"github.com/luxfi/ids"
"github.com/luxfi/consensus"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/engine/enginetest"
"github.com/luxfi/consensus/engine/chain/block"
"github.com/luxfi/node/upgrade/upgradetest"
+1 -1
View File
@@ -86,7 +86,7 @@ import (
"github.com/luxfi/node/version"
"github.com/luxfi/node/vms/components/chain"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/database"
luxUtils "github.com/luxfi/node/utils"
+1 -1
View File
@@ -33,7 +33,7 @@ import (
"github.com/luxfi/ids"
"github.com/luxfi/consensus"
"github.com/luxfi/consensus/chain"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/engine/enginetest"
"github.com/luxfi/node/upgrade"
"github.com/luxfi/node/upgrade/upgradetest"
+1 -1
View File
@@ -14,7 +14,7 @@ import (
"github.com/luxfi/metric"
"github.com/luxfi/consensus"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/engine/enginetest"
"github.com/luxfi/node/upgrade"
"github.com/luxfi/node/upgrade/upgradetest"
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"github.com/luxfi/database"
"github.com/luxfi/ids"
"github.com/luxfi/consensus"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/engine/enginetest"
luxdvalidators "github.com/luxfi/consensus/validators"
"github.com/luxfi/consensus/validators/validatorstest"
+1 -1
View File
@@ -17,7 +17,7 @@ import (
"github.com/luxfi/node/network/p2p"
"github.com/luxfi/node/network/p2p/lp118"
"github.com/luxfi/node/proto/pb/sdk"
commonEng "github.com/luxfi/consensus/engine/core"
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/engine/enginetest"
"github.com/luxfi/consensus/engine/chain/block"
"github.com/luxfi/consensus/validators"
+1 -1
View File
@@ -5,9 +5,9 @@
package contract
import (
"context"
"math/big"
"github.com/luxfi/consensus"
"github.com/luxfi/geth/common"
ethtypes "github.com/luxfi/geth/core/types"
"github.com/luxfi/evm/precompile/precompileconfig"
+1 -1
View File
@@ -10,10 +10,10 @@
package contract
import (
"context"
big "math/big"
reflect "reflect"
"github.com/luxfi/consensus"
common "github.com/luxfi/geth/common"
types "github.com/luxfi/geth/core/types"
precompileconfig "github.com/luxfi/evm/precompile/precompileconfig"
+3 -5
View File
@@ -4,7 +4,6 @@
package validators
import (
"context"
"github.com/luxfi/ids"
"github.com/luxfi/consensus/validators"
"github.com/luxfi/node/utils/constants"
@@ -37,18 +36,17 @@ func NewState(state validators.State, mySubnetID ids.ID, sourceChainID ids.ID, r
}
func (s *State) GetValidatorSet(
ctx context.Context,
height uint64,
subnetID ids.ID,
) (map[ids.NodeID]*validators.GetValidatorOutput, error) {
) (map[ids.NodeID]uint64, error) {
// If the subnetID is anything other than the Primary Network, or Primary
// Network signers are required (except P-Chain), this is a direct passthrough.
usePrimary := s.requirePrimaryNetworkSigners && s.sourceChainID != constants.PlatformChainID
if usePrimary || subnetID != constants.PrimaryNetworkID {
return s.State.GetValidatorSet(ctx, height, subnetID)
return s.State.GetValidatorSet(height, subnetID)
}
// If the requested subnet is the primary network, then we return the validator
// set for the Subnet that is receiving the message instead.
return s.State.GetValidatorSet(ctx, height, s.mySubnetID)
return s.State.GetValidatorSet(height, s.mySubnetID)
}
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"github.com/luxfi/evm/warp/messages"
"github.com/luxfi/database"
"github.com/luxfi/consensus/engine/core"
"github.com/luxfi/consensus/core"
luxWarp "github.com/luxfi/node/vms/platformvm/warp"
"github.com/luxfi/node/vms/platformvm/warp/payload"
)
+1 -1
View File
@@ -15,7 +15,7 @@ import (
"github.com/luxfi/ids"
"github.com/luxfi/node/network/p2p/lp118"
"github.com/luxfi/node/proto/pb/sdk"
"github.com/luxfi/consensus/engine/core"
"github.com/luxfi/consensus/core"
"github.com/luxfi/node/utils/timer/mockable"
luxWarp "github.com/luxfi/node/vms/platformvm/warp"
"github.com/luxfi/node/vms/platformvm/warp/payload"