diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..b3005432811bd5186681f4183dd496d132b1834d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,59 @@ +# From: https://about.gitlab.com/2017/09/21/how-to-create-ci-cd-pipeline-with-autodeploy-to-kubernetes-using-gitlab-and-helm/ + +variables: + REPO_DIR: gitlab.com/elixxir + REPO_NAME: mainnet-commitments + DOCKER_IMAGE: elixxirlabs/cuda-go:go1.16-cuda11.1 + MIN_CODE_COVERAGE: "0.0" + +before_script: + ## + ## Go Setup + ## + - go version || echo "Go executable not found." + - echo $CI_BUILD_REF + - echo $CI_PROJECT_DIR + - echo $PWD + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - ssh-keyscan -t rsa $GITLAB_SERVER > ~/.ssh/known_hosts + - git config --global url."git@$GITLAB_SERVER:".insteadOf "https://gitlab.com/" + - git config --global url."git@$GITLAB_SERVER:".insteadOf "https://git.xx.network/" + - export PATH=$HOME/go/bin:$PATH + +stages: + - build + +build: + stage: build + image: $DOCKER_IMAGE + script: + - git clean -ffdx + - go mod vendor -v + - go build ./... + - go mod tidy + #- mkdir -p testdata + + # Test coverage + #- go-acc --covermode atomic --output testdata/coverage.out ./... -- -v + # Exclude some specific packages and files + #- grep -v -e cmd testdata/coverage.out > testdata/coverage-real.out + #- go tool cover -func=testdata/coverage-real.out + #- go tool cover -html=testdata/coverage-real.out -o testdata/coverage.html + + # Test Coverage Check + #- go tool cover -func=testdata/coverage-real.out | grep "total:" | awk '{print $3}' | sed 's/\%//g' > testdata/coverage-percentage.txt + #- export CODE_CHECK=$(echo "$(cat testdata/coverage-percentage.txt) >= $MIN_CODE_COVERAGE" | bc -l) + #- (if [ "$CODE_CHECK" == "1" ]; then echo "Minimum coverage of $MIN_CODE_COVERAGE succeeded"; else echo "Minimum coverage of $MIN_CODE_COVERAGE failed"; exit 1; fi); + + - mkdir -p release + - GOOS=linux GOARCH=amd64 go build -o release/commitments-server.linux64 + - GOOS=darwin GOARCH=amd64 go build -o release/commitments-server.darwin64 + - GOOS=js GOARCH=wasm go build -o release/main.wasm + artifacts: + paths: + - vendor/ + #- testdata/ + - release/ diff --git a/client/client.go b/client/client.go index f87f15db6192e81cc0e9e1257048873367436e4c..667f8b66922e5d956c9bc688b69197cf6f26e8c6 100644 --- a/client/client.go +++ b/client/client.go @@ -109,11 +109,10 @@ func SignAndTransmit(keyPath, idfPath, contractPath, wallet, commitmentsAddress, fmt.Println("Transmitting signature...") err = cl.TransmitSignature(h, &messages.Commitment{ - PrivateKey: pk, - IDF: idfBytes, - Contract: contractBytes, - Wallet: wallet, - Signature: sig, + IDF: idfBytes, + Contract: contractBytes, + Wallet: wallet, + Signature: sig, }) if err != nil { diff --git a/cmd/server.go b/cmd/server.go index db8c9ce1f2948d476e822d6a3057dff94c5330c7..4551bda882cfd6e6dba0d5de01fcffbdee0c160a 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -75,7 +75,7 @@ var serverCmd = &cobra.Command{ params := server.Params{ Key: key, Cert: cert, - Port: viper.GetString("address"), + Port: viper.GetString("port"), StorageParams: storage.Params{ Username: viper.GetString("dbUsername"), Password: viper.GetString("dbPassword"), diff --git a/messages/commitment_messages.pb.go b/messages/commitment_messages.pb.go index b91fde4c0c699065c564d9dcda90fa8b246317fb..ad20ec10a2d85a38504e81e318b992253a362c37 100644 --- a/messages/commitment_messages.pb.go +++ b/messages/commitment_messages.pb.go @@ -64,11 +64,10 @@ func (m *CommitmentResponse) GetError() string { } type Commitment struct { - PrivateKey []byte `protobuf:"bytes,1,opt,name=PrivateKey,proto3" json:"PrivateKey,omitempty"` - IDF []byte `protobuf:"bytes,2,opt,name=IDF,proto3" json:"IDF,omitempty"` - Contract []byte `protobuf:"bytes,3,opt,name=Contract,proto3" json:"Contract,omitempty"` - Wallet string `protobuf:"bytes,4,opt,name=Wallet,proto3" json:"Wallet,omitempty"` - Signature []byte `protobuf:"bytes,5,opt,name=Signature,proto3" json:"Signature,omitempty"` + IDF []byte `protobuf:"bytes,1,opt,name=IDF,proto3" json:"IDF,omitempty"` + Contract []byte `protobuf:"bytes,2,opt,name=Contract,proto3" json:"Contract,omitempty"` + Wallet string `protobuf:"bytes,3,opt,name=Wallet,proto3" json:"Wallet,omitempty"` + Signature []byte `protobuf:"bytes,4,opt,name=Signature,proto3" json:"Signature,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -99,13 +98,6 @@ func (m *Commitment) XXX_DiscardUnknown() { var xxx_messageInfo_Commitment proto.InternalMessageInfo -func (m *Commitment) GetPrivateKey() []byte { - if m != nil { - return m.PrivateKey - } - return nil -} - func (m *Commitment) GetIDF() []byte { if m != nil { return m.IDF @@ -144,23 +136,22 @@ func init() { } var fileDescriptor_02948687e8213eef = []byte{ - // 245 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x4d, 0x4b, 0x03, 0x31, - 0x10, 0x86, 0x5d, 0x6b, 0x97, 0x76, 0xf4, 0x20, 0x43, 0x91, 0x58, 0x8a, 0x1f, 0x7b, 0x12, 0x0f, - 0x5b, 0xd0, 0xbb, 0x07, 0xab, 0x82, 0x88, 0x20, 0x2b, 0x28, 0x78, 0x91, 0x58, 0xc6, 0x25, 0xb8, - 0x9b, 0x94, 0xc9, 0xa8, 0xdb, 0x7f, 0xe1, 0x4f, 0x16, 0xa3, 0xbb, 0xf1, 0xd0, 0x5b, 0xde, 0x27, - 0xcf, 0x90, 0xbc, 0x03, 0xbb, 0x73, 0x57, 0xd7, 0x46, 0x6a, 0xb2, 0xf2, 0x5c, 0x93, 0xf7, 0xba, - 0x24, 0x9f, 0x2f, 0xd8, 0x89, 0xc3, 0x41, 0x9b, 0xb3, 0x63, 0xc0, 0x59, 0xa7, 0x15, 0xe4, 0x17, - 0xce, 0x7a, 0xc2, 0x11, 0xf4, 0x2f, 0x99, 0x1d, 0xab, 0xe4, 0x20, 0x39, 0x1a, 0x16, 0xbf, 0x21, - 0xfb, 0x4a, 0x00, 0xa2, 0x8c, 0x7b, 0x00, 0x77, 0x6c, 0x3e, 0xb4, 0xd0, 0x0d, 0x2d, 0x83, 0xb9, - 0x55, 0xfc, 0x23, 0xb8, 0x0d, 0xbd, 0xeb, 0x8b, 0x2b, 0xb5, 0x1e, 0x2e, 0x7e, 0x8e, 0x38, 0x86, - 0xc1, 0xcc, 0x59, 0x61, 0x3d, 0x17, 0xd5, 0x0b, 0xb8, 0xcb, 0xb8, 0x03, 0xe9, 0xa3, 0xae, 0x2a, - 0x12, 0xb5, 0x11, 0xde, 0xfc, 0x4b, 0x38, 0x81, 0xe1, 0xbd, 0x29, 0xad, 0x96, 0x77, 0x26, 0xd5, - 0x0f, 0x43, 0x11, 0x9c, 0xdc, 0xc2, 0x66, 0xfc, 0x91, 0xc7, 0x33, 0x48, 0x1f, 0x88, 0xcd, 0xeb, - 0x12, 0x47, 0x79, 0x57, 0x39, 0x0a, 0xe3, 0xc9, 0x2a, 0xda, 0xb6, 0xce, 0xd6, 0xce, 0x0f, 0x9f, - 0xf6, 0x4b, 0x23, 0x79, 0xd3, 0xe4, 0x96, 0xe4, 0xd3, 0xf1, 0xdb, 0x94, 0x2a, 0xd3, 0x34, 0x86, - 0xa7, 0xed, 0xdc, 0x4b, 0x1a, 0x36, 0x78, 0xfa, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x95, 0xa7, 0xd1, - 0xa9, 0x5e, 0x01, 0x00, 0x00, + // 225 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x41, 0x4b, 0x03, 0x31, + 0x10, 0x85, 0xad, 0xd5, 0xa5, 0x1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0d, 0x2f, 0xfb, 0xde, 0x5b, + 0x91, 0x3e, 0xe8, 0xf2, 0x27, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xeb, 0x78, 0x79, 0x3d, 0x01, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/messages/commitment_messages.proto b/messages/commitment_messages.proto index 5291fb8cd08f3e6e58de69d0ce3a9d5b0f94f7ad..1d089e8e05ec83d4ff2576ed99e9d2cf95a165a0 100644 --- a/messages/commitment_messages.proto +++ b/messages/commitment_messages.proto @@ -19,9 +19,8 @@ message CommitmentResponse { } message Commitment { - bytes PrivateKey = 1; - bytes IDF = 2; - bytes Contract = 3; - string Wallet = 4; - bytes Signature = 5; + bytes IDF = 1; + bytes Contract = 2; + string Wallet = 3; + bytes Signature = 4; } diff --git a/server/serverImpl.go b/server/serverImpl.go index 66f63afcefa12a9b54c4ec0c694d9e7dfb04eba7..835afcbc9a9eb58f7a06698d294b83fa34120ff2 100644 --- a/server/serverImpl.go +++ b/server/serverImpl.go @@ -35,7 +35,8 @@ type Params struct { // StartServer creates a server object from params func StartServer(params Params) (*Impl, error) { // Create grpc server - pc, lis, err := connect.StartCommServer(&utils.ServerID, fmt.Sprintf("0.0.0.0:%s", params.Port), + addr := fmt.Sprintf("0.0.0.0:%s", params.Port) + pc, lis, err := connect.StartCommServer(&utils.ServerID, addr, params.Cert, params.Key, nil) if err != nil { return nil, errors.WithMessage(err, "Failed to start comms server") @@ -61,7 +62,6 @@ func StartServer(params Params) (*Impl, error) { " %s", lis) }() - // Register verify implementation return impl, nil } @@ -105,7 +105,8 @@ func (i *Impl) Verify(_ context.Context, msg *messages.Commitment) (*messages.Co } // Get member info from database - m, err := i.s.GetMember(idfStruct.IdBytes[:]) + hexId := "\\" + idfStruct.HexNodeID[1:] + m, err := i.s.GetMember([]byte(hexId)) if err != nil { err = errors.WithMessagef(err, "Member %s [%+v] not found", idfStruct.ID, idfStruct.IdBytes) jww.ERROR.Printf(err.Error())