mirror of
https://github.com/luxfi/netrunner.git
synced 2026-07-27 00:04:23 +00:00
fix(netrunner): update for node API changes
- Update peer.NewTLSServerUpgrader to include prometheus.Counter for invalid certs - Fix UnsignedIP.Sign to include BLS secret key parameter - Migrate from Version to Handshake message with ACP support - Update ClaimedIPPort from value to pointer slice - Fix message.NewCreator to use metrics.Metrics interface - Update Chits method signature for new parameters - Fix logging API changes for log factory and level imports - Remove deprecated color formatting methods from commands - Update test imports to avoid package name conflicts - Maintain existing color logging in blockchain.go as colors are still supported
This commit is contained in:
+6
-56
@@ -8,8 +8,7 @@ import (
|
||||
|
||||
"github.com/luxfi/geth/core/types"
|
||||
"github.com/luxfi/evm/ethclient"
|
||||
"github.com/luxfi/evm/interfaces"
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
ethereum "github.com/luxfi/geth"
|
||||
"github.com/luxfi/geth/common"
|
||||
)
|
||||
|
||||
@@ -148,18 +147,7 @@ func (c *ethClient) CallContract(ctx context.Context, msg ethereum.CallMsg, bloc
|
||||
if err := c.connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Convert ethereum.CallMsg to interfaces.CallMsg
|
||||
callMsg := interfaces.CallMsg{
|
||||
From: msg.From,
|
||||
To: msg.To,
|
||||
Gas: msg.Gas,
|
||||
GasPrice: msg.GasPrice,
|
||||
GasFeeCap: msg.GasFeeCap,
|
||||
GasTipCap: msg.GasTipCap,
|
||||
Value: msg.Value,
|
||||
Data: msg.Data,
|
||||
}
|
||||
return c.client.CallContract(ctx, callMsg, blockNumber)
|
||||
return c.client.CallContract(ctx, msg, blockNumber)
|
||||
}
|
||||
|
||||
func (c *ethClient) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) {
|
||||
@@ -218,18 +206,7 @@ func (c *ethClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint
|
||||
if err := c.connect(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// Convert ethereum.CallMsg to interfaces.CallMsg
|
||||
callMsg := interfaces.CallMsg{
|
||||
From: msg.From,
|
||||
To: msg.To,
|
||||
Gas: msg.Gas,
|
||||
GasPrice: msg.GasPrice,
|
||||
GasFeeCap: msg.GasFeeCap,
|
||||
GasTipCap: msg.GasTipCap,
|
||||
Value: msg.Value,
|
||||
Data: msg.Data,
|
||||
}
|
||||
return c.client.EstimateGas(ctx, callMsg)
|
||||
return c.client.EstimateGas(ctx, msg)
|
||||
}
|
||||
|
||||
func (c *ethClient) AcceptedCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
|
||||
@@ -240,18 +217,7 @@ func (c *ethClient) AcceptedCallContract(ctx context.Context, call ethereum.Call
|
||||
}
|
||||
// TODO: AcceptedCallContract is not in standard ethclient
|
||||
// For now, use CallContract with latest block
|
||||
// Convert ethereum.CallMsg to interfaces.CallMsg
|
||||
callMsg := interfaces.CallMsg{
|
||||
From: call.From,
|
||||
To: call.To,
|
||||
Gas: call.Gas,
|
||||
GasPrice: call.GasPrice,
|
||||
GasFeeCap: call.GasFeeCap,
|
||||
GasTipCap: call.GasTipCap,
|
||||
Value: call.Value,
|
||||
Data: call.Data,
|
||||
}
|
||||
return c.client.CallContract(ctx, callMsg, nil)
|
||||
return c.client.CallContract(ctx, call, nil)
|
||||
}
|
||||
|
||||
func (c *ethClient) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
|
||||
@@ -278,15 +244,7 @@ func (c *ethClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery)
|
||||
if err := c.connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Convert ethereum.FilterQuery to interfaces.FilterQuery
|
||||
filterQuery := interfaces.FilterQuery{
|
||||
BlockHash: query.BlockHash,
|
||||
FromBlock: query.FromBlock,
|
||||
ToBlock: query.ToBlock,
|
||||
Addresses: query.Addresses,
|
||||
Topics: query.Topics,
|
||||
}
|
||||
return c.client.FilterLogs(ctx, filterQuery)
|
||||
return c.client.FilterLogs(ctx, query)
|
||||
}
|
||||
|
||||
func (c *ethClient) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
|
||||
@@ -295,13 +253,5 @@ func (c *ethClient) SubscribeFilterLogs(ctx context.Context, query ethereum.Filt
|
||||
if err := c.connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Convert ethereum.FilterQuery to interfaces.FilterQuery
|
||||
filterQuery := interfaces.FilterQuery{
|
||||
BlockHash: query.BlockHash,
|
||||
FromBlock: query.FromBlock,
|
||||
ToBlock: query.ToBlock,
|
||||
Addresses: query.Addresses,
|
||||
Topics: query.Topics,
|
||||
}
|
||||
return c.client.SubscribeFilterLogs(ctx, filterQuery, ch)
|
||||
return c.client.SubscribeFilterLogs(ctx, query, ch)
|
||||
}
|
||||
|
||||
+17
-18
@@ -14,8 +14,7 @@ import (
|
||||
|
||||
"github.com/luxfi/netrunner/local"
|
||||
"github.com/luxfi/netrunner/rpcpb"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"go.uber.org/zap"
|
||||
"github.com/luxfi/log"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
@@ -58,7 +57,7 @@ type Client interface {
|
||||
|
||||
type client struct {
|
||||
cfg Config
|
||||
log logging.Logger
|
||||
log log.Logger
|
||||
|
||||
conn *grpc.ClientConn
|
||||
|
||||
@@ -69,8 +68,8 @@ type client struct {
|
||||
closeOnce sync.Once
|
||||
}
|
||||
|
||||
func New(cfg Config, log logging.Logger) (Client, error) {
|
||||
log.Debug("dialing server at ", zap.String("endpoint", cfg.Endpoint))
|
||||
func New(cfg Config, log log.Logger) (Client, error) {
|
||||
log.Debug("dialing server at", "endpoint", cfg.Endpoint)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cfg.DialTimeout)
|
||||
conn, err := grpc.DialContext(
|
||||
@@ -223,7 +222,7 @@ func (c *client) StreamStatus(ctx context.Context, pushInterval time.Duration) (
|
||||
ch := make(chan *rpcpb.ClusterInfo, 1)
|
||||
go func() {
|
||||
defer func() {
|
||||
c.log.Debug("closing stream send", zap.Error(stream.CloseSend()))
|
||||
c.log.Debug("closing stream send", log.Err(stream.CloseSend()))
|
||||
close(ch)
|
||||
}()
|
||||
c.log.Info("start receive routine")
|
||||
@@ -249,9 +248,9 @@ func (c *client) StreamStatus(ctx context.Context, pushInterval time.Duration) (
|
||||
return
|
||||
}
|
||||
if isClientCanceled(stream.Context().Err(), err) {
|
||||
c.log.Warn("failed to receive status request from gRPC stream due to client cancellation", zap.Error(err))
|
||||
c.log.Warn("failed to receive status request from gRPC stream due to client cancellation", log.Err(err))
|
||||
} else {
|
||||
c.log.Warn("failed to receive status request from gRPC stream", zap.Error(err))
|
||||
c.log.Warn("failed to receive status request from gRPC stream", log.Err(err))
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -281,22 +280,22 @@ func (c *client) AddNode(ctx context.Context, name string, execPath string, opts
|
||||
req.PluginDir = ret.pluginDir
|
||||
}
|
||||
|
||||
c.log.Info("add node", zap.String("name", name))
|
||||
c.log.Info("add node", log.String("name", name))
|
||||
return c.controlc.AddNode(ctx, req)
|
||||
}
|
||||
|
||||
func (c *client) RemoveNode(ctx context.Context, name string) (*rpcpb.RemoveNodeResponse, error) {
|
||||
c.log.Info("remove node", zap.String("name", name))
|
||||
c.log.Info("remove node", log.String("name", name))
|
||||
return c.controlc.RemoveNode(ctx, &rpcpb.RemoveNodeRequest{Name: name})
|
||||
}
|
||||
|
||||
func (c *client) PauseNode(ctx context.Context, name string) (*rpcpb.PauseNodeResponse, error) {
|
||||
c.log.Info("pause node", zap.String("name", name))
|
||||
c.log.Info("pause node", log.String("name", name))
|
||||
return c.controlc.PauseNode(ctx, &rpcpb.PauseNodeRequest{Name: name})
|
||||
}
|
||||
|
||||
func (c *client) ResumeNode(ctx context.Context, name string) (*rpcpb.ResumeNodeResponse, error) {
|
||||
c.log.Info("resume node", zap.String("name", name))
|
||||
c.log.Info("resume node", log.String("name", name))
|
||||
return c.controlc.ResumeNode(ctx, &rpcpb.ResumeNodeRequest{Name: name})
|
||||
}
|
||||
|
||||
@@ -318,17 +317,17 @@ func (c *client) RestartNode(ctx context.Context, name string, opts ...OpOption)
|
||||
req.UpgradeConfigs = ret.upgradeConfigs
|
||||
req.SubnetConfigs = ret.subnetConfigs
|
||||
|
||||
c.log.Info("restart node", zap.String("name", name))
|
||||
c.log.Info("restart node", log.String("name", name))
|
||||
return c.controlc.RestartNode(ctx, req)
|
||||
}
|
||||
|
||||
func (c *client) AttachPeer(ctx context.Context, nodeName string) (*rpcpb.AttachPeerResponse, error) {
|
||||
c.log.Info("attaching peer", zap.String("name", nodeName))
|
||||
c.log.Info("attaching peer", log.String("name", nodeName))
|
||||
return c.controlc.AttachPeer(ctx, &rpcpb.AttachPeerRequest{NodeName: nodeName})
|
||||
}
|
||||
|
||||
func (c *client) SendOutboundMessage(ctx context.Context, nodeName string, peerID string, op uint32, msgBody []byte) (*rpcpb.SendOutboundMessageResponse, error) {
|
||||
c.log.Info("sending outbound message", zap.String("name", nodeName), zap.String("peer-ID", peerID))
|
||||
c.log.Info("sending outbound message", log.String("name", nodeName), log.String("peer-ID", peerID))
|
||||
return c.controlc.SendOutboundMessage(ctx, &rpcpb.SendOutboundMessageRequest{
|
||||
NodeName: nodeName,
|
||||
PeerId: peerID,
|
||||
@@ -338,12 +337,12 @@ func (c *client) SendOutboundMessage(ctx context.Context, nodeName string, peerI
|
||||
}
|
||||
|
||||
func (c *client) SaveSnapshot(ctx context.Context, snapshotName string) (*rpcpb.SaveSnapshotResponse, error) {
|
||||
c.log.Info("save snapshot", zap.String("snapshot-name", snapshotName))
|
||||
c.log.Info("save snapshot", log.String("snapshot-name", snapshotName))
|
||||
return c.controlc.SaveSnapshot(ctx, &rpcpb.SaveSnapshotRequest{SnapshotName: snapshotName})
|
||||
}
|
||||
|
||||
func (c *client) LoadSnapshot(ctx context.Context, snapshotName string, opts ...OpOption) (*rpcpb.LoadSnapshotResponse, error) {
|
||||
c.log.Info("load snapshot", zap.String("snapshot-name", snapshotName))
|
||||
c.log.Info("load snapshot", log.String("snapshot-name", snapshotName))
|
||||
ret := &Op{}
|
||||
ret.applyOpts(opts)
|
||||
req := rpcpb.LoadSnapshotRequest{
|
||||
@@ -369,7 +368,7 @@ func (c *client) LoadSnapshot(ctx context.Context, snapshotName string, opts ...
|
||||
}
|
||||
|
||||
func (c *client) RemoveSnapshot(ctx context.Context, snapshotName string) (*rpcpb.RemoveSnapshotResponse, error) {
|
||||
c.log.Info("remove snapshot", zap.String("snapshot-name", snapshotName))
|
||||
c.log.Info("remove snapshot", log.String("snapshot-name", snapshotName))
|
||||
return c.controlc.RemoveSnapshot(ctx, &rpcpb.RemoveSnapshotRequest{SnapshotName: snapshotName})
|
||||
}
|
||||
|
||||
|
||||
+35
-35
@@ -20,9 +20,9 @@ import (
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/netrunner/utils/constants"
|
||||
"github.com/luxfi/netrunner/ux"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
llog "github.com/luxfi/log"
|
||||
"github.com/luxfi/log/level"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -38,7 +38,7 @@ var (
|
||||
endpoint string
|
||||
dialTimeout time.Duration
|
||||
requestTimeout time.Duration
|
||||
log logging.Logger
|
||||
log llog.Logger
|
||||
)
|
||||
|
||||
// NOTE: Naming convention for node names is currently `node` + number, i.e. `node1,node2,node3,...node101`
|
||||
@@ -49,7 +49,7 @@ func NewCommand() *cobra.Command {
|
||||
Short: "Start a network runner controller.",
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringVar(&logLevel, "log-level", logging.Info.String(), "log level")
|
||||
cmd.PersistentFlags().StringVar(&logLevel, "log-level", level.Info.String(), "log level")
|
||||
cmd.PersistentFlags().StringVar(&logDir, "log-dir", "", "log directory")
|
||||
cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "0.0.0.0:8080", "server endpoint")
|
||||
cmd.PersistentFlags().DurationVar(&dialTimeout, "dial-timeout", 10*time.Second, "server dial timeout")
|
||||
@@ -115,12 +115,12 @@ func setLogs() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
lvl, err := logging.ToLevel(logLevel)
|
||||
lvl, err := llog.ToLevel(logLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logFactory := logging.NewFactory(logging.Config{
|
||||
RotatingWriterConfig: logging.RotatingWriterConfig{
|
||||
logFactory := llog.NewFactoryWithConfig(llog.Config{
|
||||
RotatingWriterConfig: llog.RotatingWriterConfig{
|
||||
Directory: logDir,
|
||||
},
|
||||
DisplayLevel: lvl,
|
||||
@@ -154,7 +154,7 @@ func RPCVersionFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("version response: %+v"), resp)
|
||||
ux.Print(log, "version response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ func startFunc(*cobra.Command, []string) error {
|
||||
}
|
||||
|
||||
if globalNodeConfig != "" {
|
||||
ux.Print(log, logging.Yellow.Wrap("global node config provided, will be applied to all nodes: %s"), globalNodeConfig)
|
||||
ux.Print(log, "WARNING: global node config provided, will be applied to all nodes: %s", globalNodeConfig)
|
||||
// validate it's valid JSON
|
||||
var js json.RawMessage
|
||||
if err := json.Unmarshal([]byte(globalNodeConfig), &js); err != nil {
|
||||
@@ -324,7 +324,7 @@ func startFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("start response: %+v"), info)
|
||||
ux.Print(log, "start response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ func createBlockchainsFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("create-blockchains response: %+v"), info)
|
||||
ux.Print(log, "create-blockchains response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ func createSubnetsFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("create-subnets response: %+v"), info)
|
||||
ux.Print(log, "create-subnets response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ func transformElasticSubnetsFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("elastic-subnets response: %+v"), info)
|
||||
ux.Print(log, "elastic-subnets response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ func addPermissionlessValidatorFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("add-permissionless-validator response: %+v"), info)
|
||||
ux.Print(log, "add-permissionless-validator response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ func removeSubnetValidatorFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("remove-subnet-validator response: %+v"), info)
|
||||
ux.Print(log, "remove-subnet-validator response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ func healthFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("health response: %+v"), resp)
|
||||
ux.Print(log, "health response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ func waitForHealthy(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("wait for healthy response: %+v"), resp)
|
||||
ux.Print(log, "wait for healthy response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ func urisFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("URIs: %s"), uris)
|
||||
ux.Print(log, "URIs: %s", uris)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -626,7 +626,7 @@ func statusFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("status response: %+v"), resp)
|
||||
ux.Print(log, "status response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ func streamStatusFunc(*cobra.Command, []string) error {
|
||||
go func() {
|
||||
select {
|
||||
case sig := <-sigc:
|
||||
log.Warn("received signal", zap.String("signal", sig.String()))
|
||||
log.Warn("received signal", llog.String("signal", sig.String()))
|
||||
case <-ctx.Done():
|
||||
}
|
||||
cancel()
|
||||
@@ -676,7 +676,7 @@ func streamStatusFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
for info := range ch {
|
||||
ux.Print(log, logging.Cyan.Wrap("cluster info: %+v"), info)
|
||||
ux.Print(log, "cluster info: %+v", info)
|
||||
}
|
||||
cancel() // receiver channel is closed, so cancel goroutine
|
||||
<-donec
|
||||
@@ -709,7 +709,7 @@ func removeNodeFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("remove node response: %+v"), info)
|
||||
ux.Print(log, "remove node response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -739,7 +739,7 @@ func pauseNodeFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("pause node response: %+v"), info)
|
||||
ux.Print(log, "pause node response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -769,7 +769,7 @@ func resumeNodeFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("resume node response: %+v"), info)
|
||||
ux.Print(log, "resume node response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -833,7 +833,7 @@ func addNodeFunc(_ *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if addNodeConfig != "" {
|
||||
ux.Print(log, logging.Yellow.Wrap("WARNING: overriding node configs with custom provided config %s"), addNodeConfig)
|
||||
ux.Print(log, "WARNING: overriding node configs with custom provided config %s", addNodeConfig)
|
||||
// validate it's valid JSON
|
||||
var js json.RawMessage
|
||||
if err := json.Unmarshal([]byte(addNodeConfig), &js); err != nil {
|
||||
@@ -876,7 +876,7 @@ func addNodeFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("add node response: %+v"), info)
|
||||
ux.Print(log, "add node response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -974,7 +974,7 @@ func restartNodeFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("restart node response: %+v"), info)
|
||||
ux.Print(log, "restart node response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1004,7 +1004,7 @@ func attachPeerFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("attach peer response: %+v"), resp)
|
||||
ux.Print(log, "attach peer response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1073,7 +1073,7 @@ func sendOutboundMessageFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("send outbound message response: %+v"), resp)
|
||||
ux.Print(log, "send outbound message response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1101,7 +1101,7 @@ func stopFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("stop response: %+v"), info)
|
||||
ux.Print(log, "stop response: %+v", info)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1129,7 +1129,7 @@ func saveSnapshotFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("save-snapshot response: %+v"), resp)
|
||||
ux.Print(log, "save-snapshot response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1228,7 +1228,7 @@ func loadSnapshotFunc(_ *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if globalNodeConfig != "" {
|
||||
ux.Print(log, logging.Yellow.Wrap("global node config provided, will be applied to all nodes: %s"), globalNodeConfig)
|
||||
ux.Print(log, "WARNING: global node config provided, will be applied to all nodes: %s", globalNodeConfig)
|
||||
|
||||
// validate it's valid JSON
|
||||
var js json.RawMessage
|
||||
@@ -1245,7 +1245,7 @@ func loadSnapshotFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("load-snapshot response: %+v"), resp)
|
||||
ux.Print(log, "load-snapshot response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1273,7 +1273,7 @@ func removeSnapshotFunc(_ *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("remove-snapshot response: %+v"), resp)
|
||||
ux.Print(log, "remove-snapshot response: %+v", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1300,7 +1300,7 @@ func getSnapshotNamesFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("Snapshots: %s"), snapshotNames)
|
||||
ux.Print(log, "Snapshots: %s", snapshotNames)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+8
-7
@@ -10,7 +10,8 @@ import (
|
||||
"github.com/luxfi/netrunner/client"
|
||||
"github.com/luxfi/netrunner/utils/constants"
|
||||
"github.com/luxfi/netrunner/ux"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/log/level"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -28,7 +29,7 @@ func NewCommand() *cobra.Command {
|
||||
RunE: pingFunc,
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringVar(&logLevel, "log-level", logging.Info.String(), "log level")
|
||||
cmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "log level")
|
||||
cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "0.0.0.0:8080", "server endpoint")
|
||||
cmd.PersistentFlags().DurationVar(&dialTimeout, "dial-timeout", 10*time.Second, "server dial timeout")
|
||||
cmd.PersistentFlags().DurationVar(&requestTimeout, "request-timeout", 10*time.Second, "client request timeout")
|
||||
@@ -37,15 +38,15 @@ func NewCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
func pingFunc(*cobra.Command, []string) error {
|
||||
lvl, err := logging.ToLevel(logLevel)
|
||||
lvl, err := log.ToLevel(logLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lcfg := logging.Config{
|
||||
lcfg := log.Config{
|
||||
DisplayLevel: lvl,
|
||||
LogLevel: logging.Off,
|
||||
LogLevel: level.Off,
|
||||
}
|
||||
logFactory := logging.NewFactory(lcfg)
|
||||
logFactory := log.NewFactoryWithConfig(lcfg)
|
||||
log, err := logFactory.Make(constants.LogNameControl)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -67,7 +68,7 @@ func pingFunc(*cobra.Command, []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logString := "ping response: " + logging.Green.Wrap("%s")
|
||||
logString := "ping response: %s"
|
||||
ux.Print(log, logString, resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"github.com/luxfi/netrunner/server"
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/netrunner/utils/constants"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
llog "github.com/luxfi/log"
|
||||
"github.com/luxfi/log/level"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -44,7 +44,7 @@ func NewCommand() *cobra.Command {
|
||||
Args: cobra.ExactArgs(0),
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringVar(&logLevel, "log-level", logging.Info.String(), "log level for server logs")
|
||||
cmd.PersistentFlags().StringVar(&logLevel, "log-level", level.Info.String(), "log level for server logs")
|
||||
cmd.PersistentFlags().StringVar(&logDir, "log-dir", "", "log directory")
|
||||
cmd.PersistentFlags().StringVar(&port, "port", ":8080", "server port")
|
||||
cmd.PersistentFlags().StringVar(&gwPort, "grpc-gateway-port", ":8081", "grpc-gateway server port")
|
||||
@@ -70,13 +70,13 @@ func serverFunc(*cobra.Command, []string) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
logLevel, err := logging.ToLevel(logLevel)
|
||||
logLevel, err := llog.ToLevel(logLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logFactory := logging.NewFactory(logging.Config{
|
||||
RotatingWriterConfig: logging.RotatingWriterConfig{
|
||||
logFactory := llog.NewFactoryWithConfig(llog.Config{
|
||||
RotatingWriterConfig: llog.RotatingWriterConfig{
|
||||
Directory: logDir,
|
||||
},
|
||||
DisplayLevel: logLevel,
|
||||
@@ -114,13 +114,13 @@ func serverFunc(*cobra.Command, []string) (err error) {
|
||||
select {
|
||||
case sig := <-sigChan:
|
||||
// Got a SIGINT or SIGTERM; stop the server and wait for it to finish.
|
||||
log.Warn("signal received: closing server", zap.String("signal", sig.String()))
|
||||
log.Warn("signal received: closing server", llog.String("signal", sig.String()))
|
||||
cancel()
|
||||
waitForServerStop := <-errChan
|
||||
log.Warn("closed server", zap.Error(waitForServerStop))
|
||||
log.Warn("closed server", llog.Err(waitForServerStop))
|
||||
case serverClosed := <-errChan:
|
||||
// The server stopped.
|
||||
log.Warn("server closed", zap.Error(serverClosed))
|
||||
log.Warn("server closed", llog.Err(serverClosed))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/luxfi/netrunner/local"
|
||||
"github.com/luxfi/netrunner/network"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"go.uber.org/zap"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/log/level"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,15 +26,15 @@ var goPath = os.ExpandEnv("$GOPATH")
|
||||
// Closes [closedOnShutdownChan] amd [signalChan] when done shutting down network.
|
||||
// This function should only be called once.
|
||||
func shutdownOnSignal(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
n network.Network,
|
||||
signalChan chan os.Signal,
|
||||
closedOnShutdownChan chan struct{},
|
||||
) {
|
||||
sig := <-signalChan
|
||||
log.Info("got OS signal", zap.Stringer("signal", sig))
|
||||
log.Info("got OS signal", "signal", sig)
|
||||
if err := n.Stop(context.Background()); err != nil {
|
||||
log.Info("error stopping network", zap.Error(err))
|
||||
log.Info("error stopping network", "error", err)
|
||||
}
|
||||
signal.Reset()
|
||||
close(signalChan)
|
||||
@@ -47,11 +47,11 @@ func shutdownOnSignal(
|
||||
// The network runs until the user provides a SIGINT or SIGTERM.
|
||||
func main() {
|
||||
// Create the logger
|
||||
logFactory := logging.NewFactory(logging.Config{
|
||||
DisplayLevel: logging.Info,
|
||||
LogLevel: logging.Debug,
|
||||
logFactory := log.NewFactoryWithConfig(log.Config{
|
||||
DisplayLevel: level.Info,
|
||||
LogLevel: level.Debug,
|
||||
})
|
||||
log, err := logFactory.Make("main")
|
||||
logger, err := logFactory.Make("main")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
@@ -60,13 +60,13 @@ func main() {
|
||||
goPath = build.Default.GOPATH
|
||||
}
|
||||
binaryPath := fmt.Sprintf("%s%s", goPath, "/src/github.com/luxfi/node/build/node")
|
||||
if err := run(log, binaryPath); err != nil {
|
||||
log.Fatal("fatal error", zap.Error(err))
|
||||
if err := run(logger, binaryPath); err != nil {
|
||||
logger.Fatal("fatal error", log.Err(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func run(log logging.Logger, binaryPath string) error {
|
||||
func run(log log.Logger, binaryPath string) error {
|
||||
// Create the network
|
||||
nw, err := local.NewDefaultNetwork(log, binaryPath, true)
|
||||
if err != nil {
|
||||
@@ -74,7 +74,7 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
}
|
||||
defer func() { // Stop the network when this function returns
|
||||
if err := nw.Stop(context.Background()); err != nil {
|
||||
log.Info("error stopping network", zap.Error(err))
|
||||
log.Info("error stopping network", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/staking"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"go.uber.org/zap"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/log/level"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -29,15 +29,15 @@ var goPath = os.ExpandEnv("$GOPATH")
|
||||
// Closes [closedOnShutdownChan] amd [signalChan] when done shutting down network.
|
||||
// This function should only be called once.
|
||||
func shutdownOnSignal(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
n network.Network,
|
||||
signalChan chan os.Signal,
|
||||
closedOnShutdownChan chan struct{},
|
||||
) {
|
||||
sig := <-signalChan
|
||||
log.Info("got OS signal", zap.Stringer("signal", sig))
|
||||
log.Info("got OS signal", "signal", sig)
|
||||
if err := n.Stop(context.Background()); err != nil {
|
||||
log.Info("error stopping network", zap.Error(err))
|
||||
log.Info("error stopping network", "error", err)
|
||||
}
|
||||
signal.Reset()
|
||||
close(signalChan)
|
||||
@@ -55,31 +55,31 @@ func shutdownOnSignal(
|
||||
// The network runs until the user provides a SIGINT or SIGTERM.
|
||||
func main() {
|
||||
// Create the logger
|
||||
logFactory := logging.NewFactory(logging.Config{
|
||||
DisplayLevel: logging.Info,
|
||||
LogLevel: logging.Debug,
|
||||
logFactory := log.NewFactoryWithConfig(log.Config{
|
||||
DisplayLevel: level.Info,
|
||||
LogLevel: level.Debug,
|
||||
})
|
||||
log, err := logFactory.Make("main")
|
||||
logger, err := logFactory.Make("main")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
binaryPath := fmt.Sprintf("%s%s", goPath, "/src/github.com/luxfi/node/build/node")
|
||||
if err := run(log, binaryPath); err != nil {
|
||||
log.Fatal("fatal error", zap.Error(err))
|
||||
if err := run(logger, binaryPath); err != nil {
|
||||
logger.Fatal("fatal error", log.Err(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func run(log logging.Logger, binaryPath string) error {
|
||||
func run(logger log.Logger, binaryPath string) error {
|
||||
// Create the network
|
||||
nw, err := local.NewDefaultNetwork(log, binaryPath, true)
|
||||
nw, err := local.NewDefaultNetwork(logger, binaryPath, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { // Stop the network when this function returns
|
||||
if err := nw.Stop(context.Background()); err != nil {
|
||||
log.Info("error stopping network", zap.Error(err))
|
||||
logger.Info("error stopping network", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -89,13 +89,13 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
signal.Notify(signalsChan, syscall.SIGTERM)
|
||||
closedOnShutdownCh := make(chan struct{})
|
||||
go func() {
|
||||
shutdownOnSignal(log, nw, signalsChan, closedOnShutdownCh)
|
||||
shutdownOnSignal(logger, nw, signalsChan, closedOnShutdownCh)
|
||||
}()
|
||||
|
||||
// Wait until the nodes in the network are ready
|
||||
ctx, cancel := context.WithTimeout(context.Background(), healthyTimeout)
|
||||
defer cancel()
|
||||
log.Info("waiting for all nodes to report healthy...")
|
||||
logger.Info("waiting for all nodes to report healthy...")
|
||||
if err := nw.Healthy(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info("current network's nodes", zap.Strings("nodes", nodeNames))
|
||||
logger.Info("current network's nodes", "nodes", nodeNames)
|
||||
|
||||
// Get one node
|
||||
node1, err := nw.GetNode(nodeNames[0])
|
||||
@@ -114,11 +114,11 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
}
|
||||
|
||||
// Get its node ID through its API and print it
|
||||
node1ID, _, err := node1.GetAPIClient().InfoAPI().GetNodeID(context.Background())
|
||||
node1ID, _, err := (*node1.GetAPIClient().InfoAPI()).GetNodeID(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info("one node's ID is", zap.Stringer("nodeID", node1ID))
|
||||
logger.Info("one node's ID is", log.Stringer("nodeID", node1ID))
|
||||
|
||||
// Add a new node with generated cert/key/nodeid
|
||||
stakingCert, stakingKey, err := staking.NewCertAndKeyBytes()
|
||||
@@ -133,7 +133,7 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
// The flags below would override the config in this node's config file,
|
||||
// if it had one.
|
||||
Flags: map[string]interface{}{
|
||||
config.LogLevelKey: logging.Debug,
|
||||
config.LogLevelKey: level.Debug,
|
||||
config.HTTPHostKey: "0.0.0.0",
|
||||
},
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
|
||||
// Remove one node
|
||||
nodeToRemove := nodeNames[3]
|
||||
log.Info("removing node", zap.String("name", nodeToRemove))
|
||||
logger.Info("removing node", "name", nodeToRemove)
|
||||
removeNodeCtx, removeNodeCtxCancel := context.WithTimeout(context.Background(), removeNodeTimeout)
|
||||
defer removeNodeCtxCancel()
|
||||
if err := nw.RemoveNode(removeNodeCtx, nodeToRemove); err != nil {
|
||||
@@ -153,7 +153,7 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
// Wait until the nodes in the updated network are ready
|
||||
ctx, cancel = context.WithTimeout(context.Background(), healthyTimeout)
|
||||
defer cancel()
|
||||
log.Info("waiting for updated network to report healthy...")
|
||||
logger.Info("waiting for updated network to report healthy...")
|
||||
if err := nw.Healthy(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -164,8 +164,8 @@ func run(log logging.Logger, binaryPath string) error {
|
||||
return err
|
||||
}
|
||||
// Will have the new node but not the removed one
|
||||
log.Info("updated network's nodes", zap.Strings("nodes", nodeNames))
|
||||
log.Info("Network will run until you CTRL + C to exit...")
|
||||
logger.Info("updated network's nodes", "nodes", nodeNames)
|
||||
logger.Info("Network will run until you CTRL + C to exit...")
|
||||
// Wait until done shutting down network after SIGINT/SIGTERM
|
||||
<-closedOnShutdownCh
|
||||
return nil
|
||||
|
||||
@@ -2,17 +2,27 @@ module github.com/luxfi/netrunner
|
||||
|
||||
go 1.24.5
|
||||
|
||||
// Removed luxfi/ids replace - should use node/ids directly
|
||||
replace (
|
||||
github.com/luxfi/crypto => ../crypto
|
||||
github.com/luxfi/evm => ../evm
|
||||
github.com/luxfi/geth => ../geth
|
||||
github.com/luxfi/ids => ../ids
|
||||
github.com/luxfi/log => ../log
|
||||
github.com/luxfi/metrics => ../metrics
|
||||
github.com/luxfi/node => ../node
|
||||
)
|
||||
|
||||
exclude google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1
|
||||
|
||||
require (
|
||||
github.com/ethereum/go-ethereum v1.16.1
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1
|
||||
github.com/luxfi/crypto v1.1.1
|
||||
github.com/luxfi/crypto v1.2.1
|
||||
github.com/luxfi/evm v0.8.3
|
||||
github.com/luxfi/geth v1.16.7
|
||||
github.com/luxfi/node v1.13.13
|
||||
github.com/luxfi/geth v1.16.23
|
||||
github.com/luxfi/ids v1.0.2
|
||||
github.com/luxfi/log v0.1.1
|
||||
github.com/luxfi/metrics v1.1.1
|
||||
github.com/luxfi/node v1.13.16
|
||||
github.com/onsi/ginkgo/v2 v2.23.4
|
||||
github.com/onsi/gomega v1.37.0
|
||||
github.com/otiai10/copy v1.14.1
|
||||
@@ -33,6 +43,7 @@ require (
|
||||
require (
|
||||
github.com/DataDog/zstd v1.5.7 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/NYTimes/gziphandler v1.1.1 // indirect
|
||||
github.com/StephenButtolph/canoto v0.17.2 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.12.5 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
@@ -53,8 +64,14 @@ require (
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
|
||||
github.com/dgraph-io/badger/v4 v4.8.0 // indirect
|
||||
github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/emicklei/dot v1.6.2 // indirect
|
||||
github.com/ethereum/c-kzg-4844/v2 v2.1.1 // indirect
|
||||
github.com/ethereum/go-ethereum v1.16.1 // indirect
|
||||
github.com/ethereum/go-verkle v0.2.2 // indirect
|
||||
github.com/ferranbt/fastssz v0.1.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
@@ -62,9 +79,11 @@ require (
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||
github.com/gofrs/flock v0.12.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/snappy v1.0.0 // indirect
|
||||
github.com/google/btree v1.1.3 // indirect
|
||||
github.com/google/flatbuffers v25.2.10+incompatible // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
|
||||
github.com/google/renameio/v2 v2.0.0 // indirect
|
||||
@@ -73,17 +92,26 @@ require (
|
||||
github.com/gorilla/rpc v1.2.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.1 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
|
||||
github.com/holiman/billy v0.0.0-20250707135307-f2f9b9aae7db // indirect
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.3.2 // indirect
|
||||
github.com/huin/goupnp v1.3.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jackpal/gateway v1.0.6 // indirect
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/luxfi/ids v1.0.2 // indirect
|
||||
github.com/luxfi/log v0.1.1 // indirect
|
||||
github.com/luxfi/metrics v1.1.1 // indirect
|
||||
github.com/luxfi/database v1.1.7 // indirect
|
||||
github.com/luxfi/trace v0.1.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/otiai10/mint v1.6.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pires/go-proxyproto v0.7.0 // indirect
|
||||
@@ -92,10 +120,10 @@ require (
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
github.com/rs/cors v1.10.1 // indirect
|
||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||
github.com/sanity-io/litter v1.5.5 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.14.0 // indirect
|
||||
github.com/spf13/cast v1.9.2 // indirect
|
||||
@@ -115,7 +143,6 @@ require (
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.37.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.37.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
@@ -130,5 +157,6 @@ require (
|
||||
gonum.org/v1/gonum v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -2,7 +2,10 @@ github.com/DataDog/zstd v1.5.7 h1:ybO8RBeh29qrxIhCA9E8gKY6xfONU9T6G6aP9DTKfLE=
|
||||
github.com/DataDog/zstd v1.5.7/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
|
||||
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
|
||||
github.com/StephenButtolph/canoto v0.17.2 h1:kRLJwtYk0bzdGEeEvwHaVmmDm0HFHxrS0VlVN5Hyo7U=
|
||||
github.com/StephenButtolph/canoto v0.17.2/go.mod h1:IcnAHC6nJUfQFVR9y60ko2ecUqqHHSB6UwI9NnBFZnE=
|
||||
github.com/VictoriaMetrics/fastcache v1.12.5 h1:966OX9JjqYmDAFdp3wEXLwzukiHIm+GVlZHv6B8KW3k=
|
||||
github.com/VictoriaMetrics/fastcache v1.12.5/go.mod h1:K+JGPBn0sueFlLjZ8rcVM0cKkWKNElKyQXmw57QOoYI=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
@@ -11,6 +14,7 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bits-and-blooms/bitset v1.22.0 h1:Tquv9S8+SGaS3EhyA+up3FXzmkhxPGjQQCkcs2uw7w4=
|
||||
github.com/bits-and-blooms/bitset v1.22.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
|
||||
github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||
@@ -75,13 +79,17 @@ github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80N
|
||||
github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs=
|
||||
github.com/dgraph-io/badger/v4 v4.8.0/go.mod h1:U6on6e8k/RTbUWxqKR0MvugJuVmkxSNc79ap4917h4w=
|
||||
github.com/dgraph-io/ristretto/v2 v2.2.0 h1:bkY3XzJcXoMuELV8F+vS8kzNgicwQFAaGINAEJdWGOM=
|
||||
github.com/dgraph-io/ristretto/v2 v2.2.0/go.mod h1:RZrm63UmcBAaYWC1DotLYBmTvgkrs0+XhBd7Npn7/zI=
|
||||
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38=
|
||||
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A=
|
||||
@@ -101,6 +109,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
|
||||
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
|
||||
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
|
||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||
@@ -122,6 +132,8 @@ github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
|
||||
github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/gojuukaze/go-bip39 v1.1.0 h1:nZoA8BOLhiOhTdH3iMYnWKgfD5FXTKZHZZS9QubH0VE=
|
||||
github.com/gojuukaze/go-bip39 v1.1.0/go.mod h1:tHp4ihCWJ8KpPTymBOFVAMwfzxO4B7+OhNtVW3u1nY8=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -137,6 +149,7 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
|
||||
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
|
||||
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
||||
github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q=
|
||||
@@ -166,6 +179,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 h1:X5VWvz21y3gzm9Nw/kaUeku/1+u
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1/go.mod h1:Zanoh4+gvIgluNqcfMVTJueD4wSS5hT7zTt4Mrutd90=
|
||||
github.com/hashicorp/go-bexpr v0.1.14 h1:uKDeyuOhWhT1r5CiMTjdVY4Aoxdxs6EtwgTGnlosyp4=
|
||||
github.com/hashicorp/go-bexpr v0.1.14/go.mod h1:gN7hRKB3s7yT+YvTdnhZVLTENejvhlkZ8UE4YVBS+Q8=
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs=
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/holiman/billy v0.0.0-20250707135307-f2f9b9aae7db h1:IZUYC/xb3giYwBLMnr8d0TGTzPKFGNTCGgGLoyeX330=
|
||||
github.com/holiman/billy v0.0.0-20250707135307-f2f9b9aae7db/go.mod h1:xTEYN9KCHxuYHs+NmrmzFcnvHMzLLNiGFafCb1n3Mfg=
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
|
||||
@@ -178,6 +193,8 @@ github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFck
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jackpal/gateway v1.0.6 h1:/MJORKvJEwNVldtGVJC2p2cwCnsSoLn3hl3zxmZT7tk=
|
||||
github.com/jackpal/gateway v1.0.6/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
|
||||
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
@@ -188,7 +205,9 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
@@ -197,25 +216,17 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
|
||||
github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c=
|
||||
github.com/luxfi/crypto v1.1.1 h1:6roT/QzdwUoz3v7Fv2bM1s1CyCp/UpEnG7yRVWbw0do=
|
||||
github.com/luxfi/crypto v1.1.1/go.mod h1:Wt4fomM14VWfQ/89PZh1dApz+0XteEG9x99Q9SHIRtY=
|
||||
github.com/luxfi/database v1.1.4 h1:C8yFA7ilwYnde/+tjSif9RgBlC9mN8Lj52jIIv/Vayk=
|
||||
github.com/luxfi/database v1.1.4/go.mod h1:/dUq+IYFvgFitQEXr4zj/9jJ0cjT/bf5558pB1rKpX8=
|
||||
github.com/luxfi/evm v0.8.3 h1:jicx/ZOxQ737UbomrpJAR5oRkaiy6UN+Sy+trIlJUaA=
|
||||
github.com/luxfi/evm v0.8.3/go.mod h1:TK1auIh5hv4YtW8a3XRhusVtiAR9MajVawt8bCeAugM=
|
||||
github.com/luxfi/geth v1.16.7 h1:z869sxfth/VUmo6dKcGbToyzw2mD3Y2PZS2zk0a4JjA=
|
||||
github.com/luxfi/geth v1.16.7/go.mod h1:TbnZRLszKJTfOH6tJoSSnLwFXiE047p6/H98BDr2lAM=
|
||||
github.com/luxfi/ids v1.0.2 h1:OnbCWBgdmuBPZat1r1vRikk1FFrdHMfSknpfKmX0KBg=
|
||||
github.com/luxfi/ids v1.0.2/go.mod h1:cMbto3Q8N3IaBxdz4Lzaq9wYl33coGXUdlr2+YwXeUw=
|
||||
github.com/luxfi/log v0.1.1 h1:KRTOIGqyPTrN3nWcBMVI50B6EXTayYex2+HyGjJ06Ew=
|
||||
github.com/luxfi/log v0.1.1/go.mod h1:trb99HbI+YW6nu+So4jWKey20oHeRhlee70xbuR6Gak=
|
||||
github.com/luxfi/metrics v1.1.1 h1:aKVEtytAl3TqSvInRpDc6ZdSJsCbTmCCl0UAl2YNXWU=
|
||||
github.com/luxfi/metrics v1.1.1/go.mod h1:ynSRcRjG+t1snUvFUbQFEu0UGibyw8gsitltQ9H1YDA=
|
||||
github.com/luxfi/node v1.13.13 h1:d9EBufYVsUAX0djLg7GJkMWnrb4TEhSUY/rDwJEbdhc=
|
||||
github.com/luxfi/database v1.1.7 h1:PV1x+if18v7xPASx+bGFp5cAH6GScfYxtb/GH8VFU2o=
|
||||
github.com/luxfi/database v1.1.7/go.mod h1:xRxzVwaT00jqeKAtVfvYzSdvEuT5Y+NIvD3HQQLaVmg=
|
||||
github.com/luxfi/go-bip39 v1.1.0 h1:wU1LmWYXB3gbUV+k0hFImWSUVIK1iYNoQNisbTiVl9M=
|
||||
github.com/luxfi/go-bip39 v1.1.0/go.mod h1:OxPL7QXUfnqqk7nOTPWgNfShxqg69OYJ4+ATKCmZWP8=
|
||||
github.com/luxfi/trace v0.1.1 h1:T/ReB1MvwAJpgQaPWGsBLUx96rr5OMlJocWRo5JSvkU=
|
||||
github.com/luxfi/trace v0.1.1/go.mod h1:6jhCW0hPCFv7qzFsL0w/amHRv7PfNIyW77N4WDS3U5Q=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
||||
@@ -228,6 +239,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA=
|
||||
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
@@ -287,6 +300,9 @@ github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ
|
||||
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/prysmaticlabs/gohashtree v0.0.4-beta h1:H/EbCuXPeTV3lpKeXGPpEV9gsUpkqOOVnWapUyeWro4=
|
||||
github.com/prysmaticlabs/gohashtree v0.0.4-beta/go.mod h1:BFdtALS+Ffhg3lGQIHv9HDWuHS8cTvHZzrHWxwOtGOs=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
@@ -314,9 +330,13 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
||||
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
||||
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
|
||||
github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
@@ -402,6 +422,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -457,6 +478,7 @@ gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250721164621-a45f3dfb1074 h1:mVXdvnmR3S3BQOqHECm9NGMjYiRtEvDYcqAqedTXY6s=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250721164621-a45f3dfb1074/go.mod h1:vYFwMYFbmA8vl6Z/krj/h7+U/AqpHknwJX4Uqgfyc7I=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 h1:MAKi5q709QWfnkkpNQ0M12hYJ1+e8qYVDyowc4U1XZM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
|
||||
google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
||||
+68
-69
@@ -27,10 +27,10 @@ import (
|
||||
"github.com/luxfi/node/api/admin"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/genesis"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/utils/constants"
|
||||
"github.com/luxfi/crypto/bls"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/node/utils/set"
|
||||
"github.com/luxfi/node/vms/platformvm"
|
||||
"github.com/luxfi/node/vms/platformvm/signer"
|
||||
@@ -43,7 +43,6 @@ import (
|
||||
xsigner "github.com/luxfi/node/wallet/chain/x/signer"
|
||||
primary "github.com/luxfi/node/wallet/subnet/primary"
|
||||
common "github.com/luxfi/node/wallet/subnet/primary/common"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
@@ -97,8 +96,8 @@ func (ln *localNetwork) getClientURI() (string, error) { //nolint
|
||||
node := ln.getNode()
|
||||
clientURI := fmt.Sprintf("http://%s:%d", node.GetURL(), node.GetAPIPort())
|
||||
ln.log.Info("getClientURI",
|
||||
zap.String("nodeName", node.GetName()),
|
||||
zap.String("uri", clientURI))
|
||||
log.String("nodeName", node.GetName()),
|
||||
log.String("uri", clientURI))
|
||||
return clientURI, nil
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ func (ln *localNetwork) RegisterBlockchainAliases(
|
||||
chainSpecs []network.BlockchainSpec,
|
||||
) error {
|
||||
fmt.Println()
|
||||
ln.log.Info(logging.Blue.Wrap(logging.Bold.Wrap("registering blockchain aliases")))
|
||||
ln.log.Info(log.Blue.Wrap(log.Bold.Wrap("registering blockchain aliases")))
|
||||
for i, chainSpec := range chainSpecs {
|
||||
if chainSpec.BlockchainAlias == "" {
|
||||
continue
|
||||
@@ -145,8 +144,8 @@ func (ln *localNetwork) RegisterBlockchainAliases(
|
||||
blockchainAlias := chainSpec.BlockchainAlias
|
||||
chainID := chainInfos[i].blockchainID.String()
|
||||
ln.log.Info("registering blockchain alias",
|
||||
zap.String("alias", blockchainAlias),
|
||||
zap.String("chain-id", chainID))
|
||||
log.String("alias", blockchainAlias),
|
||||
log.String("chain-id", chainID))
|
||||
for nodeName, node := range ln.nodes {
|
||||
if node.paused {
|
||||
continue
|
||||
@@ -210,7 +209,7 @@ func (ln *localNetwork) installCustomChains(
|
||||
chainSpecs []network.BlockchainSpec,
|
||||
) ([]blockchainInfo, error) {
|
||||
fmt.Println()
|
||||
ln.log.Info(logging.Blue.Wrap(logging.Bold.Wrap("create and install custom chains")))
|
||||
ln.log.Info(log.Blue.Wrap(log.Bold.Wrap("create and install custom chains")))
|
||||
|
||||
clientURI, err := ln.getClientURI()
|
||||
if err != nil {
|
||||
@@ -268,7 +267,7 @@ func (ln *localNetwork) installCustomChains(
|
||||
for _, nodeName := range subnetSpec.Participants {
|
||||
_, ok := ln.nodes[nodeName]
|
||||
if !ok {
|
||||
ln.log.Info(logging.Green.Wrap(fmt.Sprintf("adding new participant %s", nodeName)))
|
||||
ln.log.Info(log.Green.Wrap(fmt.Sprintf("adding new participant %s", nodeName)))
|
||||
if _, err := ln.addNode(node.Config{Name: nodeName}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -378,7 +377,7 @@ func (ln *localNetwork) installSubnets(
|
||||
subnetSpecs []network.SubnetSpec,
|
||||
) ([]ids.ID, error) {
|
||||
fmt.Println()
|
||||
ln.log.Info(logging.Blue.Wrap(logging.Bold.Wrap("create subnets")))
|
||||
ln.log.Info(log.Blue.Wrap(log.Bold.Wrap("create subnets")))
|
||||
|
||||
clientURI, err := ln.getClientURI()
|
||||
if err != nil {
|
||||
@@ -405,7 +404,7 @@ func (ln *localNetwork) installSubnets(
|
||||
for _, nodeName := range subnetSpec.Participants {
|
||||
_, ok := ln.nodes[nodeName]
|
||||
if !ok {
|
||||
ln.log.Info(logging.Green.Wrap(fmt.Sprintf("adding new participant %s", nodeName)))
|
||||
ln.log.Info(log.Green.Wrap(fmt.Sprintf("adding new participant %s", nodeName)))
|
||||
if _, err := ln.addNode(node.Config{Name: nodeName}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -485,7 +484,7 @@ func (ln *localNetwork) waitForCustomChainsReady(
|
||||
chainInfos []blockchainInfo,
|
||||
) error {
|
||||
fmt.Println()
|
||||
ln.log.Info(logging.Blue.Wrap(logging.Bold.Wrap("waiting for custom chains to report healthy...")))
|
||||
ln.log.Info(log.Blue.Wrap(log.Bold.Wrap("waiting for custom chains to report healthy...")))
|
||||
|
||||
if err := ln.healthy(ctx); err != nil {
|
||||
return err
|
||||
@@ -502,23 +501,23 @@ func (ln *localNetwork) waitForCustomChainsReady(
|
||||
if node.paused {
|
||||
continue
|
||||
}
|
||||
ln.log.Info("inspecting node log directory for custom chain logs", zap.String("log-dir", node.GetLogsDir()), zap.String("node-name", nodeName))
|
||||
ln.log.Info("inspecting node log directory for custom chain logs", log.String("log-dir", node.GetLogsDir()), log.String("node-name", nodeName))
|
||||
p := filepath.Join(node.GetLogsDir(), chainInfo.blockchainID.String()+".log")
|
||||
ln.log.Info("checking log",
|
||||
zap.String("vm-ID", chainInfo.vmID.String()),
|
||||
zap.String("subnet-ID", chainInfo.subnetID.String()),
|
||||
zap.String("blockchain-ID", chainInfo.blockchainID.String()),
|
||||
zap.String("path", p),
|
||||
log.String("vm-ID", chainInfo.vmID.String()),
|
||||
log.String("subnet-ID", chainInfo.subnetID.String()),
|
||||
log.String("blockchain-ID", chainInfo.blockchainID.String()),
|
||||
log.String("path", p),
|
||||
)
|
||||
for {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
ln.log.Info("found the log", zap.String("path", p))
|
||||
ln.log.Info("found the log", log.String("path", p))
|
||||
break
|
||||
}
|
||||
ln.log.Info("log not found yet, retrying...",
|
||||
zap.String("vm-ID", chainInfo.vmID.String()),
|
||||
zap.String("subnet-ID", chainInfo.subnetID.String()),
|
||||
zap.String("blockchain-ID", chainInfo.blockchainID.String()),
|
||||
log.String("vm-ID", chainInfo.vmID.String()),
|
||||
log.String("subnet-ID", chainInfo.subnetID.String()),
|
||||
log.String("blockchain-ID", chainInfo.blockchainID.String()),
|
||||
)
|
||||
select {
|
||||
case <-ln.onStopCh:
|
||||
@@ -532,10 +531,10 @@ func (ln *localNetwork) waitForCustomChainsReady(
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
ln.log.Info(logging.Green.Wrap("all custom chains are running!!!"))
|
||||
ln.log.Info(log.Green.Wrap("all custom chains are running!!!"))
|
||||
|
||||
fmt.Println()
|
||||
ln.log.Info(logging.Green.Wrap(logging.Bold.Wrap("all custom chains are ready on RPC server-side -- network-runner RPC client can poll and query the cluster status")))
|
||||
ln.log.Info(log.Green.Wrap(log.Bold.Wrap("all custom chains are ready on RPC server-side -- network-runner RPC client can poll and query the cluster status")))
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -554,7 +553,7 @@ func (ln *localNetwork) restartNodes(
|
||||
"remove validator specs can be supplied at one time")
|
||||
}
|
||||
fmt.Println()
|
||||
ln.log.Info(logging.Blue.Wrap(logging.Bold.Wrap("restarting network")))
|
||||
ln.log.Info(log.Blue.Wrap(log.Bold.Wrap("restarting network")))
|
||||
|
||||
nodeNames := maps.Keys(ln.nodes)
|
||||
sort.Strings(nodeNames)
|
||||
@@ -627,9 +626,9 @@ func (ln *localNetwork) restartNodes(
|
||||
}
|
||||
|
||||
if removeValidatorSpecs != nil {
|
||||
ln.log.Info(logging.Green.Wrap(fmt.Sprintf("restarting node %s to stop tracking subnets %s", nodeName, tracked)))
|
||||
ln.log.Info(log.Green.Wrap(fmt.Sprintf("restarting node %s to stop tracking subnets %s", nodeName, tracked)))
|
||||
} else {
|
||||
ln.log.Info(logging.Green.Wrap(fmt.Sprintf("restarting node %s to track subnets %s", nodeName, tracked)))
|
||||
ln.log.Info(log.Green.Wrap(fmt.Sprintf("restarting node %s to track subnets %s", nodeName, tracked)))
|
||||
}
|
||||
|
||||
if err := ln.restartNode(ctx, nodeName, "", "", "", nil, nil, nil); err != nil {
|
||||
@@ -710,7 +709,7 @@ func (ln *localNetwork) addPrimaryValidators(
|
||||
platformCli platformvm.Client,
|
||||
w *wallet,
|
||||
) error {
|
||||
ln.log.Info(logging.Green.Wrap("adding the nodes as primary network validators"))
|
||||
ln.log.Info(log.Green.Wrap("adding the nodes as primary network validators"))
|
||||
// ref. https://docs.lux.network/build/node-apis/p-chain/#platformgetcurrentvalidators
|
||||
ctx, cancel := createDefaultCtx(ctx)
|
||||
vdrs, err := platformCli.GetCurrentValidators(ctx, constants.PrimaryNetworkID, nil)
|
||||
@@ -769,7 +768,7 @@ func (ln *localNetwork) addPrimaryValidators(
|
||||
if err != nil {
|
||||
return fmt.Errorf("P-Wallet Tx Error %s %w, node ID %s", "IssueAddPermissionlessValidatorTx", err, nodeID.String())
|
||||
}
|
||||
ln.log.Info("added node as primary subnet validator", zap.String("node-name", nodeName), zap.String("node-ID", nodeID.String()), zap.String("tx-ID", tx.ID().String()))
|
||||
ln.log.Info("added node as primary subnet validator", log.String("node-name", nodeName), log.String("node-ID", nodeID.String()), log.String("tx-ID", tx.ID().String()))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -860,7 +859,7 @@ func (ln *localNetwork) removeSubnetValidators(
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ln.log.Info(logging.Green.Wrap("removing the nodes as subnet validators"))
|
||||
ln.log.Info(log.Green.Wrap("removing the nodes as subnet validators"))
|
||||
for i, subnetSpec := range removeSubnetSpecs {
|
||||
subnetID, err := ids.FromString(subnetSpec.SubnetID)
|
||||
if err != nil {
|
||||
@@ -897,10 +896,10 @@ func (ln *localNetwork) removeSubnetValidators(
|
||||
return fmt.Errorf("P-Wallet Tx Error %s %w, node ID %s, subnetID %s", "IssueRemoveSubnetValidatorTx", err, nodeID.String(), subnetID.String())
|
||||
}
|
||||
ln.log.Info("removed node as subnet validator",
|
||||
zap.String("node-name", nodeName),
|
||||
zap.String("node-ID", nodeID.String()),
|
||||
zap.String("subnet-ID", subnetID.String()),
|
||||
zap.String("tx-ID", tx.ID().String()),
|
||||
log.String("node-name", nodeName),
|
||||
log.String("node-ID", nodeID.String()),
|
||||
log.String("subnet-ID", subnetID.String()),
|
||||
log.String("tx-ID", tx.ID().String()),
|
||||
)
|
||||
removeSubnetSpecIDs[i] = tx.ID()
|
||||
}
|
||||
@@ -941,7 +940,7 @@ func (ln *localNetwork) addPermissionlessValidators(
|
||||
for _, validatorSpec := range validatorSpecs {
|
||||
_, ok := ln.nodes[validatorSpec.NodeName]
|
||||
if !ok {
|
||||
ln.log.Info(logging.Green.Wrap(fmt.Sprintf("adding new participant %s", validatorSpec.NodeName)))
|
||||
ln.log.Info(log.Green.Wrap(fmt.Sprintf("adding new participant %s", validatorSpec.NodeName)))
|
||||
if _, err := ln.addNode(node.Config{Name: validatorSpec.NodeName}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -973,7 +972,7 @@ func (ln *localNetwork) addPermissionlessValidators(
|
||||
}
|
||||
|
||||
for _, validatorSpec := range validatorSpecs {
|
||||
ln.log.Info(logging.Green.Wrap("adding permissionless validator"), zap.String("node ", validatorSpec.NodeName))
|
||||
ln.log.Info(log.Green.Wrap("adding permissionless validator"), log.String("node ", validatorSpec.NodeName))
|
||||
_, cancel := createDefaultCtx(ctx)
|
||||
validatorNodeID := ln.nodes[validatorSpec.NodeName].nodeID
|
||||
subnetID, err := ids.FromString(validatorSpec.SubnetID)
|
||||
@@ -1018,7 +1017,7 @@ func (ln *localNetwork) addPermissionlessValidators(
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ln.log.Info("Validator successfully added as permissionless validator", zap.String("TX ID", tx.ID().String()))
|
||||
ln.log.Info("Validator successfully added as permissionless validator", log.String("TX ID", tx.ID().String()))
|
||||
}
|
||||
return ln.restartNodes(ctx, nil, nil, validatorSpecs, nil, nil)
|
||||
}
|
||||
@@ -1053,14 +1052,14 @@ func (ln *localNetwork) transformToElasticSubnets(
|
||||
}
|
||||
|
||||
for i, elasticSubnetSpec := range elasticSubnetSpecs {
|
||||
ln.log.Info(logging.Green.Wrap("transforming elastic subnet"), zap.String("subnet ID", *elasticSubnetSpec.SubnetID))
|
||||
ln.log.Info(log.Green.Wrap("transforming elastic subnet"), log.String("subnet ID", *elasticSubnetSpec.SubnetID))
|
||||
|
||||
subnetAssetID, err := getXChainAssetID(ctx, w, elasticSubnetSpec.AssetName, elasticSubnetSpec.AssetSymbol, elasticSubnetSpec.MaxSupply)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
assetIDs[i] = subnetAssetID
|
||||
ln.log.Info("created asset ID", zap.String("asset-ID", subnetAssetID.String()))
|
||||
ln.log.Info("created asset ID", log.String("asset-ID", subnetAssetID.String()))
|
||||
owner := &secp256k1fx.OutputOwners{
|
||||
Threshold: 1,
|
||||
Addrs: []ids.ShortID{
|
||||
@@ -1093,7 +1092,7 @@ func (ln *localNetwork) transformToElasticSubnets(
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ln.log.Info("Subnet transformed into elastic subnet", zap.String("TX ID", transformSubnetTx.ID().String()))
|
||||
ln.log.Info("Subnet transformed into elastic subnet", log.String("TX ID", transformSubnetTx.ID().String()))
|
||||
elasticSubnetIDs[i] = transformSubnetTx.ID()
|
||||
ln.subnetID2ElasticSubnetID[subnetID] = transformSubnetTx.ID()
|
||||
}
|
||||
@@ -1112,13 +1111,13 @@ func createSubnets(
|
||||
ctx context.Context,
|
||||
numSubnets uint32,
|
||||
w *wallet,
|
||||
log logging.Logger,
|
||||
logger log.Logger,
|
||||
) ([]ids.ID, error) {
|
||||
fmt.Println()
|
||||
log.Info(logging.Green.Wrap("creating subnets"), zap.Uint32("num-subnets", numSubnets))
|
||||
logger.Info(log.Green.Wrap("creating subnets"), log.Uint32("num-subnets", numSubnets))
|
||||
subnetIDs := make([]ids.ID, numSubnets)
|
||||
for i := uint32(0); i < numSubnets; i++ {
|
||||
log.Info("creating subnet tx")
|
||||
logger.Info("creating subnet tx")
|
||||
_, cancel := createDefaultCtx(ctx)
|
||||
tx, err := w.pWallet.IssueCreateSubnetTx(
|
||||
&secp256k1fx.OutputOwners{
|
||||
@@ -1133,7 +1132,7 @@ func createSubnets(
|
||||
}
|
||||
// Get the subnet ID from the transaction
|
||||
subnetID := tx.ID()
|
||||
log.Info("created subnet tx", zap.String("subnet-ID", subnetID.String()))
|
||||
logger.Info("created subnet tx", log.String("subnet-ID", subnetID.String()))
|
||||
subnetIDs[i] = subnetID
|
||||
}
|
||||
return subnetIDs, nil
|
||||
@@ -1149,7 +1148,7 @@ func (ln *localNetwork) addSubnetValidators(
|
||||
subnetIDs []ids.ID,
|
||||
subnetSpecs []network.SubnetSpec,
|
||||
) error {
|
||||
ln.log.Info(logging.Green.Wrap("adding the nodes as subnet validators"))
|
||||
ln.log.Info(log.Green.Wrap("adding the nodes as subnet validators"))
|
||||
for i, subnetID := range subnetIDs {
|
||||
ctx, cancel := createDefaultCtx(ctx)
|
||||
vs, err := platformCli.GetCurrentValidators(ctx, constants.PrimaryNetworkID, nil)
|
||||
@@ -1200,10 +1199,10 @@ func (ln *localNetwork) addSubnetValidators(
|
||||
return fmt.Errorf("P-Wallet Tx Error %s %w, node ID %s, subnetID %s", "IssueAddSubnetValidatorTx", err, nodeID.String(), subnetID.String())
|
||||
}
|
||||
ln.log.Info("added node as a subnet validator to subnet",
|
||||
zap.String("node-name", nodeName),
|
||||
zap.String("node-ID", nodeID.String()),
|
||||
zap.String("subnet-ID", subnetID.String()),
|
||||
zap.String("tx-ID", tx.ID().String()),
|
||||
log.String("node-name", nodeName),
|
||||
log.String("node-ID", nodeID.String()),
|
||||
log.String("subnet-ID", subnetID.String()),
|
||||
log.String("tx-ID", tx.ID().String()),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1215,7 +1214,7 @@ func (ln *localNetwork) waitPrimaryValidators(
|
||||
ctx context.Context,
|
||||
platformCli platformvm.Client,
|
||||
) error {
|
||||
ln.log.Info(logging.Green.Wrap("waiting for the nodes to become primary validators"))
|
||||
ln.log.Info(log.Green.Wrap("waiting for the nodes to become primary validators"))
|
||||
for {
|
||||
ready := true
|
||||
ctx, cancel := createDefaultCtx(ctx)
|
||||
@@ -1254,7 +1253,7 @@ func (ln *localNetwork) waitSubnetValidators(
|
||||
subnetIDs []ids.ID,
|
||||
subnetSpecs []network.SubnetSpec,
|
||||
) error {
|
||||
ln.log.Info(logging.Green.Wrap("waiting for the nodes to become subnet validators"))
|
||||
ln.log.Info(log.Green.Wrap("waiting for the nodes to become subnet validators"))
|
||||
for {
|
||||
ready := true
|
||||
for i, subnetID := range subnetIDs {
|
||||
@@ -1298,7 +1297,7 @@ func (ln *localNetwork) waitSubnetValidators(
|
||||
|
||||
// reload VM plugins on all nodes
|
||||
func (ln *localNetwork) reloadVMPlugins(ctx context.Context) error {
|
||||
ln.log.Info(logging.Green.Wrap("reloading plugin binaries"))
|
||||
ln.log.Info(log.Green.Wrap("reloading plugin binaries"))
|
||||
for _, node := range ln.nodes {
|
||||
if node.paused {
|
||||
continue
|
||||
@@ -1322,10 +1321,10 @@ func createBlockchainTxs(
|
||||
ctx context.Context,
|
||||
chainSpecs []network.BlockchainSpec,
|
||||
w *wallet,
|
||||
log logging.Logger,
|
||||
logger log.Logger,
|
||||
) ([]*txs.Tx, error) {
|
||||
fmt.Println()
|
||||
log.Info(logging.Green.Wrap("creating tx for each custom chain"))
|
||||
logger.Info(log.Green.Wrap("creating tx for each custom chain"))
|
||||
blockchainTxs := make([]*txs.Tx, len(chainSpecs))
|
||||
for i, chainSpec := range chainSpecs {
|
||||
vmName := chainSpec.VMName
|
||||
@@ -1335,10 +1334,10 @@ func createBlockchainTxs(
|
||||
}
|
||||
genesisBytes := chainSpec.Genesis
|
||||
|
||||
log.Info("creating blockchain tx",
|
||||
zap.String("vm-name", vmName),
|
||||
zap.String("vm-ID", vmID.String()),
|
||||
zap.Int("bytes length of genesis", len(genesisBytes)),
|
||||
logger.Info("creating blockchain tx",
|
||||
log.String("vm-name", vmName),
|
||||
log.String("vm-ID", vmID.String()),
|
||||
log.Int("bytes length of genesis", len(genesisBytes)),
|
||||
)
|
||||
ctx, cancel := createDefaultCtx(ctx)
|
||||
defer cancel()
|
||||
@@ -1370,10 +1369,10 @@ func (ln *localNetwork) setBlockchainConfigFiles(
|
||||
blockchainTxs []*txs.Tx,
|
||||
subnetIDs []ids.ID,
|
||||
subnetSpecs []network.SubnetSpec,
|
||||
log logging.Logger,
|
||||
logger log.Logger,
|
||||
) (set.Set[string], error) {
|
||||
fmt.Println()
|
||||
log.Info(logging.Green.Wrap("creating config files for each custom chain"))
|
||||
logger.Info(log.Green.Wrap("creating config files for each custom chain"))
|
||||
nodesToRestart := set.Set[string]{}
|
||||
for i, chainSpec := range chainSpecs {
|
||||
// get subnet participants
|
||||
@@ -1451,19 +1450,19 @@ func (*localNetwork) createBlockchains(
|
||||
chainSpecs []network.BlockchainSpec,
|
||||
blockchainTxs []*txs.Tx,
|
||||
w *wallet,
|
||||
log logging.Logger,
|
||||
logger log.Logger,
|
||||
) error {
|
||||
fmt.Println()
|
||||
log.Info(logging.Green.Wrap("creating each custom chain"))
|
||||
logger.Info(log.Green.Wrap("creating each custom chain"))
|
||||
for i, chainSpec := range chainSpecs {
|
||||
vmName := chainSpec.VMName
|
||||
vmID, err := utils.VMID(vmName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info("creating blockchain",
|
||||
zap.String("vm-name", vmName),
|
||||
zap.String("vm-ID", vmID.String()),
|
||||
logger.Info("creating blockchain",
|
||||
log.String("vm-name", vmName),
|
||||
log.String("vm-ID", vmID.String()),
|
||||
)
|
||||
|
||||
ctx, cancel := createDefaultCtx(ctx)
|
||||
@@ -1479,10 +1478,10 @@ func (*localNetwork) createBlockchains(
|
||||
}
|
||||
blockchainID := blockchainTxs[i].ID()
|
||||
|
||||
log.Info("created a new blockchain",
|
||||
zap.String("vm-name", vmName),
|
||||
zap.String("vm-ID", vmID.String()),
|
||||
zap.String("blockchain-ID", blockchainID.String()),
|
||||
logger.Info("created a new blockchain",
|
||||
log.String("vm-name", vmName),
|
||||
log.String("vm-ID", vmID.String()),
|
||||
log.String("blockchain-ID", blockchainID.String()),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -14,8 +14,7 @@ import (
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/utils/constants"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"go.uber.org/zap"
|
||||
"github.com/luxfi/log"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -223,7 +222,7 @@ func getPort(
|
||||
return port, nil
|
||||
}
|
||||
|
||||
func makeNodeDir(log logging.Logger, rootDir, nodeName string) (string, error) {
|
||||
func makeNodeDir(log log.Logger, rootDir, nodeName string) (string, error) {
|
||||
if rootDir == "" {
|
||||
log.Warn("no network root directory defined; will create this node's runtime directory in working directory")
|
||||
}
|
||||
@@ -236,7 +235,7 @@ func makeNodeDir(log logging.Logger, rootDir, nodeName string) (string, error) {
|
||||
if !os.IsExist(err) {
|
||||
return "", fmt.Errorf("error creating temp dir %w", err)
|
||||
}
|
||||
log.Warn("node root directory already exists", zap.String("root-dir", nodeRootDir))
|
||||
log.Warn("node root directory already exists", "root-dir", nodeRootDir)
|
||||
}
|
||||
return nodeRootDir, nil
|
||||
}
|
||||
|
||||
+23
-24
@@ -25,15 +25,14 @@ import (
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/netrunner/utils/constants"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/network/peer"
|
||||
"github.com/luxfi/node/staking"
|
||||
"github.com/luxfi/node/utils/beacon"
|
||||
"github.com/luxfi/crypto/bls"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/node/utils/set"
|
||||
"github.com/luxfi/node/utils/wrappers"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/mod/semver"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@@ -79,7 +78,7 @@ var (
|
||||
// network keeps information uses for network management, and accessing all the nodes
|
||||
type localNetwork struct {
|
||||
lock sync.RWMutex
|
||||
log logging.Logger
|
||||
log log.Logger
|
||||
// This network's ID.
|
||||
networkID uint32
|
||||
// This network's genesis file.
|
||||
@@ -260,7 +259,7 @@ func init() {
|
||||
// If len([dir]) == 0, files will be written underneath a new temporary directory.
|
||||
// Snapshots are saved to snapshotsDir, defaults to defaultSnapshotsDir if not given
|
||||
func NewNetwork(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
networkConfig network.Config,
|
||||
rootDir string,
|
||||
snapshotsDir string,
|
||||
@@ -289,7 +288,7 @@ func NewNetwork(
|
||||
// [newAPIClientF] is used to create new API clients.
|
||||
// [nodeProcessCreator] is used to launch new node processes.
|
||||
func newNetwork(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
newAPIClientF api.NewAPIClientF,
|
||||
nodeProcessCreator NodeProcessCreator,
|
||||
rootDir string,
|
||||
@@ -354,7 +353,7 @@ func newNetwork(
|
||||
// * NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu
|
||||
// * NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5
|
||||
func NewDefaultNetwork(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
binaryPath string,
|
||||
reassignPortsIfUsed bool,
|
||||
) (network.Network, error) {
|
||||
@@ -426,7 +425,7 @@ func (ln *localNetwork) loadConfig(ctx context.Context, networkConfig network.Co
|
||||
if err := networkConfig.Validate(); err != nil {
|
||||
return fmt.Errorf("config failed validation: %w", err)
|
||||
}
|
||||
ln.log.Info("creating network", zap.Int("node-num", len(networkConfig.NodeConfigs)))
|
||||
ln.log.Info("creating network", log.Int("node-num", len(networkConfig.NodeConfigs)))
|
||||
|
||||
ln.genesis = []byte(networkConfig.Genesis)
|
||||
|
||||
@@ -469,7 +468,7 @@ func (ln *localNetwork) loadConfig(ctx context.Context, networkConfig network.Co
|
||||
if _, err := ln.addNode(nodeConfig); err != nil {
|
||||
if err := ln.stop(ctx); err != nil {
|
||||
// Clean up nodes already created
|
||||
ln.log.Debug("error stopping network", zap.Error(err))
|
||||
ln.log.Debug("error stopping network", log.Err(err))
|
||||
}
|
||||
return fmt.Errorf("error adding node %s: %w", nodeConfig.Name, err)
|
||||
}
|
||||
@@ -596,19 +595,19 @@ func (ln *localNetwork) addNode(nodeConfig node.Config) (node.Node, error) {
|
||||
|
||||
ln.log.Info(
|
||||
"adding node",
|
||||
zap.String("node-name", nodeConfig.Name),
|
||||
zap.String("node-dir", nodeData.dataDir),
|
||||
zap.String("log-dir", nodeData.logsDir),
|
||||
zap.String("db-dir", nodeData.dbDir),
|
||||
zap.Uint16("p2p-port", nodeData.p2pPort),
|
||||
zap.Uint16("api-port", nodeData.apiPort),
|
||||
log.String("node-name", nodeConfig.Name),
|
||||
log.String("node-dir", nodeData.dataDir),
|
||||
log.String("log-dir", nodeData.logsDir),
|
||||
log.String("db-dir", nodeData.dbDir),
|
||||
log.Uint16("p2p-port", nodeData.p2pPort),
|
||||
log.Uint16("api-port", nodeData.apiPort),
|
||||
)
|
||||
|
||||
ln.log.Debug(
|
||||
"starting node",
|
||||
zap.String("name", nodeConfig.Name),
|
||||
zap.String("binaryPath", nodeConfig.BinaryPath),
|
||||
zap.Strings("args", nodeData.args),
|
||||
log.String("name", nodeConfig.Name),
|
||||
log.String("binaryPath", nodeConfig.BinaryPath),
|
||||
log.Strings("args", nodeData.args),
|
||||
)
|
||||
|
||||
// Create a wrapper for this node so we can reference it later
|
||||
@@ -651,7 +650,7 @@ func (ln *localNetwork) Healthy(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (ln *localNetwork) healthy(ctx context.Context) error {
|
||||
ln.log.Info("checking local network healthiness", zap.Int("num-of-nodes", len(ln.nodes)))
|
||||
ln.log.Info("checking local network healthiness", log.Int("num-of-nodes", len(ln.nodes)))
|
||||
|
||||
// Return unhealthy if the network is stopped
|
||||
if ln.stopCalled() {
|
||||
@@ -695,7 +694,7 @@ func (ln *localNetwork) healthy(ctx context.Context) error {
|
||||
}
|
||||
health, err := (*healthClient).Health(ctx, nil)
|
||||
if err == nil && health.Healthy {
|
||||
ln.log.Debug("node became healthy", zap.String("name", nodeName))
|
||||
ln.log.Debug("node became healthy", log.String("name", nodeName))
|
||||
return nil
|
||||
}
|
||||
select {
|
||||
@@ -775,7 +774,7 @@ func (ln *localNetwork) stop(ctx context.Context) error {
|
||||
for nodeName := range ln.nodes {
|
||||
stopCtx, stopCtxCancel := context.WithTimeout(ctx, stopTimeout)
|
||||
if err := ln.removeNode(stopCtx, nodeName); err != nil {
|
||||
ln.log.Error("error stopping node", zap.String("name", nodeName), zap.Error(err))
|
||||
ln.log.Error("error stopping node", "name", nodeName, "error", err)
|
||||
errs.Add(err)
|
||||
}
|
||||
stopCtxCancel()
|
||||
@@ -797,7 +796,7 @@ func (ln *localNetwork) RemoveNode(ctx context.Context, nodeName string) error {
|
||||
|
||||
// Assumes [ln.lock] is held.
|
||||
func (ln *localNetwork) removeNode(ctx context.Context, nodeName string) error {
|
||||
ln.log.Debug("removing node", zap.String("name", nodeName))
|
||||
ln.log.Debug("removing node", log.String("name", nodeName))
|
||||
node, ok := ln.nodes[nodeName]
|
||||
if !ok {
|
||||
return fmt.Errorf("node %q not found", nodeName)
|
||||
@@ -832,7 +831,7 @@ func (ln *localNetwork) PauseNode(ctx context.Context, nodeName string) error {
|
||||
|
||||
// Assumes [ln.lock] is held.
|
||||
func (ln *localNetwork) pauseNode(ctx context.Context, nodeName string) error {
|
||||
ln.log.Debug("pausing node", zap.String("name", nodeName))
|
||||
ln.log.Debug("pausing node", log.String("name", nodeName))
|
||||
node, ok := ln.nodes[nodeName]
|
||||
if !ok {
|
||||
return fmt.Errorf("node %q not found", nodeName)
|
||||
@@ -1114,7 +1113,7 @@ func (ln *localNetwork) buildArgs(
|
||||
// Note these will overwrite existing flags if the same flag is given twice.
|
||||
for flagName, flagVal := range nodeConfig.Flags {
|
||||
if _, ok := warnFlags[flagName]; ok {
|
||||
ln.log.Warn("A provided flag can create conflicts with the runner. The suggestion is to remove this flag", zap.String("flag-name", flagName))
|
||||
ln.log.Warn("A provided flag can create conflicts with the runner. The suggestion is to remove this flag", log.String("flag-name", flagName))
|
||||
}
|
||||
if portFlags.Contains(flagName) {
|
||||
continue
|
||||
|
||||
+21
-21
@@ -23,10 +23,10 @@ import (
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/node/api/health"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/message"
|
||||
"github.com/luxfi/node/consensus/networking/router"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/node/utils/rpc"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -144,7 +144,7 @@ func TestNewNetworkEmpty(t *testing.T) {
|
||||
networkConfig := testNetworkConfig(t)
|
||||
networkConfig.NodeConfigs = nil
|
||||
net, err := newNetwork(
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
newMockAPISuccessful,
|
||||
&localTestProcessUndefNodeProcessCreator{},
|
||||
"",
|
||||
@@ -207,7 +207,7 @@ func TestNewNetworkOneNode(t *testing.T) {
|
||||
networkConfig.NodeConfigs = networkConfig.NodeConfigs[:1]
|
||||
creator := newLocalTestOneNodeCreator(require, networkConfig)
|
||||
net, err := newNetwork(
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
newMockAPISuccessful,
|
||||
creator,
|
||||
"",
|
||||
@@ -235,7 +235,7 @@ func TestNewNetworkFailToStartNode(t *testing.T) {
|
||||
require := require.New(t)
|
||||
networkConfig := testNetworkConfig(t)
|
||||
net, err := newNetwork(
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
newMockAPISuccessful,
|
||||
&localTestFailedStartProcessCreator{},
|
||||
"",
|
||||
@@ -477,7 +477,7 @@ func TestWrongNetworkConfigs(t *testing.T) {
|
||||
require := require.New(t)
|
||||
for name, tt := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), tt.config)
|
||||
require.Error(err)
|
||||
@@ -491,7 +491,7 @@ func TestUnhealthyNetwork(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
networkConfig := testNetworkConfig(t)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPIUnhealthy, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPIUnhealthy, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), networkConfig)
|
||||
require.NoError(err)
|
||||
@@ -506,7 +506,7 @@ func TestGeneratedNodesNames(t *testing.T) {
|
||||
for i := range networkConfig.NodeConfigs {
|
||||
networkConfig.NodeConfigs[i].Name = ""
|
||||
}
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), networkConfig)
|
||||
require.NoError(err)
|
||||
@@ -526,7 +526,7 @@ func TestGenerateDefaultNetwork(t *testing.T) {
|
||||
require := require.New(t)
|
||||
binaryPath := "pepito"
|
||||
networkConfig := NewDefaultConfig(binaryPath)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), networkConfig)
|
||||
require.NoError(err)
|
||||
@@ -576,7 +576,7 @@ func TestNetworkFromConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
networkConfig := testNetworkConfig(t)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), networkConfig)
|
||||
require.NoError(err)
|
||||
@@ -600,7 +600,7 @@ func TestNetworkNodeOps(t *testing.T) {
|
||||
// Start a new, empty network
|
||||
emptyNetworkConfig, err := emptyNetworkConfig()
|
||||
require.NoError(err)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), emptyNetworkConfig)
|
||||
require.NoError(err)
|
||||
@@ -638,7 +638,7 @@ func TestNodeNotFound(t *testing.T) {
|
||||
emptyNetworkConfig, err := emptyNetworkConfig()
|
||||
require.NoError(err)
|
||||
networkConfig := testNetworkConfig(t)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), emptyNetworkConfig)
|
||||
require.NoError(err)
|
||||
@@ -671,7 +671,7 @@ func TestStoppedNetwork(t *testing.T) {
|
||||
emptyNetworkConfig, err := emptyNetworkConfig()
|
||||
require.NoError(err)
|
||||
networkConfig := testNetworkConfig(t)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), emptyNetworkConfig)
|
||||
require.NoError(err)
|
||||
@@ -704,7 +704,7 @@ func TestStoppedNetwork(t *testing.T) {
|
||||
func TestGetAllNodes(t *testing.T) {
|
||||
require := require.New(t)
|
||||
networkConfig := testNetworkConfig(t)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), networkConfig)
|
||||
require.NoError(err)
|
||||
@@ -746,7 +746,7 @@ func TestFlags(t *testing.T) {
|
||||
}
|
||||
|
||||
nw, err := newNetwork(
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
newMockAPISuccessful,
|
||||
&localTestFlagCheckProcessCreator{
|
||||
// after creating the network, one flag should have been overridden by the node configs
|
||||
@@ -775,7 +775,7 @@ func TestFlags(t *testing.T) {
|
||||
v.Flags = flags
|
||||
}
|
||||
nw, err = newNetwork(
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
newMockAPISuccessful,
|
||||
&localTestFlagCheckProcessCreator{
|
||||
// after creating the network, only node configs should exist
|
||||
@@ -803,7 +803,7 @@ func TestFlags(t *testing.T) {
|
||||
v.Flags = nil
|
||||
}
|
||||
nw, err = newNetwork(
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
newMockAPISuccessful,
|
||||
&localTestFlagCheckProcessCreator{
|
||||
// after creating the network, only flags from the network config should exist
|
||||
@@ -845,7 +845,7 @@ func TestChildCmdRedirection(t *testing.T) {
|
||||
writtenCh: make(chan struct{}),
|
||||
}
|
||||
npc := &nodeProcessCreator{
|
||||
log: logging.NoLog{},
|
||||
log: log.NoLog{},
|
||||
stdout: buf,
|
||||
stderr: buf,
|
||||
colorPicker: utils.NewColorPicker(),
|
||||
@@ -895,7 +895,7 @@ func TestChildCmdRedirection(t *testing.T) {
|
||||
|
||||
// and it should have a specific length:
|
||||
// the actual output + the color terminal escape sequence + node name + []<space> + color terminal reset escape sequence
|
||||
expectedLen := len(expectedResult) + len(utils.NewColorPicker().NextColor()) + len(mockNodeName) + 3 + len(logging.Reset)
|
||||
expectedLen := len(expectedResult) + len(utils.NewColorPicker().NextColor()) + len(mockNodeName) + 3 + len(log.Reset)
|
||||
if len(result) != expectedLen {
|
||||
t.Fatalf("expected string length to be %d, but it was %d", expectedLen, len(result))
|
||||
}
|
||||
@@ -1273,7 +1273,7 @@ func TestRemoveBeacon(t *testing.T) {
|
||||
// create a network with no nodes in it
|
||||
emptyNetworkConfig, err := emptyNetworkConfig()
|
||||
require.NoError(err)
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPISuccessful, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), emptyNetworkConfig)
|
||||
require.NoError(err)
|
||||
@@ -1324,7 +1324,7 @@ func TestHealthyDuringNetworkStop(t *testing.T) {
|
||||
require := require.New(t)
|
||||
networkConfig := testNetworkConfig(t)
|
||||
// Calls to a node's Healthy() function blocks until context cancelled
|
||||
net, err := newNetwork(logging.NoLog{}, newMockAPIHealthyBlocks, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
net, err := newNetwork(log.NoLog{}, newMockAPIHealthyBlocks, &localTestSuccessfulNodeProcessCreator{}, "", "", false)
|
||||
require.NoError(err)
|
||||
err = net.loadConfig(context.Background(), networkConfig)
|
||||
require.NoError(err)
|
||||
|
||||
+11
-7
@@ -12,7 +12,9 @@ import (
|
||||
"github.com/luxfi/netrunner/api"
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/netrunner/network/node/status"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/metrics"
|
||||
"github.com/luxfi/node/message"
|
||||
"github.com/luxfi/node/network/peer"
|
||||
"github.com/luxfi/node/network/throttling"
|
||||
@@ -23,7 +25,6 @@ import (
|
||||
"github.com/luxfi/node/utils"
|
||||
"github.com/luxfi/node/utils/constants"
|
||||
"github.com/luxfi/crypto/bls"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/node/utils/math/meter"
|
||||
"github.com/luxfi/node/utils/resource"
|
||||
"github.com/luxfi/node/utils/set"
|
||||
@@ -100,8 +101,8 @@ func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHand
|
||||
return nil, err
|
||||
}
|
||||
mc, err := message.NewCreator(
|
||||
logging.NoLog{},
|
||||
prometheus.NewRegistry(),
|
||||
log.NoLog{},
|
||||
metrics.NewNoOpMetrics("netrunner"),
|
||||
constants.DefaultNetworkCompressionType,
|
||||
10*time.Second,
|
||||
)
|
||||
@@ -134,7 +135,7 @@ func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHand
|
||||
config := &peer.Config{
|
||||
Metrics: metrics,
|
||||
MessageCreator: mc,
|
||||
Log: logging.NoLog{},
|
||||
Log: log.NoLog{},
|
||||
InboundMsgThrottler: throttling.NewNoInboundThrottler(),
|
||||
Network: peer.TestNetwork,
|
||||
Router: router,
|
||||
@@ -158,10 +159,13 @@ func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHand
|
||||
config,
|
||||
conn,
|
||||
cert,
|
||||
ids.NodeIDFromCert(cert),
|
||||
ids.NodeIDFromCert(&ids.Certificate{
|
||||
Raw: cert.Raw,
|
||||
PublicKey: cert.PublicKey,
|
||||
}),
|
||||
peer.NewBlockingMessageQueue(
|
||||
config.Metrics,
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
peerMsgQueueBufferSize,
|
||||
),
|
||||
)
|
||||
|
||||
+13
-14
@@ -11,9 +11,8 @@ import (
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/netrunner/network/node/status"
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/shirou/gopsutil/process"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var _ NodeProcess = (*nodeProcess)(nil)
|
||||
@@ -38,7 +37,7 @@ type NodeProcessCreator interface {
|
||||
}
|
||||
|
||||
type nodeProcessCreator struct {
|
||||
log logging.Logger
|
||||
log log.Logger
|
||||
// If this node's stdout or stderr are redirected, [colorPicker] determines
|
||||
// the color of logs printed to stdout and/or stderr
|
||||
colorPicker utils.ColorPicker
|
||||
@@ -80,7 +79,7 @@ func (npc *nodeProcessCreator) NewNodeProcess(config node.Config, args ...string
|
||||
|
||||
type nodeProcess struct {
|
||||
name string
|
||||
log logging.Logger
|
||||
log log.Logger
|
||||
lock sync.RWMutex
|
||||
cmd *exec.Cmd
|
||||
// Process status
|
||||
@@ -89,7 +88,7 @@ type nodeProcess struct {
|
||||
closedOnStop chan struct{}
|
||||
}
|
||||
|
||||
func newNodeProcess(name string, log logging.Logger, cmd *exec.Cmd) (*nodeProcess, error) {
|
||||
func newNodeProcess(name string, log log.Logger, cmd *exec.Cmd) (*nodeProcess, error) {
|
||||
np := &nodeProcess{
|
||||
name: name,
|
||||
log: log,
|
||||
@@ -120,10 +119,10 @@ func (p *nodeProcess) start() error {
|
||||
// When it does, update the state and close [p.closedOnStop]
|
||||
func (p *nodeProcess) awaitExit() {
|
||||
if err := p.cmd.Wait(); err != nil {
|
||||
p.log.Debug("node returned error on wait", zap.String("node", p.name), zap.Error(err))
|
||||
p.log.Debug("node returned error on wait", log.String("node", p.name), log.Err(err))
|
||||
}
|
||||
|
||||
p.log.Debug("node process finished", zap.String("node", p.name))
|
||||
p.log.Debug("node process finished", log.String("node", p.name))
|
||||
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
@@ -160,15 +159,15 @@ func (p *nodeProcess) Stop(ctx context.Context) int {
|
||||
p.lock.Unlock()
|
||||
|
||||
if err := proc.Signal(os.Interrupt); err != nil {
|
||||
p.log.Warn("sending SIGINT errored", zap.Error(err))
|
||||
p.log.Warn("sending SIGINT errored", log.Err(err))
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
p.log.Warn("context cancelled while waiting for node to stop", zap.String("node", p.name))
|
||||
p.log.Warn("context cancelled while waiting for node to stop", log.String("node", p.name))
|
||||
killDescendants(int32(proc.Pid), p.log)
|
||||
if err := proc.Signal(os.Kill); err != nil {
|
||||
p.log.Warn("sending SIGKILL errored", zap.Error(err))
|
||||
p.log.Warn("sending SIGKILL errored", log.Err(err))
|
||||
}
|
||||
case <-p.closedOnStop:
|
||||
}
|
||||
@@ -187,16 +186,16 @@ func (p *nodeProcess) Status() status.Status {
|
||||
return p.state
|
||||
}
|
||||
|
||||
func killDescendants(pid int32, log logging.Logger) {
|
||||
func killDescendants(pid int32, log log.Logger) {
|
||||
procs, err := process.Processes()
|
||||
if err != nil {
|
||||
log.Warn("couldn't get processes", zap.Error(err))
|
||||
log.Warn("couldn't get processes", "error", err)
|
||||
return
|
||||
}
|
||||
for _, proc := range procs {
|
||||
ppid, err := proc.Ppid()
|
||||
if err != nil {
|
||||
log.Warn("couldn't get process ID", zap.Error(err))
|
||||
log.Warn("couldn't get process ID", "error", err)
|
||||
continue
|
||||
}
|
||||
if ppid != pid {
|
||||
@@ -204,7 +203,7 @@ func killDescendants(pid int32, log logging.Logger) {
|
||||
}
|
||||
killDescendants(proc.Pid, log)
|
||||
if err := proc.Kill(); err != nil {
|
||||
log.Warn("error killing process", zap.Int32("pid", proc.Pid), zap.Error(err))
|
||||
log.Warn("error killing process", "pid", proc.Pid, "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
-12
@@ -13,15 +13,17 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/message"
|
||||
"github.com/luxfi/node/network/peer"
|
||||
"github.com/luxfi/node/staking"
|
||||
"github.com/luxfi/node/utils/constants"
|
||||
"github.com/luxfi/node/utils/ips"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/node/utils/wrappers"
|
||||
"github.com/luxfi/node/version"
|
||||
"github.com/luxfi/crypto/bls"
|
||||
"github.com/luxfi/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -30,7 +32,11 @@ const bitmaskCodec = uint32(1 << 31)
|
||||
|
||||
func upgradeConn(myTLSCert *tls.Certificate, conn net.Conn) (ids.NodeID, net.Conn, error) {
|
||||
tlsConfig := peer.TLSConfig(*myTLSCert, nil)
|
||||
upgrader := peer.NewTLSServerUpgrader(tlsConfig)
|
||||
invalidCerts := prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Name: "test_invalid_certs",
|
||||
Help: "test invalid certificates counter",
|
||||
})
|
||||
upgrader := peer.NewTLSServerUpgrader(tlsConfig, invalidCerts)
|
||||
// this will block until the ssh handshake is done
|
||||
peerID, tlsConn, _, err := upgrader.Upgrade(conn)
|
||||
return peerID, tlsConn, err
|
||||
@@ -75,19 +81,33 @@ func verifyProtocol(
|
||||
Timestamp: now,
|
||||
}
|
||||
signer := myTLSCert.PrivateKey.(crypto.Signer)
|
||||
signedIP, err := unsignedIP.Sign(signer)
|
||||
// Create a dummy BLS key for testing
|
||||
blsKey, err := bls.NewSecretKey()
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
verMsg, err := mc.Version(
|
||||
signedIP, err := unsignedIP.Sign(signer, blsKey)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
verMsg, err := mc.Handshake(
|
||||
constants.MainnetID,
|
||||
now,
|
||||
myIP,
|
||||
version.CurrentApp.String(),
|
||||
uint32(version.CurrentApp.Major),
|
||||
uint32(version.CurrentApp.Minor),
|
||||
uint32(version.CurrentApp.Patch),
|
||||
now,
|
||||
signedIP.Signature,
|
||||
signedIP.TLSSignature,
|
||||
signedIP.BLSSignatureBytes,
|
||||
[]ids.ID{},
|
||||
[]uint32{}, // supportedACPs
|
||||
[]uint32{}, // objectedACPs
|
||||
nil, // knownPeersFilter
|
||||
nil, // knownPeersSalt
|
||||
)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
@@ -95,7 +115,7 @@ func verifyProtocol(
|
||||
}
|
||||
|
||||
// create the PeerList message
|
||||
plMsg, err := mc.PeerList([]ips.ClaimedIPPort{}, true)
|
||||
plMsg, err := mc.PeerList([]*ips.ClaimedIPPort{}, true)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
@@ -195,10 +215,10 @@ func TestAttachPeer(t *testing.T) {
|
||||
}
|
||||
|
||||
// For message creation and parsing
|
||||
m := metrics.NewNoOpMetrics("test")
|
||||
mc, err := message.NewCreator(
|
||||
logging.NoLog{},
|
||||
prometheus.NewRegistry(),
|
||||
"",
|
||||
log.NoLog{},
|
||||
m,
|
||||
constants.DefaultNetworkCompressionType,
|
||||
10*time.Second,
|
||||
)
|
||||
@@ -206,7 +226,7 @@ func TestAttachPeer(t *testing.T) {
|
||||
|
||||
// Expect the peer to send these messages in this order.
|
||||
expectedMessages := []message.Op{
|
||||
message.VersionOp,
|
||||
message.HandshakeOp,
|
||||
message.PeerListOp,
|
||||
message.ChitsOp,
|
||||
}
|
||||
@@ -231,7 +251,11 @@ func TestAttachPeer(t *testing.T) {
|
||||
requestID := uint32(42)
|
||||
chainID := constants.PlatformChainID
|
||||
// create the Chits message
|
||||
msg, err := mc.Chits(chainID, requestID, []ids.ID{}, containerIDs)
|
||||
// For the test, we'll use the same ID for all three parameters
|
||||
preferredID := containerIDs[0]
|
||||
preferredIDAtHeight := containerIDs[1]
|
||||
acceptedID := containerIDs[2]
|
||||
msg, err := mc.Chits(chainID, requestID, preferredID, preferredIDAtHeight, acceptedID)
|
||||
require.NoError(err)
|
||||
// send chits to [node]
|
||||
ok := p.Send(context.Background(), msg)
|
||||
|
||||
+3
-3
@@ -15,9 +15,9 @@ import (
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/utils/constants"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
dircopy "github.com/otiai10/copy"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
@@ -60,7 +60,7 @@ func fixDeprecatedLuxdFlags(flags map[string]interface{}) error {
|
||||
|
||||
// NewNetwork returns a new network from the given snapshot
|
||||
func NewNetworkFromSnapshot(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
snapshotName string,
|
||||
rootDir string,
|
||||
snapshotsDir string,
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/node/genesis"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/utils/constants"
|
||||
"github.com/luxfi/node/utils/formatting/address"
|
||||
"github.com/luxfi/node/utils/units"
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func LoadLocalGenesis() (map[string]interface{}, error) {
|
||||
cChainGenesis := genesisMap["cChainGenesis"]
|
||||
// set the cchain genesis directly from geth
|
||||
// the whole of `cChainGenesis` should be set as a string, not a json object...
|
||||
gethCChainGenesis := geth_params.LuxLocalChainConfig
|
||||
gethCChainGenesis := geth_params.TestChainConfig
|
||||
// but the part in geth is only the "config" part.
|
||||
// In order to set it easily, first we get the cChainGenesis item
|
||||
// convert it to a map
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/luxfi/netrunner/api"
|
||||
"github.com/luxfi/netrunner/network/node/status"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/network/peer"
|
||||
"github.com/luxfi/node/consensus/networking/router"
|
||||
)
|
||||
|
||||
+21
-21
@@ -20,9 +20,9 @@ import (
|
||||
"github.com/luxfi/netrunner/utils/constants"
|
||||
"github.com/luxfi/netrunner/ux"
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
luxd_constants "github.com/luxfi/node/utils/constants"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
@@ -51,7 +51,7 @@ scrape_configs:
|
||||
|
||||
type localNetwork struct {
|
||||
lock sync.Mutex
|
||||
log logging.Logger
|
||||
log log.Logger
|
||||
|
||||
execPath string
|
||||
pluginDir string
|
||||
@@ -102,7 +102,7 @@ type localNetworkOptions struct {
|
||||
|
||||
snapshotsDir string
|
||||
|
||||
logLevel logging.Level
|
||||
logLevel log.Level
|
||||
|
||||
reassignPortsIfUsed bool
|
||||
|
||||
@@ -110,8 +110,8 @@ type localNetworkOptions struct {
|
||||
}
|
||||
|
||||
func newLocalNetwork(opts localNetworkOptions) (*localNetwork, error) {
|
||||
logFactory := logging.NewFactory(logging.Config{
|
||||
RotatingWriterConfig: logging.RotatingWriterConfig{
|
||||
logFactory := log.NewFactoryWithConfig(log.Config{
|
||||
RotatingWriterConfig: log.RotatingWriterConfig{
|
||||
Directory: opts.rootDataDir,
|
||||
},
|
||||
LogLevel: opts.logLevel,
|
||||
@@ -232,7 +232,7 @@ func (lc *localNetwork) Start(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(lc.log, logging.Blue.Wrap(logging.Bold.Wrap("create and run local network")))
|
||||
ux.Print(lc.log, log.Blue.Wrap(log.Bold.Wrap("create and run local network")))
|
||||
nw, err := local.NewNetwork(lc.log, lc.cfg, lc.options.rootDataDir, lc.options.snapshotsDir, lc.options.reassignPortsIfUsed)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -298,7 +298,7 @@ func (lc *localNetwork) AddPermissionlessValidators(ctx context.Context, validat
|
||||
defer lc.lock.Unlock()
|
||||
|
||||
if len(validatorSpecs) == 0 {
|
||||
ux.Print(lc.log, logging.Orange.Wrap(logging.Bold.Wrap("no validator specs provided...")))
|
||||
ux.Print(lc.log, log.Orange.Wrap(log.Bold.Wrap("no validator specs provided...")))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ func (lc *localNetwork) AddPermissionlessValidators(ctx context.Context, validat
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(lc.log, logging.Green.Wrap(logging.Bold.Wrap("finished adding permissionless validators")))
|
||||
ux.Print(lc.log, log.Green.Wrap(log.Bold.Wrap("finished adding permissionless validators")))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ func (lc *localNetwork) RemoveSubnetValidator(ctx context.Context, validatorSpec
|
||||
defer lc.lock.Unlock()
|
||||
|
||||
if len(validatorSpecs) == 0 {
|
||||
ux.Print(lc.log, logging.Orange.Wrap(logging.Bold.Wrap("no validator specs provided...")))
|
||||
ux.Print(lc.log, log.Orange.Wrap(log.Bold.Wrap("no validator specs provided...")))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ func (lc *localNetwork) RemoveSubnetValidator(ctx context.Context, validatorSpec
|
||||
return err
|
||||
}
|
||||
|
||||
ux.Print(lc.log, logging.Green.Wrap(logging.Bold.Wrap("finished removing subnet validators")))
|
||||
ux.Print(lc.log, log.Green.Wrap(log.Bold.Wrap("finished removing subnet validators")))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ func (lc *localNetwork) TransformSubnets(ctx context.Context, elasticSubnetSpecs
|
||||
defer lc.lock.Unlock()
|
||||
|
||||
if len(elasticSubnetSpecs) == 0 {
|
||||
ux.Print(lc.log, logging.Orange.Wrap(logging.Bold.Wrap("no subnets specified...")))
|
||||
ux.Print(lc.log, log.Orange.Wrap(log.Bold.Wrap("no subnets specified...")))
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ func (lc *localNetwork) TransformSubnets(ctx context.Context, elasticSubnetSpecs
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
ux.Print(lc.log, logging.Green.Wrap(logging.Bold.Wrap("finished transforming subnets")))
|
||||
ux.Print(lc.log, log.Green.Wrap(log.Bold.Wrap("finished transforming subnets")))
|
||||
return chainIDs, assetIDs, nil
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ func (lc *localNetwork) CreateSubnets(ctx context.Context, subnetSpecs []network
|
||||
defer lc.lock.Unlock()
|
||||
|
||||
if len(subnetSpecs) == 0 {
|
||||
ux.Print(lc.log, logging.Orange.Wrap(logging.Bold.Wrap("no subnets specified...")))
|
||||
ux.Print(lc.log, log.Orange.Wrap(log.Bold.Wrap("no subnets specified...")))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ func (lc *localNetwork) CreateSubnets(ctx context.Context, subnetSpecs []network
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ux.Print(lc.log, logging.Green.Wrap(logging.Bold.Wrap("finished adding subnets")))
|
||||
ux.Print(lc.log, log.Green.Wrap(log.Bold.Wrap("finished adding subnets")))
|
||||
return subnetIDs, nil
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ func (lc *localNetwork) LoadSnapshot(snapshotName string) error {
|
||||
lc.lock.Lock()
|
||||
defer lc.lock.Unlock()
|
||||
|
||||
ux.Print(lc.log, logging.Blue.Wrap(logging.Bold.Wrap("create and run local network from snapshot")))
|
||||
ux.Print(lc.log, log.Blue.Wrap(log.Bold.Wrap("create and run local network from snapshot")))
|
||||
|
||||
var globalNodeConfig map[string]interface{}
|
||||
if lc.options.globalNodeConfig != "" {
|
||||
@@ -609,7 +609,7 @@ func (lc *localNetwork) updateSubnetInfo(ctx context.Context) error {
|
||||
if nodeInfo.Paused {
|
||||
continue
|
||||
}
|
||||
lc.log.Info(fmt.Sprintf(logging.LightBlue.Wrap("[blockchain RPC for %q] \"%s/ext/bc/%s\""), chainInfo.info.VmId, nodeInfo.GetUri(), chainID))
|
||||
lc.log.Info(fmt.Sprintf(log.LightBlue.Wrap("[blockchain RPC for %q] \"%s/ext/bc/%s\""), chainInfo.info.VmId, nodeInfo.GetUri(), chainID))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ func (lc *localNetwork) AwaitHealthyAndUpdateNetworkInfo(ctx context.Context) er
|
||||
// Updates node and subnet info.
|
||||
// Assumes [lc.lock] is held.
|
||||
func (lc *localNetwork) awaitHealthyAndUpdateNetworkInfo(ctx context.Context) error {
|
||||
ux.Print(lc.log, logging.Blue.Wrap(logging.Bold.Wrap("waiting for all nodes to report healthy...")))
|
||||
ux.Print(lc.log, log.Blue.Wrap(log.Bold.Wrap("waiting for all nodes to report healthy...")))
|
||||
|
||||
if err := lc.nw.Healthy(ctx); err != nil {
|
||||
return err
|
||||
@@ -649,7 +649,7 @@ func (lc *localNetwork) awaitHealthyAndUpdateNetworkInfo(ctx context.Context) er
|
||||
if nodeInfo.Paused {
|
||||
continue
|
||||
}
|
||||
lc.log.Debug(fmt.Sprintf(logging.Cyan.Wrap("node-info: node-name %s, node-ID: %s, URI: %s"), nodeName, nodeInfo.Id, nodeInfo.Uri))
|
||||
lc.log.Debug(fmt.Sprintf(log.Cyan.Wrap("node-info: node-name %s, node-ID: %s, URI: %s"), nodeName, nodeInfo.Id, nodeInfo.Uri))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -706,7 +706,7 @@ func (lc *localNetwork) updateNodeInfo() error {
|
||||
func (lc *localNetwork) generatePrometheusConf() error {
|
||||
if lc.prometheusConfPath == "" {
|
||||
lc.prometheusConfPath = filepath.Join(lc.options.rootDataDir, prometheusConfFname)
|
||||
lc.log.Info(fmt.Sprintf(logging.Cyan.Wrap("prometheus conf file %s"), lc.prometheusConfPath))
|
||||
lc.log.Info(fmt.Sprintf(log.Cyan.Wrap("prometheus conf file %s"), lc.prometheusConfPath))
|
||||
}
|
||||
prometheusConf := prometheusConfCommon
|
||||
for _, nodeInfo := range lc.nodeInfos {
|
||||
@@ -737,7 +737,7 @@ func (lc *localNetwork) Stop(ctx context.Context) {
|
||||
if err != nil {
|
||||
msg += fmt.Sprintf(" (error %v)", err)
|
||||
}
|
||||
ux.Print(lc.log, logging.Red.Wrap(msg))
|
||||
ux.Print(lc.log, log.Red.Wrap(msg))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+53
-54
@@ -29,10 +29,9 @@ import (
|
||||
"github.com/luxfi/node/config"
|
||||
"github.com/luxfi/node/message"
|
||||
"github.com/luxfi/node/consensus/networking/router"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/node/utils/set"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/exp/maps"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -79,7 +78,7 @@ type Config struct {
|
||||
DialTimeout time.Duration
|
||||
RedirectNodesOutput bool
|
||||
SnapshotsDir string
|
||||
LogLevel logging.Level
|
||||
LogLevel log.Level
|
||||
}
|
||||
|
||||
type Server interface {
|
||||
@@ -90,7 +89,7 @@ type server struct {
|
||||
mu *sync.RWMutex
|
||||
|
||||
cfg Config
|
||||
log logging.Logger
|
||||
log log.Logger
|
||||
|
||||
rootCtx context.Context
|
||||
rootCancel context.CancelFunc
|
||||
@@ -123,7 +122,7 @@ func IsServerError(err error, serverError error) bool {
|
||||
return status.Code() == codes.Unknown && status.Message() == serverError.Error()
|
||||
}
|
||||
|
||||
func New(cfg Config, log logging.Logger) (Server, error) {
|
||||
func New(cfg Config, log log.Logger) (Server, error) {
|
||||
if cfg.Port == "" || cfg.GwPort == "" {
|
||||
return nil, ErrInvalidPort
|
||||
}
|
||||
@@ -162,7 +161,7 @@ func (s *server) Run(rootCtx context.Context) (err error) {
|
||||
|
||||
gRPCErrChan := make(chan error)
|
||||
go func() {
|
||||
s.log.Info("serving gRPC server", zap.String("port", s.cfg.Port))
|
||||
s.log.Info("serving gRPC server", "port", s.cfg.Port)
|
||||
gRPCErrChan <- s.gRPCServer.Serve(s.ln)
|
||||
}()
|
||||
|
||||
@@ -172,7 +171,7 @@ func (s *server) Run(rootCtx context.Context) (err error) {
|
||||
} else {
|
||||
// Set up gRPC gateway to allow for HTTP requests to [s.gRPCServer].
|
||||
go func() {
|
||||
s.log.Info("dialing gRPC server for gRPC gateway", zap.String("port", s.cfg.Port))
|
||||
s.log.Info("dialing gRPC server for gRPC gateway", "port", s.cfg.Port)
|
||||
ctx, cancel := context.WithTimeout(rootCtx, s.cfg.DialTimeout)
|
||||
gwConn, err := grpc.DialContext(
|
||||
ctx,
|
||||
@@ -196,7 +195,7 @@ func (s *server) Run(rootCtx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
s.log.Info("serving gRPC gateway", zap.String("port", s.cfg.GwPort))
|
||||
s.log.Info("serving gRPC gateway", "port", s.cfg.GwPort)
|
||||
gwErrChan <- s.gwServer.ListenAndServe()
|
||||
}()
|
||||
}
|
||||
@@ -206,7 +205,7 @@ func (s *server) Run(rootCtx context.Context) (err error) {
|
||||
s.log.Warn("root context is done")
|
||||
|
||||
if !s.cfg.GwDisabled {
|
||||
s.log.Warn("closed gRPC gateway server", zap.Error(s.gwServer.Close()))
|
||||
s.log.Warn("closed gRPC gateway server", "error", s.gwServer.Close())
|
||||
<-gwErrChan
|
||||
}
|
||||
|
||||
@@ -216,17 +215,17 @@ func (s *server) Run(rootCtx context.Context) (err error) {
|
||||
s.log.Warn("gRPC terminated")
|
||||
|
||||
case err = <-gRPCErrChan:
|
||||
s.log.Warn("gRPC server failed", zap.Error(err))
|
||||
s.log.Warn("gRPC server failed", "error", err)
|
||||
|
||||
// [s.grpcServer] is already stopped.
|
||||
if !s.cfg.GwDisabled {
|
||||
s.log.Warn("closed gRPC gateway server", zap.Error(s.gwServer.Close()))
|
||||
s.log.Warn("closed gRPC gateway server", "error", s.gwServer.Close())
|
||||
<-gwErrChan
|
||||
}
|
||||
|
||||
case err = <-gwErrChan: // if disabled, this will never be selected
|
||||
// [s.gwServer] is already closed.
|
||||
s.log.Warn("gRPC gateway server failed", zap.Error(err))
|
||||
s.log.Warn("gRPC gateway server failed", "error", err)
|
||||
s.gRPCServer.Stop()
|
||||
s.log.Warn("closed gRPC server")
|
||||
<-gRPCErrChan // Wait for [s.gRPCServer.Serve] to return.
|
||||
@@ -282,7 +281,7 @@ func (s *server) Start(_ context.Context, req *rpcpb.StartRequest) (*rpcpb.Start
|
||||
pluginDir := req.GetPluginDir()
|
||||
chainSpecs := []network.BlockchainSpec{}
|
||||
if len(req.GetBlockchainSpecs()) > 0 {
|
||||
s.log.Info("plugin-dir:", zap.String("plugin-dir", pluginDir))
|
||||
s.log.Info("plugin-dir:", "plugin-dir", pluginDir)
|
||||
for _, spec := range req.GetBlockchainSpecs() {
|
||||
chainSpec, err := getNetworkBlockchainSpec(s.log, spec, true, pluginDir)
|
||||
if err != nil {
|
||||
@@ -317,7 +316,7 @@ func (s *server) Start(_ context.Context, req *rpcpb.StartRequest) (*rpcpb.Start
|
||||
}
|
||||
|
||||
if len(customNodeConfigs) > 0 {
|
||||
s.log.Warn("custom node configs have been provided; ignoring the 'number-of-nodes' parameter and setting it to:", zap.Int("number-of-nodes", len(customNodeConfigs)))
|
||||
s.log.Warn("custom node configs have been provided; ignoring the 'number-of-nodes' parameter and setting it to:", log.Int("number-of-nodes", len(customNodeConfigs)))
|
||||
numNodes = uint32(len(customNodeConfigs))
|
||||
}
|
||||
|
||||
@@ -348,20 +347,20 @@ func (s *server) Start(_ context.Context, req *rpcpb.StartRequest) (*rpcpb.Start
|
||||
}
|
||||
|
||||
s.log.Info("starting",
|
||||
zap.String("exec-path", execPath),
|
||||
zap.Uint32("num-nodes", numNodes),
|
||||
zap.String("track-subnets", trackSubnets),
|
||||
zap.Int32("pid", pid),
|
||||
zap.String("root-data-dir", rootDataDir),
|
||||
zap.String("plugin-dir", pluginDir),
|
||||
zap.Any("chain-configs", req.ChainConfigs),
|
||||
zap.String("global-node-config", globalNodeConfig),
|
||||
log.String("exec-path", execPath),
|
||||
log.Uint32("num-nodes", numNodes),
|
||||
log.String("track-subnets", trackSubnets),
|
||||
log.Int32("pid", pid),
|
||||
log.String("root-data-dir", rootDataDir),
|
||||
log.String("plugin-dir", pluginDir),
|
||||
log.Any("chain-configs", req.ChainConfigs),
|
||||
log.String("global-node-config", globalNodeConfig),
|
||||
)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), waitForHealthyTimeout)
|
||||
defer cancel()
|
||||
if err := s.network.Start(ctx); err != nil {
|
||||
s.log.Warn("start failed to complete", zap.Error(err))
|
||||
s.log.Warn("start failed to complete", "error", err)
|
||||
s.stopAndRemoveNetwork(nil)
|
||||
return nil, err
|
||||
}
|
||||
@@ -370,7 +369,7 @@ func (s *server) Start(_ context.Context, req *rpcpb.StartRequest) (*rpcpb.Start
|
||||
defer cancel()
|
||||
chainIDs, err := s.network.CreateChains(ctx, chainSpecs)
|
||||
if err != nil {
|
||||
s.log.Error("network never became healthy", zap.Error(err))
|
||||
s.log.Error("network never became healthy", "error", err)
|
||||
s.stopAndRemoveNetwork(err)
|
||||
return nil, err
|
||||
}
|
||||
@@ -502,7 +501,7 @@ func (s *server) CreateBlockchains(
|
||||
defer cancel()
|
||||
chainIDs, err := s.network.CreateChains(ctx, chainSpecs)
|
||||
if err != nil {
|
||||
s.log.Error("failed to create blockchains", zap.Error(err))
|
||||
s.log.Error("failed to create blockchains", "error", err)
|
||||
s.stopAndRemoveNetwork(err)
|
||||
return nil, err
|
||||
} else {
|
||||
@@ -570,7 +569,7 @@ func (s *server) AddPermissionlessValidator(
|
||||
s.updateClusterInfo()
|
||||
|
||||
if err != nil {
|
||||
s.log.Error("failed to add permissionless validator", zap.Error(err))
|
||||
s.log.Error("failed to add permissionless validator", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -628,7 +627,7 @@ func (s *server) RemoveSubnetValidator(
|
||||
s.updateClusterInfo()
|
||||
|
||||
if err != nil {
|
||||
s.log.Error("failed to remove subnet validator", zap.Error(err))
|
||||
s.log.Error("failed to remove subnet validator", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -686,7 +685,7 @@ func (s *server) TransformElasticSubnets(
|
||||
s.updateClusterInfo()
|
||||
|
||||
if err != nil {
|
||||
s.log.Error("failed to transform subnet into elastic subnet", zap.Error(err))
|
||||
s.log.Error("failed to transform subnet into elastic subnet", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -717,7 +716,7 @@ func (s *server) CreateSubnets(_ context.Context, req *rpcpb.CreateSubnetsReques
|
||||
return nil, ErrNotBootstrapped
|
||||
}
|
||||
|
||||
s.log.Debug("CreateSubnets", zap.Uint32("num-subnets", uint32(len(req.GetSubnetSpecs()))))
|
||||
s.log.Debug("CreateSubnets", log.Uint32("num-subnets", uint32(len(req.GetSubnetSpecs()))))
|
||||
|
||||
subnetSpecs := []network.SubnetSpec{}
|
||||
for _, spec := range req.GetSubnetSpecs() {
|
||||
@@ -734,7 +733,7 @@ func (s *server) CreateSubnets(_ context.Context, req *rpcpb.CreateSubnetsReques
|
||||
defer cancel()
|
||||
subnetIDs, err := s.network.CreateSubnets(ctx, subnetSpecs)
|
||||
if err != nil {
|
||||
s.log.Error("failed to create subnets", zap.Error(err))
|
||||
s.log.Error("failed to create subnets", "error", err)
|
||||
s.stopAndRemoveNetwork(err)
|
||||
return nil, err
|
||||
} else {
|
||||
@@ -844,7 +843,7 @@ func (s *server) StreamStatus(req *rpcpb.StreamStatusRequest, stream rpcpb.Contr
|
||||
interval := time.Duration(req.PushInterval)
|
||||
|
||||
// returns this method, then server closes the stream
|
||||
s.log.Info("pushing status updates to the stream", zap.String("interval", interval.String()))
|
||||
s.log.Info("pushing status updates to the stream", "interval", interval.String())
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
@@ -857,9 +856,9 @@ func (s *server) StreamStatus(req *rpcpb.StreamStatusRequest, stream rpcpb.Contr
|
||||
err := s.recvLoop(stream)
|
||||
if err != nil {
|
||||
if isClientCanceled(stream.Context().Err(), err) {
|
||||
s.log.Warn("failed to receive status request from gRPC stream due to client cancellation", zap.Error(err))
|
||||
s.log.Warn("failed to receive status request from gRPC stream due to client cancellation", "error", err)
|
||||
} else {
|
||||
s.log.Warn("failed to receive status request from gRPC stream", zap.Error(err))
|
||||
s.log.Warn("failed to receive status request from gRPC stream", "error", err)
|
||||
}
|
||||
}
|
||||
errCh <- err
|
||||
@@ -903,10 +902,10 @@ func (s *server) sendLoop(stream rpcpb.ControlService_StreamStatusServer, interv
|
||||
s.mu.RUnlock()
|
||||
if err != nil {
|
||||
if isClientCanceled(stream.Context().Err(), err) {
|
||||
s.log.Debug("client stream canceled", zap.Error(err))
|
||||
s.log.Debug("client stream canceled", "error", err)
|
||||
return
|
||||
}
|
||||
s.log.Warn("failed to send an event", zap.Error(err))
|
||||
s.log.Warn("failed to send an event", "error", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -940,7 +939,7 @@ func (s *server) AddNode(_ context.Context, req *rpcpb.AddNodeRequest) (*rpcpb.A
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.log.Debug("AddNode", zap.String("name", req.Name))
|
||||
s.log.Debug("AddNode", "name", req.Name)
|
||||
|
||||
if s.network == nil {
|
||||
return nil, ErrNotBootstrapped
|
||||
@@ -991,7 +990,7 @@ func (s *server) RemoveNode(ctx context.Context, req *rpcpb.RemoveNodeRequest) (
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.log.Debug("RemoveNode", zap.String("name", req.Name))
|
||||
s.log.Debug("RemoveNode", "name", req.Name)
|
||||
|
||||
if s.network == nil {
|
||||
return nil, ErrNotBootstrapped
|
||||
@@ -1020,7 +1019,7 @@ func (s *server) RestartNode(ctx context.Context, req *rpcpb.RestartNodeRequest)
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.log.Debug("RestartNode", zap.String("name", req.Name))
|
||||
s.log.Debug("RestartNode", "name", req.Name)
|
||||
|
||||
if s.network == nil {
|
||||
return nil, ErrNotBootstrapped
|
||||
@@ -1058,7 +1057,7 @@ func (s *server) PauseNode(ctx context.Context, req *rpcpb.PauseNodeRequest) (*r
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.log.Debug("PauseNode", zap.String("name", req.Name))
|
||||
s.log.Debug("PauseNode", "name", req.Name)
|
||||
|
||||
if s.network == nil {
|
||||
return nil, ErrNotBootstrapped
|
||||
@@ -1086,7 +1085,7 @@ func (s *server) ResumeNode(ctx context.Context, req *rpcpb.ResumeNodeRequest) (
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.log.Debug("ResumeNode", zap.String("name", req.Name))
|
||||
s.log.Debug("ResumeNode", "name", req.Name)
|
||||
|
||||
if s.network == nil {
|
||||
return nil, ErrNotBootstrapped
|
||||
@@ -1125,14 +1124,14 @@ var _ router.InboundHandler = &loggingInboundHandler{}
|
||||
|
||||
type loggingInboundHandler struct {
|
||||
nodeName string
|
||||
log logging.Logger
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
func (lh *loggingInboundHandler) HandleInbound(_ context.Context, m message.InboundMessage) {
|
||||
lh.log.Debug(
|
||||
"inbound handler received a message",
|
||||
zap.String("message", m.Op().String()),
|
||||
zap.String("node-name", lh.nodeName),
|
||||
log.String("message", m.Op().String()),
|
||||
log.String("node-name", lh.nodeName),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1158,7 +1157,7 @@ func (s *server) AttachPeer(ctx context.Context, req *rpcpb.AttachPeerRequest) (
|
||||
}
|
||||
|
||||
newPeerID := newPeer.ID().String()
|
||||
s.log.Debug("new peer is attached to", zap.String("peer-ID", newPeerID), zap.String("node-name", node.GetName()))
|
||||
s.log.Debug("new peer is attached to", "peer-ID", newPeerID, "node-name", node.GetName())
|
||||
|
||||
if s.clusterInfo.AttachedPeerInfos == nil {
|
||||
s.clusterInfo.AttachedPeerInfos = make(map[string]*rpcpb.ListOfAttachedPeerInfo)
|
||||
@@ -1224,7 +1223,7 @@ func (s *server) LoadSnapshot(_ context.Context, req *rpcpb.LoadSnapshotRequest)
|
||||
}
|
||||
|
||||
pid := int32(os.Getpid())
|
||||
s.log.Info("starting", zap.Int32("pid", pid), zap.String("root-data-dir", rootDataDir))
|
||||
s.log.Info("starting", log.Int32("pid", pid), "root-data-dir", rootDataDir)
|
||||
|
||||
s.network, err = newLocalNetwork(localNetworkOptions{
|
||||
execPath: req.GetExecPath(),
|
||||
@@ -1248,7 +1247,7 @@ func (s *server) LoadSnapshot(_ context.Context, req *rpcpb.LoadSnapshotRequest)
|
||||
|
||||
// blocking load snapshot to soon get not found snapshot errors
|
||||
if err := s.network.LoadSnapshot(req.SnapshotName); err != nil {
|
||||
s.log.Warn("snapshot load failed to complete", zap.Error(err))
|
||||
s.log.Warn("snapshot load failed to complete", "error", err)
|
||||
s.stopAndRemoveNetwork(nil)
|
||||
return nil, err
|
||||
}
|
||||
@@ -1257,7 +1256,7 @@ func (s *server) LoadSnapshot(_ context.Context, req *rpcpb.LoadSnapshotRequest)
|
||||
defer cancel()
|
||||
err = s.network.AwaitHealthyAndUpdateNetworkInfo(ctx)
|
||||
if err != nil {
|
||||
s.log.Warn("snapshot load failed to complete. stopping network and cleaning up network", zap.Error(err))
|
||||
s.log.Warn("snapshot load failed to complete. stopping network and cleaning up network", "error", err)
|
||||
s.stopAndRemoveNetwork(err)
|
||||
return nil, err
|
||||
}
|
||||
@@ -1275,7 +1274,7 @@ func (s *server) SaveSnapshot(ctx context.Context, req *rpcpb.SaveSnapshotReques
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.log.Info("SaveSnapshot", zap.String("snapshot-name", req.SnapshotName))
|
||||
s.log.Info("SaveSnapshot", "snapshot-name", req.SnapshotName)
|
||||
|
||||
if s.network == nil {
|
||||
return nil, ErrNotBootstrapped
|
||||
@@ -1283,7 +1282,7 @@ func (s *server) SaveSnapshot(ctx context.Context, req *rpcpb.SaveSnapshotReques
|
||||
|
||||
snapshotPath, err := s.network.nw.SaveSnapshot(ctx, req.SnapshotName)
|
||||
if err != nil {
|
||||
s.log.Warn("snapshot save failed to complete", zap.Error(err))
|
||||
s.log.Warn("snapshot save failed to complete", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1296,14 +1295,14 @@ func (s *server) RemoveSnapshot(_ context.Context, req *rpcpb.RemoveSnapshotRequ
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.log.Info("RemoveSnapshot", zap.String("snapshot-name", req.SnapshotName))
|
||||
s.log.Info("RemoveSnapshot", "snapshot-name", req.SnapshotName)
|
||||
|
||||
if s.network == nil {
|
||||
return nil, ErrNotBootstrapped
|
||||
}
|
||||
|
||||
if err := s.network.nw.RemoveSnapshot(req.SnapshotName); err != nil {
|
||||
s.log.Warn("snapshot remove failed to complete", zap.Error(err))
|
||||
s.log.Warn("snapshot remove failed to complete", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
return &rpcpb.RemoveSnapshotResponse{}, nil
|
||||
@@ -1423,7 +1422,7 @@ func getRemoveSubnetValidatorSpec(
|
||||
}
|
||||
|
||||
func getNetworkBlockchainSpec(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
spec *rpcpb.BlockchainSpec,
|
||||
isNewEmptyNetwork bool,
|
||||
pluginDir string,
|
||||
@@ -1433,10 +1432,10 @@ func getNetworkBlockchainSpec(
|
||||
}
|
||||
|
||||
vmName := spec.VmName
|
||||
log.Info("checking custom chain's VM ID before installation", zap.String("id", vmName))
|
||||
log.Info("checking custom chain's VM ID before installation", "id", vmName)
|
||||
vmID, err := utils.VMID(vmName)
|
||||
if err != nil {
|
||||
log.Warn("failed to convert VM name to VM ID", zap.String("vm-name", vmName), zap.Error(err))
|
||||
log.Warn("failed to convert VM name to VM ID", "vm-name", vmName, "error", err)
|
||||
return network.BlockchainSpec{}, ErrInvalidVMName
|
||||
}
|
||||
|
||||
|
||||
+43
-42
@@ -27,8 +27,9 @@ import (
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/netrunner/utils/constants"
|
||||
"github.com/luxfi/netrunner/ux"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/ids"
|
||||
llog "github.com/luxfi/log"
|
||||
"github.com/luxfi/log/level"
|
||||
ginkgo "github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
@@ -109,7 +110,7 @@ func init() {
|
||||
flag.StringVar(
|
||||
&logLevel,
|
||||
"log-level",
|
||||
logging.Info.String(),
|
||||
level.Info.String(),
|
||||
"log level",
|
||||
)
|
||||
flag.StringVar(
|
||||
@@ -152,7 +153,7 @@ func init() {
|
||||
|
||||
var (
|
||||
cli client.Client
|
||||
log logging.Logger
|
||||
log llog.Logger
|
||||
)
|
||||
|
||||
var _ = ginkgo.BeforeSuite(func() {
|
||||
@@ -165,10 +166,10 @@ var _ = ginkgo.BeforeSuite(func() {
|
||||
logDir, err = utils.MkDirWithTimestamp(clientRootDir)
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
}
|
||||
lvl, err := logging.ToLevel(logLevel)
|
||||
lvl, err := llog.ToLevel(logLevel)
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
logFactory := logging.NewFactory(logging.Config{
|
||||
RotatingWriterConfig: logging.RotatingWriterConfig{
|
||||
logFactory := llog.NewFactoryWithConfig(llog.Config{
|
||||
RotatingWriterConfig: llog.RotatingWriterConfig{
|
||||
Directory: logDir,
|
||||
},
|
||||
DisplayLevel: lvl,
|
||||
@@ -190,13 +191,13 @@ var _ = ginkgo.BeforeSuite(func() {
|
||||
})
|
||||
|
||||
var _ = ginkgo.AfterSuite(func() {
|
||||
ux.Print(log, logging.Red.Wrap("shutting down cluster"))
|
||||
ux.Print(log, log.Red.Wrap("shutting down cluster"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
_, err := cli.Stop(ctx)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
|
||||
ux.Print(log, logging.Red.Wrap("shutting down client"))
|
||||
ux.Print(log, log.Red.Wrap("shutting down client"))
|
||||
err = cli.Close()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
})
|
||||
@@ -207,7 +208,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
createdBlockchainID := ""
|
||||
createdBlockchainID2 := ""
|
||||
ginkgo.By("start with blockchain specs", func() {
|
||||
ux.Print(log, logging.Green.Wrap("sending 'start' with the valid binary path: %s"), execPath1)
|
||||
ux.Print(log, log.Green.Wrap("sending 'start' with the valid binary path: %s"), execPath1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
resp, err := cli.Start(ctx, execPath1,
|
||||
client.WithPluginDir(filepath.Join(filepath.Dir(execPath1), "plugins")),
|
||||
@@ -222,11 +223,11 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
gomega.Ω(len(resp.ChainIds)).Should(gomega.Equal(1))
|
||||
createdBlockchainID = resp.ChainIds[0]
|
||||
ux.Print(log, logging.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
|
||||
ginkgo.By("can create a blockchain with a new subnet id", func() {
|
||||
ux.Print(log, logging.Blue.Wrap("can create a blockchain in a new subnet"))
|
||||
ux.Print(log, log.Blue.Wrap("can create a blockchain in a new subnet"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
resp, err := cli.CreateBlockchains(ctx,
|
||||
[]*rpcpb.BlockchainSpec{
|
||||
@@ -266,7 +267,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
})
|
||||
|
||||
ginkgo.By("can create a blockchain with an existing subnet id", func() {
|
||||
ux.Print(log, logging.Blue.Wrap("can create a blockchain in an existing subnet"))
|
||||
ux.Print(log, log.Blue.Wrap("can create a blockchain in an existing subnet"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
resp, err := cli.CreateBlockchains(ctx,
|
||||
[]*rpcpb.BlockchainSpec{
|
||||
@@ -306,7 +307,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
})
|
||||
|
||||
ginkgo.By("can create a blockchain with an existing subnet id loaded from snapshot", func() {
|
||||
ux.Print(log, logging.Blue.Wrap("can create a blockchain in an existing subnet"))
|
||||
ux.Print(log, log.Blue.Wrap("can create a blockchain in an existing subnet"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
_, err := cli.CreateBlockchains(ctx,
|
||||
[]*rpcpb.BlockchainSpec{
|
||||
@@ -322,7 +323,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
})
|
||||
|
||||
ginkgo.By("can create a blockchain with new subnet id with some of existing participating nodes", func() {
|
||||
ux.Print(log, logging.Blue.Wrap("can create a blockchain with new subnet id with some of existing participating nodes"))
|
||||
ux.Print(log, log.Blue.Wrap("can create a blockchain with new subnet id with some of existing participating nodes"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
resp, err := cli.CreateBlockchains(ctx,
|
||||
[]*rpcpb.BlockchainSpec{
|
||||
@@ -354,7 +355,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
})
|
||||
|
||||
ginkgo.By("can create a blockchain with new subnet id with some of existing participating nodes and a new node", func() {
|
||||
ux.Print(log, logging.Blue.Wrap("can create a blockchain new subnet id with some of existing participating nodes and a new node"))
|
||||
ux.Print(log, log.Blue.Wrap("can create a blockchain new subnet id with some of existing participating nodes and a new node"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
resp, err := cli.CreateBlockchains(ctx,
|
||||
[]*rpcpb.BlockchainSpec{
|
||||
@@ -547,12 +548,12 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
})
|
||||
|
||||
ginkgo.By("calling start API with the valid binary path", func() {
|
||||
ux.Print(log, logging.Green.Wrap("sending 'start' with the valid binary path: %s"), execPath1)
|
||||
ux.Print(log, log.Green.Wrap("sending 'start' with the valid binary path: %s"), execPath1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
resp, err := cli.Start(ctx, execPath1)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -568,7 +569,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
uris, err := cli.URIs(ctx)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Blue.Wrap("URIs: %s"), uris)
|
||||
ux.Print(log, log.Blue.Wrap("URIs: %s"), uris)
|
||||
})
|
||||
|
||||
ginkgo.It("can fetch status", func() {
|
||||
@@ -588,7 +589,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
ch, err := cli.StreamStatus(ctx, 5*time.Second)
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
for info := range ch {
|
||||
ux.Print(log, logging.Green.Wrap("fetched info, node-names: %s"), info.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("fetched info, node-names: %s"), info.NodeNames)
|
||||
if info.Healthy {
|
||||
break
|
||||
}
|
||||
@@ -601,7 +602,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
resp, err := cli.RemoveNode(ctx, "node5")
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("successfully removed, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully removed, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -611,7 +612,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
resp, err := cli.RestartNode(ctx, "node4", client.WithExecPath(execPath2))
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("successfully restarted, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully restarted, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -624,10 +625,10 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
|
||||
v, ok := resp.ClusterInfo.AttachedPeerInfos["node1"]
|
||||
gomega.Ω(ok).Should(gomega.BeTrue())
|
||||
ux.Print(log, logging.Green.Wrap("successfully attached peer, peers: %+v"), v.Peers)
|
||||
ux.Print(log, log.Green.Wrap("successfully attached peer, peers: %+v"), v.Peers)
|
||||
|
||||
mc, err := message.NewCreator(
|
||||
logging.NoLog{},
|
||||
log.NoLog{},
|
||||
prometheus.NewRegistry(),
|
||||
"",
|
||||
luxd_constants.DefaultNetworkCompressionType,
|
||||
@@ -655,38 +656,38 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
|
||||
ginkgo.It("can add a node", func() {
|
||||
ginkgo.By("calling AddNode", func() {
|
||||
ux.Print(log, logging.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ux.Print(log, log.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
resp, err := cli.AddNode(ctx, newNodeName, execPath1)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
|
||||
ginkgo.By("calling AddNode with existing node name, should fail", func() {
|
||||
ux.Print(log, logging.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ux.Print(log, log.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
resp, err := cli.AddNode(ctx, newNodeName, execPath1)
|
||||
cancel()
|
||||
gomega.Ω(err.Error()).Should(gomega.ContainSubstring("repeated node name"))
|
||||
gomega.Ω(resp).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("'add-node' failed as expected"))
|
||||
ux.Print(log, log.Green.Wrap("'add-node' failed as expected"))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.It("can start with custom config", func() {
|
||||
ginkgo.By("stopping network first", func() {
|
||||
ux.Print(log, logging.Red.Wrap("shutting down cluster"))
|
||||
ux.Print(log, log.Red.Wrap("shutting down cluster"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
_, err := cli.Stop(ctx)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
|
||||
ux.Print(log, logging.Red.Wrap("shutting down client"))
|
||||
ux.Print(log, log.Red.Wrap("shutting down client"))
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
})
|
||||
ginkgo.By("calling start API with custom config", func() {
|
||||
ux.Print(log, logging.Green.Wrap("sending 'start' with the valid binary path: %s"), execPath1)
|
||||
ux.Print(log, log.Green.Wrap("sending 'start' with the valid binary path: %s"), execPath1)
|
||||
opts := []client.OpOption{
|
||||
client.WithNumNodes(numNodes),
|
||||
client.WithCustomNodeConfigs(customNodeConfigs),
|
||||
@@ -695,7 +696,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
resp, err := cli.Start(ctx, execPath1, opts...)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
ginkgo.By("can wait for health", func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
@@ -704,15 +705,15 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
})
|
||||
ginkgo.By("overrides num-nodes", func() {
|
||||
ux.Print(log, logging.Green.Wrap("checking that given num-nodes %d have been overridden by custom configs: %d"), numNodes, len(customNodeConfigs))
|
||||
ux.Print(log, log.Green.Wrap("checking that given num-nodes %d have been overridden by custom configs: %d"), numNodes, len(customNodeConfigs))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
uris, err := cli.URIs(ctx)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
gomega.Ω(uris).Should(gomega.HaveLen(len(customNodeConfigs)))
|
||||
ux.Print(log, logging.Green.Wrap("expected number of nodes up: %d"), len(customNodeConfigs))
|
||||
ux.Print(log, log.Green.Wrap("expected number of nodes up: %d"), len(customNodeConfigs))
|
||||
|
||||
ux.Print(log, logging.Green.Wrap("checking correct admin APIs are enabled resp. disabled"))
|
||||
ux.Print(log, log.Green.Wrap("checking correct admin APIs are enabled resp. disabled"))
|
||||
// we have 7 nodes, 3 have the admin API enabled, the other 4 disabled
|
||||
// therefore we expect exactly 4 calls to fail and exactly 3 to succeed.
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 15*time.Second)
|
||||
@@ -751,12 +752,12 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
})
|
||||
ginkgo.It("can pause a node", func() {
|
||||
ginkgo.By("calling PauseNode", func() {
|
||||
ux.Print(log, logging.Green.Wrap("calling 'pause-node'"))
|
||||
ux.Print(log, log.Green.Wrap("calling 'pause-node'"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
resp, err := cli.PauseNode(ctx, pausedNodeName)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("successfully paused, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully paused, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
ginkgo.By("can wait for health", func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
@@ -776,7 +777,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
resp, err := cli.ResumeNode(ctx, pausedNodeName)
|
||||
cancel()
|
||||
gomega.Ω(err).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("successfully resumed %s, cluster node-names: %s"), "node1", resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully resumed %s, cluster node-names: %s"), "node1", resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
ginkgo.By("can wait for health", func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
@@ -795,7 +796,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
|
||||
ginkgo.It("can add primary validator with BLS Keys", func() {
|
||||
ginkgo.By("calling AddNode", func() {
|
||||
ux.Print(log, logging.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ux.Print(log, log.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
resp, err := cli.AddNode(ctx, newNodeName2, execPath1)
|
||||
cancel()
|
||||
@@ -805,7 +806,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
newNode2NodeID = nodeInfo.Id
|
||||
}
|
||||
}
|
||||
ux.Print(log, logging.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
ux.Print(log, log.Green.Wrap("successfully started, node-names: %s"), resp.ClusterInfo.NodeNames)
|
||||
})
|
||||
ginkgo.By("can wait for health", func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
@@ -887,13 +888,13 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
|
||||
newSubnetID = response.SubnetIds[0]
|
||||
})
|
||||
ginkgo.By("calling AddNode with existing node name, should fail", func() {
|
||||
ux.Print(log, logging.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ux.Print(log, log.Green.Wrap("calling 'add-node' with the valid binary path: %s"), execPath1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
resp, err := cli.AddNode(ctx, newParticipantNode, execPath1)
|
||||
cancel()
|
||||
gomega.Ω(err.Error()).Should(gomega.ContainSubstring("repeated node name"))
|
||||
gomega.Ω(resp).Should(gomega.BeNil())
|
||||
ux.Print(log, logging.Green.Wrap("'add-node' failed as expected"))
|
||||
ux.Print(log, log.Green.Wrap("'add-node' failed as expected"))
|
||||
})
|
||||
ginkgo.By("verify the newer subnet also has correct participants", func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
|
||||
+13
-13
@@ -6,24 +6,24 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
)
|
||||
|
||||
var supportedColors = []logging.Color{
|
||||
logging.Cyan,
|
||||
logging.LightBlue,
|
||||
logging.LightGray,
|
||||
logging.LightGreen,
|
||||
logging.LightPurple,
|
||||
logging.LightCyan,
|
||||
logging.Purple,
|
||||
logging.Yellow,
|
||||
var supportedColors = []log.Color{
|
||||
log.Cyan,
|
||||
log.LightBlue,
|
||||
log.LightGray,
|
||||
log.LightGreen,
|
||||
log.LightPurple,
|
||||
log.LightCyan,
|
||||
log.Purple,
|
||||
log.Yellow,
|
||||
}
|
||||
|
||||
// ColorPicker allows to assign a new color
|
||||
type ColorPicker interface {
|
||||
// get the next color
|
||||
NextColor() logging.Color
|
||||
NextColor() log.Color
|
||||
}
|
||||
|
||||
// colorPicker implements ColorPicker
|
||||
@@ -39,7 +39,7 @@ func NewColorPicker() *colorPicker {
|
||||
|
||||
// NextColor for a client. If all supportedColors have been assigned,
|
||||
// it starts over with the first color.
|
||||
func (c *colorPicker) NextColor() logging.Color {
|
||||
func (c *colorPicker) NextColor() log.Color {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
@@ -51,7 +51,7 @@ func (c *colorPicker) NextColor() logging.Color {
|
||||
// ColorAndPrepend reads each line from [reader], prepends it
|
||||
// with [prependText] and colors it with [color], and then prints the
|
||||
// prepended/colored line to [writer].
|
||||
func ColorAndPrepend(reader io.Reader, writer io.Writer, prependText string, color logging.Color) {
|
||||
func ColorAndPrepend(reader io.Reader, writer io.Writer, prependText string, color log.Color) {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
go func(scanner *bufio.Scanner) {
|
||||
// we should not need any go routine control here:
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
)
|
||||
|
||||
// TestColorAssignment tests that each color assignment is different and that it "wraps"
|
||||
@@ -84,7 +84,7 @@ func TestColorAndPrepend(t *testing.T) {
|
||||
}
|
||||
|
||||
// 4 is []<space>\n
|
||||
expLen := len("test") + len(color) + len(fakeNodeName) + 4 + len(logging.Reset)
|
||||
expLen := len("test") + len(color) + len(fakeNodeName) + 4 + len(log.Reset)
|
||||
if len(res) != expLen {
|
||||
t.Fatalf("expected lengh to be %d, but was %d", expLen, len(res))
|
||||
}
|
||||
|
||||
+7
-7
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
rpcb "github.com/luxfi/netrunner/rpcpb"
|
||||
"github.com/luxfi/netrunner/ux"
|
||||
"github.com/luxfi/node/ids"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/node/staking"
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -25,7 +25,7 @@ func ToNodeID(stakingKey, stakingCert []byte) (ids.NodeID, error) {
|
||||
if err != nil {
|
||||
return ids.EmptyNodeID, err
|
||||
}
|
||||
stakingCertificate := &staking.Certificate{
|
||||
stakingCertificate := &ids.Certificate{
|
||||
Raw: cert.Leaf.Raw,
|
||||
PublicKey: cert.Leaf.PublicKey,
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func MkDirWithTimestamp(dirPrefix string) (string, error) {
|
||||
}
|
||||
|
||||
func VerifySubnetHasCorrectParticipants(
|
||||
log logging.Logger,
|
||||
log log.Logger,
|
||||
subnetParticipants []string,
|
||||
cluster *rpcb.ClusterInfo,
|
||||
subnetID string,
|
||||
@@ -117,14 +117,14 @@ func VerifySubnetHasCorrectParticipants(
|
||||
}
|
||||
}
|
||||
if !nodeIsInList {
|
||||
ux.Print(log, logging.Red.Wrap(fmt.Sprintf("VerifySubnetHasCorrectParticipants: %#v", cluster)))
|
||||
ux.Print(log, logging.Red.Wrap(fmt.Sprintf("VerifySubnetHasCorrectParticipants: node not in list subnet %q node %q %v %v", subnetID, node, subnetParticipants, participatingNodeNames)))
|
||||
ux.Print(log, "VerifySubnetHasCorrectParticipants: %#v", cluster)
|
||||
ux.Print(log, "VerifySubnetHasCorrectParticipants: node not in list subnet %q node %q %v %v", subnetID, node, subnetParticipants, participatingNodeNames)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
ux.Print(log, logging.Red.Wrap("VerifySubnetHasCorrectParticipants: cluster is nil"))
|
||||
ux.Print(log, "VerifySubnetHasCorrectParticipants: cluster is nil")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,10 +5,10 @@ package ux
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/luxfi/node/utils/logging"
|
||||
"github.com/luxfi/log"
|
||||
)
|
||||
|
||||
func Print(log logging.Logger, msg string, args ...interface{}) {
|
||||
func Print(log log.Logger, msg string, args ...interface{}) {
|
||||
fmtMsg := fmt.Sprintf(msg, args...)
|
||||
log.Info(fmtMsg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user