From: Florian Dold Date: Mon, 27 Feb 2017 04:10:52 +0000 (+0100) Subject: fix set element type problem, make consensus work X-Git-Tag: taler-0.2.1~10 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ee3327de8fd04b2b8ce8692560c9f1d01a822baa;p=oweals%2Fgnunet.git fix set element type problem, make consensus work --- diff --git a/src/consensus/consensus_protocol.h b/src/consensus/consensus_protocol.h index fa445dc2e..e0002de56 100644 --- a/src/consensus/consensus_protocol.h +++ b/src/consensus/consensus_protocol.h @@ -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 diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 8b02031fd..6662ae8ca 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c @@ -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, diff --git a/src/consensus/test_consensus.conf b/src/consensus/test_consensus.conf index c3077b65d..c75205739 100644 --- a/src/consensus/test_consensus.conf +++ b/src/consensus/test_consensus.conf @@ -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 diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h index ca46d8746..6e822d82e 100644 --- a/src/include/gnunet_set_service.h +++ b/src/include/gnunet_set_service.h @@ -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. diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index 6b0520374..c69aa2a9c 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c @@ -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;