From e5597650760f74219527c542e9c2feb9a2b9899f Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 11 Dec 2024 11:17:30 +0200 Subject: [PATCH 1/2] remove extra substrate connection from rmb --- rmb-sdk-go/peer/peer.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/rmb-sdk-go/peer/peer.go b/rmb-sdk-go/peer/peer.go index 47c932bf2..0f185e352 100644 --- a/rmb-sdk-go/peer/peer.go +++ b/rmb-sdk-go/peer/peer.go @@ -229,12 +229,6 @@ func NewPeer( if !bytes.Equal(twin.E2EKey, publicKey) || twin.Relay == nil || joinURLs != *twin.Relay { log.Info().Str("Relay url/s", joinURLs).Msg("twin relay/public key didn't match, updating on chain ...") - subConn, err := subManager.Substrate() - if err != nil { - return nil, errors.Wrap(err, "could not start substrate connection") - } - defer subConn.Close() - if _, err = subConn.UpdateTwin(identity, joinURLs, publicKey); err != nil { return nil, errors.Wrap(err, "could not update twin relay information") } From 4c02a35b98149b036ae75c5624926d26c3a97562 Mon Sep 17 00:00:00 2001 From: Eslam-Nawara Date: Wed, 11 Dec 2024 13:44:35 +0200 Subject: [PATCH 2/2] remove extra substrate connection from mon-bot --- monitoring-bot/internal/monitor.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/monitoring-bot/internal/monitor.go b/monitoring-bot/internal/monitor.go index f8aea9311..d0cc5f35a 100644 --- a/monitoring-bot/internal/monitor.go +++ b/monitoring-bot/internal/monitor.go @@ -17,11 +17,14 @@ import ( "github.com/cosmos/go-bip39" "github.com/rs/zerolog/log" client "github.com/threefoldtech/tfchain/clients/tfchain-client-go" + substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go" "github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go/peer" ) -type address string -type network string +type ( + address string + network string +) type config struct { testMnemonic string `env:"TESTNET_MNEMONIC"` @@ -364,7 +367,8 @@ func (m *Monitor) systemVersion(ctx context.Context) (map[network]version, map[n for _, NodeID := range randomNodes { log.Debug().Msgf("check node %d", NodeID) - ver, working, failed, err := m.checkNodeSystemVersion(ctx, NodeID, network) + ver, working, failed, err := m.checkNodeSystemVersion(ctx, con, NodeID, network) + failedNodes[network] = append(failedNodes[network], failed...) if err != nil { log.Error().Err(err).Msgf("check node %d failed", NodeID) @@ -379,18 +383,12 @@ func (m *Monitor) systemVersion(ctx context.Context) (map[network]version, map[n return versions, workingNodes, failedNodes } -func (m *Monitor) checkNodeSystemVersion(ctx context.Context, NodeID uint32, net network) (version, []uint32, []uint32, error) { +func (m *Monitor) checkNodeSystemVersion(ctx context.Context, con *substrate.Substrate, NodeID uint32, net network) (version, []uint32, []uint32, error) { const cmd = "zos.system.version" var ver version var workingNodes []uint32 var failedNodes []uint32 - con, err := m.managers[net].Substrate() - if err != nil { - return version{}, []uint32{}, []uint32{}, fmt.Errorf("substrate connection for %v network failed with error: %w", NodeID, err) - } - defer con.Close() - node, err := con.GetNode(NodeID) if err != nil { failedNodes = append(failedNodes, NodeID)