Move the logic of creating Cfd representation suitable for UI into the
projection actor
For the time being, keep the logic as free functions that are still used in the
"old" way (inside ToSseEvent)
This is to avoid going on chain in a scenario where one party finished the rollover, while the other party ran into a timeout after send-/receiving the last message for the revoke-commit.
This is to avoid going on chain in a scenario where one party sent the signed lock transaction, but did not get the signed transaction from the other party before running into the timeout.
With this solution, we fail the setup (on either side) if we don't receive an acknowledgment message at the end of the setup.
The acknoledge message is a temporary fix.
Once we add monitoring for incomplete DLCs (special case of contract-setup / rollover / collaborative-settlement failing) the ack message should be removed.
As we do not process messages concurrently, heartbeat messages are not processed
during lengthy operations, such as contract setup.
The spam in the amount of commit messages is a bit unfortunate, but only failing
tests on various machines can indicate that the timing might cause issues.
Contract setup test keeps failing when bors runs it.
Note: contract setup got recently refactored into a dedicated actor, this might
have increased the time it takes to finish the process.
By default tests use the same heartbeat interval as production code.
Allow adjusting the value using builder pattern is tests that otherwise take too
long to complete (as they wait for timeout to trigger).
Disable long-running test to speed up build/test cycle for devs.
This means it is not run by default, in order to run it you have to specify the
test name or run `cargo test -- --ignored`
Either of the roles has to record the outcome of the setup, which should be the same for them.
In order to handle this in our event model we need `Completed` in the model so it is not role specific.
The dirty shutdown we observed were caused by the sqlite pool patiently waiting
until we close the connection we've opened in the application setup.
This is turn was eventually triggering Rocket timeout (which is by default
configured to wait 5s for cleanup).
Tighten the scope of connections needed during application startup only to the
necessary minimum (housekeeping & loading cfds at startup)
Originally we thought we need this enum because we would need to use
`MessageChannel`s from the rocket layer. But we can actually fully
qualify the address without issues.
We also introduce `xtra_productivity` to remove some of the indirection
that is happening in this file.
Note: Projection actor is used across both taker and maker, so it really should
publish information about connected counterparty.
Taker should use that channel for deriving maker online status.
Oracle event-id and Dlc have to exist together, one without the other is incomplete, hence we move the event id inside.
Note that the ID is actually already know to the Dlc as part of the `cet` hashmap, but this was not cleaned up in this patch.
This patch goes towards getting the model boundaries right to transition the architecture towards an event model.
Instead of blocking and awaiting for connection to maker before the start, spawn
the connection attempt in a separate task that will also attempt to reconnect if
the maker goes offline.
Extend the unit test to cover the new behaviour.
Do not shutdown the taker upon connection loss anymore.
Co-authored-by: rishflab <rishflab@hotmail.com>
It only makes sense to allow proposing a settlement when in `Open` state.
Theoretically we could argue that it should be allowed in `PendingRefund` and `PendingCommit`, but I don't see an advantage in that.
Note: This only guards the taker side, no guards were added to the maker side because it remains unclear if the deamon should contain logic for this, or we always want to handle acceptance criteria for settlement from the outside.
A configurable settlement interval for the maker causes friction when implementing auto-rollover, because the settlement interval is not known to the taker.
The settlement interval should not be configurable, thus the configurable settlement interval is removed on the maker side.
The cfd actors and oracle actor use a global constant to decide the settlement interval and oracle even lookahead.
Not pulling the constant into the actors is a conscious decision, it allows us to set this to a different value in the actor tests.
The fact that we use the same constant for cfd actor and oracle actor is an implementation detail.