diff --git a/Makefile b/Makefile index fb2bc5744b7d3be16e7818df83dcce7fc260d3d3..86491db6d4e21f04eabcc8c459b22012d683b24e 100644 --- a/Makefile +++ b/Makefile @@ -20,14 +20,12 @@ build: update_release: GOFLAGS="" go get -u gitlab.com/elixxir/primitives@release - GOFLAGS="" go get -u gitlab.com/xx_network/primitives@release GOFLAGS="" go get -u gitlab.com/elixxir/crypto@release GOFLAGS="" go get -u gitlab.com/xx_network/comms@release GOFLAGS="" go get -u gitlab.com/elixxir/comms@release update_master: GOFLAGS="" go get -u gitlab.com/elixxir/primitives@master - GOFLAGS="" go get -u gitlab.com/xx_network/primitives@master GOFLAGS="" go get -u gitlab.com/elixxir/crypto@master GOFLAGS="" go get -u gitlab.com/xx_network/comms@master GOFLAGS="" go get -u gitlab.com/elixxir/comms@master diff --git a/cmd/bannedNodeTracker_test.go b/cmd/bannedNodeTracker_test.go index d663202710f4c0391937f8a85e6247ffb950b97c..dc278f5e9c38c6ccb3f2cb444c959393b1ec753e 100644 --- a/cmd/bannedNodeTracker_test.go +++ b/cmd/bannedNodeTracker_test.go @@ -9,10 +9,10 @@ import ( "crypto/rand" "fmt" "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/primitives/id" + "gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" - "gitlab.com/xx_network/primitives/ndf" "sync" "testing" ) diff --git a/cmd/impl.go b/cmd/impl.go index f845823f3095e4ebf9a6f78e253ff03be50aec99..94c060bd15d1354565f1a56b5e287ec79e3c3333 100644 --- a/cmd/impl.go +++ b/cmd/impl.go @@ -16,13 +16,13 @@ import ( "gitlab.com/elixxir/comms/registration" "gitlab.com/elixxir/crypto/signature/rsa" "gitlab.com/elixxir/crypto/tls" + "gitlab.com/elixxir/primitives/id" + "gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/primitives/version" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" - "gitlab.com/xx_network/primitives/ndf" "sync" "time" ) @@ -302,11 +302,11 @@ func NewImplementation(instance *RegistrationImpl) *registration.Implementation return response, err } - impl.Functions.RegisterNode = func(ID *id.ID, ServerAddr, ServerTlsCert, - GatewayAddr, GatewayTlsCert, RegistrationCode string) error { + impl.Functions.RegisterNode = func(salt []byte, serverAddr, serverTlsCert, gatewayAddr, + gatewayTlsCert, registrationCode string) error { - err := instance.RegisterNode(ID, ServerAddr, - ServerTlsCert, GatewayAddr, GatewayTlsCert, RegistrationCode) + err := instance.RegisterNode(salt, serverAddr, serverTlsCert, gatewayAddr, + gatewayTlsCert, registrationCode) if err != nil { jww.ERROR.Printf("RegisterNode error: %+v", err) } diff --git a/cmd/permissioning.go b/cmd/permissioning.go index e2071710d01039358ef295d425ce1cf427a198b8..97bc377972cbc3872ab1a2a54b9c380897702f5b 100644 --- a/cmd/permissioning.go +++ b/cmd/permissioning.go @@ -10,14 +10,18 @@ package cmd import ( "bytes" + gorsa "crypto/rsa" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/comms/mixmessages" + "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/crypto/tls" + "gitlab.com/elixxir/crypto/xx" + "gitlab.com/elixxir/primitives/id" + "gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" - "gitlab.com/xx_network/primitives/ndf" "strconv" "sync/atomic" ) @@ -45,8 +49,8 @@ func (m *RegistrationImpl) CheckNodeRegistration(msg *mixmessages.RegisteredNode return false, nil } - // If the node's id is not empty, then the node has been registered - if !bytes.Equal(nodeInfo.Id, []byte("")) { + // If the node's ID and Salt are not empty, then the node has been registered + if !bytes.Equal(nodeInfo.Id, []byte("")) && len(nodeInfo.Salt) > 0 { return true, nil } @@ -56,45 +60,71 @@ func (m *RegistrationImpl) CheckNodeRegistration(msg *mixmessages.RegisteredNode } // Handle registration attempt by a Node -func (m *RegistrationImpl) RegisterNode(ID *id.ID, ServerAddr, ServerTlsCert, - GatewayAddr, GatewayTlsCert, RegistrationCode string) error { +func (m *RegistrationImpl) RegisterNode(salt []byte, serverAddr, serverTlsCert, gatewayAddr, + gatewayTlsCert, registrationCode string) error { // Check that the node hasn't already been registered - nodeInfo, err := storage.PermissioningDb.GetNode(RegistrationCode) + nodeInfo, err := storage.PermissioningDb.GetNode(registrationCode) if err != nil { return errors.Errorf( - "Registration code %+v is invalid or not currently enabled: %+v", RegistrationCode, err) + "Registration code %+v is invalid or not currently enabled: %+v", registrationCode, err) } - if !bytes.Equal(nodeInfo.Id, []byte("")) { - return errors.Errorf( - "Node with registration code %+v has already been registered", RegistrationCode) + // Generate the Node ID + tlsCert, err := tls.LoadCertificate(serverTlsCert) + if err != nil { + return errors.Errorf("Could not decode server certificate into a tls cert: %v", err) + } + nodePubKey := &rsa.PublicKey{PublicKey: *tlsCert.PublicKey.(*gorsa.PublicKey)} + if len(salt) > 32 { + salt = salt[:32] + } + nodeId, err := xx.NewID(nodePubKey, salt, id.Node) + if err != nil { + return errors.Errorf("Unable to generate Node ID with salt %v: %+v", salt, err) + } + + // Handle various re-registration cases + if len(nodeInfo.Id) != 0 { + + // Ensure that generated ID matches stored ID + // Ensure that salt is not already stored + if !bytes.Equal(nodeInfo.Id, nodeId.Marshal()) { + return errors.Errorf("Submitted salt %+v does not match stored salt: %+v", salt, nodeInfo.Salt) + + } else if len(nodeInfo.Salt) != 0 { + return errors.Errorf( + "Node with registration code %s has already been registered", registrationCode) + } + + // Store the newly-provided salt + return storage.PermissioningDb.UpdateSalt(nodeId, salt) } // Attempt to insert Node into the database - err = storage.PermissioningDb.RegisterNode(ID, RegistrationCode, ServerAddr, - ServerTlsCert, GatewayAddr, GatewayTlsCert) + err = storage.PermissioningDb.RegisterNode(nodeId, salt, registrationCode, serverAddr, + serverTlsCert, gatewayAddr, gatewayTlsCert) if err != nil { return errors.Errorf("unable to insert node: %+v", err) } jww.DEBUG.Printf("Inserted node %s into the database with code %s", - ID.String(), RegistrationCode) + nodeId.String(), registrationCode) //add the node to the host object for authenticated communications - _, err = m.Comms.AddHost(ID, ServerAddr, []byte(ServerTlsCert), false, true) + _, err = m.Comms.AddHost(nodeId, serverAddr, []byte(serverTlsCert), false, true) if err != nil { - return errors.Errorf("Could not register host for Server %s: %+v", ServerAddr, err) + return errors.Errorf("Could not register host for Server %s: %+v", serverAddr, err) } //add the node to the node map to track its state - err = m.State.GetNodeMap().AddNode(ID, nodeInfo.Sequence, ServerAddr, GatewayAddr, nodeInfo.ApplicationId) + err = m.State.GetNodeMap().AddNode(nodeId, nodeInfo.Sequence, serverAddr, gatewayAddr, nodeInfo.ApplicationId) if err != nil { return errors.WithMessage(err, "Could not register node with "+ "state tracker") } // Notify registration thread - return m.completeNodeRegistration(RegistrationCode) + return m.completeNodeRegistration(registrationCode) } // Loads all registered nodes and puts them into the host object and node map. diff --git a/cmd/permissioning_test.go b/cmd/permissioning_test.go index d7707ac4933f57094b7150c2339cf899bfeb7561..eda3286f79611d71d5ad475812f503a0d399e2c9 100644 --- a/cmd/permissioning_test.go +++ b/cmd/permissioning_test.go @@ -1,11 +1,11 @@ package cmd import ( + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/testkeys" - "gitlab.com/xx_network/primitives/id" "testing" "time" ) @@ -34,7 +34,7 @@ func TestLoadAllRegisteredNodes(t *testing.T) { // Create a new ID and store a new active node into the database activeNodeId := id.NewIdFromUInt(0, id.Node, t) - err = storage.PermissioningDb.RegisterNode(activeNodeId, "AAAA", "0.0.0.0", string(crt), + err = storage.PermissioningDb.RegisterNode(activeNodeId, []byte("test"), "AAAA", "0.0.0.0", string(crt), "0.0.0.0", string(crt)) if err != nil { t.Error(err) @@ -42,7 +42,7 @@ func TestLoadAllRegisteredNodes(t *testing.T) { // Create a new ID and store a new *banned* node into the database bannedNodeId := id.NewIdFromUInt(1, id.Node, t) - err = storage.PermissioningDb.RegisterNode(bannedNodeId, "BBBB", "0.0.0.0", string(crt), + err = storage.PermissioningDb.RegisterNode(bannedNodeId, []byte("test"), "BBBB", "0.0.0.0", string(crt), "0.0.0.0", string(crt)) if err != nil { t.Error(err) diff --git a/cmd/poll.go b/cmd/poll.go index 08cf1fed9a019ece5d2d087f89e933225bcef46d..0ef11287b980f787d9b8d6fc8b6f73f8a3279c06 100644 --- a/cmd/poll.go +++ b/cmd/poll.go @@ -15,11 +15,11 @@ import ( pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/crypto/signature" "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" + "gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/primitives/version" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" - "gitlab.com/xx_network/primitives/ndf" "net" "sync/atomic" ) diff --git a/cmd/poll_test.go b/cmd/poll_test.go index c90f7dbc9027b770fa34483acee3e3342e5288ab..96bd32d7f9f107a01548d97c6c533ba6ff880df6 100644 --- a/cmd/poll_test.go +++ b/cmd/poll_test.go @@ -14,6 +14,8 @@ import ( "gitlab.com/elixxir/crypto/signature" "gitlab.com/elixxir/crypto/signature/rsa" "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" + "gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/primitives/version" @@ -22,8 +24,6 @@ import ( "gitlab.com/elixxir/registration/storage/round" "gitlab.com/elixxir/registration/testkeys" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" - "gitlab.com/xx_network/primitives/ndf" "sync" "sync/atomic" "testing" @@ -226,31 +226,33 @@ func TestRegistrationImpl_PollNdf(t *testing.T) { impl, err := StartRegistration(RegParams, nil) if err != nil { t.Errorf(err.Error()) + return } + defer impl.Comms.Shutdown() var l sync.Mutex go func() { l.Lock() defer l.Unlock() - fmt.Println("A") //Register 1st node - err = impl.RegisterNode(id.NewIdFromString("B", id.Node, t), + testSalt := []byte("testtesttesttesttesttesttesttest") + testSalt2 := []byte("testtesttesttesttesttesttesttesc") + testSalt3 := []byte("testtesttesttesttesttesttesttesd") + err = impl.RegisterNode(testSalt, nodeAddr, string(nodeCert), "0.0.0.0:7900", string(gatewayCert), "BBBB") if err != nil { t.Errorf("Expected happy path, recieved error: %+v", err) } - fmt.Println("B") //Register 2nd node - err = impl.RegisterNode(id.NewIdFromString("C", id.Node, t), + err = impl.RegisterNode(testSalt2, "0.0.0.0:6901", string(nodeCert), "0.0.0.0:7901", string(gatewayCert), "CCCC") if err != nil { t.Errorf("Expected happy path, recieved error: %+v", err) } - fmt.Println("C") //Register 3rd node - err = impl.RegisterNode(id.NewIdFromString("D", id.Node, t), + err = impl.RegisterNode(testSalt3, "0.0.0.0:6902", string(nodeCert), "0.0.0.0:7902", string(gatewayCert), "DDDD") if err != nil { @@ -258,9 +260,6 @@ func TestRegistrationImpl_PollNdf(t *testing.T) { } }() - expectedNodeIDs := []*id.ID{id.NewIdFromString("B", id.Node, t), - id.NewIdFromString("C", id.Node, t), id.NewIdFromString("D", id.Node, t)} - //wait for registration to complete select { case <-time.NewTimer(1000 * time.Millisecond).C: @@ -292,17 +291,6 @@ func TestRegistrationImpl_PollNdf(t *testing.T) { t.Errorf("Failed to set registration address. Expected: %v \n Recieved: %v", permAddr, observedNDF.Registration.Address) } - - for i := range observedNDF.Nodes { - if bytes.Compare(expectedNodeIDs[i].Bytes(), - observedNDF.Nodes[i].ID) != 0 { - t.Errorf("Could not build node %d's id id: Expected: %v \nRecieved: %v", i, - expectedNodeIDs[i].String(), observedNDF.Nodes[i].ID) - } - } - - //Shutdown node comms - impl.Comms.Shutdown() } //Error path @@ -333,9 +321,12 @@ func TestRegistrationImpl_PollNdf_NoNDF(t *testing.T) { t.Errorf(err.Error()) return } + //Shutdown registration + defer impl.Comms.Shutdown() //Register 1st node - err = impl.RegisterNode(id.NewIdFromString("B", id.Node, t), nodeAddr, string(nodeCert), + testSalt := []byte("testtesttesttesttesttesttesttest") + err = impl.RegisterNode(testSalt, nodeAddr, string(nodeCert), "0.0.0.0:7900", string(gatewayCert), "BBBB") if err != nil { t.Errorf("Expected happy path, recieved error: %+v", err) @@ -351,9 +342,6 @@ func TestRegistrationImpl_PollNdf_NoNDF(t *testing.T) { if err != nil && err.Error() != ndf.NO_NDF { t.Errorf("Expected correct error message: %+v", err) } - - //Shutdown registration - impl.Comms.Shutdown() } func TestPoll_BannedNode(t *testing.T) { @@ -374,6 +362,7 @@ func TestPoll_BannedNode(t *testing.T) { if err != nil { t.Errorf("Unable to start registration: %+v", err) } + defer impl.Comms.Shutdown() atomic.CompareAndSwapUint32(impl.NdfReady, 0, 1) err = impl.State.UpdateNdf(&ndf.NetworkDefinition{ diff --git a/cmd/registration_test.go b/cmd/registration_test.go index c513f97d6ae9c1282b82cac971059a414bc4424f..6959c6b4c6f8839252ea5f430303d8fe732a182f 100644 --- a/cmd/registration_test.go +++ b/cmd/registration_test.go @@ -10,12 +10,12 @@ import ( jww "github.com/spf13/jwalterweatherman" pb "gitlab.com/elixxir/comms/mixmessages" nodeComms "gitlab.com/elixxir/comms/node" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/primitives/version" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/testkeys" - "gitlab.com/xx_network/primitives/id" "os" "sync" "testing" @@ -109,7 +109,7 @@ func TestEmptyDataBase(t *testing.T) { } //using node cert as gateway cert - err = impl.RegisterNode(id.NewIdFromString("test", id.Node, t), nodeAddr, string(nodeCert), + err = impl.RegisterNode([]byte("test"), nodeAddr, string(nodeCert), nodeAddr, string(nodeCert), "AAA") if err == nil { expectedErr := "Unable to insert node: unable to register node AAA" @@ -126,7 +126,9 @@ func TestRegCodeExists_InsertRegCode(t *testing.T) { impl, err := StartRegistration(testParams, nil) if err != nil { t.Errorf(err.Error()) + return } + defer impl.Comms.Shutdown() dblck.Lock() defer dblck.Unlock() @@ -149,14 +151,12 @@ func TestRegCodeExists_InsertRegCode(t *testing.T) { t.Errorf("Failed to insert client reg code %+v", err) } //Register a node with that regCode - err = impl.RegisterNode(id.NewIdFromString("test", id.Node, t), nodeAddr, string(nodeCert), + testSalt := []byte("testtesttesttesttesttesttesttest") + err = impl.RegisterNode(testSalt, nodeAddr, string(nodeCert), nodeAddr, string(nodeCert), newNode.Code) if err != nil { t.Errorf("Registered a node with a known reg code, but recieved the following error: %+v", err) } - - //Kill the connections for the next test - impl.Comms.Shutdown() } //Happy Path: Insert a reg code along with a node @@ -218,11 +218,14 @@ func TestCompleteRegistration_HappyPath(t *testing.T) { impl, err := StartRegistration(localParams, nil) if err != nil { t.Errorf(err.Error()) + return } + defer impl.Comms.Shutdown() RegParams = testParams go func() { - err = impl.RegisterNode(id.NewIdFromString("test", id.Node, t), "0.0.0.0:6900", string(nodeCert), + testSalt := []byte("testtesttesttesttesttesttesttest") + err = impl.RegisterNode(testSalt, "0.0.0.0:6900", string(nodeCert), "0.0.0.0:6900", string(nodeCert), "BBBB") if err != nil { t.Errorf("Expected happy path, recieved error: %+v", err) @@ -236,10 +239,6 @@ func TestCompleteRegistration_HappyPath(t *testing.T) { t.FailNow() case <-impl.beginScheduling: } - - fmt.Println("DONE!") - //Kill the connections for the next test - impl.Comms.Shutdown() } //Error path: test that trying to register with the same reg code fails @@ -269,23 +268,22 @@ func TestDoubleRegistration(t *testing.T) { t.Errorf(err.Error()) return } + defer impl.Comms.Shutdown() //Create a second node to register nodeComm2 := nodeComms.StartNode(&id.TempGateway, "0.0.0.0:6901", nodeComms.NewImplementation(), nodeCert, nodeKey) - + defer nodeComm2.Shutdown() //Register 1st node - err = impl.RegisterNode(id.NewIdFromBytes([]byte("test"), t), nodeAddr, string(nodeCert), + testSalt := []byte("testtesttesttesttesttesttesttest") + err = impl.RegisterNode(testSalt, nodeAddr, string(nodeCert), nodeAddr, string(nodeCert), "BBBB") if err != nil { t.Errorf("Expected happy path, recieved error: %+v", err) } //Register 2nd node - err = impl.RegisterNode(id.NewIdFromBytes([]byte("B"), t), "0.0.0.0:6901", string(nodeCert), + err = impl.RegisterNode(testSalt, "0.0.0.0:6901", string(nodeCert), "0.0.0.0:6901", string(nodeCert), "BBBB") - //Kill the connections for the next test - nodeComm2.Shutdown() - impl.Comms.Shutdown() if err != nil { return } @@ -321,14 +319,18 @@ func TestTopology_MultiNodes(t *testing.T) { impl, err := StartRegistration(localParams, nil) if err != nil { t.Errorf(err.Error()) + return } + defer impl.Comms.Shutdown() //Create a second node to register nodeComm2 := nodeComms.StartNode(&id.TempGateway, "0.0.0.0:6901", nodeComms.NewImplementation(), nodeCert, nodeKey) - + //Kill the connections for the next test + defer nodeComm2.Shutdown() go func() { + testSalt := []byte("testtesttesttesttesttesttesttest") //Register 1st node - err = impl.RegisterNode(id.NewIdFromString("A", id.Node, t), + err = impl.RegisterNode(testSalt, nodeAddr, string(nodeCert), nodeAddr, string(nodeCert), "BBBB") if err != nil { @@ -336,7 +338,7 @@ func TestTopology_MultiNodes(t *testing.T) { } //Register 2nd node - err = impl.RegisterNode(id.NewIdFromString("B", id.Node, t), + err = impl.RegisterNode(testSalt, "0.0.0.0:6901", string(gatewayCert), "0.0.0.0:6901", string(gatewayCert), "CCCC") if err != nil { @@ -350,10 +352,6 @@ func TestTopology_MultiNodes(t *testing.T) { t.FailNow() case <-impl.beginScheduling: } - - //Kill the connections for the next test - nodeComm2.Shutdown() - impl.Comms.Shutdown() } // Happy path @@ -393,7 +391,7 @@ func TestRegistrationImpl_CheckNodeRegistration(t *testing.T) { testNodeID := id.NewIdFromString("A", id.Node, t) //Register 1st node - err = impl.RegisterNode(testNodeID, + err = impl.RegisterNode(testNodeID.Marshal(), nodeAddr, string(nodeCert), nodeAddr, string(nodeCert), "BBBB") if err != nil { @@ -407,8 +405,8 @@ func TestRegistrationImpl_CheckNodeRegistration(t *testing.T) { // Check if node that has been registered is registered isRegistered, _ := impl.CheckNodeRegistration(registrationMessage) - if !isRegistered { - t.Errorf("Registration code should have been registered!") + if isRegistered { + t.Errorf("Registration code should have been registered due to missing salt!") } // Craft unregistered node id @@ -464,7 +462,7 @@ func TestCheckRegistration_NilMsg(t *testing.T) { testNodeID := id.NewIdFromString("A", id.Node, t) //Register 1st node - err = impl.RegisterNode(testNodeID, + err = impl.RegisterNode(testNodeID.Marshal(), nodeAddr, string(nodeCert), nodeAddr, string(nodeCert), "BBBB") if err != nil { @@ -514,7 +512,7 @@ func TestCheckRegistration_InvalidID(t *testing.T) { testNodeID := id.NewIdFromString("A", id.Node, t) //Register 1st node - err = impl.RegisterNode(testNodeID, + err = impl.RegisterNode(testNodeID.Marshal(), nodeAddr, string(nodeCert), nodeAddr, string(nodeCert), "BBBB") if err != nil { @@ -547,7 +545,6 @@ func TestRegistrationImpl_GetCurrentClientVersion(t *testing.T) { if ver != testVersion { t.Errorf("Version was %+v, expected %+v", ver, testVersion) } - } // Test a case that should pass validation @@ -647,4 +644,6 @@ func TestRegCodeExists_RegUser_Timer(t *testing.T) { if err != nil { t.Errorf("Failed to register a user when it should have worked: %+v", err) } + + impl.Comms.Shutdown() } diff --git a/cmd/version_vars.go b/cmd/version_vars.go index 989fc65035110b00a15ea9a983332956394ec88e..fd0261273bf6233986deba1f983502d8160c09cf 100644 --- a/cmd/version_vars.go +++ b/cmd/version_vars.go @@ -1,9 +1,9 @@ // Code generated by go generate; DO NOT EDIT. // This file was generated by robots at -// 2020-08-05 08:56:49.022216 -0700 PDT m=+0.021882636 +// 2020-08-20 16:26:36.154485 -0500 CDT m=+0.016064374 package cmd -const GITVERSION = `9e69ec3 run make release` +const GITVERSION = `54df81c fix tests` const SEMVER = "1.4.0" const DEPENDENCIES = `module gitlab.com/elixxir/registration @@ -30,11 +30,10 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.0 - gitlab.com/elixxir/comms v0.0.0-20200805155232-35bd8b06f2fb - gitlab.com/elixxir/crypto v0.0.0-20200804231945-1354885c51cd - gitlab.com/elixxir/primitives v0.0.0-20200804231232-ad79a9e8f113 - gitlab.com/xx_network/comms v0.0.0-20200805155312-9a2642a3574b - gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da + gitlab.com/elixxir/comms v0.0.0-20200820212104-7d54af613a75 + gitlab.com/elixxir/crypto v0.0.0-20200731174640-0503cf80524a + gitlab.com/elixxir/primitives v0.0.0-20200708185800-a06e961280e6 + gitlab.com/xx_network/comms v0.0.0-20200820210701-016f5017b13c ) replace ( diff --git a/go.mod b/go.mod index 175a1bc93deaa5f2c19060ce3bde0b6184a67702..33aeb2dd367baf5e8c3a9da620152a66c1ed8771 100644 --- a/go.mod +++ b/go.mod @@ -23,14 +23,12 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.0 - gitlab.com/elixxir/comms v0.0.0-20200805155232-35bd8b06f2fb - gitlab.com/elixxir/crypto v0.0.0-20200804231945-1354885c51cd - gitlab.com/elixxir/primitives v0.0.0-20200804231232-ad79a9e8f113 - gitlab.com/xx_network/comms v0.0.0-20200805155312-9a2642a3574b - gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da + gitlab.com/elixxir/comms v0.0.0-20200820212104-7d54af613a75 + gitlab.com/elixxir/crypto v0.0.0-20200731174640-0503cf80524a + gitlab.com/elixxir/primitives v0.0.0-20200708185800-a06e961280e6 + gitlab.com/xx_network/comms v0.0.0-20200820210701-016f5017b13c ) replace ( - gitlab.com/xx_network/collections/ring => gitlab.com/xx_network/collections/ring.git v0.0.1 google.golang.org/grpc => github.com/grpc/grpc-go v1.27.1 ) diff --git a/go.sum b/go.sum index e2b734bd344dd6aa7b6e47694f2ef0d87810c050..d8e1453ba4228b18c67646e9de7404ed0b0882a0 100644 --- a/go.sum +++ b/go.sum @@ -263,29 +263,17 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1 github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/zeebo/assert v0.0.0-20181109011804-10f827ce2ed6/go.mod h1:yssERNPivllc1yU3BvpjYI5BUW+zglcz6QWqeVRL5t0= -github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= -github.com/zeebo/blake3 v0.0.4/go.mod h1:YOZo8A49yNqM0X/Y+JmDUZshJWLt1laHsNSn5ny2i34= -github.com/zeebo/pcg v0.0.0-20181207190024-3cdc6b625a05/go.mod h1:Gr+78ptB0MwXxm//LBaEvBiaXY7hXJ6KGe2V32X2F6E= -gitlab.com/elixxir/comms v0.0.0-20200805155232-35bd8b06f2fb h1:ZOHIR4liBQ3TVp5AxIm4RQ/6WPEDnFrz95npg6rBtw4= -gitlab.com/elixxir/comms v0.0.0-20200805155232-35bd8b06f2fb/go.mod h1:Wc6fZyP/M4sBjnzb9pRScLeqwMOCv6DRXoTOd07bO3g= -gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= -gitlab.com/elixxir/crypto v0.0.0-20200804231945-1354885c51cd h1:3Kd2+8eftJ/Y0f2QxUtCw74bKkzSBLNivQ0NVXpjPtg= -gitlab.com/elixxir/crypto v0.0.0-20200804231945-1354885c51cd/go.mod h1:cu6uNoANVLV0J6HyTL6KqVtVyh9SHU1RjJhytYlsbVQ= -gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d h1:OKWTmYN5q8XVHo8JXThIH0TCuvl/fLXR7MGVacpqfRg= -gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= -gitlab.com/elixxir/primitives v0.0.0-20200804170709-a1896d262cd9/go.mod h1:p0VelQda72OzoUckr1O+vPW0AiFe0nyKQ6gYcmFSuF8= -gitlab.com/elixxir/primitives v0.0.0-20200804182913-788f47bded40/go.mod h1:tzdFFvb1ESmuTCOl1z6+yf6oAICDxH2NPUemVgoNLxc= -gitlab.com/elixxir/primitives v0.0.0-20200804231232-ad79a9e8f113 h1:66qCDQobeKqfiuFjzWaMysJxa58AedSj6X2o/TCLaqU= -gitlab.com/elixxir/primitives v0.0.0-20200804231232-ad79a9e8f113/go.mod h1:tzdFFvb1ESmuTCOl1z6+yf6oAICDxH2NPUemVgoNLxc= -gitlab.com/xx_network/comms v0.0.0-20200804225654-09a9af23d699/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw= -gitlab.com/xx_network/comms v0.0.0-20200805155312-9a2642a3574b h1:SV36Ie0WOBEgIU7cS7D7TFyY/CBJDxTdS7upQoG8RT8= -gitlab.com/xx_network/comms v0.0.0-20200805155312-9a2642a3574b/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw= -gitlab.com/xx_network/primitives v0.0.0-20200803231956-9b192c57ea7c/go.mod h1:wtdCMr7DPePz9qwctNoAUzZtbOSHSedcK++3Df3psjA= -gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da h1:CCVslUwNC7Ul7NG5nu3ThGTSVUt1TxNRX+47f5TUwnk= -gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug= -gitlab.com/xx_network/ring v0.0.2 h1:TlPjlbFdhtJrwvRgIg4ScdngMTaynx/ByHBRZiXCoL0= -gitlab.com/xx_network/ring v0.0.2/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM= +gitlab.com/elixxir/comms v0.0.0-20200707210150-b8ebd0951d23/go.mod h1:OsWMZ1O/R9fOkm+PoHnR3rkXfFtipGoPs73FuKuurHY= +gitlab.com/elixxir/comms v0.0.0-20200820212104-7d54af613a75 h1:yng9GhldVufuAKycKLmqUmSvm8uAr841/Dmi5azTi8s= +gitlab.com/elixxir/comms v0.0.0-20200820212104-7d54af613a75/go.mod h1:VtMYqSprauTHtbeLchSoUdABX0LD6vR7khlYaREQejU= +gitlab.com/elixxir/crypto v0.0.0-20200707005343-97f868cbd930/go.mod h1:LHBAaEf48a0/AjU118rjoworH0LgXifhAqmNX3ZRvME= +gitlab.com/elixxir/crypto v0.0.0-20200731174640-0503cf80524a h1:peZpulfSqLSceA5ovtzQ5MPgQt4YbJY8FzpV2S2Nrhc= +gitlab.com/elixxir/crypto v0.0.0-20200731174640-0503cf80524a/go.mod h1:LHBAaEf48a0/AjU118rjoworH0LgXifhAqmNX3ZRvME= +gitlab.com/elixxir/primitives v0.0.0-20200706165052-9fe7a4fb99a3/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= +gitlab.com/elixxir/primitives v0.0.0-20200708185800-a06e961280e6 h1:7xLD8w5qAKN1YqG2UiMiN3rODUACyQME83uDlVhvWLo= +gitlab.com/elixxir/primitives v0.0.0-20200708185800-a06e961280e6/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= +gitlab.com/xx_network/comms v0.0.0-20200820210701-016f5017b13c h1:EHyp6GAXuT0/P3R9+9yUEaw0A8BZcSIC2Tfow11//ew= +gitlab.com/xx_network/comms v0.0.0-20200820210701-016f5017b13c/go.mod h1:J+GJ6fn71a4xnYVvbcrhtvWSOQIqqhaGcaej5xB3/JY= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= @@ -336,6 +324,7 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -358,7 +347,6 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -410,6 +398,7 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200514193133-8feb7f20f2a2/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200709005830-7a2ca40e9dc3 h1:JwLN1jVnmIsfE4HkDVe2AblFAbo0Z+4cjteDSOnv6oE= diff --git a/scheduling/nodeStateChange.go b/scheduling/nodeStateChange.go index a33a52ef09a18dc85a5da208aeab95284392496e..710f250473c81e0e2d99b5c55d85ddc4ed4cc845 100644 --- a/scheduling/nodeStateChange.go +++ b/scheduling/nodeStateChange.go @@ -13,11 +13,11 @@ import ( pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/crypto/signature" "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/storage/round" - "gitlab.com/xx_network/primitives/id" "time" ) diff --git a/scheduling/nodeStateChange_test.go b/scheduling/nodeStateChange_test.go index 8c0a06f1cc347d600e3b341ff359cc6c1f4c0818..4456b3d08ab039967369d68c23949919d9db987f 100644 --- a/scheduling/nodeStateChange_test.go +++ b/scheduling/nodeStateChange_test.go @@ -10,11 +10,11 @@ import ( "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/crypto/signature/rsa" "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/storage/round" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" "strconv" "testing" "time" diff --git a/scheduling/params.go b/scheduling/params.go index 556dee4fa6bd7c349d3394c807d207dad97342c0..04c9b8d538d8fcbdbc443d226cf750668e8ef4a5 100644 --- a/scheduling/params.go +++ b/scheduling/params.go @@ -8,9 +8,9 @@ package scheduling // Contains the scheduling params object and the internal protoround object import ( + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" "time" ) diff --git a/scheduling/pool_test.go b/scheduling/pool_test.go index 84cc9ff137cfdbba937b90e2f22e892e4c145df5..636a2e40d3cd707242924f1ab69d2c87fd974294 100644 --- a/scheduling/pool_test.go +++ b/scheduling/pool_test.go @@ -9,9 +9,9 @@ import ( "crypto/rand" "github.com/golang-collections/collections/set" "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "reflect" "testing" "time" diff --git a/scheduling/roundTracker.go b/scheduling/roundTracker.go index e8b43de4cf5476d0ff2b6b2607183cdac2e254c6..b7f2ca8a314e915fc5dcf12d1988a45c930e6437 100644 --- a/scheduling/roundTracker.go +++ b/scheduling/roundTracker.go @@ -9,7 +9,7 @@ package scheduling import ( - "gitlab.com/xx_network/primitives/id" + "gitlab.com/elixxir/primitives/id" "sync" ) diff --git a/scheduling/roundTracker_test.go b/scheduling/roundTracker_test.go index 3019fee382aa80eb62486c98ecf4545861bfda02..a7272026a9452a02146b8c1095773dea35c9725b 100644 --- a/scheduling/roundTracker_test.go +++ b/scheduling/roundTracker_test.go @@ -7,7 +7,7 @@ package scheduling import ( - "gitlab.com/xx_network/primitives/id" + "gitlab.com/elixxir/primitives/id" "math/rand" "reflect" "testing" diff --git a/scheduling/schedule.go b/scheduling/schedule.go index 1395b203160a084834de856493f372b732b3da43..689fe02518870feb12d94d2ea4578ecab221dec8 100644 --- a/scheduling/schedule.go +++ b/scheduling/schedule.go @@ -12,10 +12,10 @@ import ( jww "github.com/spf13/jwalterweatherman" pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/crypto/signature" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "sync/atomic" "time" ) diff --git a/scheduling/schedule_test.go b/scheduling/schedule_test.go index c3811e94bbdaf3e217ba228b7265f6c0fcbb33bf..4a7a91b27e346cdc6e26c81d54833d8f408d65a7 100644 --- a/scheduling/schedule_test.go +++ b/scheduling/schedule_test.go @@ -4,11 +4,11 @@ import ( "encoding/json" "gitlab.com/elixxir/crypto/signature/rsa" "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/testkeys" - "gitlab.com/xx_network/primitives/id" "reflect" "strconv" "testing" diff --git a/scheduling/secureCreateRound.go b/scheduling/secureCreateRound.go index 42165c011424a3404d5b05e838386dfadade244e..80ded9b90a6b1f163a516f46a3edd4ffe28ec4b2 100644 --- a/scheduling/secureCreateRound.go +++ b/scheduling/secureCreateRound.go @@ -3,10 +3,10 @@ package scheduling import ( "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" "time" ) diff --git a/scheduling/secureCreateRound_test.go b/scheduling/secureCreateRound_test.go index 5fa5490070f7fa73c5198e74a488aae2668fd6d4..a87922240054a09204c496c4d699ba7d96933985 100644 --- a/scheduling/secureCreateRound_test.go +++ b/scheduling/secureCreateRound_test.go @@ -4,9 +4,9 @@ import ( "crypto/rand" "fmt" "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" mathRand "math/rand" "strconv" diff --git a/scheduling/simpleCreateRound.go b/scheduling/simpleCreateRound.go index a1ebd85986c0029f4ab16c8a434c309a4253a9f1..7ff99eb91efa355297574c6537df0a3333e20fa9 100644 --- a/scheduling/simpleCreateRound.go +++ b/scheduling/simpleCreateRound.go @@ -8,10 +8,10 @@ package scheduling import ( "github.com/pkg/errors" "gitlab.com/elixxir/crypto/shuffle" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" "strconv" ) diff --git a/scheduling/simpleCreateRound_test.go b/scheduling/simpleCreateRound_test.go index ea6041cf8ae763cfd1fe9098921f1f6e7ac2041e..9f7ac12b16d38a9089fcefce6a5a1a4bc3bba119 100644 --- a/scheduling/simpleCreateRound_test.go +++ b/scheduling/simpleCreateRound_test.go @@ -8,10 +8,10 @@ package scheduling import ( "crypto/rand" "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" mathRand "math/rand" "reflect" "strconv" diff --git a/scheduling/startRound_test.go b/scheduling/startRound_test.go index 4ccf45bad4ae48a026c61425d7f27d15b52fee4a..df86282cc0e6407d6ffe5276ab75f73086c41b2e 100644 --- a/scheduling/startRound_test.go +++ b/scheduling/startRound_test.go @@ -8,11 +8,11 @@ package scheduling import ( "crypto/rand" "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/registration/storage" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/storage/round" - "gitlab.com/xx_network/primitives/id" "testing" ) diff --git a/storage/database.go b/storage/database.go index 99280e4ad15bf25c934c09a950f413d1b3136beb..a009257e10e0d5514da387d584edf55600069f64 100644 --- a/storage/database.go +++ b/storage/database.go @@ -13,8 +13,8 @@ import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "sync" "time" ) @@ -41,8 +41,10 @@ var PermissioningDb Storage type NodeRegistration interface { // If Node registration code is valid, add Node information - RegisterNode(id *id.ID, code, serverAddr, serverCert, + RegisterNode(id *id.ID, salt []byte, code, serverAddr, serverCert, gatewayAddress, gatewayCert string) error + // Update the Salt for a given Node ID + UpdateSalt(id *id.ID, salt []byte) error // Get Node information for the given Node registration code GetNode(code string) (*Node, error) // Get Node information for the given Node ID @@ -132,6 +134,8 @@ type Node struct { // Unique Node ID Id []byte `gorm:"UNIQUE_INDEX;default: null"` + // Salt used for generation of Node ID + Salt []byte // Server IP address ServerAddress string // Gateway IP address diff --git a/storage/disabledNodes.go b/storage/disabledNodes.go index 5e33537625ed896fee8d8b7f95665d5e480b27ad..1605c207cf91041546d1d26417bac64a34cbb573 100644 --- a/storage/disabledNodes.go +++ b/storage/disabledNodes.go @@ -14,9 +14,9 @@ import ( "github.com/golang-collections/collections/set" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "strings" "sync" "time" diff --git a/storage/disabledNodes_test.go b/storage/disabledNodes_test.go index f7aef1b2770b29e69deae104bb69b52d3117e74c..c4ec03c4dfefc0541beab48d942b725489f55eae 100644 --- a/storage/disabledNodes_test.go +++ b/storage/disabledNodes_test.go @@ -9,9 +9,9 @@ package storage import ( "crypto/rand" "github.com/golang-collections/collections/set" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "os" "reflect" "strings" diff --git a/storage/node/map.go b/storage/node/map.go index 31e05b6093eec3d2af3210551b4c30e4ea221345..de356cdbd366f0a0ab0a76ff8183d46a6186f90e 100644 --- a/storage/node/map.go +++ b/storage/node/map.go @@ -9,7 +9,7 @@ package node import ( "errors" "gitlab.com/elixxir/primitives/current" - "gitlab.com/xx_network/primitives/id" + "gitlab.com/elixxir/primitives/id" "sync" "time" ) diff --git a/storage/node/map_test.go b/storage/node/map_test.go index e082ee1151946fe9d4b10b9f09cb3abd7dbeefb7..e806a88411787512a997387981174eade09dfa74 100644 --- a/storage/node/map_test.go +++ b/storage/node/map_test.go @@ -8,8 +8,8 @@ package node import ( "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage/round" - "gitlab.com/xx_network/primitives/id" "math/rand" "strings" "testing" diff --git a/storage/node/state.go b/storage/node/state.go index e2624925f451081e983289e2ee2c01bab46893bf..06fd2a0445ab2ad29f99c305e51f0e2eb1d9b3a9 100644 --- a/storage/node/state.go +++ b/storage/node/state.go @@ -9,10 +9,10 @@ package node import ( "github.com/pkg/errors" "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/registration/storage/round" "gitlab.com/elixxir/registration/transition" - "gitlab.com/xx_network/primitives/id" "sync" "sync/atomic" "testing" diff --git a/storage/node/state_test.go b/storage/node/state_test.go index 8dc88476b161d87c264fd1a94cc0bc6d76ac694f..c44fb15bfe986316cfdec99d7896d97fae32027b 100644 --- a/storage/node/state_test.go +++ b/storage/node/state_test.go @@ -8,9 +8,9 @@ package node import ( "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/registration/storage/round" - "gitlab.com/xx_network/primitives/id" "math" "reflect" "strings" diff --git a/storage/node/updateNotification.go b/storage/node/updateNotification.go index 5cc000a9ef94872c1cb61d9f88a65118f5c57d3e..6a939df7b9b3f8fa1ca205a6bd076621d6657cdc 100644 --- a/storage/node/updateNotification.go +++ b/storage/node/updateNotification.go @@ -10,7 +10,7 @@ package node import ( "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/primitives/current" - "gitlab.com/xx_network/primitives/id" + "gitlab.com/elixxir/primitives/id" ) // UpdateNotification structure used to notify the control thread that the diff --git a/storage/permissioningDb.go b/storage/permissioningDb.go index 8950ddf2e81a869336be3c9f3b17d0e85bf5c1cb..c6ed67c164ea1737a172444b73ed04ca7ea730ce 100644 --- a/storage/permissioningDb.go +++ b/storage/permissioningDb.go @@ -11,8 +11,8 @@ package storage import ( "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "time" ) @@ -60,12 +60,21 @@ func (m *DatabaseImpl) InsertRoundMetric(metric *RoundMetric, topology [][]byte) return m.db.Create(metric).Error } +// Update the Salt for a given Node ID +func (m *DatabaseImpl) UpdateSalt(id *id.ID, salt []byte) error { + newNode := Node{ + Salt: salt, + } + return m.db.First(&newNode, "id = ?", id.Marshal()).Update("salt", salt).Error +} + // If Node registration code is valid, add Node information -func (m *DatabaseImpl) RegisterNode(id *id.ID, code, serverAddr, serverCert, +func (m *DatabaseImpl) RegisterNode(id *id.ID, salt []byte, code, serverAddr, serverCert, gatewayAddress, gatewayCert string) error { newNode := Node{ Code: code, Id: id.Marshal(), + Salt: salt, ServerAddress: serverAddr, GatewayAddress: gatewayAddress, NodeCertificate: serverCert, diff --git a/storage/permissioningMap.go b/storage/permissioningMap.go index bd350aa4eaf51fb1bd2b3d053158b5d081ef40db..7ea0fac7b1c5fb34f64b1ef2df6c8ec57a1da1e9 100644 --- a/storage/permissioningMap.go +++ b/storage/permissioningMap.go @@ -12,8 +12,8 @@ import ( "bytes" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "testing" ) @@ -99,8 +99,22 @@ func (m *MapImpl) InsertRoundMetric(metric *RoundMetric, topology [][]byte) erro return nil } +// Update the Salt for a given Node ID +func (m *MapImpl) UpdateSalt(id *id.ID, salt []byte) error { + n, err := m.GetNodeById(id) + if err != nil { + return err + } + + m.mut.Lock() + defer m.mut.Unlock() + n.Salt = salt + + return nil +} + // If Node registration code is valid, add Node information -func (m *MapImpl) RegisterNode(id *id.ID, code, serverAddress, serverCert, +func (m *MapImpl) RegisterNode(id *id.ID, salt []byte, code, serverAddress, serverCert, gatewayAddress, gatewayCert string) error { m.mut.Lock() defer m.mut.Unlock() @@ -108,6 +122,7 @@ func (m *MapImpl) RegisterNode(id *id.ID, code, serverAddress, serverCert, jww.INFO.Printf("Attempting to register node with code: %s", code) if info := m.nodes[code]; info != nil { info.Id = id.Marshal() + info.Salt = salt info.ServerAddress = serverAddress info.GatewayCertificate = gatewayCert info.GatewayAddress = gatewayAddress diff --git a/storage/permissioningMap_test.go b/storage/permissioningMap_test.go index 69bbe77eb055cff09c0d5c5cd300c0ebbb497dd7..8fbe4a2cec3a929ed6b3116f97c02bdb95fa134d 100644 --- a/storage/permissioningMap_test.go +++ b/storage/permissioningMap_test.go @@ -7,12 +7,55 @@ package storage import ( + "bytes" + "crypto/rand" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/registration/storage/node" - "gitlab.com/xx_network/primitives/id" "testing" "time" ) +// Hidden function for one-time unit testing database implementation +//func TestDatabaseImpl(t *testing.T) { +// db, _, err := NewDatabase("cmix", "", "cmix_server", "0.0.0.0", "5432") +// if err != nil { +// t.Errorf(err.Error()) +// return +// } +// +// testCode := "test" +// testId := id.NewIdFromString(testCode, id.Node, t) +// testAppId := uint64(10010) +// newApp := &Application{ +// Id: testAppId, +// Node: Node{}, +// Name: testCode, +// } +// newNode := &Node{ +// Code: testCode, +// Sequence: testCode, +// Status: 0, +// ApplicationId: testAppId, +// } +// +// err = db.InsertApplication(newApp, newNode) +// if err != nil { +// t.Errorf(err.Error()) +// return +// } +// err = db.RegisterNode(testId, nil, +// testCode, "5.5.5.5", "test", "5.6.7.7", "test") +// if err != nil { +// t.Errorf(err.Error()) +// return +// } +// err = db.UpdateSalt(testId, []byte("test123")) +// if err != nil { +// t.Errorf(err.Error()) +// return +// } +//} + // Happy path func TestMapImpl_InsertNodeMetric(t *testing.T) { m := &MapImpl{nodeMetrics: make(map[uint64]*NodeMetric)} @@ -191,6 +234,49 @@ func TestMapImpl_InsertApplication_Duplicate(t *testing.T) { } } +// Happy path +func TestMapImpl_UpdateSalt(t *testing.T) { + testID := id.NewIdFromString("test", id.Node, t) + key := "testKey" + newSalt := make([]byte, 8) + _, _ = rand.Read(newSalt) + + m := &MapImpl{ + nodes: map[string]*Node{key: {Id: testID.Bytes(), Salt: []byte("b")}}, + } + + err := m.UpdateSalt(testID, newSalt) + if err != nil { + t.Errorf("Received unexpected error when upadting salt."+ + "\n\terror: %v", err) + } + + // Verify that the new salt matches the passed in salt + if !bytes.Equal(newSalt, m.nodes[key].Salt) { + t.Errorf("Node in map has unexpected salt."+ + "\n\texpected: %d\n\treceived: %d", newSalt, m.nodes[key].Salt) + } +} + +// Tests that MapImpl.UpdateSalt returns an error if no Node is found in the map +// for the given ID. +func TestMapImpl_UpdateSalt_NodeNotInMap(t *testing.T) { + testID := id.NewIdFromString("test", id.Node, t) + key := "testKey" + newSalt := make([]byte, 8) + _, _ = rand.Read(newSalt) + + m := &MapImpl{ + nodes: map[string]*Node{key: {Id: id.NewIdFromString("test3", id.Node, t).Bytes(), Salt: []byte("b")}}, + } + + err := m.UpdateSalt(testID, newSalt) + if err == nil { + t.Errorf("Did not receive an error when the Node does not exist in " + + "the map.") + } +} + // Happy path func TestMapImpl_RegisterNode(t *testing.T) { m := &MapImpl{ @@ -206,7 +292,7 @@ func TestMapImpl_RegisterNode(t *testing.T) { m.nodes[code] = &Node{Code: code} // Attempt to insert a node - err := m.RegisterNode(id.NewIdFromString("", id.Node, t), code, addr, + err := m.RegisterNode(id.NewIdFromString("", id.Node, t), []byte("test"), code, addr, cert, gwAddr, gwCert) // Verify the insert was successful @@ -227,7 +313,7 @@ func TestMapImpl_RegisterNode_Invalid(t *testing.T) { code := "TEST" // Attempt to insert a node without an associated registration code - err := m.RegisterNode(id.NewIdFromString("", id.Node, t), code, code, + err := m.RegisterNode(id.NewIdFromString("", id.Node, t), []byte("test"), code, code, code, code, code) // Verify the insert failed diff --git a/storage/round/map.go b/storage/round/map.go index 246b83331f642b340328be70a34b24a5adbe25a9..7016474130d175fa9d099127edde4188ca1ff152 100644 --- a/storage/round/map.go +++ b/storage/round/map.go @@ -9,8 +9,8 @@ package round import ( "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/primitives/id" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" "sync" "testing" "time" diff --git a/storage/round/map_test.go b/storage/round/map_test.go index 6668a392300100eb003e569c8f7733422a471f53..6f36d4c5970ff8fe4a3485d0dc4244d89d81f053 100644 --- a/storage/round/map_test.go +++ b/storage/round/map_test.go @@ -7,9 +7,9 @@ package round import ( + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" "testing" "time" ) diff --git a/storage/round/state.go b/storage/round/state.go index f02e8b9449f690faca48b212bba162816b00d32f..529dd2bfcc6bade1fcf46a57243d8b265eedf7f2 100644 --- a/storage/round/state.go +++ b/storage/round/state.go @@ -10,9 +10,9 @@ import ( "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" pb "gitlab.com/elixxir/comms/mixmessages" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" "gitlab.com/xx_network/comms/connect" - "gitlab.com/xx_network/primitives/id" "math" "sync" "testing" diff --git a/storage/round/state_test.go b/storage/round/state_test.go index fddd351e4dc9cbb0f62b7247e3ddf08e7c977de3..85f510bff39e691fe22862a1649b7d3f4acb6bcf 100644 --- a/storage/round/state_test.go +++ b/storage/round/state_test.go @@ -8,8 +8,8 @@ package round import ( "bytes" + "gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/states" - "gitlab.com/xx_network/primitives/id" "math" "reflect" "strings" diff --git a/storage/state.go b/storage/state.go index 925a6ad7663623d1c79d0c40f1809b4697481ba5..96eb0fbe5cfd0f9b71fffa919162e4a9f81d8a64 100644 --- a/storage/state.go +++ b/storage/state.go @@ -16,11 +16,11 @@ import ( "gitlab.com/elixxir/comms/network/dataStructures" "gitlab.com/elixxir/crypto/signature" "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/primitives/id" + "gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/storage/round" - "gitlab.com/xx_network/primitives/id" - "gitlab.com/xx_network/primitives/ndf" "sync" "time" ) diff --git a/storage/state_test.go b/storage/state_test.go index 3e53fb3d077808402513a066f3fc2d20a2cceb54..4d3b80379419450c4470c0fc49f45e68eeda9eff 100644 --- a/storage/state_test.go +++ b/storage/state_test.go @@ -15,11 +15,11 @@ import ( "gitlab.com/elixxir/crypto/signature" "gitlab.com/elixxir/crypto/signature/rsa" "gitlab.com/elixxir/primitives/current" + "gitlab.com/elixxir/primitives/id" + "gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/primitives/utils" "gitlab.com/elixxir/registration/storage/node" "gitlab.com/elixxir/registration/storage/round" - "gitlab.com/xx_network/primitives/id" - "gitlab.com/xx_network/primitives/ndf" mrand "math/rand" "os" "reflect"