Commit graph

189 commits

Author SHA1 Message Date
Sergi Delgado Segura
2bf555c07f
Adds --forceupdate to teosd
If a tower hasn't been running for a long time and the backend runs in pruned
mode it could be the case that by the time the tower comes back online, the Last
known block by the tower is not being known by the node anymore. In this situation,
the tower cannot bootstrap normally, given the cache cannot be populated.

This commits adds a new argument to teosd (`--forceupdate`) that can be used to
force a tower to update its last known block to the earliest known block by the backend
under this situation. Notice that doing so may make the tower miss some of its state
transitions (the ones triggered by missed blocks), so this must be done as a last resource.
2023-05-09 09:49:11 -04:00
Sergi Delgado Segura
c0f4ebc82c
Makes teos-cli cannot connect to backend error message more friendly
Let's not just spit a debug error when calling `teos-cli` pointing to an unreachable backend.
2023-05-08 21:53:56 -04: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
anipaul2
ca577c558b
Improve log messages for data directory and configuration details
This commit enhances the logging output to provide clearer information
about the data directory and configuration file details. By providing
this information, it improves the user experience and make it easier for
users to find and understand the relevant paths and settings.
2023-05-02 01:36:19 +05:30
Sergi Delgado Segura
801ef5d808
Removes unnecessary into_iter from Responder tests
The conversion was triggering https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
2023-03-13 12:54:02 +01:00
Sergi Delgado Segura
939d87c0f0
Makes http::serve take a SocketAddr instead of a String
`PublicTowerServicesClient::connect` needs `dest` to be `std::convert::TryInto<tonic::transport::Endpoint>`
hence why we were passing a `String`. However, we'll be better of passing something that's `Copy`, like
`SocketAddr` and converting to `String` here.
2023-02-24 22:37:55 +01:00
Sergi Delgado Segura
f628b358db
Replaces Result<T, E> for Option<T> in DBM load methods
The `DBM` methods related to loading data return `Result<T, E>` where `E` is always `dbm::Error::NotFound`.

It may makes more sense make them return `Option<T>`.
2023-02-20 11:26:38 +01:00
Sergi Delgado Segura
4bcfbf7c5d
Formats strings to use inline params when possible 2023-02-06 22:56:09 +01:00
Omer Yacine
75db9c6519
fixup: record the correct port for the Tor interface 2023-02-06 18:18:40 +02:00
Sergi Delgado Segura
403044298f
Updates teosd.service, adds tor link 2023-02-06 16:15: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
72b1805c1b
Adds logs to RPC requests and improves the ones for the http interface
Also updates the severity from the http logs from info to debug
2023-01-23 17:44:29 -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
39e817c51b
Fixes clippy related issues 2023-01-10 13:20:27 +01:00
Richard Ulrich
4a7a2e0228
using mainnet rather than bitcoin in the output of the help command 2023-01-09 12:35:23 +01:00
Jonathan Plasse
f7d144c6f3
Refactor to avoid using SELECT * 2022-12-11 16:19:16 +01:00
Sergi Delgado Segura
0c1b4c17b4
Adds addresses to gettowerinfo 2022-11-25 14:25:53 +01:00
Sergi Delgado Segura
441a37155d
Revamps tor.rs so the onion address can be queried 2022-11-25 14:25:48 +01:00
Sergi Delgado Segura
c4b5fd1eb1
Changes the onion hidden service port to match the clearnet API port
Turns out both the clearnet API and the Tor hidden service can be run on the same
port.
2022-11-12 11:52:27 -03:00
Sergi Delgado Segura
ecaba32e3e
Fixes tor proxy redirection
Traffic routed trough Tor was being redirected to localhost indistinguishably of whether
the public http API was being offered there or not. This made the tower unavailable
(trough Tor) when it was being offered both in clearnet and Tor.
2022-11-12 11:33:16 -03:00
Sergi Delgado Segura
a20065567f
Changes rpc commands naming from snake case to lower case 2022-11-08 14:13:27 +01:00
Sergi Delgado Segura
1788b4d722
Adds TxIndex to Responder 2022-11-07 11:57:44 +01:00
Sergi Delgado Segura
770b6e6db7
Generalizes LocatorCache into a TxIndex
In order to fix #130 we need to implement our own txindex. Turns out this is almost identical
to our `LocatorCache`, so we can generalize it and use it for both purposes.
2022-11-07 11:57:38 +01:00
Sergi Delgado Segura
8e44159dd6
Fixes an uncaught clippy issue prior to rust 1.65.0 2022-11-04 19:09:38 +01:00
Sergi Delgado Segura
22dc24c561
Removes debug from teos-cli
teos-cli is not using logging, so the debug flag was useless.
2022-11-03 12:10:38 +01:00
Sergi Delgado Segura
0ca6f80149
Splits log levels into local and third party libs
The log level was setup equally between local code and third party libs, making
really verbose libs log a lot of unnecessary data when setting loglevel to debug
for instance.

This splits the loglevel config option into two: `debug` and `depsdebug`. The latter
covers third party libs.
2022-11-03 12:10:38 +01:00
Sergi Delgado Segura
b1b1d83659
Removes chunked-transfer from deps
chunked-transfer was used in an old version of the test suite for a custom HTTP server.
The test server was removed in bbd3857c70, hence the dependency was
never used from that point on.
2022-09-21 10:45:04 +00: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
meryacine
6461e7e72b
teosd: Normalize bitcoin chain network naming 2022-09-20 12:42:46 +02:00
meryacine
b0f294a17b
teosd: Sanity check that bitcoind is running on the specified network 2022-09-20 08:29:26 +02:00
Sergi Delgado Segura
fec3790494 Fixes #119
Wraps `CloseHandle` inside `BitcoindStopper` and implements `Drop` for the latter so the server does not need to be manually stopped
2022-09-17 14:33:28 +02:00
meryacine
388c643109
tests: Fix with_height may produce invalid blocks
`with_height` test method might produce invalid blocks because, after #79, we can't create empty blocks any more, and some random txs might result in a not enough proof of work as in #56
2022-09-17 14:18:32 +02:00
Sergi Delgado Segura
b2dc2e908b Simplifies bind_with_graceful_shutdown for http api
`bind_with_graceful_shutdown` requires the shutdown signal to implement `std::future::Future`.
Turns out `triggered::Listener` already does, so there is no need to wrap this in an async block.
2022-08-30 13:45:39 +02:00
Sergi Delgado Segura
013df67402 Adds a ready signal for the http API
In normal conditions, if the http API cannot bootstrap (due to the gRPC
server being temporary unavailable) it will just retry until it connects.

However, this is done asynchronously, meaning that it could be the case that
the tower is reported as ready when it is actually not. This can be hit during
E2E testing if the tower is restarted too quickly, resulting in a test failure:

https://github.com/sr-gi/rust-teos/runs/8074272734?check_suite_focus=true#step:9:5543
https://github.com/sr-gi/rust-teos/runs/8074272734?check_suite_focus=true#step:9:6970
2022-08-30 13:45:39 +02:00
Sergi Delgado Segura
a1aea5dcec Avoid having to hit the db if there is no data to delete 2022-08-30 13:30:48 +02:00
Sergi Delgado Segura
47ba8b0cb9 Makes Tor task panics more user friendly 2022-08-26 15:10:20 +02:00
Sergi Delgado Segura
e70561d39e Updates register for re-register
Makes it so if a user registers more than once the expiry is not based on the current
height but on the old expiry.
2022-08-24 15:50:36 +02:00
Sergi Delgado Segura
3b7842a0f4 Properly capitalizes Tor
See https://support.torproject.org/about/why-is-it-called-tor/
2022-08-22 11:37:32 +02:00
Sergi Delgado Segura
2373681402 Persists Tor secret key to disk 2022-08-22 11:29:53 +02:00
Sergi Delgado Segura
d4a293feb2 Adds getsubscriptioninfo to the CLN plugin 2022-08-16 12:41:10 +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
booklearner
2c91e94e70
change rename_all macro value to snake_case 2022-07-31 12:19:51 -04: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
b0e169a549 Minor fixes re: tests and logs
- Adds a log to signal the tower is ready
- Updates the message to wait for in tests
- Removes unnecessary logs in tls
- Sets tests to run in SLOW MACHINE mode, given tests tend to fail in CI
apparently due to that
2022-07-11 16:28:32 +02:00
Sergi Delgado Segura
82e452c6b7 Makes sure generated blocks have valid pow
Close #56
2022-07-08 17:18:56 +02:00
Sergi Delgado Segura
1f5b13e23d fix: Fixes connection between gRPC client and server
In some rare occasions, when restarting the tower, the gRPC client is unable
to connect to the server. This is a temporary error that get's fixed by simply
waiting a bit. Looks like the root of the issue if the server not being fully up
when the client tries connect.

More info: https://github.com/talaia-labs/rust-teos/pull/65#issuecomment-1164469285

The fix mainly consists on  looping with a wait until the client is able to connect.
2022-07-07 15:08:12 +02:00
Sergi Delgado Segura
f9f6b3be32 fix: Fixes incorrect log in get_appointment
`get_appointment` was logging as if the data was not found when the data
was pulled from the `Responder`, looks like it had to do with `ok_or` being
eagerly evaluated. It has been replaced by `ok_or_else`.
2022-07-07 15:08:12 +02:00
Sergi Delgado Segura
0e614273e6 Adds config::Config::is_default
Changes the way of reporting whether the tower was run with defaults or
using the config file. Now it is logged instead of printing, which feels
more inline.

This also affected the CLI, where the line reporting was shown for every
run command. That's not the case anymore.
2022-07-07 15:08:12 +02:00