From 50a27bdddfe86c83a61216bdd0a6b4c58313d755 Mon Sep 17 00:00:00 2001 From: brewmaster012 <88689859+brewmaster012@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:46:00 -0500 Subject: [PATCH] remove rendezvous; no longer needed as DHT is removed --- cmd/tss/main.go | 2 +- keygen/ecdsa/keygen_test.go | 4 ++-- keygen/eddsa/keygen_test.go | 4 ++-- keysign/ecdsa/keysign_old_test.go | 4 ++-- keysign/ecdsa/keysign_test.go | 4 ++-- keysign/eddsa/keysign_test.go | 4 ++-- p2p/communication.go | 5 ++--- p2p/communication_test.go | 10 +++++----- p2p/discovery_test.go | 8 ++++---- tss/tss.go | 4 ++-- tss/tss_4nodes_test.go | 2 +- tss/tss_4nodes_zeta_test.go | 2 +- 12 files changed, 26 insertions(+), 27 deletions(-) diff --git a/cmd/tss/main.go b/cmd/tss/main.go index a23c017..cd2f569 100644 --- a/cmd/tss/main.go +++ b/cmd/tss/main.go @@ -56,7 +56,7 @@ func main() { p2pConf.BootstrapPeers, p2pConf.Port, priKey, - p2pConf.RendezvousString, + baseFolder, tssConf, nil, diff --git a/keygen/ecdsa/keygen_test.go b/keygen/ecdsa/keygen_test.go index 5093a9d..56948ac 100644 --- a/keygen/ecdsa/keygen_test.go +++ b/keygen/ecdsa/keygen_test.go @@ -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 diff --git a/keygen/eddsa/keygen_test.go b/keygen/eddsa/keygen_test.go index 13e6f87..bfbb929 100644 --- a/keygen/eddsa/keygen_test.go +++ b/keygen/eddsa/keygen_test.go @@ -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 diff --git a/keysign/ecdsa/keysign_old_test.go b/keysign/ecdsa/keysign_old_test.go index 4211a27..d4a5381 100644 --- a/keysign/ecdsa/keysign_old_test.go +++ b/keysign/ecdsa/keysign_old_test.go @@ -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 diff --git a/keysign/ecdsa/keysign_test.go b/keysign/ecdsa/keysign_test.go index a8bf7af..344f644 100644 --- a/keysign/ecdsa/keysign_test.go +++ b/keysign/ecdsa/keysign_test.go @@ -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 diff --git a/keysign/eddsa/keysign_test.go b/keysign/eddsa/keysign_test.go index 5697a00..82cb406 100644 --- a/keysign/eddsa/keysign_test.go +++ b/keysign/eddsa/keysign_test.go @@ -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 diff --git a/p2p/communication.go b/p2p/communication.go index 42f81e9..3b9ee64 100644 --- a/p2p/communication.go +++ b/p2p/communication.go @@ -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 @@ -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) @@ -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, diff --git a/p2p/communication_test.go b/p2p/communication_test.go index 9d77c40..bdf4014 100644 --- a/p2p/communication_test.go +++ b/p2p/communication_test.go @@ -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)) @@ -47,7 +47,7 @@ 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) @@ -55,7 +55,7 @@ func (CommunicationTestSuite) TestEstablishP2pCommunication(c *C) { 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) @@ -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) diff --git a/p2p/discovery_test.go b/p2p/discovery_test.go index 409e1e2..3810d01 100644 --- a/p2p/discovery_test.go +++ b/p2p/discovery_test.go @@ -22,7 +22,7 @@ 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() @@ -30,7 +30,7 @@ func TestDiscovery(t *testing.T) { 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) @@ -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() @@ -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) diff --git a/tss/tss.go b/tss/tss.go index 81cb280..024b849 100644 --- a/tss/tss.go +++ b/tss/tss.go @@ -53,7 +53,7 @@ func NewTss( cmdBootstrapPeers []maddr.Multiaddr, p2pPort int, priKey tcrypto.PrivKey, - rendezvous, + baseFolder string, conf common.TssConfig, preParams *bkeygen.LocalPreParams, @@ -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) } diff --git a/tss/tss_4nodes_test.go b/tss/tss_4nodes_test.go index be58e52..773471f 100644 --- a/tss/tss_4nodes_test.go +++ b/tss/tss_4nodes_test.go @@ -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 } diff --git a/tss/tss_4nodes_zeta_test.go b/tss/tss_4nodes_zeta_test.go index 208b1c8..29a34e4 100644 --- a/tss/tss_4nodes_zeta_test.go +++ b/tss/tss_4nodes_zeta_test.go @@ -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 }