Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove redialing #842

Merged
merged 45 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1806be6
Remove redialing of transport
i-hate-nicknames Jul 8, 2021
b19b8e6
Fix panics when transport is closed
i-hate-nicknames Jul 8, 2021
8ba1738
Refactor managed transport Serve
i-hate-nicknames Jul 8, 2021
745ea4e
Force sorted edge order in transport entry
i-hate-nicknames Jul 8, 2021
68b3129
Remove up/down transport status
i-hate-nicknames Jul 9, 2021
dd734ef
Remove closed transports in transport manager
i-hate-nicknames Jul 9, 2021
764f34a
Move raw address to network.Conn
i-hate-nicknames Jul 9, 2021
738454c
Simplify dial logic
i-hate-nicknames Jul 9, 2021
8016a92
Delete entry instead of updating status
i-hate-nicknames Jul 9, 2021
f1b5ea0
Fix visor cli transport print
i-hate-nicknames Jul 9, 2021
afc7945
Add persistent transports todo
i-hate-nicknames Jul 9, 2021
edfb6b2
Add heartbeat loop
i-hate-nicknames Jul 9, 2021
43ac032
Merge branch 'develop' into feature/remove-redialing
i-hate-nicknames Jul 27, 2021
d94386e
Send heartbeat request in transport
i-hate-nicknames Jul 27, 2021
f9092b9
Remove transport status
i-hate-nicknames Jul 27, 2021
657734d
Fix linter errors
i-hate-nicknames Jul 28, 2021
6b35e2f
Remove transport entry with status
i-hate-nicknames Jul 28, 2021
9b76a8b
Fix visor cli transports
i-hate-nicknames Jul 28, 2021
300b9c8
Add persistent transports config
i-hate-nicknames Jul 29, 2021
8ed6bfb
Make lint and format
i-hate-nicknames Jul 29, 2021
876f9f3
Fix deadlocks in transport layer
i-hate-nicknames Jul 30, 2021
f84dc64
Relax locking when saving transport
i-hate-nicknames Aug 3, 2021
964e0a6
Add transport connection deadline
i-hate-nicknames Aug 3, 2021
88d397b
Fix transport manager shutdown logic
i-hate-nicknames Aug 3, 2021
c7e14a8
Simplify transport manager closing
i-hate-nicknames Aug 3, 2021
039d017
Merge branch 'develop' into feature/remove-redialing
i-hate-nicknames Aug 3, 2021
21db980
Remove isPublic transport entry field
i-hate-nicknames Aug 4, 2021
11fdf3f
Fix NPE for transport handshake
i-hate-nicknames Aug 5, 2021
1116d80
Code review fixes
i-hate-nicknames Aug 6, 2021
6b8741b
Update heartbeat interval
ersonp Aug 12, 2021
a565ce3
Update comment
ersonp Aug 12, 2021
d18e26c
Remove updateConnDeadline
ersonp Aug 12, 2021
ed0ee66
Rename Conn interface to Transport
ersonp Aug 12, 2021
816474b
Remove EntryWithStatus
ersonp Aug 16, 2021
21cadd8
Add Deprecated Public field to Entry struct
ersonp Aug 16, 2021
c04c889
Make public true
ersonp Aug 17, 2021
3514308
Update and add todo
ersonp Aug 17, 2021
651520a
Remove old todo
ersonp Aug 19, 2021
0a0d5c2
Remove public field from Entry struct
ersonp Aug 20, 2021
8a3c6d8
Rename PersistentRemote to PersistentTransports
ersonp Aug 20, 2021
1b580f4
Requested changes
ersonp Aug 20, 2021
7cd8f5c
Add api for persistent_transports
ersonp Aug 20, 2021
6431095
Add persistent_transports to summary
ersonp Aug 23, 2021
1b8e547
Remove GetPersistentTransports api
ersonp Aug 23, 2021
c8e2a62
Merge branch 'develop' into feature/remove-redialing
ersonp Aug 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions cmd/skywire-cli/commands/visor/transports.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ var addTpCmd = &cobra.Command{
logger.WithError(err).Fatalf("Failed to establish %v transport", transportType)
}

if !tp.IsUp {
logger.Fatalf("Established %v transport to %v with ID %v, but it isn't up", transportType, pk, tp.ID)
}

logger.Infof("Established %v transport to %v", transportType, pk)
} else {
transportTypes := []network.Type{
Expand Down Expand Up @@ -148,14 +144,14 @@ var rmTpCmd = &cobra.Command{
func printTransports(tps ...*visor.TransportSummary) {
sortTransports(tps...)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 5, ' ', tabwriter.TabIndent)
_, err := fmt.Fprintln(w, "type\tid\tremote\tmode\tlabel\tis_up")
_, err := fmt.Fprintln(w, "type\tid\tremote\tmode\tlabel")
internal.Catch(err)
for _, tp := range tps {
tpMode := "regular"
if tp.IsSetup {
tpMode = "setup"
}
_, err = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%v\n", tp.Type, tp.ID, tp.Remote, tpMode, tp.Label, tp.IsUp)
_, err = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", tp.Type, tp.ID, tp.Remote, tpMode, tp.Label)
internal.Catch(err)
}
internal.Catch(w.Flush())
Expand Down
17 changes: 1 addition & 16 deletions pkg/servicedisc/autoconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (a *autoconnector) Run(ctx context.Context) error {
a.log.Errorf("Cannot fetch public services: %s", err)
}

tps := a.updateTransports()
tps := a.tm.GetTransportsByLabel(transport.LabelAutomatic)
absent := a.filterDuplicates(addresses, tps)
for _, pk := range absent {
a.log.WithField("pk", pk).Infoln("Adding transport to public visor")
Expand All @@ -69,21 +69,6 @@ func (a *autoconnector) Run(ctx context.Context) error {
}
}

// Remove all inactive automatic transports and return all active
// automatic transports
func (a *autoconnector) updateTransports() []*transport.ManagedTransport {
tps := a.tm.GetTransportsByLabel(transport.LabelAutomatic)
var tpsActive []*transport.ManagedTransport
for _, tr := range tps {
if !tr.IsUp() {
a.tm.DeleteTransport(tr.Entry.ID)
} else {
tpsActive = append(tpsActive, tr)
}
}
return tpsActive
}

func (a *autoconnector) fetchPubAddresses(ctx context.Context) ([]cipher.PubKey, error) {
retrier := netutil.NewRetrier(fetchServicesDelay, 0, 2)
var services []Service
Expand Down
1 change: 0 additions & 1 deletion pkg/transport/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type DiscoveryClient interface {
GetTransportByID(ctx context.Context, id uuid.UUID) (*EntryWithStatus, error)
GetTransportsByEdge(ctx context.Context, pk cipher.PubKey) ([]*EntryWithStatus, error)
DeleteTransport(ctx context.Context, id uuid.UUID) error
UpdateStatuses(ctx context.Context, statuses ...*Status) ([]*EntryWithStatus, error)
Health(ctx context.Context) (int, error)
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/transport/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@ func TestNewDiscoveryMock(t *testing.T) {
entriesWS, err := dc.GetTransportsByEdge(context.TODO(), pk1)
require.NoError(t, err)
require.Equal(t, entry.Edges, entriesWS[0].Entry.Edges)

_, err = dc.UpdateStatuses(context.TODO(), &transport.Status{})
require.NoError(t, err)
}
13 changes: 6 additions & 7 deletions pkg/transport/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Entry struct {
ID uuid.UUID `json:"t_id"`

// Edges contains the public keys of the Transport's edge nodes
// (should only have 2 edges and the first edge is transport original initiator).
// Edges should always be sorted in ascending order
Edges [2]cipher.PubKey `json:"edges"`

// Type represents the transport type.
Expand All @@ -50,15 +50,14 @@ type Entry struct {
}

// MakeEntry creates a new transport entry
func MakeEntry(initiator, target cipher.PubKey, netType network.Type, public bool, label Label) Entry {
func MakeEntry(aPK, bPK cipher.PubKey, netType network.Type, public bool, label Label) Entry {
entry := Entry{
ID: MakeTransportID(initiator, target, netType),
ID: MakeTransportID(aPK, bPK, netType),
Type: netType,
Public: public,
Label: label,
Edges: SortEdges(aPK, bPK),
}
entry.Edges[0] = initiator
entry.Edges[1] = target
return entry
}

Expand Down Expand Up @@ -105,8 +104,8 @@ func (e *Entry) String() string {
res += fmt.Sprintf("\ttype: %s\n", e.Type)
res += fmt.Sprintf("\tid: %s\n", e.ID)
res += "\tedges:\n"
res += fmt.Sprintf("\t\tedge 1 (initiator): %s\n", e.Edges[0])
res += fmt.Sprintf("\t\tedge 2 (target): %s\n", e.Edges[1])
res += fmt.Sprintf("\t\tedge 1: %s\n", e.Edges[0])
res += fmt.Sprintf("\t\tedge 2: %s\n", e.Edges[1])
return res
}

Expand Down
13 changes: 5 additions & 8 deletions pkg/transport/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ const (
responseInvalidEntry
)

func makeEntryFromTpConn(conn network.Conn, isInitiator bool) Entry {
initiator, target := conn.LocalPK(), conn.RemotePK()
if !isInitiator {
initiator, target = target, initiator
}
return MakeEntry(initiator, target, conn.Network(), true, LabelUser)
func makeEntryFromTpConn(conn network.Conn) Entry {
aPK, bPK := conn.LocalPK(), conn.RemotePK()
return MakeEntry(aPK, bPK, conn.Network(), true, LabelUser)
}

func compareEntries(expected, received *Entry) error {
Expand Down Expand Up @@ -99,7 +96,7 @@ func (hs SettlementHS) Do(ctx context.Context, dc DiscoveryClient, conn network.
func MakeSettlementHS(init bool) SettlementHS {
// initiating logic.
initHS := func(ctx context.Context, dc DiscoveryClient, conn network.Conn, sk cipher.SecKey) (err error) {
entry := makeEntryFromTpConn(conn, true)
entry := makeEntryFromTpConn(conn)

// TODO(evanlinjin): Probably not needed as this is called in mTp already. Need to double check.
ersonp marked this conversation as resolved.
Show resolved Hide resolved
//defer func() {
Expand Down Expand Up @@ -139,7 +136,7 @@ func MakeSettlementHS(init bool) SettlementHS {

// responding logic.
respHS := func(ctx context.Context, dc DiscoveryClient, conn network.Conn, sk cipher.SecKey) error {
entry := makeEntryFromTpConn(conn, false)
entry := makeEntryFromTpConn(conn)

// receive, verify and sign entry.
recvSE, err := receiveAndVerifyEntry(conn, &entry, conn.RemotePK())
Expand Down
Loading