Commit graph

62 commits

Author SHA1 Message Date
dzdidi
b3a621a781
Update dependencies
- Add toolchain
- Common:
  - bitcoin v0.32.0;
  - lightning v0.1.0
- TEOS:
  - bitcoin v0.32.0;
  - bitcoincore-rpc v0.19.0;
  - lightning v0.1.0;
  - lightning-net-tokio v0.1.0;
  - lightning-block-sync v0.1.0
- Watchtower-Plugin:
  - bitcoin v0.32.0;
  - cln-plugin v0.3.0
2025-03-25 12:06:21 +01:00
Sergi Delgado Segura
81a659c0f6
Bumps tonic to 0.11 and prost to 0.12, adapts Cargo files accordingly
Bumping tonic required cargo file edition to be bumped to 2021
2024-07-29 16:27:32 -04:00
Sergi Delgado Segura
d30fc7d121
Fixes clippy issues 2024-07-29 13:12:27 -04:00
Sergi Delgado Segura
95f1c4c21d
Fixes cryptography tests utils 2024-03-28 12:58:59 +01:00
Omer Yacine
1790fe31e0
Make random appointments variable in size 2023-09-01 16:39:54 +03:00
Omer Yacine
cab6151ccc
Getting rid of in-memory data to avoid unbounded memory growth
Regrading the `Watcher`, fields (appointments, locator_uuid_map) has
been replaced by DB calls when needed.

For `Responder`, the field `trackers` has been replaced by DB calls when
needed, and `tx_tracker_map` wasn't actually needed for the tower to
operate, so was just dropped.

For `GateKeeper`, `registered_users::appointments` which used to hold
the uuids of every appointment the user submitted was removed so that
`registered_users` only holds meta information about users.

Also now the gatekeeper is the entity responsible for deleting appointments from the database. Instead of the watcher/responder asking the gatekeeper for the users to update and carry out the deletion and update itself, now the watcher/responder will hand the gatekeeper the uuids to delete and the gatekeeper will figure out which users it needs to update (refund the freed slots to).

Also now, like in `Watcher::store_triggered_appointment`, if the appointment is invalid or was rejected by the network in block connections, the freed slots will not be refunded to the user.

Also the block connection order starts with the gatekeeper first, this
allows the gatekeeper to delete the outdated users so that the watcher
and the responder doesn't take them into account.
2023-09-01 16:39:54 +03:00
Anmol Agrawal
2229251702
Implements ping/pong logic for the tower and CLN plugin
Implements ping/pong logic for the tower and CLN plugin
Modification in test as suggested and some more

Some fixed

Signed-off-by: Anmol Agrawal <anmol2002.aa1@gmail.com>
2023-05-02 07:49:24 +05:30
Sergi Delgado Segura
4bcfbf7c5d
Formats strings to use inline params when possible 2023-02-06 22:56:09 +01:00
Sergi Delgado Segura
5cf9029fe9
Bumps teos version to 0.2 in preparation for code release 2023-01-23 17:45:20 -05:00
Sergi Delgado Segura
44df8bb6f3
Defines Endpoint enum to avoid using hardcoded strings as endpoints
Useful for both the tower API and the clients
2023-01-20 08:55:22 -05:00
Sergi Delgado Segura
d50ce639bf
Improves tor flag logic in watchtower-plugin
The `watchtower-plugin` was specifying a custom tor flag to signal whether Tor may be used by the client. This was due to `cln-plugin (v0.1.1-)` not allowing plugins to access the CoreLN configuration options and, therefore, our plugin was unable to fetch the `proxy` / `always-use-proxy` options.

This fetches the aforementioned options and revamps the logic to comply with the `always-use-proxy` requirements, that is, if the flag is set all communications must be performed using Tor. Also, it replaces some of the currently used `String`s for more meaningful types to store network data (such as `AddressType`, `NetAddress`, or `ProxyInfo`).

This drops our custom `watchtower-proxy` config option
2023-01-20 08:37:03 -05:00
Sergi Delgado Segura
d0a476d4af
Adds named arguments to CoreLN plugin 2022-12-14 11:59:19 -06:00
Sergi Delgado Segura
a6ef6946ab
Implements auto-register for the watchtower-plugin 2022-12-12 10:30:56 -06:00
Sergi Delgado Segura
0c1b4c17b4
Adds addresses to gettowerinfo 2022-11-25 14:25:53 +01:00
Sergi Delgado Segura
b6e223a4ed
Bumps version to 0.1.2
Makes it so the .rs files pull the version info from the Cargo files so it is always consistent
2022-09-20 12:41:59 +00:00
Sergi Delgado Segura
d4a293feb2 Adds getsubscriptioninfo to the CLN plugin 2022-08-16 12:41:10 +02:00
Sergi Delgado Segura
7e7dc973f5 Fixes Tracker serialization for get_all_appointments
close #64
2022-08-16 12:08:27 +02:00
Sergi Delgado Segura
3d816cc8af Disable clippy::derive_partial_eq_without_eq in protos
Clippy for Rust 1.63.0 raises a lint warning regarding structures implementing
PartialEq but not Eq: https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

The autogenerated code from the protos does fall into this constrain. However, the current recommended
solution from the `prost` team is to disable the check: https://github.com/tokio-rs/prost/issues/661
2022-08-16 11:12:19 +02:00
meryacine
50356fee97
Renaming block_connected to filtered_block_connected
Implement `filtered_block_connected` and rely on `block_connected` default implementation that calls `filtered_block_connected`
2022-07-31 16:28:16 +02:00
meryacine
b5fe75a5be
Bump up some deps
Needed to bump the lightning version used and had to bump bitcoin, bitcoincore-rpc aswell to match dep verions in lightining
merkle root computation changed in `bitcoin`, thus some methods in the test_utils needed to adapt (basically by adding a tx if there is none in a block). See: b454cf8e15
Also SecretKey had it's `to_string` method removed, so TEOS now encodes its tower key using `display_secret().to_string()`. See: https://github.com/rust-bitcoin/rust-secp256k1/pull/312
2022-07-31 16:28:15 +02:00
Sergi Delgado Segura
c14543d6ea Add start_time to registration receipt 2022-07-19 15:46:04 +02:00
Sergi Delgado Segura
409f04e622 Adds the core logic of the CoreLN tower plugin 2022-07-06 17:39:47 +02:00
Sergi Delgado Segura
1e020eac44 Allows receipts to be built including the signature and adds verify method
This new constructor useful for passing the information along in the clients,
avoiding moving around a struct with an empty field and the signature separately.
On the other hand, the verify functions makes it easier cleaner a valid receipt.
2022-07-06 17:39:47 +02:00
Sergi Delgado Segura
0b01ae1a52 Adds "use-serde" feature to bitcoin crate
In order to derive serde from UserId (which in turn derives it from PublicKey)
use-serde needs to be enabled.
2022-07-06 17:39:47 +02:00
Sergi Delgado Segura
382cce1ec5 Moves compute_appointment_slots to teos-common 2022-07-06 17:39:47 +02:00
Sergi Delgado Segura
063bf44c9d Aliases UserId to TowerId for readability 2022-07-06 17:39:47 +02:00
Sergi Delgado Segura
2cbdfff340 Splits the DBM so some of its parts can be commonly used
teos-common now have some DBM traits that need to be implemented by DBM.
Some common functionality is also implemented to reduce code replication.
2022-07-06 17:39:47 +02:00
Sergi Delgado Segura
6b635c2546 Creates teos_common/test_utils and moves utils that can be used by clients from teos/test_utils 2022-07-06 17:39:44 +02:00
Sergi Delgado Segura
d871bc133c Reworks serde methods for local types
Local types were using a mix between serialize / deserialize / to_vec / from_slice
methods to serialize / deserialize structures without using the serde crate.

Normalizes the method naming to it/s to_vec / from_slice. May reformat to serialize / deserialize
if we end up using serde for that.

Also adds some utility serde methods and derives serde from some structs that required so for client building.
2022-07-06 17:30:50 +02:00
Sergi Delgado Segura
c777dd69d4 Splits protos in main and common
Some functionality can be reused by clients, like the API requests/responses,
so splitting the protos will reduce the boilerplate when building them.
2022-07-06 17:23:04 +02:00
Sergi Delgado Segura
a6d0b6f311 Uses serde functions from bitcoin crate in a consistent manner
The codebase had different ways of performing bitcoin serde:

- Using bitcoin::consensus::{encode, decode}
- Using bitcoin::util::psbt::serialize::{Deserialize, Serialize};

The former feels like a cleaner way of doing so, normalizing all the appearances.
2022-04-26 10:50:59 +02:00
meryacine
3ac228c662
compiling lightning v0.0.99 up till v0.0.104 fails with the current rust stable toolchain
version 0.0.105 fixes the compilation issue with cargo 1.60.0.
2022-04-19 12:11:31 +02:00
Sergi Delgado Segura
756403bb47 Cleans some pending comments, adds checked_txs to get_completed_trackers
checked_txs cache the transactions that have already been queried to bitcoind so we do not need to spam it
in case multiple trackers share the same penalty.
2022-02-24 14:27:04 +03:00
Sergi Delgado Segura
009096f0c5 Code improvements across the board w/ clippy 2022-02-24 12:47:13 +03:00
Sergi Delgado Segura
53505e2cbb Adds bitcoind_unavailable flag to InternalAPI and chain_monitor
The ChainMonitor will set the flag as false if the connection with bitcoind is lost. As a result,
the InternalAPI can block the PublicAPI so no requests are accepted until bitcoind is back up.
2022-02-18 11:42:06 +01:00
Sergi Delgado Segura
08e6d35e8f Updates HTTP API with richer StatusCodes
Makes subscription errors return UNAUTHORIZED and not_founds NOT_FOUND
2022-02-16 14:59:51 +01:00
Sergi Delgado Segura
8a64d7e4de Does a bit of code housekeeping
- Old TODOs/FIXMes are removed
- Cargo.toml files are reformatted
    - base64 is replaces by bitcoin::base64
    - prost_types is removed (it was unused)
    - Unnecessary crate features are removed
    - simple_logger is bumped
2022-02-11 12:49:57 +01:00
Sergi Delgado Segura
af396055f2 Removes unnecesary api errors 2022-01-20 15:07:39 +01:00
Sergi Delgado Segura
da97379659 Adds HTTP API 2022-01-20 12:29:51 +01:00
Sergi Delgado Segura
944f8eb953 Adds the Internal API
The Internal API is a sink API that handles requests from the public API
and the RPC client (teos-cli)
2022-01-04 15:37:20 +01:00
Sergi Delgado Segura
000302fcae Updates Appointment constructor
Appointment used to require a raw locator in the constructor (`[u8;16]`)
but that has turned out to be highly unuseful specially when having to
deserialize appointments and/or build them from user provided data.

Updates the constructor so a Locator is passed instead.
2021-12-29 15:42:25 +01:00
Sergi Delgado Segura
1ff886f98b Adds UUID::deserialize, makes Locator::deserialize match the same design 2021-12-15 10:35:05 +01:00
Sergi Delgado Segura
eacb2446f9 Adds missing teos-common docs. Updates teos/lib main description 2021-12-13 11:31:15 +01:00
Sergi Delgado Segura
8a8772df99 Improves overall memory management
Refactors severals parts of the code so:

- Copy values are not passed as reference
- Copy values are derefered when needed instead of cloned
- Clones are avoided as much as possible
- Strings are replaced by &str when possible

More passes to the code may be necessary in the future, but this is a good start
2021-12-03 17:17:01 +01:00
Sergi Delgado Segura
c9bcc65b56
Moves get_random_{bytes, keypair} to teos_common::cryptography
Both functions are needed to create a keypair for the tower, so they need to be somewhere not meant for testing
2021-11-05 15:51:15 +01:00
Sergi Delgado Segura
257f4449e0
Makes code a bit more idiomatic applying maps and turbofishing 2021-10-29 18:05:22 +02:00
Sergi Delgado Segura
dcf6d71de6
Updates UserId, Locator and AppointmentSummary
- Adds Copy to Locator
- Implements Display in UserId
- Makes AppointmentSummary fields public
2021-10-28 16:09:57 +02:00
Sergi Delgado Segura
b5da110cbb
Removes JSON serde, moves slots computation logic to appointment.rs
The JSON serialization logic was added to deal with data storage. Given won't be using LevelDB for this implementation, but a SQL database, all that serialization logic in unnecessary.
2021-10-18 17:22:35 +02:00
Sergi Delgado Segura
9f51256b54
Adds missing methods to Responder
Moves temporary parsing between `bitcoin` and `bitcoincore-rpc` data types to the `Carrier` so it is transparent to the rest of the system.

Adds `httpmock` to Watcher test so RPC conversation between the `Responder` and `bitcoind` can be mocked.
2021-09-23 11:43:21 +02:00
Sergi Delgado Segura
19ee4daf5c
Bumps lightning to 0.0.99 and bitcoin to 0.27
lightning 0.0.99 requires bitcoin 0.27 and includes some fixes regarding message_signing (functions borrow keys instead of taking ownership of them).
2021-08-04 11:56:23 +02:00