diff options
author | Micah Elizabeth Scott <beth@torproject.org> | 2023-03-31 13:36:58 -0700 |
---|---|---|
committer | Micah Elizabeth Scott <beth@torproject.org> | 2023-05-10 07:40:46 -0700 |
commit | 903c6cf1ab5ba115bbfd33385e0acd5f88ad2ba3 (patch) | |
tree | cfdc82f2f312dcf7c6567c67958ee2249b2a76d7 /src/test/test_hs_pow_slow.c | |
parent | ac466a22195f8d550a8612bb89583c5e58eadb1a (diff) | |
download | tor-903c6cf1ab5ba115bbfd33385e0acd5f88ad2ba3.tar.gz tor-903c6cf1ab5ba115bbfd33385e0acd5f88ad2ba3.zip |
hs_pow: client side effort adjustment
The goal of this patch is to add an additional mechanism for adjusting
PoW effort upwards, where clients rather than services can choose to
solve their puzzles at a higher effort than what was suggested in the
descriptor.
I wanted to use hs_cache's existing unreachability stats to drive this
effort bump, but this revealed some cases where a circuit (intro or
rend) closed early on can end up in hs_cache with an all zero intro
point key, where nobody will find it. This moves intro_auth_pk
initialization earlier in a couple places and adds nonfatal asserts to
catch the problem if it shows up elsewhere.
The actual effort adjustment method I chose is to multiply the suggested
effort by (1 + unresponsive_count), then ensure the result is at least
1. If a service has suggested effort of 0 but we fail to connect,
retries will all use an effort of 1. If the suggestion was 50, we'll try
50, 100, 150, 200, etc. This is bounded both by our client effort limit
and by the limit on unresponsive_count (currently 5).
Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
Diffstat (limited to 'src/test/test_hs_pow_slow.c')
-rw-r--r-- | src/test/test_hs_pow_slow.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/test/test_hs_pow_slow.c b/src/test/test_hs_pow_slow.c index fdade2d3fa..e7d1311cee 100644 --- a/src/test/test_hs_pow_slow.c +++ b/src/test/test_hs_pow_slow.c @@ -187,17 +187,16 @@ test_hs_pow_vectors(void *arg) uint8_t rng_bytes[HS_POW_NONCE_LEN]; hs_pow_solution_t output; hs_pow_solution_t solution = { 0 }; - hs_pow_desc_params_t params = { - .type = HS_POW_DESC_V1, - .suggested_effort = vectors[vec_i].effort, + hs_pow_solver_inputs_t input = { + .effort = vectors[vec_i].effort, }; - tt_int_op(strlen(seed_hex), OP_EQ, 2 * sizeof params.seed); + tt_int_op(strlen(seed_hex), OP_EQ, 2 * sizeof input.seed); tt_int_op(strlen(solve_rng_hex), OP_EQ, 2 * sizeof rng_bytes); tt_int_op(strlen(nonce_hex), OP_EQ, 2 * sizeof solution.nonce); tt_int_op(strlen(sol_hex), OP_EQ, 2 * sizeof solution.equix_solution); - tt_int_op(base16_decode((char*)params.seed, HS_POW_SEED_LEN, + tt_int_op(base16_decode((char*)input.seed, HS_POW_SEED_LEN, seed_hex, 2 * HS_POW_SEED_LEN), OP_EQ, HS_POW_SEED_LEN); tt_int_op(base16_decode((char*)rng_bytes, sizeof rng_bytes, @@ -210,11 +209,11 @@ test_hs_pow_vectors(void *arg) sizeof solution.equix_solution, sol_hex, 2 * sizeof solution.equix_solution), OP_EQ, HS_POW_EQX_SOL_LEN); - memcpy(solution.seed_head, params.seed, HS_POW_SEED_HEAD_LEN); + memcpy(solution.seed_head, input.seed, HS_POW_SEED_HEAD_LEN); memset(&output, 0xaa, sizeof output); testing_enable_prefilled_rng(rng_bytes, HS_POW_NONCE_LEN); - tt_int_op(0, OP_EQ, hs_pow_solve(¶ms, &output)); + tt_int_op(0, OP_EQ, hs_pow_solve(&input, &output)); testing_disable_prefilled_rng(); tt_mem_op(solution.seed_head, OP_EQ, output.seed_head, @@ -224,7 +223,7 @@ test_hs_pow_vectors(void *arg) tt_mem_op(&solution.equix_solution, OP_EQ, &output.equix_solution, sizeof output.equix_solution); - tt_int_op(testing_one_hs_pow_solution(&output, params.seed), OP_EQ, 0); + tt_int_op(testing_one_hs_pow_solution(&output, input.seed), OP_EQ, 0); } done: |