Commit Graph

1350 Commits

Author SHA1 Message Date
eta 082a968eb8 Merge branch 'move-system-config' into 'main'
Move SystemConfig to arti::cfg

Closes #418 and #314

See merge request tpo/core/arti!427
2022-03-23 11:43:19 +00:00
eta c35bd79f5c Merge branch 'more_iso_docs' into 'main'
Expand documentation for isolation traits

See merge request tpo/core/arti!420
2022-03-23 11:42:51 +00:00
Nick Mathewson 84b98136c2 Merge branch 'channel_retries' into 'main'
Change rules for retrying guards (and marking them broken)

See merge request tpo/core/arti!426
2022-03-21 20:02:08 +00:00
Nick Mathewson ee204328dd Expand some comments based on review from @diziet. 2022-03-21 15:16:00 -04:00
Nick Mathewson 4a644a9879 circmgr: When planning, only keep one error; log them all. 2022-03-21 15:06:05 -04:00
Ian Jackson 9de0c024bf Adjust a comment
Noticed this while reviewing !426
2022-03-21 17:44:50 +00:00
Nick Mathewson 9ee502cbec Fix build with Rust 1.53.
Pattern bindings after `@` weren't stabilized then :/
2022-03-21 12:15:23 -04:00
Ian Jackson 1c213d4d89 Move SystemConfig to arti::cfg
Fixes #314, #418.
2022-03-21 15:54:11 +00:00
Nick Mathewson 28553d1cf4 Merge branch 'move-more-config' into 'main'
Move almost all of the rest of options.rs to arti crate

See merge request tpo/core/arti!425
2022-03-21 14:46:46 +00:00
Nick Mathewson 1ec0ed45c8 dirmgr: Note errors and inform the circmgr about them.
Some error types indicate that the guard has failed as a dircache.
We should treat these errors as signs to close the circuit, and to
mark the guard as having failed.
2022-03-21 10:27:53 -04:00
Nick Mathewson 8306a9cdcf GuardMgr:: generalize GuardId::from_relay. 2022-03-21 10:27:53 -04:00
Ian Jackson c3d56fb137 Run rustfmt to tidy up imports 2022-03-21 13:27:07 +00:00
Nick Mathewson 24e89a470f GuardMgr: new API to record guard problems from outside the crate.
We'll need this so that we can say "This guard behaved bogusly
as a directory cache; try somebody else."
2022-03-21 09:06:32 -04:00
Nick Mathewson acfa0f7770 dirclient: Collect and expose peer information from errors.
This commit refactors the dirclient error type into two cases:
errors when constructing a circuit, and errors that occur once we
already have a one-hop circuit.  The latter can usually be
attributed to the specific cache we're talking to.

This commit also adds a function to expose the information about
which directory gave us the info.
2022-03-21 09:06:32 -04:00
Nick Mathewson d38aafa054 Expose more peer information from circuit build failures
We already have the ability to get peer information from ChanMgr
errors, and therefore from any RetryErrors that contain ChanMgr
errors.

This commit adds optional peer information to tor-proto errors, and
a function to expose whatever peer information is available.
2022-03-21 09:06:32 -04:00
Nick Mathewson 87a3f6b58a dirclient: Remember the source of each resposne we receive. 2022-03-21 09:06:32 -04:00
Nick Mathewson 138287beb5 Reformat tor-dirclient Cargo.toml 2022-03-21 09:06:32 -04:00
Nick Mathewson d778a92225 circmgr: Change API for using FallbackDirs
It'll soon more convenient to pass in FallbackDirs as a slice of
references, rather than just a slice of FallbackDirs: I'm going to
be changing how we handle these in tor-dirmgr.
2022-03-21 09:06:32 -04:00
Nick Mathewson 451a53a5bf circmgr: use AllGuardsDown to retry better
If all guards are down and they won't be retriable for a while, try
waiting that long to get whichever guard _is_ retriable.

Additionally, if we are making multiple circuit plans in parallel,
only report our planning as having failed if we failed at making
_all_ the plans.  Previously we treated any failure as fatal for the
other plans, which could lead to trouble in the case when guards
were all down or pending.

Part of #407.
2022-03-21 09:06:32 -04:00
Nick Mathewson eed1f06662 GuardMgr: revise handling of "all guards are down".
When all guards are down, we would previously mark them all as up,
and retry aggressively.  But that's far too aggressive: if there's
something wrong with our ability to connect to guards, it makes us
hammer the network over and over, ignoring all the guard retry
timeouts in practice.

Instead,
  * We now allow the `pick_guard()` function to fail without
    automatically retrying.
  * We give different errors in the cases when all our guards are
    down, and when all of the guards selected by our active usage
    are down.
  * Our "guards are down" error includes the time at which a guard
    will next be retriable.

This is part of #407.
2022-03-21 09:06:32 -04:00
Nick Mathewson cb103e04cf GuardMgr: use decorrelated-jitter backoff for retrying guards.
C tor used one schedule, and guard-spec specified another.  But in
reality we should probably use a randomized schedule to retry
guards, for the reasons explained in the documentation for
RetrySchedule.

I've chosen the minima to be not too far from our previous minima
for primary and non-primary guards.

This is part of #407.
2022-03-21 09:06:32 -04:00
Ian Jackson a1236406c8 Merge branch 'udp-cleanup-410' into 'main'
UdpSocket: remove support for connect().

Closes #410

See merge request tpo/core/arti!424
2022-03-21 12:45:28 +00:00
Ian Jackson 94f4728a1c ApplicationConfig: abolish accessor 2022-03-21 12:39:50 +00:00
Ian Jackson 85cf744e9e Move ApplicationConfig to arti crate
Code motion and import fixups.
2022-03-21 12:39:50 +00:00
Ian Jackson 6986a433aa socks: abolish config accessors
Making these fields pub(crate) is quite reasonable and does away with
the need for accessors.
2022-03-21 12:39:50 +00:00
Ian Jackson 77b425ea0c Move ProxyConfig to arti crate
We put this in cfg.rs, rather than (say) socks.rs, because it has
config relating to both socks.rs and dns.rs.

Code motion and import fixups.
2022-03-21 12:39:50 +00:00
Ian Jackson f7c9910a43 Tidy up filt_from_opt_str
This was clumsy.  Now it is brought together it can be simplified.
2022-03-21 11:44:21 +00:00
Ian Jackson 75a7c91161 Abolish logging filter option accessors
This de-duplicates the code that was in those accessors, and is now in
filt_from_opt_str.

Code motion and direct field access.
2022-03-21 11:44:21 +00:00
Ian Jackson 7e64f65d76 Abolish easy accessors for logging config
There are no longer needed, because the code that uses this
configuration now lives in the same module as the configuration
itself.
2022-03-21 11:44:21 +00:00
Ian Jackson 32d3076a82 Move logging configuration from arti_config::options to arti::logging
Code motion and import fixups.
2022-03-21 11:44:21 +00:00
Ian Jackson b51fccb70e Rename arti::trace module to arti::logging
We are going to move LoggingConfig here.  We should follow the
already-public name IMO.
2022-03-21 11:42:44 +00:00
Ian Jackson 8aea5c9e43 Move ArtiConfig to new arti::cfg module
Code motion and import fixups.
2022-03-21 11:42:33 +00:00
Nick Mathewson ff05ed61d7 Merge branch 'accessors' into 'main'
Abolish some accessors in drmgr

See merge request tpo/core/arti!423
2022-03-18 21:14:14 +00:00
Ian Jackson d651a894de dirmgr: Authority: Abolish v3ident accessor
This makes this information crate-private.  The crate can reasonably
just access it.
2022-03-18 16:49:25 -04:00
Ian Jackson d1a9ed62f7 dirmgr: Authority: Move a method used only for testing 2022-03-18 16:49:25 -04:00
Ian Jackson 23cac566e1 dirmgr: Authority: Abolish two unused accessors 2022-03-18 16:49:25 -04:00
Ian Jackson 9c5480480a dirmgr: NetworkConfig: Abolish accessors
Using accessors for crate-only fields is otiose.
2022-03-18 16:49:25 -04:00
Ian Jackson a6d4109414 dirmgr: NetworkConfig: Rename fallbacks struct field
Rename this to be named the same as its accessor, and use the rename
feature of builder and serde.  (The shorter name is nicer in the code
IMO.)
2022-03-18 16:49:25 -04:00
Nick Mathewson 2aa5f45bc8 UdpSocket: remove support for connect().
Currently, Arti doesn't need this.  But once it does, it will be
way better to have a separate type for connected sockets, rather
than having to error-check every time somebody gives us a socket.

Part of #410
2022-03-18 15:39:40 -04:00
Ian Jackson 5a2f1b89f3 Actually throw an anyhow
Prompted by a compiler warning which I weirdly can't seem to reproduce?
2022-03-18 15:52:28 +00:00
Ian Jackson 981e6d7f01 Merge branch 'circ_path_api' into 'main'
ClientCirc: add functions to return the circuit's actual path

Closes #415

See merge request tpo/core/arti!419
2022-03-18 12:38:29 +00:00
Nick Mathewson cb29921e16 Expand documentation for isolation traits
These aren't complete yet; I'm just making this commit to capture
the notes we took on a pad when we were discussing these APIs.

Part of #414.
2022-03-17 13:49:32 -04:00
Nick Mathewson 9b7663b4ba Merge branch 'md_allocation' into 'main'
Use less space in hashtables for microdescriptors

Closes #386

See merge request tpo/core/arti!415
2022-03-17 16:45:38 +00:00
Nick Mathewson d39557b851 Define accessors for circuit hops.
Closes #415
2022-03-17 12:36:57 -04:00
Ian Jackson 0c0133dcc6 Run rustfmt 2022-03-17 16:22:15 +00:00
Nick Mathewson 764930b9cd tor-proto: Remember peer information in circuit and channel
Each channel now remembers an OwnedChanTarget.

Each circuit now remembers a vector of OwnedChanTarget to represent
the path that it was constructed for.

Part of #415.
2022-03-17 12:03:34 -04:00
Ian Jackson 955e3a3e40 GetMicrodescsState: Abolish separate n_missing field in 2022-03-17 15:49:31 +00:00
Ian Jackson 3a1e599d5a GetMicrodescsState: Break out with_mdreceiver_for_missing 2022-03-17 15:49:29 +00:00
Ian Jackson 1c6f4aaa9b GetMicrodescsState: Dedupe slightly 2022-03-17 15:29:10 +00:00
Nick Mathewson 567995a7ca ClientCirc: Move n_hops into a new Path type.
This will help with #415
2022-03-17 10:34:06 -04:00
Nick Mathewson 85a20ae4ec Alternative API for set_isolation_group().
Instead of requiring a `Box<dyn Isolation>`, it now takes either a
`Box<dyn Isolation>`, or an arbitrary `T` that implements
`Isolation`.

This API still allows the user to pass in a `Box<dyn Isolation>` if
that's what they have, but it doesn't require them to Box the
isolation on their own.

Part of #414.
2022-03-17 09:07:08 -04:00
Nick Mathewson 2818a3cb35 Merge branch 'test-isolation' into 'main'
new api for isolation

See merge request tpo/core/arti!377
2022-03-17 12:46:13 +00:00
Ian Jackson 40bede587c Merge branch 'config-partials-transparent' into 'main'
Absolish builders for CircMgrConfig and DirMgrConfig

See merge request tpo/core/arti!417
2022-03-17 12:30:46 +00:00
eta dd967e66b9 Merge branch 'always-ims' into 'main'
dirmgr: Always send if-modified-since on consensus documents.

Closes #403

See merge request tpo/core/arti!412
2022-03-16 21:32:48 +00:00
trinity-1686a 575792b583 replace TODOs with documentation 2022-03-16 20:33:36 +01:00
Ian Jackson a020f82de2 DirMgrConfig: abolish builder; make it transparent and exhaustive
See rationale in the comment.
2022-03-16 19:31:10 +00:00
Ian Jackson ab352881e3 Add rationale for CircMgrConfig transparency and trait 2022-03-16 19:31:08 +00:00
Ian Jackson 82aa4b902a Provide define_accessor_trait and use it to generate CircMgrConfig 2022-03-16 19:31:05 +00:00
Ian Jackson 8bde40fdd3 Make CircMgrConfig transparent (and make it a trait)
See commentary for the rationale.
2022-03-16 19:30:59 +00:00
Ian Jackson 8d54c0f073 Change type of TorClientConfig::override_net_params
Now we use NetParams.  That implies making its constructor public,
which I think it fine.

This is related to #413 but is far from completing that ticket.
2022-03-16 19:30:59 +00:00
Ian Jackson d0c71b3872 Actually honour preemptive circuits configuration
This handwritten conversion function omitted a field.  There was
nothing to spot this mistake.

IMO this shows why these particular types ought not to use builders,
but instead, should cause API breaks when things change.

Adding this line here to explicitly fix the bug, although we are about
to abolish this function completely almost right away.
2022-03-16 19:22:13 +00:00
trinity-1686a 8a2b8eb9b8 add isolation to dns requests 2022-03-16 19:50:24 +01:00
Dimitris Apostolou 7353fd4397
Fix typo 2022-03-16 20:25:46 +02:00
trinity-1686a 7c606048f2 accept boxed isolation in StreamPref::set_isolation_group 2022-03-16 19:24:23 +01:00
trinity-1686a 4eb90b72c0 add trait to help test isolation related code 2022-03-16 19:24:23 +01:00
trinity-1686a 0b7c71a888 add tests on Isolation and fix conditional compilation issues
it seems I added conditional compilation without noticing it??
and there was some errors when choosing a prefered runtime depending on
feature flags
2022-03-16 19:24:23 +01:00
trinity-1686a 59bef598a3 replace IsolationMap with new Isolation trait 2022-03-16 19:24:23 +01:00
trinity-1686a 698132a762 refactor restrict_mut 2022-03-16 19:24:23 +01:00
trinity-1686a cb00ac677b replace Arc with Box and use dyn-clone
this also removes JoinResult
2022-03-16 19:24:23 +01:00
trinity-1686a 43abd119cf replace result with either 2022-03-16 19:24:23 +01:00
trinity-1686a ec7737b322 add some documentation for new traits 2022-03-16 19:24:23 +01:00
trinity-1686a 778d6f3380 replace isolated with compatible
the inverted logic was too easy to mess up
2022-03-16 19:24:23 +01:00
trinity-1686a 4826d757ac use downcast-rs instead of our own AsAny 2022-03-16 19:24:19 +01:00
trinity-1686a 234291f666 fix existing tests 2022-03-16 19:23:21 +01:00
trinity-1686a b3b27c9bd3 add a join() on Isolation 2022-03-16 19:23:21 +01:00
Trinity Pointard a1b8b4999f testing new api for isolation 2022-03-16 19:23:21 +01:00
Ian Jackson fb4111f524 Merge branch 'derive-builder' into 'main'
derive_builder: Switch to upstream 0.11

See merge request tpo/core/arti!414
2022-03-16 17:54:53 +00:00
Ian Jackson da787d074a derive_builder: Switch to upstream 0.11
This has the different syntax for builder field attributes than what I
originally proposed in my MR, and which therefore is in the pinned
branch.

My upstream MR for the field attributes feature was morged:
  https://github.com/colin-kiegel/rust-derive-builder/issues/239
2022-03-16 16:34:44 +00:00
Nick Mathewson c3e74973b4 netdir: Use an even smaller rep for list of microdescs
Every time we want a microdescriptor, we know the index of that
microdesc's corresponding routerstatus within the consensus.
Therefore, we can use that index to store `Arc<Microdesc>`s in a
dense array, and not have to use a HashSet here at all.
2022-03-16 11:52:47 -04:00
Ian Jackson 644f962cfd Merge branch 'move-retry-delay' into 'main'
Move RetryDelay into tor-basic-utils

See merge request tpo/core/arti!411
2022-03-16 15:37:44 +00:00
Nick Mathewson 76df9e4014 tor-dirmgr: Remove redundant hashtable.
We were using a hashtable to keep track of missing microdescriptor
digests.  But this information is redundant with the NetDir state,
and there's now no longer any performance benefit to keeping a
separate copy.

Part of #386.
2022-03-16 11:33:19 -04:00
Nick Mathewson 233613cd79 NetDir: Use less space in hash tables
We previously kept missing-MD entries and present-MD entries all in
the same HashSet, which resulted in using more slack space than we
need.  Now we use separate tables, so we can drop missing-MD
entries as we move forward.

Also, when constructing a NetDir, set its hash tables to their final
capacities.

This also lets us simplify some of our missing-md-listing code a
lot.
2022-03-16 11:12:15 -04:00
Nick Mathewson 09f750c2c8 RetryDelay: remove accessors.
Instead, check initial_delay in dirmgr directly.
2022-03-16 10:50:13 -04:00
Ian Jackson 7564fabd68 Replace a match with some as_ref and as
The match was doing a deref coercion.

Found by current nightly's needless_match (whose suggestion doesn't
compile, https://github.com/rust-lang/rust-clippy/issues/8551 )
2022-03-16 14:41:04 +00:00
Nick Mathewson 4ccc3af423 dirmgr: Always send if-modified-since on consensus documents.
We never want a consensus document that's super-old, since we would
reject it immediately for being too old.

Also, never send an if-modified-since that's so old that we'd reject
the response.

Closes #403
2022-03-16 09:48:37 -04:00
Nick Mathewson 11883b9e8d Remove re-export of retry-schedule in tor-dirmgr.
It wasn't necessary.
2022-03-16 08:47:02 -04:00
Nick Mathewson 90c48dc1b0 Fix up documentation on RetryDelay.
It's no longer about downloads; it's about whatever you need to
retry.
2022-03-16 08:42:46 -04:00
Nick Mathewson 67645473d5 Move RetryDelay from dirmgr to basic-utils.
This (almost) a pure code-movement commit: it also makes one public
function private in order to suppress a warning.
2022-03-16 08:31:54 -04:00
Nick Mathewson ef619ba70a RetryDelay: add accessors for state
We'll need these for our unit tests in tor-dirmgr once we move
RetryDelay into tor-basic-utils.
2022-03-16 08:26:14 -04:00
Nick Mathewson e8c63fe3e8 tor-basic-utils/Cargo.toml: reformat.
This is a separate commit to avoid putting format changes in the
next commit.
2022-03-16 08:21:44 -04:00
trinity-1686a 60431ade4f make run_dns_resolver public and fix typo 2022-03-15 14:11:42 +01:00
trinity-1686a f4581ffd04 add simple unit test on UDP 2022-03-14 21:19:20 +01:00
trinity-1686a fa29925689 fix typos and minor issues 2022-03-14 21:16:56 +01:00
trinity-1686a 604362bf80 actually add DNS support 2022-03-14 21:04:38 +01:00
trinity-1686a 9b3be0ad47 add skeleton for DNS handling 2022-03-14 20:59:35 +01:00
trinity-1686a 4a44ef56c0 add udp to runtime 2022-03-14 20:59:33 +01:00
Nick Mathewson 8f430fd58d Merge branch 'main' into 'intern-more'
# Conflicts:
#   doc/semver_status.md
2022-03-14 14:19:44 +00:00
eta c0baf86e52 Merge branch 'missing_shrink_to_fit' into 'main'
dirmgr: Call shrink_to_fit on missing-microdesc hashtable

Closes #388

See merge request tpo/core/arti!399
2022-03-14 13:20:57 +00:00
eta 258e42ad3e Merge branch 'slice-from-ref' into 'main'
Simpify tor-netdoc TokVal

See merge request tpo/core/arti!404
2022-03-14 13:14:05 +00:00
Ian Jackson 8f5d089f53 Revert "humantime_serde_option: New module in tor-basic-utils"
We have upstreamed this code.

This reverts commit 6193c9d974.
2022-03-14 10:33:59 +00:00
Ian Jackson 409c5dd6d2 Use new upstream humantime_serde_option feature
Replace all uses of our copy of this code.
2022-03-14 10:33:59 +00:00
Ian Jackson 8b8c2a426e humantime: Update to humantime-serde 1.1.1
This has the humantime_serde::option module, which we have upstreamed
and are about to switch to.

The remaining dependency with  version = "1"  is going to be removed
in a moment.
2022-03-14 10:33:59 +00:00
Nick Mathewson a98ae2a1f0 Canonicalize and intern protover lines on descriptors
This should save around 1MB per consensus, since every relay has a
'protocols' lines, but there are only a few distinct possibilities
for such a line.

Closes #385.
2022-03-11 16:56:12 -05:00
Nick Mathewson 16f1bda324 Canonicalize and intern family representations to save memory.
This should save 1-3 MB of ram on each running arti client.

Closes #384. See also tor#27359 and proposal 298.
2022-03-11 16:54:33 -05:00
Ian Jackson 927594c3a6 Merge branch 'arti-lib' into 'main'
arti: Move all code from binary crate to library crate

See merge request tpo/core/arti!403
2022-03-11 19:57:53 +00:00
Nick Mathewson b835a48528 Merge branch 'smaller_routerstatus' into 'main'
tor-netdoc: Save allocation space in GenericRouterstatus

Closes #387

See merge request tpo/core/arti!400
2022-03-11 19:55:22 +00:00
Nick Mathewson 718a1ee340 Add a more generic implementation of intern-by-ref 2022-03-11 14:03:29 -05:00
Nick Mathewson 6f42c79654 netdoc: Call shrink_to_fit() when we're done parsing rs sections
(Once we're done parsing these, the vector will never get any
longer.)
2022-03-11 14:03:29 -05:00
Nick Mathewson 1c6c05fac3 netdoc: allocate no extra space for RouterStatus addresses.
This should save around 181K of heap on a current directory.
2022-03-11 14:03:29 -05:00
Nick Mathewson e7c584f1b3 netdoc: Make versions smaller in GenericRouterStatus
When the version is a Tor version, we can just parse it; otherwise,
we can intern it.  This shrinks GenericRouterStatus and avoids a lot
of extra help allocations.
2022-03-11 14:03:29 -05:00
Nick Mathewson 3c9093f294 tor-netdoc: reformat cargo.toml.
This is the default vscode format, and seems popular elsewhere.
This commit does nothing but reformat.
2022-03-11 14:03:29 -05:00
Nick Mathewson da82c76399 tor-netdoc: Remove unused or_port field from RS.
Part of #387
2022-03-11 14:03:29 -05:00
Ian Jackson 888eea47b3 tor-netdoc: Actually, make TokVal be a Vec
This enum was otiose: its set of valid values is precisely those of a
Vec.  (Indeed what would TokVal::Multi(vec![]) have meant?)
2022-03-11 18:42:01 +00:00
Ian Jackson 8226a68f7c arti library crate: Add another note about panicking 2022-03-11 18:28:37 +00:00
Ian Jackson 3b7d37e218 arti library crate: re-add clippy lints
I ought to have c&p these.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/403#note_2786099
2022-03-11 18:28:37 +00:00
Ian Jackson 4a9c660ce2 arti library crate: Add note about panicking 2022-03-11 18:28:37 +00:00
Ian Jackson 32fe5cdd5b arti: Make main module entrypoints pub
This does not constitute any kind of stable API promise.
But it might allow people to use our arti client code in novel ways.
2022-03-11 18:28:15 +00:00
Ian Jackson 4ae5f11c20 arti: Provide some rubric docs. 2022-03-11 18:28:15 +00:00
Ian Jackson e680960619 arti: Move all code from binary crate to library crate
This is just code motion and the minimal fixups.
2022-03-11 18:28:15 +00:00
Ian Jackson 9a7783a230 Remove a pointless slice
std::slice::from_ref exists.  Spotted while reviewing !400
2022-03-11 18:24:03 +00:00
Ian Jackson d320413912 Merge branch 'config-flatten' into 'main'
Make ArtiConfigBuilder contain a TorClientConfigBuilder

See merge request tpo/core/arti!401
2022-03-11 18:22:23 +00:00
Ian Jackson f914eee6bc rustfmt 2022-03-11 16:41:59 +00:00
Nick Mathewson 837c7d717b Follow-up from arti!318
Make update_config only conditionally exported; add semver-status update.
2022-03-11 11:34:51 -05:00
Nick Mathewson d95dce7c70 Merge branch 'add-flatfile-dirmgr' into 'main'
Add flatfile DirMgr

See merge request tpo/core/arti!318
2022-03-11 16:34:26 +00:00
Ian Jackson 1d281abaf8 Make ArtiConfigBuilder contain a TorClientConfigBuilder
This is an API break: now one must use `.tor()` to access the Tor
configuration parts.

But it is not a config file format break, because `#[serde(flatten)]`.
2022-03-11 16:18:27 +00:00
Ian Jackson 0bbee1e477 Make TorClientConfigBuilder Deserialize
As per #371
2022-03-11 16:18:22 +00:00
Christian Grigis 65486b185a
Expose APIs for external DirProvider 2022-03-11 13:44:48 +01:00
Nick Mathewson d9c1555229 dirmgr: Call shrink_to_fit on missing-microdesc hashtable
This hashtable starts out pretty large, but it can spend most of our
runtime (when we aren't downloading) being small.  To avoid doing
too much work, I've made it so we only call shrink_to_fit twice per
consensus: once when we're no longer pending, and once when we're
complete.

Closes #388.
2022-03-10 11:48:58 -05:00
Ian Jackson 6761cf2b69 Merge branch 'config-no-retcon' into 'main'
Drop config back-conversion from FooConfig to FooConfigBuilder

See merge request tpo/core/arti!391
2022-03-10 14:47:01 +00:00
Nick Mathewson 98c5c5b824 Merge branch 'arti-testing-part2' into 'main'
arti-testing: support for simulated TCP breakage

See merge request tpo/core/arti!392
2022-03-10 14:08:44 +00:00
Nick Mathewson d1b151436e arti-testing: Make Action implement Copy 2022-03-10 08:45:56 -05:00
Christian Grigis 335af4ac30
Add methods to `UnverifiedConsensus` 2022-03-10 11:29:58 +01:00
eta 4f34f7cea8 Merge branch 'ticket_391' into 'main'
arti-bench: don't allocate a separate receive-buffer for each job

Closes #391

See merge request tpo/core/arti!395
2022-03-09 13:26:44 +00:00
Ian Jackson 3425a6cbcd Merge branch 'ticket_383' into 'main'
tor-chanmgr: Do not allocate an Internal error unless we mean it.

Closes #383

See merge request tpo/core/arti!394
2022-03-09 11:30:08 +00:00
Nick Mathewson 26bdbc4b61 arti-bench: don't allocate a separate receive-buffer for each job
This makes heap profiling more viable.

Closes #391.
2022-03-08 16:41:06 -05:00
Nick Mathewson a110755193 tor-chanmgr: Do not allocate an Internal error unless we mean it.
Previously we'd allocate an error as a place-holder here, but it's
not a great idea to do that with a `Bug`: each `Bug` stores a whole
stack trace, which uses a whole pile of allocations to construct.

Now we keep an `Option<Error>` instead.

Found while heap profiling.

Closes #383.
2022-03-08 14:04:25 -05:00
Nick Mathewson a460de6e75 arti-testing: reverse two more attrs in attempt to fix min-versions 2022-03-07 15:29:44 -05:00
Nick Mathewson 84536a9c1e arti-testing: reverse two attrs in attempt to fix min-versions 2022-03-07 14:34:02 -05:00
Nick Mathewson de0cf90a32 arti-testing: todo comment cleanup 2022-03-07 11:47:25 -05:00
Nick Mathewson a86f00c222 arti-testing: support for conditional TCP failure. 2022-03-07 11:44:43 -05:00
Ian Jackson 56c2153b9e Merge branch 'fix-expand-tilde-on-windows' into 'main'
Fix expand tilde and invalid path chars on windows

See merge request tpo/core/arti!274
2022-03-07 16:35:15 +00:00
Nick Mathewson 3aed633559 arti-testing: add support for black-holing TCP connections. 2022-03-07 11:26:13 -05:00
Ian Jackson 1b1ce8cc82 Drop remaining conversion from FooConfig to FooConfigBuilder 2022-03-07 15:58:53 +00:00
Ian Jackson 56cb1cef4e Have ArtiConfig contain a TorClientConfig, and drop builder retcon
Replace the recapitulation of TorClientConfig fields in ArtiConfig and
instead just have it contain one.  This is part of #374.

The conversions from ArtiConfig back to ArtiConfigBuilder and
TorClientConfigBuilder would need to change, but, since we don't want
them anyway,

No longer impl Deserialize for ArtiConfig.  (As per #371 this will
want to become a private type.)

No longer impl From<ArtiConfig> for ArtiConfigBuilder and
TorClientConfigBuilder.  And abolish tests of that code.

(This all has to be in one commit, because previously
ArtiConfig::tor_client_config used the validated-to-builder config
retcon.)
2022-03-07 15:58:53 +00:00
Ian Jackson 92d1855b0e Provide way to get TorConfigBuilder from ArtiConfigBuilder
This is needed according to #372, where we observe that builders ought
not to be generated from validated structs.  So we need this
conversion.
2022-03-07 15:58:53 +00:00
Ian Jackson 56bd15b671 Derive Deserialize for handwritten ArtiConfigBuilder 2022-03-07 15:58:53 +00:00
Ian Jackson 5203311a97 Derive Deserialize for derive-builder-generated config builders
I used
  git-grep -P '\#\[serde\((?!default|deny_unknown)'
to find places where I needed to add additional attributes on the
builder method fields.

This is currently a bit duplicative, but when #371 is completely done,
the validated (non-builder) configs won't need to be Deserialize any
more.

This is part of #371 and #372.
2022-03-07 15:58:53 +00:00
Ian Jackson 416b56d852 Use git source for derive_builder for now, for attrs feature
We are going to want to specify custom attributes on fields of the
builder struct.  This feature was missing from derive_builder.

This commitid is the current head of my MR branch
  https://github.com/colin-kiegel/rust-derive-builder/pull/237
  https://github.com/ijackson/rust-derive-builder/tree/builder-field-attrs
Using the commitid prevents surprises if that branch is updated.

We will require this newer version of derive_builder.  The version
will need to be bumped again later, assuming the upstream MR is merged
and upstream do a release containing the needed changes.
2022-03-07 15:56:57 +00:00
Nick Mathewson 5d91fa7f5a arti-testing: CLI for making TCP connections break. 2022-03-07 10:52:04 -05:00
eta c27dde59b6 Merge branch 'moderately-enthused-eyeballs' into 'main'
Implement a basic form of RFC 8305 ("happy eyeballs") for channels

See merge request tpo/core/arti!382
2022-03-07 15:26:37 +00:00
Nick Mathewson ca6070b962 arti-testing: Initial support for broken TCP.
This commit adds support for a BrokenTcp provider that can make
connection attempts fail or time out.  It doesn't yet have a way to
turn on the failure.
2022-03-07 10:12:48 -05:00
eta c98d9dc5fe Implement a basic form of RFC 8305 ("happy eyeballs") for channels
This makes Arti usable in IPv6-only environments (arti#92) by letting us
attempt multiple connections to a given relay using all of its
addresses instead of just using the first (probably IPv4) one, using the
strategy from RFC 8305 § 5.

This isn't a complete implementation of Happy Eyeballs; ideally, we'd
sort the address list before doing concurrent connections. However, it
works (and has been tested inside an IPv6-only container inside eta's
network :p)
2022-03-07 14:56:51 +00:00
Nick Mathewson cc6ba72dc3 Merge branch 'bench_multicirc' into 'main'
arti-bench: support multiple streams per circuit, multiple circuits per sample.

Closes #380

See merge request tpo/core/arti!384
2022-03-07 14:11:53 +00:00
Nick Mathewson 49216a5202 arti-bench: documentation fixes 2022-03-07 08:42:20 -05:00
Nick Mathewson 22ee7671f8 arti-bench: record streams_per_circ and circs_per_sample. 2022-03-07 08:38:02 -05:00
Ian Jackson 6193c9d974 humantime_serde_option: New module in tor-basic-utils
This will be used to allow our config *builder* structs to be
Deserialize.
2022-03-07 12:38:30 +00:00
Michael 206714f2e4 Test shell variable expansion on windows 2022-03-05 01:40:42 +00:00
Lennart Kloock ef21559df1
Add config paths table in `arti` docs 2022-03-04 22:43:14 +01:00
Nick Mathewson cb846de367 Merge branch 'reproducible-build-fix-summary-git' into 'main'
fix reproducible build summary giving invalid branch and commit id

Closes #378

See merge request tpo/core/arti!383
2022-03-04 19:52:19 +00:00
Nick Mathewson 994a8f7cfa Merge branch 'errors-for-dirprovider' into 'main'
Errors for dirprovider

Closes #370

See merge request tpo/core/arti!385
2022-03-04 19:51:23 +00:00
trinity-1686a 5e5864802d fix reproducible build summary giving invalid branch and commit id
fix #378
also fix unrelated error in nightly rustdoc CI
2022-03-04 19:25:40 +01:00
Ian Jackson b095265257 Merge branch 'educe-traits' into 'main'
Replace many manual trait impls with use of educe

See merge request tpo/core/arti!375
2022-03-04 18:00:17 +00:00
Nick Mathewson e4ed8241ba Fix an unwrap() error. 2022-03-04 12:37:22 -05:00
Ian Jackson 055b7399f2 Provide ErrorKind::Other 2022-03-04 17:35:34 +00:00
Ian Jackson 4bff33c397 Provide an error variant for external directory providers 2022-03-04 17:35:34 +00:00
Ian Jackson 952aef1be3 Merge branch 'hex_decode' into 'main'
Speed up RsaIdentity decoding

Closes #377

See merge request tpo/core/arti!381
2022-03-04 17:22:52 +00:00
Nick Mathewson 8c34896651 arti-bench: use isolation to support multiple circuits per run. 2022-03-04 12:22:43 -05:00
Ian Jackson 0cfb6a0e0f tor-basic-utils: copy the README into lib.rs
The doc include rune does not work with our MSRV; it needs 1.54.

The alternative would be some kind of cfg() but that would
  - not provide the crate-level doc on Rust 1.53
  - involve the use of cfg_attr

Instead, just do it the old way.
2022-03-04 16:54:54 +00:00
Nick Mathewson 42245de9f5 arti-bench: simplify future-creation code slightly 2022-03-04 11:45:45 -05:00
Nick Mathewson c978a0d78b arti-bench: refactor stream construction to connect in parallel
Previously we tried to do each connection in a run, and only then did we
start transferring data over them.  Now we collect a bunch of the
futures that return an open stream, and run them all in parallel
with using them.  This change includes connect-time in our
benchmarks, and allows us to test contention in our connect code.

Instead of using a Stream, I've changed the connection-generation
code to call a future-returning function directly, so we have a way
to explicitly pass which run we're in.
2022-03-04 11:41:51 -05:00
eta 8d26726fdf Merge branch 'arti-testing-part1' into 'main'
arti-testing: Initial implementation

See merge request tpo/core/arti!378
2022-03-04 16:29:41 +00:00
Nick Mathewson c23dad8c2d Use RsaIdentity::from_hex() and hex::decode_to_slice in more places
These aren't critical-path, but they do make the code a little nicer.
2022-03-04 09:23:26 -05:00
Nick Mathewson caf372ac0f tor-netdoc: Use RsaIdentity::from_hex() in critical path.
This commit changes the main parsing code for RsaIdentity in
tor-netdoc, and .

Previously, parse_hex_ident was something like 10% of our startup
CPU time; now it's only like ~2%.  (Still not perfect, but way
better.)

Closes #377.
2022-03-04 09:05:04 -05:00
Nick Mathewson b6452b4812 Add a from_hex method for RsaIdentity.
We perform this operation in a bunch of places, and most of them
use hex::decode().  That's not great, since hex::decode() has to do
heap allocation.  This implementation uses hex::decode_to_slice(),
which should be faster.

(In the future we might choose to use one of the faster hex
implementations, but I'm hoping that this change will be sufficient
to get hex decoding out of our profiles.)

Part of #377.
2022-03-04 08:55:34 -05:00
Ian Jackson 6e1da0145b Remove now-obsolete note about location of skip_fmt
Now the diff from the merge base does not contain any hits for ^\+.*bytes
2022-03-04 11:45:24 +00:00
Ian Jackson ebfd734956 Move skip_fmt into tor-basic-utils
Code motion and the minimal mechanical changes.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/375#note_2783078
2022-03-04 11:45:24 +00:00
Ian Jackson aba68088d1 Introduce tor-basic-utils
Empty crate right now
2022-03-04 11:45:24 +00:00
Ian Jackson eb66d0af6f Merge branch 'derive-traits' into 'main'
Tidy up many open-coded trait impls

See merge request tpo/core/arti!374
2022-03-04 11:25:57 +00:00
Ian Jackson 64cc5b8537 Move educe to dev-dependencies of tor-bytes
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/375#note_2783080

This is going to move to a new crate, but doing this now makes
things slightly clearer for me.
2022-03-04 11:03:04 +00:00
eta e9f8ddfb9c Fix introduced junk in doc comment. 2022-03-04 10:56:40 +00:00
Ian Jackson 2a7915e6f6 Merge branch 'return_ref_arc' into 'main'
arti-client: Make dirmgr() and circmgr() return &Arc<..>

Closes #369

See merge request tpo/core/arti!379
2022-03-04 10:55:21 +00:00
Nick Mathewson a4914b990b arti-client: Make dirmgr() and circmgr() return &Arc<..>
Previously they returned an Arc, which wasn't necessary unless the
client actually _wanted_ a new Arc.

This would be an API break, except that these functions are marked
'experimental-api', so semver does not apply; nonetheless I've noted
the break in semver_status.md, just in case we care.

Closes #369
2022-03-03 14:08:27 -05:00
Nick Mathewson 06f0339b97 Allow println in arti-testing. 2022-03-03 14:01:44 -05:00
Nick Mathewson 9329c7b878 arti-testing: Initial implementation
This commit adds a new program to try to implement the ideas behind
experimentation in arti#329.  In particular, it tries to implement
basic client "can I bootstrap and connect" functionality testing,
with a lot of instrumentation, and support for breaking things.

So far, the instrumentation is limited to counting TCP bytes and
connections, and counting events.  Still, this is enough to measure
behavior on some of the incorrect-clock tests.

NOTE:

For now, you are _required_ to pass in an explicit configuration, in
hopes that this will lead you to override your storage directories
for doing specific experiments.
2022-03-03 13:05:30 -05:00
eta 64c8ee0d1f Merge branch 'shellexpand' into 'main'
Switch to shellexpand-fork version of shellexpand

See merge request tpo/core/arti!373
2022-03-03 14:31:52 +00:00
Ian Jackson b27ffe14fb Merge branch 'dir-provider-redux' into 'main'
Alternative DirProvider setup

See merge request tpo/core/arti!347
2022-03-02 18:41:50 +00:00
Ian Jackson daa44df221 Replace manual Default impls with educe in tor-guardmgr 2022-03-02 18:06:37 +00:00
Ian Jackson 738f7efa3d Replace manual Default impl with educe in tor-dirmgr 2022-03-02 18:06:37 +00:00
Ian Jackson 4fbb088907 Replace manual Default impl with educe+std in tor-dirmgr 2022-03-02 18:06:37 +00:00
Ian Jackson bb1d59e073 Replace manual Default impl with educe in tor-cell 2022-03-02 18:06:37 +00:00
Ian Jackson ac0ed6ab65 Replace manual Default impls on enums with educe in arti-client 2022-03-02 18:06:37 +00:00
Ian Jackson 2a782a71c0 Refrain from replacing manual with educe Debug impl in caret
Instead, leave a comment saying we have left it this way deliberately.
2022-03-02 18:06:37 +00:00
Ian Jackson 1b8a8f933a Replace manual Debug impl with educe in arti-client 2022-03-02 18:06:37 +00:00
Ian Jackson decdd05ec5 Replace manual Clone impl with educe in arti-hyper 2022-03-02 18:06:37 +00:00
Ian Jackson ea03cc4084 Replace manual Clone impl with educe in tor-rtcompat 2022-03-02 18:06:37 +00:00
Ian Jackson 9dca756e23 Replace manual Debug impls with educe in tor-proto
We now print slighly more information.
2022-03-02 18:06:37 +00:00
Ian Jackson 210b9b70a8 Replace manual Debug impl with educe in tor-dirmgr 2022-03-02 18:06:37 +00:00
Ian Jackson f467f4666e Replace manual Debug impl with educe in tor-chanmgr 2022-03-02 18:06:37 +00:00
Ian Jackson 1c44dfa595 Replace manual Debug impl with educe in tor-cell 2022-03-02 18:03:00 +00:00
Ian Jackson b2d8c14c90 Replace manual Debug impl with educe in tor-guardmgr 2022-03-02 18:03:00 +00:00