Skip to content

Commit

Permalink
remove rendezvous; no longer needed as DHT is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
brewmaster012 committed Oct 25, 2024
1 parent 7e55943 commit 50a27bd
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmd/tss/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
p2pConf.BootstrapPeers,
p2pConf.Port,
priKey,
p2pConf.RendezvousString,

baseFolder,
tssConf,
nil,
Expand Down
4 changes: 2 additions & 2 deletions keygen/ecdsa/keygen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ func (s *TssECDSAKeygenTestSuite) SetUpTest(c *C) {
buf, err := base64.StdEncoding.DecodeString(testPriKeyArr[i])
c.Assert(err, IsNil)
if i == 0 {
comm, err := p2p.NewCommunication("asgard", nil, ports[i], "")
comm, err := p2p.NewCommunication(nil, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf[:]), IsNil)
s.comms[i] = comm
continue
}
comm, err := p2p.NewCommunication("asgard", []maddr.Multiaddr{multiAddr}, ports[i], "")
comm, err := p2p.NewCommunication([]maddr.Multiaddr{multiAddr}, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf[:]), IsNil)
s.comms[i] = comm
Expand Down
4 changes: 2 additions & 2 deletions keygen/eddsa/keygen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ func (s *EddsaKeygenTestSuite) SetUpTest(c *C) {
buf, err := base64.StdEncoding.DecodeString(testPriKeyArr[i])
c.Assert(err, IsNil)
if i == 0 {
comm, err := p2p.NewCommunication("asgard", nil, ports[i], "")
comm, err := p2p.NewCommunication(nil, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
continue
}
comm, err := p2p.NewCommunication("asgard", []maddr.Multiaddr{multiAddr}, ports[i], "")
comm, err := p2p.NewCommunication([]maddr.Multiaddr{multiAddr}, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
Expand Down
4 changes: 2 additions & 2 deletions keysign/ecdsa/keysign_old_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ func (s *TssECDSAKeysignOldTestSuite) SetUpTest(c *C) {
buf, err := base64.StdEncoding.DecodeString(testPriKeyArr[i])
c.Assert(err, IsNil)
if i == 0 {
comm, err := p2p.NewCommunication("asgard", nil, ports[i], "")
comm, err := p2p.NewCommunication(nil, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
continue
}
comm, err := p2p.NewCommunication("asgard", []maddr.Multiaddr{multiAddr}, ports[i], "")
comm, err := p2p.NewCommunication([]maddr.Multiaddr{multiAddr}, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
Expand Down
4 changes: 2 additions & 2 deletions keysign/ecdsa/keysign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ func (s *TssECDSAKeysignTestSuite) SetUpTest(c *C) {
buf, err := base64.StdEncoding.DecodeString(testPriKeyArr[i])
c.Assert(err, IsNil)
if i == 0 {
comm, err := p2p.NewCommunication("asgard", nil, ports[i], "")
comm, err := p2p.NewCommunication(nil, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
continue
}
comm, err := p2p.NewCommunication("asgard", []maddr.Multiaddr{multiAddr}, ports[i], "")
comm, err := p2p.NewCommunication([]maddr.Multiaddr{multiAddr}, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
Expand Down
4 changes: 2 additions & 2 deletions keysign/eddsa/keysign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ func (s *EddsaKeysignTestSuite) SetUpTest(c *C) {
buf, err := base64.StdEncoding.DecodeString(testPriKeyArr[i])
c.Assert(err, IsNil)
if i == 0 {
comm, err := p2p.NewCommunication("asgard", nil, ports[i], "")
comm, err := p2p.NewCommunication(nil, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
continue
}
comm, err := p2p.NewCommunication("asgard", []maddr.Multiaddr{multiAddr}, ports[i], "")
comm, err := p2p.NewCommunication([]maddr.Multiaddr{multiAddr}, ports[i], "")
c.Assert(err, IsNil)
c.Assert(comm.Start(buf), IsNil)
s.comms[i] = comm
Expand Down
5 changes: 2 additions & 3 deletions p2p/communication.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type Message struct {

// Communication use p2p to broadcast messages among all the TSS nodes
type Communication struct {
rendezvous string // based on group
bootstrapPeers []maddr.Multiaddr
logger zerolog.Logger
listenAddr maddr.Multiaddr
Expand All @@ -62,7 +61,7 @@ type Communication struct {
}

// NewCommunication create a new instance of Communication
func NewCommunication(rendezvous string, bootstrapPeers []maddr.Multiaddr, port int, externalIP string) (*Communication, error) {
func NewCommunication(bootstrapPeers []maddr.Multiaddr, port int, externalIP string) (*Communication, error) {
addr, err := maddr.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port))
if err != nil {
return nil, fmt.Errorf("fail to create listen addr: %w", err)
Expand All @@ -75,7 +74,7 @@ func NewCommunication(rendezvous string, bootstrapPeers []maddr.Multiaddr, port
}
}
return &Communication{
rendezvous: rendezvous,

bootstrapPeers: bootstrapPeers,
logger: log.With().Str("module", "communication").Logger(),
listenAddr: addr,
Expand Down
10 changes: 5 additions & 5 deletions p2p/communication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type CommunicationTestSuite struct{}
var _ = Suite(&CommunicationTestSuite{})

func (CommunicationTestSuite) TestBasicCommunication(c *C) {
comm, err := NewCommunication("rendezvous", nil, 6668, "")
comm, err := NewCommunication(nil, 6668, "")
c.Assert(err, IsNil)
c.Assert(comm, NotNil)
comm.SetSubscribe(messages.TSSKeyGenMsg, "hello", make(chan *Message))
Expand Down Expand Up @@ -47,15 +47,15 @@ func (CommunicationTestSuite) TestEstablishP2pCommunication(c *C) {
c.Assert(err, IsNil)
privKey, err := base64.StdEncoding.DecodeString(bootstrapPrivKey)
c.Assert(err, IsNil)
comm, err := NewCommunication("commTest", nil, 2220, fakeExternalIP)
comm, err := NewCommunication(nil, 2220, fakeExternalIP)
c.Assert(err, IsNil)
c.Assert(comm.Start(privKey), IsNil)

defer comm.Stop()
sk1, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
sk1raw, _ := sk1.Raw()
c.Assert(err, IsNil)
comm2, err := NewCommunication("commTest", []maddr.Multiaddr{validMultiAddr}, 2221, "")
comm2, err := NewCommunication([]maddr.Multiaddr{validMultiAddr}, 2221, "")
c.Assert(err, IsNil)
err = comm2.Start(sk1raw)
c.Assert(err, IsNil)
Expand All @@ -69,14 +69,14 @@ func (CommunicationTestSuite) TestEstablishP2pCommunication(c *C) {
invalidAddr := "/ip4/127.0.0.1/tcp/2220/p2p/" + id.String()
invalidMultiAddr, err := maddr.NewMultiaddr(invalidAddr)
c.Assert(err, IsNil)
comm3, err := NewCommunication("commTest", []maddr.Multiaddr{invalidMultiAddr}, 2222, "")
comm3, err := NewCommunication([]maddr.Multiaddr{invalidMultiAddr}, 2222, "")
c.Assert(err, IsNil)
err = comm3.Start(sk1raw)
c.Assert(err, ErrorMatches, "fail to connect to bootstrap peer: fail to connect to any peer")
defer comm3.Stop()

// we connect to one invalid and one valid address
comm4, err := NewCommunication("commTest", []maddr.Multiaddr{invalidMultiAddr, validMultiAddr}, 2223, "")
comm4, err := NewCommunication([]maddr.Multiaddr{invalidMultiAddr, validMultiAddr}, 2223, "")
c.Assert(err, IsNil)
err = comm4.Start(sk1raw)
c.Assert(err, IsNil)
Expand Down
8 changes: 4 additions & 4 deletions p2p/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ func TestDiscovery(t *testing.T) {

privKey, err := base64.StdEncoding.DecodeString(bootstrapPrivKey)
assert.NoError(t, err)
comm, err := NewCommunication("commTest", nil, 2220, externalIP)
comm, err := NewCommunication(nil, 2220, externalIP)
assert.NoError(t, err)
assert.NoError(t, comm.Start(privKey))
defer comm.Stop()

sk1, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
sk1raw, _ := sk1.Raw()
assert.NoError(t, err)
comm2, err := NewCommunication("commTest", []maddr.Multiaddr{validMultiAddr}, 2221, externalIP)
comm2, err := NewCommunication([]maddr.Multiaddr{validMultiAddr}, 2221, externalIP)
assert.NoError(t, err)
err = comm2.Start(sk1raw)
assert.NoError(t, err)
Expand All @@ -45,7 +45,7 @@ func TestDiscovery(t *testing.T) {
//invalidAddr := "/ip4/127.0.0.1/tcp/2220/p2p/" + id.String()
//invalidMultiAddr, err := maddr.NewMultiaddr(invalidAddr)
assert.NoError(t, err)
comm3, err := NewCommunication("commTest", []maddr.Multiaddr{validMultiAddr}, 2222, externalIP)
comm3, err := NewCommunication([]maddr.Multiaddr{validMultiAddr}, 2222, externalIP)
assert.NoError(t, err)
err = comm3.Start(sk2raw)
defer comm3.Stop()
Expand All @@ -54,7 +54,7 @@ func TestDiscovery(t *testing.T) {
sk3, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
assert.NoError(t, err)
sk3raw, _ := sk3.Raw()
comm4, err := NewCommunication("commTest", []maddr.Multiaddr{validMultiAddr}, 2223, externalIP)
comm4, err := NewCommunication([]maddr.Multiaddr{validMultiAddr}, 2223, externalIP)
assert.NoError(t, err)
err = comm4.Start(sk3raw)
assert.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions tss/tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewTss(
cmdBootstrapPeers []maddr.Multiaddr,
p2pPort int,
priKey tcrypto.PrivKey,
rendezvous,

baseFolder string,
conf common.TssConfig,
preParams *bkeygen.LocalPreParams,
Expand Down Expand Up @@ -83,7 +83,7 @@ func NewTss(
bootstrapPeers = savedPeers
bootstrapPeers = append(bootstrapPeers, cmdBootstrapPeers...)
}
comm, err := p2p.NewCommunication(rendezvous, bootstrapPeers, p2pPort, externalIP)
comm, err := p2p.NewCommunication(bootstrapPeers, p2pPort, externalIP)
if err != nil {
return nil, fmt.Errorf("fail to create communication layer: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion tss/tss_4nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (s *FourNodeTestSuite) getTssServer(c *C, index int, conf common.TssConfig,
} else {
peerIDs = nil
}
instance, err := NewTss(peerIDs, s.ports[index], priKey, "Asgard", baseHome, conf, s.preParams[index], "", "password")
instance, err := NewTss(peerIDs, s.ports[index], priKey, baseHome, conf, s.preParams[index], "", "password")
c.Assert(err, IsNil)
return instance
}
Expand Down
2 changes: 1 addition & 1 deletion tss/tss_4nodes_zeta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (s *FourNodeScaleZetaSuite) getTssServer(c *C, index int, conf common.TssCo
} else {
peerIDs = nil
}
instance, err := NewTss(peerIDs, s.ports[index], priKey, "Zeta", baseHome, conf, s.preParams[index], "", "password")
instance, err := NewTss(peerIDs, s.ports[index], priKey, baseHome, conf, s.preParams[index], "", "password")
c.Assert(err, IsNil)
return instance
}

0 comments on commit 50a27bd

Please sign in to comment.