Commit Graph

59 Commits

Author SHA1 Message Date
Sergi Delgado Segura
c594018dce Bug fix: Properly initializes Responder 2020-01-03 11:37:26 +01:00
Sergi Delgado Segura
8fab59975f Adds basic ChainMonitor to the system
ChainMonitor is the actor in charge of checking new blocks. It improves from the previous zmq_subscriber by also doing polling and, therefore, making sure that no blocks are missed.

Documentation and tests are still required. Partially covers #31
2020-01-02 16:15:27 +01:00
Sergi Delgado Segura
5c585a7a02 Refactors code to use appointment from common based on f4a1e34e2f4d75226c7e313b83ff5ae06c8c89ca 2019-12-17 16:22:23 +01:00
Sergi Delgado Segura
1184b4648a Fixes logs and removes redundant tailing dots 2019-12-16 19:45:30 +01:00
Sergi Delgado Segura
77b191dde2 Moves Logger to common 2019-12-16 14:15:30 +01:00
Sergi Delgado Segura
2f67ecfa6e Changes sk_path to sk_der in Watcher
The Watcher used to receive a secret key file path ion the __init__ to load a secret key for signing. That made testing the Watcher hard, since the file needed to be present. Changing it so the main (pisad) loads the file from disk and passes the data the Watcher on init.
2019-12-16 10:54:13 +01:00
Sergi Delgado Segura
63488cb69e Fixes wrong identation in Watcher 2019-12-13 19:44:19 +01:00
Sergi Delgado Segura
e2ca226b11 Last formatting details troughout the codebase 2019-12-13 18:13:29 +01:00
Sergi Delgado Segura
008a71da3a Renames matches to breaches to be consistent with the Responder. Also adds docstrings 2019-12-13 18:13:29 +01:00
Sergi Delgado Segura
d881706eb3 Refactors the codebase to match the new naming from 793d563b8c053136dd5f936b0ef0cd88af215b06 and 3046eae38ee3f34857c96e6b9d43e645f7d2de2d 2019-12-13 18:13:29 +01:00
Sergi Delgado Segura
df5dcbdfe9 Renames dispute_delta to to_self_delay and justice tx to penalty tx
Uses the naming convention followed by LN implementations and BOLTs
2019-12-11 12:45:05 +01:00
Sergi Delgado Segura
2cdd78b8e6 Simplifies the Cleaner and adds docstrings
We were passing some unnecessary parameters to the Cleaner (locator) that could be derived from other data (uuid and appointments). Also standarises the order of the  parameters to match the rest of the methods
2019-12-10 13:31:42 +01:00
Sergi Delgado Segura
d39056a0cc Refactors signing/verifiying functionality to be part of the Cryptographer
- All encryption/decryption and signing/verifying calls are performed by the cryptographer now.

- The current signature format is temporal. We should define something not base on json.

- Some Cryptographer tests are still missing.

- The cli tests should be modified to fit this too.
2019-12-07 13:22:39 +01:00
Sergi Delgado Segura
a8800ac375 Integrates encryption/decryption within the Cryptographer. Close #63
Includes unittests. Also reformats test_inspector to avoid using cli functions
2019-12-06 13:23:02 +01:00
Sergi Delgado Segura
bd08b151df Replaces locator with common/constants value 2019-12-05 11:03:36 +01:00
Sergi Delgado Segura
f0150ce585 Removes hash/cipher configuration and changes AESGCM128 for CHACHA20POLY1305
Updates tests accordingly
2019-12-04 17:46:07 +01:00
Sergi Delgado Segura
3c6f13ef00 Rename delete_completed_appointments and rearange arguments 2019-11-11 13:27:57 +00:00
Sergi Delgado Segura
4233c9d5cc Refactor get_matches and filter_valid_matches to not be static 2019-11-08 18:21:42 +00:00
Sergi Delgado Segura
20faa04c4c Refactord Watcher and BlockProcessor. Closes #36.
Brings back check_potential_matches and check_matches to the Watcher.

The methods have now been renamed to check_matches (old check_potential_matches) and filter_valid_matches (old check_matches) to provide a better description of their purpose.

decode_raw_transaction has been added to BlockProcessor
2019-11-08 16:25:35 +00:00
Sergi Delgado Segura
8b2f0efa2f Moves appointment deletion + db update to the cleaner 2019-11-07 19:16:05 +00:00
Sergi Delgado Segura
20f296c9d4 Reformats code to match code guidelines 2019-11-07 15:47:35 +00:00
Sergi Delgado Segura
e6e577c99e Updates Watcher to use serialize instead of to_json 2019-11-07 15:08:05 +00:00
Sergi Delgado Segura
31afb1373a Integrates the locator map dumping to the Watcher and Cleaner 2019-11-06 17:08:42 +00:00
Sergi Delgado Segura
8ad3ae5f1d Initializes block_queue on init
Building from backed up data may require initializing the block queues of both the watcher and responder with the blocks they've missed.
2019-10-30 12:20:42 -07:00
Sergi Delgado Segura
ddcbc6a6de Fixes log level 2019-10-29 15:20:32 -07:00
Sergi Delgado Segura
bc7c7dc26f Fixes based on DBManager unit tests 2019-10-29 14:52:27 -07:00
Sergi Delgado Segura
f61474216c Fixes and tests updates
Updates tests so they run with the db_manager and fixes some bugs introduced in d7d42c9.
2019-10-28 14:49:40 -07:00
Sergi Delgado Segura
cf61e6e265 Reports the block hash to the responder on adding response
The responder can use the block hash to figure out whether or not he is on sync
2019-10-28 14:40:44 -07:00
Sergi Delgado Segura
a0538739d2 Starts data persistence integration
The difference between master and the old data-persistence branch was huge, seems more effective to manually cherry pick the changes and integrate them
2019-10-28 14:38:50 -07:00
Salvatore Ingala
21b54f048e Refactored error handling in add_appointment; minor comments from PR review 2019-10-25 14:51:15 +08:00
Salvatore Ingala
a19bfa13ff Separated signing logic of the Watcher in sign_appointment function; added unit test 2019-10-24 12:19:33 +08:00
Salvatore Ingala
9b1af92fc3 Minor fixes 2019-10-22 18:59:27 +08:00
Salvatore Ingala
1601f0ca15 Renamed constants and default file names for Pisa's private and public keys 2019-10-22 12:13:12 +08:00
Salvatore Ingala
ca64b59277 Added signature verification to pisa_cli 2019-10-18 14:56:59 +08:00
Salvatore Ingala
414a4638bd Added signature verification to watcher's add_appointment test 2019-10-18 12:37:06 +08:00
Salvatore Ingala
db522500c3 Switched to cryptography instead of ecdsa for signatures 2019-10-17 17:02:09 +08:00
Salvatore Ingala
f19c499efa Handling errors when constructing the Watcher in pisa daemon 2019-10-17 12:08:01 +08:00
Salvatore Ingala
deaf704bc5 Removed redundant parentheses 2019-10-17 09:59:36 +08:00
Salvatore Ingala
c6db6eddb3 Using a PEM keyfile instead of a DER for the signing key 2019-10-17 09:59:34 +08:00
Salvatore Ingala
7c1d8b69c7 Changed to_json to to_dict in Appointment and Job; added to_json to Appointment to actually return a string 2019-10-17 09:59:34 +08:00
Salvatore Ingala
e4e83167b7 Made signing key optional (will only sign if given) 2019-10-17 09:59:34 +08:00
Salvatore Ingala
99db9a29ad Added signatures to appointment 2019-10-17 09:59:29 +08:00
Sergi Delgado Segura
d7c89ddc91 Modifies behaviour towards a failed EncryptedBlob decrpytion
The decryption for the `EncryptedBlob` using AES-GCM-128 (the only cipher available atm) raises an `InvalidTag` exception. This was not properly captured by the watcher making it crash. This behavior was already discovered during the `EncryptedBlob` unit testing and left to be fixed in the `Watcher` unit testing.

However, making the EncryptedBlob raise such an exception may not be a good practice, since other ciphers may run into different exceptions. Therefore, the `EncryptedBlob` has been modified to return None upon facing a decryption issue, the `BlockProcessor` will detect that and return a None justice_txm and justice_txid. Upon receiving a None `justice_txid` the `Watcher` will delete the appointment without notifiying the `Responder`.
2019-10-14 16:57:46 +01:00
Salvatore Ingala
9f25ef8603 Fixes from PR review 2019-10-10 18:22:33 +07:00
Salvatore Ingala
aea1d1f1e0 Fixes from PR review 2019-10-10 11:07:58 +07:00
Salvatore Ingala
dee93e5c62 Moved StructuredMessage and Logger to separate file; refactored pisa-cli logging using new format 2019-10-10 09:59:11 +07:00
Salvatore Ingala
c524319027 Several fixes and improvements 2019-10-10 09:59:11 +07:00
Salvatore Ingala
bae9b6b913 Added Logger class; refactored logging accordingly 2019-10-10 09:59:10 +07:00
Salvatore Ingala
2a5dd48950 PEP8 linting 2019-10-10 09:58:27 +07:00
Salvatore Ingala
ed0cb4f632 Changed log format to JSON; fixed missing return value in get_potential_matches 2019-10-10 09:58:27 +07:00