Thomas Eizinger
a1dd85f481
Split `Cfd#handle` function into multiple
We always constructed the specific enum variant at the call site.
Might as well call a particular function which is simpler.
3 years ago
Thomas Eizinger
e297a4468a
Simplify invoking `oracle::GetAnnouncement`
Moving the error message into the handler reduces complexity in the
cfd actor.
3 years ago
Thomas Eizinger
211072b9ed
Remove unnecessary indirection of `TakerCommand`
3 years ago
Mariusz Klochowicz
beb10e84fd
Don't use tokio feature from xtra
Prefer using our FutureExt to enforce keeping RemoteHandles to prevent zombie
tasks.
3 years ago
Mariusz Klochowicz
855181f06c
Expand Tasks API for ergonomics
The fact that we're storing a Vec<RemoteHandle<()>) internally is an
implementation detail.
Calling `spawn_with_handle` is done internally now, guarded by a `debug_assert!`
macro discouraging from doing it twice.
3 years ago
Mariusz Klochowicz
6afe3f8e6c
Disallow calls to tokio::spawn outside dedicated extension trait
Prevent accidentally spawning a task that could outlive the actor system
and become a zombie.
Any long-lived task should be tied to its owner by keeping RemoteHandle around.
3 years ago
Mariusz Klochowicz
bea968d27b
Tie lifetimes of spawned tasks to actors
3 years ago
Thomas Eizinger
30dc9481e4
Ban do_send_async and do_send functions
Both of these discard the return value which can lead to hard to find
bugs if the return value is an `Err`.
3 years ago
Thomas Eizinger
dd69419c4e
Migrate `do_send_async` to `send`
These handlers never fail. Nothing left to do.
3 years ago
Thomas Eizinger
56170250b8
Migrate `do_send_async` to `send`
Broadcasting an order never fails.
3 years ago
Thomas Eizinger
0eaa1ff82e
Migrate `do_send_async` to `send`
These handlers never fail and we are always connected.
3 years ago
Thomas Eizinger
ca36e0b8f4
Migrate `do_send_async` to `send`
We cleaned up our internal state already, hence we can bubble up
the error here.
3 years ago
Thomas Eizinger
e448f37442
Migrate `do_send_async` to `send`
This cannot fail, nothing left to do.
3 years ago
Thomas Eizinger
4e34bbade4
Migrate `do_send_async` to `send`
First log the warning, then attempt to send. This makes sure we always
log the warning, even if we fail to send the message.
3 years ago
Thomas Eizinger
a253a62582
Migrate `do_send_async` to `send`
First clean up state, then attempt to send the message. If it fails,
we bubble up but leave things in a consistent state.
3 years ago
Thomas Eizinger
7f0a218502
Migrate `do_send_async` to `send`
If we fail to deliver `NotifySettlementAccepted`, we just clean-up
our internal state.
3 years ago
Thomas Eizinger
ec8e4d6c6a
Migrate `do_send_async` to `send`
Handling the `Sync` message is quick because we internally use
concurrency to fetch attestations and announcement. This will not
actually block startup.
3 years ago
Thomas Eizinger
8c025d4ed2
Mock handlers for contract setup
Running this test with `--nocapture` reveals that we have unmocked
handlers. Adding these mocks fixes those panics (which are being
captured by tokio and hence did not abort the test).
Additionally we specialize the `mock_common_handlers` function to just
deal with the two `Sync` messages to make it clear that no more mocks
should be added to this function.
3 years ago
Thomas Eizinger
47bfc3a2a9
Replace implementation of TakerId with public key
This is a backwards-incompatible change in regards to the database
because we previously serialized UUIDs and now expect to deserialize
public keys.
It is a first step towards #576 .
3 years ago
Thomas Eizinger
8bda269e7a
Improve variable naming
3 years ago
Thomas Eizinger
0b2d2ec3c2
Prefer tracing fields of stringified log message
3 years ago
Mariusz Klochowicz
342c36ef72
Reduce heartbeat interval in test harness
As a rule of thumb, taker waits twice the amount of HEARTBEAT_INTERVAL until it
assumes that maker disappeared.
3 years ago
Mariusz Klochowicz
e8d2c86182
Add a test for triggering and noticing a maker shutdown
3 years ago
Mariusz Klochowicz
9c4e89325f
Tie tasks spawned inside actor systems to actor system lifetime
When the actor system shuts down, async tasks spawned by it on the tokio runtime
should be stopped too.
3 years ago
Mariusz Klochowicz
143cc09e65
Extend our futures trait for better ergonomics with remote handles
Simplify dealing with spawning a task on a runtime that returns a remote a
handle that can be used to stop it.
3 years ago
Thomas Eizinger
573a950527
Remove left-over dbg!
3 years ago
Thomas Eizinger
05a883297f
Prettify log message for sending message
3 years ago
Thomas Eizinger
900d9560e2
Log readiness of actor systems
3 years ago
Thomas Eizinger
b1f6e9e1db
Generalize logging for received messages
3 years ago
Thomas Eizinger
ca2bd5e291
Statically ensure that our only failure mode is `NoConnection`
By creating a dedicated error type, we can communicate that the only
failure mode of this function is a missing connection.
3 years ago
Thomas Eizinger
561b189de1
Remove unnecessary `Result` return value
3 years ago
Thomas Eizinger
89576974e2
Inline `handle_new_order`
This indirection is unnecessary.
3 years ago
Thomas Eizinger
1e38ec38ac
`unwrap` only in the tests
This makes the stacktrace more useful because it shows us where exactly
it is failing.
3 years ago
Thomas Eizinger
7bdc93c636
Reduce timeout to 10 seconds
With the reduced number of payout curve entries, our tests are
always fast.
3 years ago
Mariusz Klochowicz
6c5e17edad
Use the same actor systems in production and testing
Removes the need to manually align test harness whenever actor systems get
expanded.
3 years ago
Thomas Eizinger
4b85cd5704
Log establishment of connection
3 years ago
Thomas Eizinger
cf5e50029c
Use `TcpStream` to connect to address
Not only this now automatically support IPv6, it is also shorter.
3 years ago
Thomas Eizinger
a4c0b181cf
Allow domains for maker argument
Resolving a DNS entry to a socket address can yield multiple A records.
Thus we need to try all of them.
Resolves #292 .
3 years ago
Thomas Eizinger
97ed7ba54e
Extract connecting into helper function
3 years ago
Thomas Eizinger
b118ffece5
Remove maker default address
This made only sense during local testing.
3 years ago
Thomas Eizinger
b01e3b1dc6
Move handling of bad connection into `send_to_taker` function
This makes sure we notice bad connections upon all messages.
3 years ago
Thomas Eizinger
49d4665fa9
Don't log entire order to avoid log spam
3 years ago
Mariusz Klochowicz
ef27eff999
Improve user-facing string if taker daemon shuts down
Make the error toast suggest the next reasonable action in case of such event.
3 years ago
Mariusz Klochowicz
31168e1cd0
Reduce log spam by logging heartbeats at trace level
This is a periodic message, no need to spam the logs.
3 years ago
Mariusz Klochowicz
8d53f397a2
Improve naming of noise protocol parameters
3 years ago
Thomas Eizinger
cfc8add012
Change to edition 2021
3 years ago
Daniel Karzel
bfb2dba0c2
Make sure not to fail in for loop sending to takers
3 years ago
Mariusz Klochowicz
cbb52f011c
Use a connection actor for the taker
Connection actor takes care of establishing a connection to the maker and is
monitoring its status.
The connection actor:
- listens for periodically sent heartbeat messages from the maker,
- publish the maker status on a watch::channel feed outside TakerActorSystem,
- observe changes on the watch channel and shut down Rocket if maker goes offline
Note: this is a stepping stone resulting in temporary behaviour. Eventually,
we'd want to support reconnecting to the maker as well as operating the
taker without the maker being online (with a limited set of actions).
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Thomas Eizinger
d2217d3f91
Make number of payouts configurable
This allows us to use less payouts in the tests which makes them
faster.
3 years ago
Daniel Karzel
ed9f368305
Configurable log levels on both taker and maker
Add configurable log levels on taker and maker and start tracing connection related information to track down a problem where the taker does not receive orders but there are not connection errors on both sides.
3 years ago