fix set element type problem, make consensus work
authorFlorian Dold <florian.dold@gmail.com>
Mon, 27 Feb 2017 04:10:52 +0000 (05:10 +0100)
committerFlorian Dold <florian.dold@gmail.com>
Mon, 27 Feb 2017 04:10:52 +0000 (05:10 +0100)
src/consensus/consensus_protocol.h
src/consensus/gnunet-service-consensus.c
src/consensus/test_consensus.conf
src/include/gnunet_set_service.h
src/set/gnunet-service-set_union.c

index fa445dc2e06b18da97718d46cc3bfdac522c9223..e0002de5606b36bd2c2ff4ba45784f3ab6f3dd24 100644 (file)
@@ -123,6 +123,12 @@ struct ConsensusSizeElement
   uint8_t sender_index;
 };
 
+struct ConsensusStuffedElement
+{
+  struct ConsensusElement ce GNUNET_PACKED;
+  struct GNUNET_HashCode rand GNUNET_PACKED;
+};
+
 
 GNUNET_NETWORK_STRUCT_END
 
index 8b02031fdd5a4038a22afa7432c9010d0c120ca0..6662ae8ca3c439d276b3d5c7e03d07671c6bc7f6 100644 (file)
@@ -915,6 +915,11 @@ set_result_cb (void *cls,
 
   if (NULL != element)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "P%u: got element of type %u, status %u\n",
+                session->local_peer_idx,
+                (unsigned) element->element_type,
+                (unsigned) status);
     GNUNET_assert (GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT == element->element_type);
     consensus_element = element->data;
   }
@@ -1371,21 +1376,21 @@ commit_set (struct ConsensusSession *session,
         }
         for (i = 0; i < evil.num; i++)
         {
-          struct GNUNET_HashCode hash;
           struct GNUNET_SET_Element element;
-          element.data = &hash;
-          element.size = sizeof (struct GNUNET_HashCode);
-          element.element_type = 0;
+          struct ConsensusStuffedElement se = { 0 };
+          element.data = &se;
+          element.size = sizeof (struct ConsensusStuffedElement);
+          element.element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT;
 
           if (EVILNESS_SUB_REPLACEMENT == evil.subtype)
           {
             /* Always generate a new element. */
-            GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &hash);
+            GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &se.rand);
           }
           else if (EVILNESS_SUB_NO_REPLACEMENT == evil.subtype)
           {
             /* Always cram the same elements, derived from counter. */
-            GNUNET_CRYPTO_hash (&i, sizeof (i), &hash);
+            GNUNET_CRYPTO_hash (&i, sizeof (i), &se.rand);
           }
           else
           {
@@ -2103,8 +2108,8 @@ task_start_reconcile (struct TaskEntry *task)
                 session->local_peer_idx, task->key.peer2, debug_str_set_key (&setop->input_set));
 
     struct GNUNET_SET_Option opts[] = {
-      {GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } },
-      {0},
+      { GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } },
+      { GNUNET_SET_OPTION_END },
     };
 
     // XXX: maybe this should be done while
@@ -2539,8 +2544,8 @@ set_listen_cb (void *cls,
                     (task->key.peer2 == session->local_peer_idx)));
 
   struct GNUNET_SET_Option opts[] = {
-    {GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } },
-    {0},
+    { GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } },
+    { GNUNET_SET_OPTION_END },
   };
 
   task->cls.setop.op = GNUNET_SET_accept (request,
index c3077b65da3604defa1655f3d173f9a6adc7d766..c75205739b5a5381602fbfbc578e585255e94cbc 100644 (file)
@@ -5,7 +5,7 @@ GNUNET_TEST_HOME = /tmp/test-consensus/
 #OPTIONS = -L INFO
 BINARY = gnunet-service-evil-consensus
 
-PREFIX = valgrind
+#PREFIX = valgrind
 
 #EVIL_SPEC = 0;cram-all;noreplace;5
 #EVIL_SPEC = 0;cram;5/1;cram;5
@@ -41,7 +41,7 @@ OPTIONS = -LERROR
 [set]
 #OPTIONS = -L INFO
 #PREFIX = valgrind --leak-check=full
-#PREFIX = valgrind
+PREFIX = valgrind
 
 [testbed]
 OVERLAY_TOPOLOGY = CLIQUE
index ca46d874673cce196020b37fd00394b230393228..6e822d82e75b682a89a30158bbdda4b79e5b5afb 100644 (file)
@@ -219,6 +219,10 @@ struct GNUNET_SET_Element
  */
 enum GNUNET_SET_OptionType
 {
+  /**
+   * List terminator.
+   */
+  GNUNET_SET_OPTION_END=0,
   /**
    * Fail set operations when the other peer shows weird behavior
    * that might by a Byzantine fault.
index 6b052037456299d9797bdb7fc2f91d4d1bff70bf..c69aa2a9c7d299f7f5e15d8617275f35d580cb56 100644 (file)
@@ -785,8 +785,9 @@ send_element_iterator (void *cls,
   struct GNUNET_SET_Element *el = &ee->element;
   struct GNUNET_MQ_Envelope *ev;
 
+
   ev = GNUNET_MQ_msg_extra (emsg, el->size, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT);
-  emsg->element_type = htonl (el->element_type);
+  emsg->element_type = htons (el->element_type);
   GNUNET_memcpy (&emsg[1], el->data, el->size);
   GNUNET_MQ_send (op->mq, ev);
   return GNUNET_YES;