diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-02-27 05:10:52 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-02-27 05:10:52 +0100 |
commit | ee3327de8fd04b2b8ce8692560c9f1d01a822baa (patch) | |
tree | 2c5e594ab5e123aa7b106cc04eb904de425ea04d /src/consensus | |
parent | 2d92ec0f27dbefef916e94f5d272a2ff72091c54 (diff) | |
download | gnunet-ee3327de8fd04b2b8ce8692560c9f1d01a822baa.tar.gz gnunet-ee3327de8fd04b2b8ce8692560c9f1d01a822baa.zip |
fix set element type problem, make consensus work
Diffstat (limited to 'src/consensus')
-rw-r--r-- | src/consensus/consensus_protocol.h | 6 | ||||
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 25 | ||||
-rw-r--r-- | src/consensus/test_consensus.conf | 4 |
3 files changed, 23 insertions, 12 deletions
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 | |||
123 | uint8_t sender_index; | 123 | uint8_t sender_index; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | struct ConsensusStuffedElement | ||
127 | { | ||
128 | struct ConsensusElement ce GNUNET_PACKED; | ||
129 | struct GNUNET_HashCode rand GNUNET_PACKED; | ||
130 | }; | ||
131 | |||
126 | 132 | ||
127 | GNUNET_NETWORK_STRUCT_END | 133 | GNUNET_NETWORK_STRUCT_END |
128 | 134 | ||
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, | |||
915 | 915 | ||
916 | if (NULL != element) | 916 | if (NULL != element) |
917 | { | 917 | { |
918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
919 | "P%u: got element of type %u, status %u\n", | ||
920 | session->local_peer_idx, | ||
921 | (unsigned) element->element_type, | ||
922 | (unsigned) status); | ||
918 | GNUNET_assert (GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT == element->element_type); | 923 | GNUNET_assert (GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT == element->element_type); |
919 | consensus_element = element->data; | 924 | consensus_element = element->data; |
920 | } | 925 | } |
@@ -1371,21 +1376,21 @@ commit_set (struct ConsensusSession *session, | |||
1371 | } | 1376 | } |
1372 | for (i = 0; i < evil.num; i++) | 1377 | for (i = 0; i < evil.num; i++) |
1373 | { | 1378 | { |
1374 | struct GNUNET_HashCode hash; | ||
1375 | struct GNUNET_SET_Element element; | 1379 | struct GNUNET_SET_Element element; |
1376 | element.data = &hash; | 1380 | struct ConsensusStuffedElement se = { 0 }; |
1377 | element.size = sizeof (struct GNUNET_HashCode); | 1381 | element.data = &se; |
1378 | element.element_type = 0; | 1382 | element.size = sizeof (struct ConsensusStuffedElement); |
1383 | element.element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT; | ||
1379 | 1384 | ||
1380 | if (EVILNESS_SUB_REPLACEMENT == evil.subtype) | 1385 | if (EVILNESS_SUB_REPLACEMENT == evil.subtype) |
1381 | { | 1386 | { |
1382 | /* Always generate a new element. */ | 1387 | /* Always generate a new element. */ |
1383 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &hash); | 1388 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &se.rand); |
1384 | } | 1389 | } |
1385 | else if (EVILNESS_SUB_NO_REPLACEMENT == evil.subtype) | 1390 | else if (EVILNESS_SUB_NO_REPLACEMENT == evil.subtype) |
1386 | { | 1391 | { |
1387 | /* Always cram the same elements, derived from counter. */ | 1392 | /* Always cram the same elements, derived from counter. */ |
1388 | GNUNET_CRYPTO_hash (&i, sizeof (i), &hash); | 1393 | GNUNET_CRYPTO_hash (&i, sizeof (i), &se.rand); |
1389 | } | 1394 | } |
1390 | else | 1395 | else |
1391 | { | 1396 | { |
@@ -2103,8 +2108,8 @@ task_start_reconcile (struct TaskEntry *task) | |||
2103 | session->local_peer_idx, task->key.peer2, debug_str_set_key (&setop->input_set)); | 2108 | session->local_peer_idx, task->key.peer2, debug_str_set_key (&setop->input_set)); |
2104 | 2109 | ||
2105 | struct GNUNET_SET_Option opts[] = { | 2110 | struct GNUNET_SET_Option opts[] = { |
2106 | {GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } }, | 2111 | { GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } }, |
2107 | {0}, | 2112 | { GNUNET_SET_OPTION_END }, |
2108 | }; | 2113 | }; |
2109 | 2114 | ||
2110 | // XXX: maybe this should be done while | 2115 | // XXX: maybe this should be done while |
@@ -2539,8 +2544,8 @@ set_listen_cb (void *cls, | |||
2539 | (task->key.peer2 == session->local_peer_idx))); | 2544 | (task->key.peer2 == session->local_peer_idx))); |
2540 | 2545 | ||
2541 | struct GNUNET_SET_Option opts[] = { | 2546 | struct GNUNET_SET_Option opts[] = { |
2542 | {GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } }, | 2547 | { GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } }, |
2543 | {0}, | 2548 | { GNUNET_SET_OPTION_END }, |
2544 | }; | 2549 | }; |
2545 | 2550 | ||
2546 | task->cls.setop.op = GNUNET_SET_accept (request, | 2551 | 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/ | |||
5 | #OPTIONS = -L INFO | 5 | #OPTIONS = -L INFO |
6 | BINARY = gnunet-service-evil-consensus | 6 | BINARY = gnunet-service-evil-consensus |
7 | 7 | ||
8 | PREFIX = valgrind | 8 | #PREFIX = valgrind |
9 | 9 | ||
10 | #EVIL_SPEC = 0;cram-all;noreplace;5 | 10 | #EVIL_SPEC = 0;cram-all;noreplace;5 |
11 | #EVIL_SPEC = 0;cram;5/1;cram;5 | 11 | #EVIL_SPEC = 0;cram;5/1;cram;5 |
@@ -41,7 +41,7 @@ OPTIONS = -LERROR | |||
41 | [set] | 41 | [set] |
42 | #OPTIONS = -L INFO | 42 | #OPTIONS = -L INFO |
43 | #PREFIX = valgrind --leak-check=full | 43 | #PREFIX = valgrind --leak-check=full |
44 | #PREFIX = valgrind | 44 | PREFIX = valgrind |
45 | 45 | ||
46 | [testbed] | 46 | [testbed] |
47 | OVERLAY_TOPOLOGY = CLIQUE | 47 | OVERLAY_TOPOLOGY = CLIQUE |