295: Db refactor r=thomaseizinger a=DeliciousHair
DB code refactoring for #88
The primary goal was to remove all of the calls to `serde_json::to_string()` for the data-handling, thus enabling us to do (more or less):
```rust
Order {
row.column,
...
}
```
as well as clean up the SQL for easier reading. This has mostly been accomplished, with further refinements easily accomplished once the upstream issues in `sqlx` are addressed. See #314 for issues we are tracking.
Co-authored-by: DelicioiusHair <mshepit@gmail.com>
The primary goal was to remove all of the calls to `serde_json::to_string()`
for the data-handling, thus enabling us to do (more or less):
```rust
Order {
row.column,
...
}
```
as well as clean up the SQL for easier reading. This has mostly been
accomplished, with further refinements easily accomplished once the
upstream issues in `sqlx` are addressed. See #314 for issues we are
tracking.
A fan-out actor takes an incoming message and forwards it to a set
of actors. This allows our `oracle::Actor` to be unaware, how many
other actors are interested in the attestation, thus simplifying it.
Anything that can fail (e.g. fetching oracle stuff) has to be tried before we change any state or notify the taker, otherwise it can happen that we remain in a failed state that causes very weird side effects.
313: Replace `Address` with `MessageChannel` in some key places r=luckysori a=luckysori
We may need to use `MessageChannel` instead of `Address` elsewhere (perhaps everywhere), but these definitely need to change.
---
Work towards #231.
Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>
The `oracle::Actor` only needs to be able to send the
`oracle::Attestation` to an actor who can handle it. We were already
able to express this using trait bounds, but it was blocking us from
being able to make the `{maker_taker}_cfd::Actor` generic over
different actors due to infinite, cyclic types.
The `monitor::Actor` only needs to be able to send the
`monitor::Event` to an actor who can handle it. We were already able
to express this using trait bounds, but it was blocking us from being
able to make the `{maker_taker}_cfd::Actor` generic over different
actors due to infinite, cyclic types.
306: Borrow CfdState when updating state in the database r=klochowicz a=klochowicz
The function signature didn't need to take the whole state, as it was only
borrowed internally.
Removes the need for many `.clone()` calls sprinkled in the codebase.
Co-authored-by: Mariusz Klochowicz <mariusz@klochowicz.com>
302: Collaborative close payout r=da-kami a=da-kami
Distinguish between collaborative close and cet closing.
Moved the payout on the `Cfd` which decides what the payout of the `Cfd` is, where
- `None` means the payout is not decided yet (we can optimize that and potentially combine this with `profit` in another iteration)
- `Some(payout)` can be a refund, collaborative or cet payout
Refund is handled in an early exit guard based on the state.
Collaborative settlement has priority over cet payout (attestation). In case there is a collaborative settlement present we always return payout based on that.
Note: I am not totally sure if collaborative close payout should always have priority over attestation payout. We could do a more complex reasoning about the state as well, but I felt for now this is probably good enough and we can adapt based on experience. Happy for other suggestions :)
Co-authored-by: Daniel Karzel <daniel@comit.network>
Distinguish between collaborative close and cet closing.
Moved the payout on the `Cfd` which decides what the payout of the `Cfd` is, where
- `None` means the payout is not decided yet (we can optimize that and potentially combine this with `profit` in another iteration)
- `Some(payout)` can be a refund, collaborative or cet payout
Refund is handled in an early exit guard based on the state.
Collaborative settlement has priority over cet payout (attestation). In case there is a collaborative settlement present we always return payout based on that.
The function signature didn't need to take the whole state, as it was only
borrowed internally.
Removes the need for many `.clone()` calls sprinkled in the codebase.
304: Re-introduce library r=luckysori a=luckysori
If we want to write proper integration tests, we need to have a library crate.
---
Work towards #231.
Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
301: Login as the repository r=bonomat a=bonomat
This allows us to publish to {orgname}/{reponame} i.e. comit-network/hermes/packages
Worked on my fork: https://github.com/bonomat/hermes/pkgs/container/hermes%2Fmaker
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
300: Fix docker image build r=bonomat a=bonomat
The new task does a few things:
1. Having an extra build target makes the workflow file cleaner
2. it downloads the release targets which we want to build docker images for
3. it extracts the tar files into sub folders. We need to extract into sub folders to so that our image can fine the binaries. By providing `platform` to `docker buildx` the variable `TARGETPLATFORM` will be available when building the image. This variable is either `linux/amd64/`, `linux/arm64/` or `linux/arm/v7`. Hence we need to extract into subfolders.
4. We create 2 images, one for the maker and one for the taker. The images are then pushed to our organisation's docker registry.
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
The new task does a few things:
1. Having an extra build target makes the workflow file cleaner
2. it downloads the release targets which we want to build docker images for
3. it extracts the tar files into sub folders. We need to extract into sub folders to so that our image can fine the binaries. By providing `platform` to `docker buildx` the variable `TARGETPLATFORM` will be available when building the image. This variable is either `linux/amd64/`, `linux/arm64/` or `linux/arm/v7`. Hence we need to extract into subfolders.
4. We create 2 images, one for the maker and one for the taker. The images are then pushed to our organisation's docker registry.
299: Only process CFDs where we have a DLC r=thomaseizinger a=thomaseizinger
If we just `.context` on the Option, we break out of the loop early
and don't process the remaining items.
Fixes#298.
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Converting from f64 to u64 can make us lose precision.
Create a new Fee type that encapsulates calculating fees, includding splitting
it between two parties.
287: Fetch attestations only when it is time r=thomaseizinger a=thomaseizinger
- Rename `OracleEventId`
- Refer to types within `fmt` module via module qualifier
- fixup! Refer to types within `fmt` module via module qualifier
- Prefer `.parse` over `FromStr` to avoid an import
- Properly model event IDs
- Fix typo
- Only fetch attestation that are likely to have occured
- Introduce drop-in replacement for tokio::spawn that logs errors
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
288: Rename order price to offer price r=bonomat a=bonomat
I want to trigger a new `preview` build and wasn't sure if there is another way. Looks like a last release build failed: https://github.com/comit-network/hermes/runs/3868563726?check_suite_focus=true
And I want to see if this was a glitch or if something else went wrong.
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
273: Build for aarch64 which is needed for RPi4 r=bonomat a=bonomat
Adds more build targets and publishes docker containers.
This was tested on my personal fork and resulted in the following container which can run on an RPi4:
```
docker run ghcr.io/bonomat/hermes-maker-aarch64-unknown-linux-gnu:latest
```
A few notes which might come up:
- The naming of the containers can be improved, please someone with sed knowledge give it a try :)
- I was not able to use the github action `docker/build-push-action`. This moves the image build into a tmp folder which I was not able to escape. Hence, I was not able to copy the binaries into the image
- I was not able to combine the containers into a single one because we have parallel builds. Apparently this should be possible though (reference: [manifest](https://www.docker.com/blog/multi-platform-docker-builds/)).
- I was also not able to use alpine because of the different libc6 version
282: Only fetch announcements when needed r=luckysori a=luckysori
Fixes#275.
I think this is what you meant with #275, `@thomaseizinger.` It does result in immediately deleting some code you wrote in #279. I do think we'll end up reintroducing it once we actually use more than one oracle event per CFD, but it seems unnecessary to keep it around until then. Let me know if you disagree.
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>