Skip to content
Snippets Groups Projects
Commit 752c5235 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

finsihed implementeing reception and sending of ephemeral IDs

parent 5fcffca3
Branches
Tags
No related merge requests found
......@@ -19,14 +19,14 @@ require (
github.com/spf13/viper v1.7.1
github.com/ugorji/go v1.1.4 // indirect
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20210114174157-1306832d440b
gitlab.com/elixxir/crypto v0.0.7-0.20210114172156-b576829ba7d8
gitlab.com/elixxir/bloomfilter v0.0.0-20210120224144-ac046983a17a
gitlab.com/elixxir/comms v0.0.4-0.20210208181740-1ad1139f7170
gitlab.com/elixxir/crypto v0.0.7-0.20210205171416-0a952e4e10de
gitlab.com/elixxir/ekv v0.1.4
gitlab.com/elixxir/primitives v0.0.3-0.20210127201240-6a42ad925e8a
gitlab.com/xx_network/comms v0.0.4-0.20210112233928-eac8db03c397
gitlab.com/xx_network/crypto v0.0.5-0.20210107183440-804e0f8b7d22
gitlab.com/xx_network/primitives v0.0.4-0.20210129204839-cc84bb5a253b
gitlab.com/xx_network/comms v0.0.4-0.20210121204701-7a1eb0542424
gitlab.com/xx_network/crypto v0.0.5-0.20210121204626-b251b926e4f7
gitlab.com/xx_network/primitives v0.0.4-0.20210208175706-a47ce8d49d4b
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 // indirect
......
......@@ -265,6 +265,9 @@ github.com/zeebo/pcg v1.0.0 h1:dt+dx+HvX8g7Un32rY9XWoYnd0NmKmrIzpHF7qiTDj0=
github.com/zeebo/pcg v1.0.0/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 h1:Gi6rj4mAlK0BJIk1HIzBVMjWNjIUfstrsXC2VqLYPcA=
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k=
gitlab.com/elixxir/bloomfilter v0.0.0-20210120224144-ac046983a17a h1:0vLmGrqRDlaru89aKQPk3MyRPUInFujpqnVspBA6QTQ=
gitlab.com/elixxir/bloomfilter v0.0.0-20210120224144-ac046983a17a/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k=
gitlab.com/elixxir/comms v0.0.3/go.mod h1:5p7oz4yFrK037rPap6ooaWrloJrzuVZ4jnzOdvgyqnU=
gitlab.com/elixxir/comms v0.0.4-0.20201217200754-6259dc49e6f1 h1:4iuAA/I8/aQ1Jn3gBguuR1u+LVy3YyShxpoNcqApaVg=
gitlab.com/elixxir/comms v0.0.4-0.20201217200754-6259dc49e6f1/go.mod h1:2sNUHm725vQG4pG1RtvMd7kJ5CNqFb7Rl9cenuQCa2c=
gitlab.com/elixxir/comms v0.0.4-0.20201229200853-c403d72e877c h1:YjTlUbZiNiJdL7Fy4TIUoWlHNK4dFOtuJ40YgsG7fac=
......@@ -279,10 +282,19 @@ gitlab.com/elixxir/comms v0.0.4-0.20210112234945-18c36b2d908f h1:EsCG5+sB1ZapIBY
gitlab.com/elixxir/comms v0.0.4-0.20210112234945-18c36b2d908f/go.mod h1:R2Ank04m99uGRhKOssWzITqN47AT+EOyG2OiCHLGroE=
gitlab.com/elixxir/comms v0.0.4-0.20210114174157-1306832d440b h1:LdlL28odDDoQbhpgF7jUR3x2TXG1P4TzGfVBg2Md6Ek=
gitlab.com/elixxir/comms v0.0.4-0.20210114174157-1306832d440b/go.mod h1:R2Ank04m99uGRhKOssWzITqN47AT+EOyG2OiCHLGroE=
gitlab.com/elixxir/comms v0.0.4-0.20210126185553-8ccfd64bf81b h1:ENB2YHpF72bbVHA6GG8BrMXEb+si9JHhO39vx7vk7hA=
gitlab.com/elixxir/comms v0.0.4-0.20210126185553-8ccfd64bf81b/go.mod h1:5hxGwa/8BEpo4cZrbxhxyXPpXmwzMPunKE/H141+rPU=
gitlab.com/elixxir/comms v0.0.4-0.20210204222703-dfa824c42c56 h1:WroFBwpYtomIhzjpDto7tr1uW9+Ihk64S7mcIaOy1/M=
gitlab.com/elixxir/comms v0.0.4-0.20210204222703-dfa824c42c56/go.mod h1:fWuPOszadMhHLOywy2+mMSMH00k9sh/zw/povSWurn4=
gitlab.com/elixxir/comms v0.0.4-0.20210208175734-0f8b551dab3c h1:YJR7jPnxyBmUVf7FB2Vq8d5J8gs3M5B7bVHyFQBrGHI=
gitlab.com/elixxir/comms v0.0.4-0.20210208175734-0f8b551dab3c/go.mod h1:fWuPOszadMhHLOywy2+mMSMH00k9sh/zw/povSWurn4=
gitlab.com/elixxir/comms v0.0.4-0.20210208181740-1ad1139f7170 h1:YD0QgSP5puQXn3bMOJuA7sT7DXLCVgHBW//PSESU45o=
gitlab.com/elixxir/comms v0.0.4-0.20210208181740-1ad1139f7170/go.mod h1:fWuPOszadMhHLOywy2+mMSMH00k9sh/zw/povSWurn4=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
gitlab.com/elixxir/crypto v0.0.3 h1:znCt/x2bL4y8czTPaaFkwzdgSgW3BJc/1+dxyf1jqVw=
gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA=
gitlab.com/elixxir/crypto v0.0.4/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA=
gitlab.com/elixxir/crypto v0.0.6 h1:c94CGzBTV7LgInGHfmeJHrqq9nIc/WEOLUd9OeQBN74=
gitlab.com/elixxir/crypto v0.0.7-0.20201217200352-0ba771a66932/go.mod h1:nqSNe486j6ua96nv1et6x2ESl/qXevkx7f31GowMRh4=
gitlab.com/elixxir/crypto v0.0.7-0.20201222203132-9b4cc1ae3da6 h1:Vyf2wJ1/CoHLznATpI+z84OJQ+sgAbpVLT9P1CNjSVI=
......@@ -293,6 +305,10 @@ gitlab.com/elixxir/crypto v0.0.7-0.20210107184400-5c3e52a35758 h1:h2l8SZbdgcyMVw
gitlab.com/elixxir/crypto v0.0.7-0.20210107184400-5c3e52a35758/go.mod h1:JDC7EFs5V97qourZyiSHBiiXHGUoKWX9XtJVhfEvpC4=
gitlab.com/elixxir/crypto v0.0.7-0.20210114172156-b576829ba7d8 h1:KhhsuPn+aPzZ66jdbbRF55SurogvQ/X9KuMWkXtmq+U=
gitlab.com/elixxir/crypto v0.0.7-0.20210114172156-b576829ba7d8/go.mod h1:4AumkGNppiEaMo6bIpFBrV6wZtaIjpbvkpA5+FBisA8=
gitlab.com/elixxir/crypto v0.0.7-0.20210125231257-b52a556be893 h1:0NjQOwdGO/xBvgBMzRLSFXpSpnluzjT16obl5AcGfmI=
gitlab.com/elixxir/crypto v0.0.7-0.20210125231257-b52a556be893/go.mod h1:BoYrgHnTJPvvd4f/f4A+y22wwgZ7IxkYtGC8x9WiwxA=
gitlab.com/elixxir/crypto v0.0.7-0.20210205171416-0a952e4e10de h1:Zy8ZY1sbEDiuVTjkObqZjePvwH3Im151iyAxnPfxV10=
gitlab.com/elixxir/crypto v0.0.7-0.20210205171416-0a952e4e10de/go.mod h1:4AumkGNppiEaMo6bIpFBrV6wZtaIjpbvkpA5+FBisA8=
gitlab.com/elixxir/ekv v0.1.4-0.20201217220111-9c7e8be21577 h1:qT3ZO9GbKv7PcmakATsXsUdzn/hlm817ETOT/csDIak=
gitlab.com/elixxir/ekv v0.1.4-0.20201217220111-9c7e8be21577/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4=
gitlab.com/elixxir/ekv v0.1.4 h1:NLVMwsFEKArWcsDHu2DbXlm9374iSgn7oIA3rVSsvjc=
......@@ -302,6 +318,7 @@ gitlab.com/elixxir/primitives v0.0.0-20200804170709-a1896d262cd9/go.mod h1:p0Vel
gitlab.com/elixxir/primitives v0.0.0-20200804182913-788f47bded40/go.mod h1:tzdFFvb1ESmuTCOl1z6+yf6oAICDxH2NPUemVgoNLxc=
gitlab.com/elixxir/primitives v0.0.1 h1:q61anawANlNAExfkeQEE1NCsNih6vNV1FFLoUQX6txQ=
gitlab.com/elixxir/primitives v0.0.1/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE=
gitlab.com/elixxir/primitives v0.0.2/go.mod h1:3fxFHSlQhkV4vs+S0dZEz3Om3m+40WX8L806yvSnNFc=
gitlab.com/elixxir/primitives v0.0.3-0.20201217193438-8ebfc882f1de/go.mod h1:H1OZ6ZXzTB3G4nOEdJzBJ7BySRnivpJTkTphxazFCl4=
gitlab.com/elixxir/primitives v0.0.3-0.20201222171449-bdfe30389bb5 h1:BUV1ouY+9NA5+ZF+QfTpIBL1vO5zk31I68N7DX9bKj8=
gitlab.com/elixxir/primitives v0.0.3-0.20201222171449-bdfe30389bb5/go.mod h1:5Z8fce94mks0aFhMvzftx2jJpDx4/pzDU20G2oTiU9w=
......@@ -313,11 +330,14 @@ gitlab.com/elixxir/primitives v0.0.3-0.20210106014507-bf3dfe228fa6 h1:sUqEla1uUI
gitlab.com/elixxir/primitives v0.0.3-0.20210106014507-bf3dfe228fa6/go.mod h1:Ph6isHUDVjmRUd9DioyKpd8W9J52gKBiDeue4DCygXA=
gitlab.com/elixxir/primitives v0.0.3-0.20210107183456-9cf6fe2de1e5 h1:50HbCJWirpX2Q+NNhIHcs0M9f45H1UJ/7LNMu81Bnn0=
gitlab.com/elixxir/primitives v0.0.3-0.20210107183456-9cf6fe2de1e5/go.mod h1:Ph6isHUDVjmRUd9DioyKpd8W9J52gKBiDeue4DCygXA=
gitlab.com/elixxir/primitives v0.0.3-0.20210125225949-9469ce6b08fc/go.mod h1:bGYfAGerVVZhNzh+PxOMZVG7iYAUfInYvtdAkAqgiY8=
gitlab.com/elixxir/primitives v0.0.3-0.20210126180712-bfbfb725c75a/go.mod h1:bGYfAGerVVZhNzh+PxOMZVG7iYAUfInYvtdAkAqgiY8=
gitlab.com/elixxir/primitives v0.0.3-0.20210127194347-988bd6621899 h1:23S/mz5H4HOj2v2b33arSeYHH8FrdPAzEoImnJP91j4=
gitlab.com/elixxir/primitives v0.0.3-0.20210127194347-988bd6621899/go.mod h1:Ph6isHUDVjmRUd9DioyKpd8W9J52gKBiDeue4DCygXA=
gitlab.com/elixxir/primitives v0.0.3-0.20210127201240-6a42ad925e8a h1:ZQncDfITNE12EdJK+shh6UzHlALhNU4Zjvv4hid2krs=
gitlab.com/elixxir/primitives v0.0.3-0.20210127201240-6a42ad925e8a/go.mod h1:Ph6isHUDVjmRUd9DioyKpd8W9J52gKBiDeue4DCygXA=
gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw=
gitlab.com/xx_network/comms v0.0.3/go.mod h1:YViGbRj7FjJYoaO4NpALGEd9dK/l8uUT000FEBbUTL8=
gitlab.com/xx_network/comms v0.0.4-0.20201130190834-365ddae56e7b/go.mod h1:YViGbRj7FjJYoaO4NpALGEd9dK/l8uUT000FEBbUTL8=
gitlab.com/xx_network/comms v0.0.4-0.20201217200138-87075d5b4ffd h1:4LjS3UuBNA/AaglIJ+k1IBoxYgCWt+FM1MPYxjAFfaQ=
gitlab.com/xx_network/comms v0.0.4-0.20201217200138-87075d5b4ffd/go.mod h1:/vIk6tSrDqk/7HZOdrbSXZT+kEL43HIoz60AoZTzTXg=
......@@ -329,6 +349,8 @@ gitlab.com/xx_network/comms v0.0.4-0.20210107184305-7bb439c08ded h1:VHAQcap/+jcF
gitlab.com/xx_network/comms v0.0.4-0.20210107184305-7bb439c08ded/go.mod h1:12OZe2Ol9lEk7JTm48GQ4zj1O01SH0ygfLqOb8EHrtU=
gitlab.com/xx_network/comms v0.0.4-0.20210112233928-eac8db03c397 h1:E7p5lGX+nTAIKB6Wno3mRxBfC+SX5ZY2FKp8JEMzdSM=
gitlab.com/xx_network/comms v0.0.4-0.20210112233928-eac8db03c397/go.mod h1:12OZe2Ol9lEk7JTm48GQ4zj1O01SH0ygfLqOb8EHrtU=
gitlab.com/xx_network/comms v0.0.4-0.20210121204701-7a1eb0542424 h1:zhfkbutYEY7PQuC1kcugCt4am/oRAyla6u4xDc5PqWs=
gitlab.com/xx_network/comms v0.0.4-0.20210121204701-7a1eb0542424/go.mod h1:MNkja6iUsM2yjBQicwLUGYctZmAU/D4AMpDD04vfBg8=
gitlab.com/xx_network/crypto v0.0.3/go.mod h1:DF2HYvvCw9wkBybXcXAgQMzX+MiGbFPjwt3t17VRqRE=
gitlab.com/xx_network/crypto v0.0.4 h1:lpKOL5mTJ2awWMfgBy30oD/UvJVrWZzUimSHlOdZZxo=
gitlab.com/xx_network/crypto v0.0.4/go.mod h1:+lcQEy+Th4eswFgQDwT0EXKp4AXrlubxalwQFH5O0Mk=
......@@ -341,6 +363,8 @@ gitlab.com/xx_network/crypto v0.0.5-0.20210106014410-0554a33a7124 h1:G2fNW7uPzJE
gitlab.com/xx_network/crypto v0.0.5-0.20210106014410-0554a33a7124/go.mod h1:tTYlvAZNUFMtndcijM37iujkM4gP8kUwGiS9n7NA5Ck=
gitlab.com/xx_network/crypto v0.0.5-0.20210107183440-804e0f8b7d22 h1:SQga1vOuAGzbYURnBjG0f37r7WmWKZRdiqmdopaNMb4=
gitlab.com/xx_network/crypto v0.0.5-0.20210107183440-804e0f8b7d22/go.mod h1:tTYlvAZNUFMtndcijM37iujkM4gP8kUwGiS9n7NA5Ck=
gitlab.com/xx_network/crypto v0.0.5-0.20210121204626-b251b926e4f7 h1:eraxUmI0EFDtfqTV4Ojndoh8Bv8PBUbZaT27VLU1yhc=
gitlab.com/xx_network/crypto v0.0.5-0.20210121204626-b251b926e4f7/go.mod h1:61fEAGI2+JD6CbT5PMzxy1SBMvgiFxE4MyiQghzoOVg=
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=
......@@ -360,10 +384,13 @@ gitlab.com/xx_network/primitives v0.0.4-0.20210118193646-93176e2e6925 h1:n40/5N6
gitlab.com/xx_network/primitives v0.0.4-0.20210118193646-93176e2e6925/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc=
gitlab.com/xx_network/primitives v0.0.4-0.20210120193504-6fb365621996 h1:ChTPjKVl3XZDsqZpaSbWT8vixiHhhcGh/ytH4feYz4A=
gitlab.com/xx_network/primitives v0.0.4-0.20210120193504-6fb365621996/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/primitives v0.0.4-0.20210121203635-8a771fc14f8a/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/primitives v0.0.4-0.20210121231232-022320b01e08 h1:NZl2gjkiSZQVls4dHys+EoE6eGIU2YBXKqLaBVuV+b0=
gitlab.com/xx_network/primitives v0.0.4-0.20210121231232-022320b01e08/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/primitives v0.0.4-0.20210129204839-cc84bb5a253b h1:zKtKCoScDcJM8/nBC4U5uhjifDHHcND3vKm1gfoc5yQ=
gitlab.com/xx_network/primitives v0.0.4-0.20210129204839-cc84bb5a253b/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/primitives v0.0.4-0.20210208175706-a47ce8d49d4b h1:JZjMW39yJXuHWqX3OPlvAPykarGB4KS0KHDU2jHG6eg=
gitlab.com/xx_network/primitives v0.0.4-0.20210208175706-a47ce8d49d4b/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/ring v0.0.2 h1:TlPjlbFdhtJrwvRgIg4ScdngMTaynx/ByHBRZiXCoL0=
gitlab.com/xx_network/ring v0.0.2/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
......@@ -539,6 +566,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
......
......@@ -25,8 +25,8 @@ package network
import (
"bytes"
jww "github.com/spf13/jwalterweatherman"
bloom "gitlab.com/elixxir/bloomfilter"
"gitlab.com/elixxir/client/network/gateway"
"gitlab.com/elixxir/client/network/rounds"
pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/primitives/knownRounds"
"gitlab.com/elixxir/primitives/states"
......@@ -36,8 +36,8 @@ import (
"time"
)
const bloomFilterSize = 71888 // In Bits
const bloomFilterHashes = 8
const BloomFilterSize = 904 // In Bits
const BloomFilterHashes = 10
//comms interface makes testing easier
type followNetworkComms interface {
......@@ -45,6 +45,7 @@ type followNetworkComms interface {
SendPoll(host *connect.Host, message *pb.GatewayPoll) (*pb.GatewayPollResponse, error)
}
// followNetwork polls the network to get updated on the state of nodes, the
// round status, and informs the client when messages can be retrieved.
func (m *manager) followNetwork(quitCh <-chan struct{}) {
......@@ -71,6 +72,14 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
jww.TRACE.Printf("follow: %d", followCnt)
followCnt++
//get the identity we will poll for
identity, err := m.Session.Reception().GetIdentity(rng)
if err!=nil{
jww.FATAL.Panicf("Failed to get an ideneity, this should be " +
"impossible: %+v", err)
}
//randomly select a gateway to poll
//TODO: make this more intelligent
gwHost, err := gateway.Get(m.Instance.GetPartialNdf().Get(), comms, rng)
......@@ -85,7 +94,9 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
Hash: m.Instance.GetPartialNdf().GetHash(),
},
LastUpdate: uint64(m.Instance.GetLastUpdateID()),
ClientID: m.Uid.Bytes(),
ReceptionID: identity.EphId[:],
StartTimestamp: identity.StartRequest.UnixNano(),
EndTimestamp: identity.EndRequest.UnixNano(),
}
jww.TRACE.Printf("Polling %s for NDF...", gwHost)
pollResp, err := comms.SendPoll(gwHost, &pollReq)
......@@ -94,33 +105,13 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
return
}
// ---- Process Update Data ----
lastTrackedRound := id.Round(pollResp.LastTrackedRound)
// ---- Process Network State Update Data ----
gwRoundsState := &knownRounds.KnownRounds{}
err = gwRoundsState.Unmarshal(pollResp.KnownRounds)
if err != nil {
jww.ERROR.Printf("Failed to unmarshal: %+v", err)
return
}
var filterList []*bloom.Ring
for _, f := range pollResp.BloomFilters {
jww.DEBUG.Printf("Bloom Filter size: %d, hashes: %d",
bloomFilterSize, bloomFilterHashes)
filter, err := bloom.InitByParameters(bloomFilterSize,
bloomFilterHashes)
if err != nil {
jww.INFO.Printf("Bloom Filter Data: %v", f)
jww.FATAL.Panicf("Unable to create a bloom filter: %+v",
err)
}
if err := filter.UnmarshalBinary(f); err != nil {
jww.WARN.Printf("Failed to unmarshal filter: %+v", err)
jww.INFO.Printf("Bloom Filter Unmarshal Data: %v", f)
continue
}
filterList = append(filterList, filter)
}
jww.INFO.Printf("Bloom filters found in response: %d", len(filterList))
// ---- Node Events ----
// NOTE: this updates the structure, AND sends events over the node
......@@ -139,6 +130,9 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
}
}
//check that the stored address space is correct
m.Session.Reception().UpdateIDSize(uint(m.Instance.GetPartialNdf().Get().AddressSpaceSize))
// NOTE: this updates rounds and updates the tracking of the health of the
// network
if pollResp.Updates != nil {
......@@ -187,20 +181,37 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
}
}
// ---- Round Processing -----
// ---- Identity Specific Round Processing -----
if identity.Fake{
return
}
//get the range fo filters which are valid for the identity
filtersStart, filtersEnd := rounds.ValidFilterRange(identity, pollResp.Filters)
//check if there are any valid filters returned
if !(filtersEnd>filtersStart){
return
}
//prepare the filter objects for processing
filterList := make([]*rounds.RemoteFilter, filtersEnd-filtersStart)
for i:=filtersStart;i<filtersEnd;i++{
filterList[i-filtersStart] = rounds.NewRemoteFilter(pollResp.Filters.Filters[i])
}
jww.INFO.Printf("Bloom filters found in response: %d, filters used: %s",
len(pollResp.Filters.Filters), len(filterList))
// check rounds using the round checker function which determines if there
// are messages waiting in rounds and then sends signals to the appropriate
// handling threads
roundChecker := func(rid id.Round) bool {
return m.round.Checker(rid, filterList)
return m.round.Checker(rid, filterList, identity)
}
// get the bit vector of rounds that have been checked
checkedRounds := m.Session.GetCheckedRounds()
// cleave off old state in the bit vector which is deprecated from the
// network
jww.DEBUG.Printf("lastCheckedRound: %v", lastTrackedRound)
checkedRounds.Forward(lastTrackedRound)
jww.TRACE.Printf("gwRoundState: %+v", gwRoundsState)
jww.TRACE.Printf("pollResp.KnownRounds: %s", string(pollResp.KnownRounds))
......@@ -208,6 +219,7 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
// loop through all rounds the client does not know about and the gateway
// does, checking the bloom filter for the user to see if there are
// messages for the user (bloom not implemented yet)
checkedRounds.RangeUncheckedMasked(gwRoundsState, roundChecker,
checkedRounds.RangeUncheckedMaskedRange(gwRoundsState, roundChecker,
filterList[0].FirstRound(), filterList[len(filterList)-1].LastRound(),
int(m.param.MaxCheckedRounds))
}
......@@ -8,6 +8,7 @@
package message
import (
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id"
)
......@@ -16,4 +17,5 @@ type Bundle struct {
Round id.Round
Messages []format.Message
Finish func()
Identity reception.IdentityUse
}
......@@ -10,10 +10,11 @@ package message
import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/elixxir/crypto/e2e"
fingerprint2 "gitlab.com/elixxir/crypto/fingerprint"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"time"
)
......@@ -25,7 +26,7 @@ func (m *Manager) handleMessages(quitCh <-chan struct{}) {
done = true
case bundle := <-m.messageReception:
for _, msg := range bundle.Messages {
m.handleMessage(msg)
m.handleMessage(msg, bundle.Identity)
}
bundle.Finish()
}
......@@ -33,7 +34,7 @@ func (m *Manager) handleMessages(quitCh <-chan struct{}) {
}
func (m *Manager) handleMessage(ecrMsg format.Message) {
func (m *Manager) handleMessage(ecrMsg format.Message, identity reception.IdentityUse) {
// We've done all the networking, now process the message
fingerprint := ecrMsg.GetKeyFP()
......@@ -45,6 +46,15 @@ func (m *Manager) handleMessage(ecrMsg format.Message) {
var err error
var relationshipFingerprint []byte
//check if the identity fingerprint matches
forMe, err := fingerprint2.CheckIdentityFP(ecrMsg.GetIdentityFP(), ecrMsg.GetContents(), identity.Source)
if err!=nil{
jww.FATAL.Panicf("Could not check IdentityFIngerprint: %+v", err)
}
if !forMe{
return
}
// try to get the key fingerprint, process as e2e encryption if
// the fingerprint is found
if key, isE2E := e2eKv.PopKey(fingerprint); isE2E {
......@@ -73,7 +83,6 @@ func (m *Manager) handleMessage(ecrMsg format.Message) {
// if it doesnt match any form of encrypted, hear it as a raw message
// and add it to garbled messages to be handled later
msg = ecrMsg
ephID, err := ephemeral.Marshal(msg.GetEphemeralRID())
if err!=nil{
jww.DEBUG.Printf("Failed to unmarshal ephemeral ID " +
"on unknown message: %+v", err)
......@@ -82,9 +91,10 @@ func (m *Manager) handleMessage(ecrMsg format.Message) {
Payload: msg.Marshal(),
MessageType: message.Raw,
Sender: nil,
EphemeralID: ephID,
EphemeralID: identity.EphId,
Timestamp: time.Time{},
Encryption: message.None,
RecipientID: identity.Source,
}
jww.INFO.Printf("Garbled/RAW Message: %v", msg.GetKeyFP())
m.Session.GetGarbledMessages().Add(msg)
......@@ -96,6 +106,11 @@ func (m *Manager) handleMessage(ecrMsg format.Message) {
// we get a full message
xxMsg, ok := m.partitioner.HandlePartition(sender, encTy, msg.GetContents(),
relationshipFingerprint)
//Set the identities
xxMsg.RecipientID = identity.Source
xxMsg.EphemeralID = identity.EphId
// If the reception completed a message, hear it on the switchboard
if ok {
if xxMsg.MessageType == message.Raw {
......
......@@ -65,6 +65,17 @@ func (m *Manager) SendCMIX(msg format.Message, recipient *id.ID, param params.CM
ephID, _, _, err := ephemeral.GetId(recipient,
uint(bestRound.AddressSpaceSize),
int64(bestRound.Timestamps[states.REALTIME]))
if err!=nil{
jww.FATAL.Panicf("Failed to generate ephemeral ID: %+v", err)
}
rng := m.Rng.GetStream()
ephID, err = ephID.Fill(uint(bestRound.AddressSpaceSize), rng)
if err!=nil{
jww.FATAL.Panicf("Failed to obviscate the ephemeralID: %+v", err)
}
rng.Close()
msg.SetEphemeralRID(ephID[:])
......
......@@ -11,6 +11,7 @@ import (
"encoding/binary"
jww "github.com/spf13/jwalterweatherman"
bloom "gitlab.com/elixxir/bloomfilter"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/xx_network/primitives/id"
)
......@@ -25,7 +26,7 @@ import (
// if the information about that round is already present, if it is the data is
// sent to Message Retrieval Workers, otherwise it is sent to Historical Round
// Retrieval
func (m *Manager) Checker(roundID id.Round, filters []*bloom.Ring) bool {
func (m *Manager) Checker(roundID id.Round, filters []*RemoteFilter, identity reception.IdentityUse) bool {
jww.DEBUG.Printf("Checker(roundID: %d)", roundID)
// Set round to processing, if we can
processing, count := m.p.Process(roundID)
......@@ -43,16 +44,26 @@ func (m *Manager) Checker(roundID id.Round, filters []*bloom.Ring) bool {
return true
}
//check if the round is in the bloom filters
hasRound := false
serialRid := serializeRound(roundID)
//find filters that could have the round
var potentialFilters []*bloom.Bloom
for _, filter := range filters {
hasRound = filter.Test(serialRid)
if hasRound {
if filter.FirstRound()<=roundID && filter.LastRound()>=roundID{
potentialFilters = append(potentialFilters, filter.GetFilter())
}
}
hasRound := false
//check if the round is in any of the potential filters
if len(potentialFilters)>0{
serialRid := serializeRound(roundID)
for _, f := range potentialFilters{
if f.Test(serialRid){
hasRound = true
break
}
}
}
//if it is not present, set the round as checked
//that means no messages are available for the user in the round
......@@ -66,11 +77,17 @@ func (m *Manager) Checker(roundID id.Round, filters []*bloom.Ring) bool {
if err != nil {
jww.DEBUG.Printf("HistoricalRound <- %d", roundID)
// If we didn't find it, send to Historical Rounds Retrieval
m.historicalRounds <- roundID
m.historicalRounds <- historicalRoundRequest{
rid: roundID,
identity: identity,
}
} else {
jww.DEBUG.Printf("lookupRoundMessages <- %d", roundID)
// IF found, send to Message Retrieval Workers
m.lookupRoundMessages <- ri
m.lookupRoundMessages <- roundLookup{
roundInfo: ri,
identity: identity,
}
}
return false
......
......@@ -10,6 +10,7 @@ package rounds
import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/network/gateway"
"gitlab.com/elixxir/client/storage/reception"
pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/primitives/id"
......@@ -31,6 +32,12 @@ type historicalRoundsComms interface {
message *pb.HistoricalRounds) (*pb.HistoricalRoundsResponse, error)
}
//structure which contains a historical round lookup
type historicalRoundRequest struct{
rid id.Round
identity reception.IdentityUse
}
// Long running thread which process historical rounds
// Can be killed by sending a signal to the quit channel
// takes a comms interface to aid in testing
......@@ -39,7 +46,7 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-c
timerCh := make(<-chan time.Time)
rng := m.Rng.GetStream()
var rounds []uint64
var roundRequests []historicalRoundRequest
done := false
for !done {
......@@ -48,28 +55,28 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-c
select {
case <-quitCh:
rng.Close()
// return all rounds in the queue to the input channel so they can
// return all roundRequests in the queue to the input channel so they can
// be checked in the future. If the queue is full, disable them as
// processing so they are picked up from the beginning
for _, rid := range rounds {
for _, r := range roundRequests {
select {
case m.historicalRounds <- id.Round(rid):
case m.historicalRounds <- r:
default:
m.p.NotProcessing(id.Round(rid))
m.p.NotProcessing(r.rid)
}
}
done = true
// if the timer elapses process rounds to ensure the delay isn't too long
// if the timer elapses process roundRequests to ensure the delay isn't too long
case <-timerCh:
if len(rounds) > 0 {
if len(roundRequests) > 0 {
shouldProcess = true
}
// get new round to lookup and force a lookup if
case rid := <-m.historicalRounds:
rounds = append(rounds, uint64(rid))
if len(rounds) > int(m.params.MaxHistoricalRounds) {
case r := <-m.historicalRounds:
roundRequests = append(roundRequests, r)
if len(roundRequests) > int(m.params.MaxHistoricalRounds) {
shouldProcess = true
} else if len(rounds) == 1 {
} else if len(roundRequests) == 1 {
//if this is the first round, start the timeout
timerCh = time.NewTimer(m.params.HistoricalRoundsPeriod).C
}
......@@ -78,21 +85,26 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-c
continue
}
//find a gateway to request about the rounds
//find a gateway to request about the roundRequests
gwHost, err := gateway.Get(m.Instance.GetPartialNdf().Get(), comm, rng)
if err != nil {
jww.FATAL.Panicf("Failed to track network, NDF has corrupt "+
"data: %s", err)
}
//send the historical rounds request
rounds := make([]uint64,len(roundRequests))
for i, rr := range roundRequests{
rounds[i] = uint64(rr.rid)
}
//send the historical roundRequests request
hr := &pb.HistoricalRounds{
Rounds: rounds,
}
response, err := comm.RequestHistoricalRounds(gwHost, hr)
if err != nil {
jww.ERROR.Printf("Failed to request historical rounds "+
jww.ERROR.Printf("Failed to request historical roundRequests "+
"data: %s", response)
// if the check fails to resolve, break the loop and so they will be
// checked again
......@@ -100,20 +112,24 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-c
continue
}
// process the returned historical rounds.
// process the returned historical roundRequests.
for i, roundInfo := range response.Rounds {
// The interface has missing returns returned as nil, such rounds
// The interface has missing returns returned as nil, such roundRequests
// need be be removes as processing so the network follower will
// pick them up in the future.
if roundInfo == nil {
jww.ERROR.Printf("could not retreive "+
"historical round %d", rounds[i])
m.p.Fail(id.Round(rounds[i]))
"historical round %d", roundRequests[i].rid)
m.p.Fail(roundRequests[i].rid)
continue
}
// Successfully retrieved rounds are sent to the Message
// Successfully retrieved roundRequests are sent to the Message
// Retrieval Workers
m.lookupRoundMessages <- roundInfo
rl := roundLookup{
roundInfo: roundInfo,
identity: roundRequests[i].identity,
}
m.lookupRoundMessages <- rl
}
}
}
......@@ -13,8 +13,6 @@ import (
"gitlab.com/elixxir/client/network/internal"
"gitlab.com/elixxir/client/network/message"
"gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/primitives/id"
)
type Manager struct {
......@@ -24,8 +22,8 @@ type Manager struct {
internal.Internal
historicalRounds chan id.Round
lookupRoundMessages chan *mixmessages.RoundInfo
historicalRounds chan historicalRoundRequest
lookupRoundMessages chan roundLookup
messageBundles chan<- message.Bundle
}
......@@ -35,8 +33,8 @@ func NewManager(internal internal.Internal, params params.Rounds,
params: params,
p: newProcessingRounds(),
historicalRounds: make(chan id.Round, params.HistoricalRoundsBufferLen),
lookupRoundMessages: make(chan *mixmessages.RoundInfo, params.LookupRoundsBufferLen),
historicalRounds: make(chan historicalRoundRequest, params.HistoricalRoundsBufferLen),
lookupRoundMessages: make(chan roundLookup, params.LookupRoundsBufferLen),
messageBundles: bundles,
}
......
package rounds
import (
bloom "gitlab.com/elixxir/bloomfilter"
"gitlab.com/elixxir/client/network"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/primitives/id"
"time"
)
func NewRemoteFilter(data *mixmessages.ClientBloom)*RemoteFilter{
return &RemoteFilter{
data: data,
}
}
type RemoteFilter struct{
data *mixmessages.ClientBloom
filter *bloom.Bloom
}
func (rf *RemoteFilter)GetFilter()*bloom.Bloom{
if rf.filter == nil{
var err error
rf.filter, err = bloom.InitByParameters(network.BloomFilterSize,
network.BloomFilterHashes)
if err!=nil{
return nil
}
}
return rf.filter
}
func (rf *RemoteFilter)FirstRound()id.Round{
return id.Round(rf.data.FirstRound)
}
func (rf *RemoteFilter)LastRound()id.Round{
return id.Round(rf.data.FirstRound + uint64(rf.data.RoundRange))
}
// ValidFilterRange calculates which of the returned filters are valid for the identity
func ValidFilterRange(identity reception.IdentityUse, filters *mixmessages.ClientBlooms)(start int, end int){
firstFilterStart:= time.Unix(0,filters.FirstTimestamp)
filterDelta := time.Duration(filters.Period)
deltaFromStart := int(identity.StartValid.Sub(firstFilterStart)/filterDelta)
deltaFromEnd := int((identity.EndValid.Sub(firstFilterStart)+filterDelta-1)/filterDelta)
if deltaFromEnd>(len(filters.Filters)-1){
deltaFromEnd = len(filters.Filters)
}
return deltaFromStart, deltaFromEnd+1
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/network/gateway"
"gitlab.com/elixxir/client/network/message"
"gitlab.com/elixxir/client/storage/reception"
pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/comms/connect"
......@@ -24,6 +25,11 @@ type messageRetrievalComms interface {
message *pb.GetMessages) (*pb.GetMessagesResponse, error)
}
type roundLookup struct{
roundInfo *pb.RoundInfo
identity reception.IdentityUse
}
func (m *Manager) processMessageRetrieval(comms messageRetrievalComms,
quitCh <-chan struct{}) {
......@@ -32,13 +38,15 @@ func (m *Manager) processMessageRetrieval(comms messageRetrievalComms,
select {
case <-quitCh:
done = true
case ri := <-m.lookupRoundMessages:
case rl := <-m.lookupRoundMessages:
ri := rl.roundInfo
bundle, err := m.getMessagesFromGateway(ri, comms)
if err != nil {
jww.WARN.Printf("Failed to get messages for round %v: %s",
ri.ID, err)
break
}
bundle.Identity = rl.identity
if len(bundle.Messages) != 0 {
m.messageBundles <- bundle
}
......
......@@ -16,9 +16,10 @@ import (
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic"
dh "gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/elixxir/crypto/e2e"
"gitlab.com/xx_network/crypto/randomness"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/xx_network/primitives/id"
"math/big"
"sync"
"testing"
"time"
......@@ -547,15 +548,12 @@ func (s *Session) generate(kv *versioned.KV) *versioned.KV {
kv = kv.Prefix(makeSessionPrefix(s.GetID()))
//generate ttl and keying info
keysTTL, numKeys := e2e.GenerateKeyTTL(s.baseKey.GetLargeInt(),
s.params.MinKeys, s.params.MaxKeys, s.params.TTLParams)
h, _ := hash.NewCMixHash()
//ensure that enough keys are remaining to rekey
if numKeys-uint32(keysTTL) < uint32(s.params.NumRekeys) {
numKeys = uint32(keysTTL + s.params.NumRekeys)
}
numKeys := uint32(randomness.RandInInterval(big.NewInt(int64(s.params.MaxKeys-s.params.MinKeys)),
s.baseKey.Bytes(),h).Int64()+int64(s.params.MinKeys))
s.ttl = uint32(keysTTL)
s.ttl = uint32(s.params.NumRekeys)
//create the new state vectors. This will cause disk operations storing them
......
......@@ -225,6 +225,10 @@ func (s *Store) RemoveIdentity(ephID ephemeral.Id) {
func (s *Store) UpdateIDSize(idSize uint) {
s.mux.Lock()
defer s.mux.Unlock()
if s.idSize == int(idSize){
return
}
s.idSize = int(idSize)
// Store the ID size
......@@ -240,6 +244,12 @@ func (s *Store) UpdateIDSize(idSize uint) {
}
}
func (s *Store)GetIDSize()uint {
s.mux.Lock()
defer s.mux.Unlock()
return uint(s.idSize)
}
func (s *Store) prune(now time.Time) {
lengthBefore := len(s.active)
......
......@@ -18,6 +18,7 @@ import (
"gitlab.com/elixxir/client/storage/conversation"
"gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/elixxir/client/storage/partition"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/elixxir/client/storage/user"
"gitlab.com/elixxir/client/storage/utility"
"gitlab.com/elixxir/client/storage/versioned"
......@@ -56,6 +57,7 @@ type Session struct {
criticalRawMessages *utility.CmixMessageBuffer
garbledMessages *utility.MeteredCmixMessageBuffer
checkedRounds *utility.KnownRounds
reception *reception.Store
}
// Initialize a new Session object
......@@ -129,6 +131,9 @@ func New(baseDir, password string, u userInterface.User, cmixGrp,
s.conversations = conversation.NewStore(s.kv)
s.partition = partition.New(s.kv)
s.reception = reception.NewStore(s.kv)
return s, nil
}
......@@ -190,6 +195,8 @@ func Load(baseDir, password string, rng *fastRNG.StreamGenerator) (*Session, err
s.conversations = conversation.NewStore(s.kv)
s.partition = partition.New(s.kv)
s.reception = reception.LoadStore(s.kv)
return s, nil
}
......@@ -217,6 +224,12 @@ func (s *Session) Auth() *auth.Store {
return s.auth
}
func (s *Session) Reception() *reception.Store {
s.mux.RLock()
defer s.mux.RUnlock()
return s.reception
}
func (s *Session) GetCriticalMessages() *utility.E2eMessageBuffer {
s.mux.RLock()
defer s.mux.RUnlock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment