Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Remove default node #2072

Merged
merged 12 commits into from
Jan 30, 2023
Merged

Conversation

k9ert
Copy link
Collaborator

@k9ert k9ert commented Jan 20, 2023

The default node is quite annoying and makes things super complicated. This PR schould change that so that a default node is no longer needed.

  • a91d331 changes the auth method rpcpasswordaspin which is used by raspiblitz to no longer use the default node. Instead it now simply assumes that there is an active node connection and if that is not the case, it searches the harddrive in the folder /mnt/hdd/bitcoin for a bitcoin.conf file and uses the connection details in that file to validate that the rpc-connection is valid with the password the user has provided. If that folder changes for some reason, it can be changed via modifying the RASPIBLITZ_SPECTER_RPC_LOGIN_BITCOIN_CONF_LOCATION env var. If the connection is not available (e.g. node down) the user can still login as the password is validated in that case with string comparison. src/cryptoadvance/specter/server_endpoints/auth.py was heavily refactored.
  • With a default-node, there was always a node available. It was one which got persisted but might not be connected properly. So to make it smooth for the rest of the code, there is now a class NonExistingNode(PersistentObject). Whenever there is no node, then instead of None, an instance of this class is returned. It returns some minimum values which probably should get shrinked even further if we would continue to refactor the frontend-code.
  • The WalletManager had an unrelated bug which was solved here as well: It stored the version of the core-node it has been initialized with but did not adjusted it, if the rpc-connection changes. As we're no longer throwing away the Walletmanager, this is quite important also if you have more than one node. See WalletManager not aware of different Core-Versions (if more than one node configured) #2077 which should be fixed with this PR

@netlify
Copy link

netlify bot commented Jan 20, 2023

Deploy Preview for specter-desktop-docs canceled.

Name Link
🔨 Latest commit dbd06c6
🔍 Latest deploy log https://app.netlify.com/sites/specter-desktop-docs/deploys/63d3c9d87bf1b80009e1e6b2

@openoms
Copy link

openoms commented Jan 20, 2023

Thank you for the heads up. Sounds like the Raspiblitzes should work as normal after this change. The rpcpassword is the same for the nodes on all networks.

@k9ert k9ert marked this pull request as ready for review January 25, 2023 16:08

@property
def bitcoin_core_version_raw(self):
raise Exception()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What? raise OR return!

@k9ert k9ert merged commit 40a6a2e into cryptoadvance:master Jan 30, 2023
k9ert added a commit to k9ert/specter-desktop that referenced this pull request Jan 30, 2023
* change passwordaspin auth implementation

* env-var for RASPIBLITZ_SPECTER_RPC_LOGIN_BITCOIN_CONF_LOCATION

* remove default

* fix tests

* fix the tests part2

* fix cypress tests

* docstrings and other default removals

* improve error_handling

* do not raise exception
k9ert added a commit that referenced this pull request Jan 31, 2023
* Chore: Remove default node (#2072)

* change passwordaspin auth implementation

* env-var for RASPIBLITZ_SPECTER_RPC_LOGIN_BITCOIN_CONF_LOCATION

* remove default

* fix tests

* fix the tests part2

* fix cypress tests

* docstrings and other default removals

* improve error_handling

* do not raise exception

* fixed debugging artifact

* Spinning refresh icon if node is still syncing

* Cypress test for sync status

* remove notification of fully synced node

* Set timeout for sync check to 5min

---------

Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
Co-authored-by: Manolis Mandrapilias <70536101+moneymanolis@users.noreply.github.com>
@k9ert k9ert deleted the chore/rid_of_defaultnode branch February 27, 2023 09:23
@openoms
Copy link

openoms commented Apr 4, 2023

@k9ert we are running into an error repeatedly in raspiblitz/raspiblitz#3709:

version: v2.0.1
Traceback (most recent call last):
  File "/home/specter/.env/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/specter/.env/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/specter/.env/lib/python3.10/site-packages/cryptoadvance/specter/server_endpoints/auth.py", line 36, in login
    return login_method_rpcpasswordaspin()
  File "/home/specter/.env/lib/python3.10/site-packages/cryptoadvance/specter/server_endpoints/auth.py", line 83, in login_method_rpcpasswordaspin
    if specter.node and specter.node._get_rpc().test_connection():
AttributeError: 'NonExistingNode' object has no attribute '_get_rpc'

The config is (+ tried some variations):

cat /home/specter/.specter/nodes/default.json
{
    "name": "raspiblitz_mainnet",
    "alias": "default",
    "autodetect": false,
    "datadir": "/mnt/hdd/bitcoin",
    "user": "raspibolt",
    "password": "passwordb",
    "port": "8332",
    "host": "localhost",
    "protocol": "http",
    "external_node": true,
    "fullpath": "/home/specter/.specter/nodes/default.json"
}
cat /home/specter/.specter/config.json
{
    "auth": {
        "method": "rpcpasswordaspin",
        "password_min_chars": 6,
        "rate_limit": 10,
        "registration_link_timeout": 1
    },
    "explorers": {
        "main": "",
        "test": "",
        "regtest": "",
        "signet": ""
    },
    "explorer_id": {
        "main": "CUSTOM",
        "test": "CUSTOM",
        "regtest": "CUSTOM",
        "signet": "CUSTOM"
    },
    "asset_labels": {
        "liquidv1": {}
    },
    "active_node_alias": "default",
    "proxy_url": "socks5h://localhost:9050",
    "only_tor": "true",
    "tor_control_port": "9051",
    "tor_status": false,
    "hwi_bridge_url": "/hwi/api/",
    "uid": "c63403c1ead1583c",
    "unit": "btc",
    "price_check": false,
    "alt_rate": 1,
    "alt_symbol": "BTC",
    "price_provider": "",
    "weight_unit": "oz",
    "validate_merkle_proofs": false,
    "fee_estimator": "bitcoin_core",
    "fee_estimator_custom_url": "",
    "hide_sensitive_info": false,
    "autohide_sensitive_info_timeout_minutes": null,
    "autologout_timeout_hours": 4,
    "testing": {
        "allow_threading_for_testing": false
    },
    "bitcoind": false
}

Logs:

Apr 04 08:19:34 raspberrypi systemd[1]: Started specter.                                                                                                                                                                                                                                                                      
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,598] INFO in server: Configuration: cryptoadvance.specter.config.ProductionConfig                                                                                                                                                                          
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,599] INFO in server: SPECTER_DATA_FOLDER: /home/specter/.specter                                                                                                                                                                                           
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,600] INFO in cli_server: CERT:/home/specter/.specter/cert.pem                                                                                                                                                                                              
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,600] INFO in cli_server: Configuring SSL-certificate /home/specter/.specter/cert.pem                                                                                                                                                                       
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,606] INFO in specter_migrator: Initiated MigDataManager(/home/specter/.specter/migration_data.json events:2 execs:2 )                                                                                                                                      
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,613] INFO in specter_migrator: Collecting possible migrations ...                                                                                                                                                                                          
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,616] INFO in specter_migrator: Collecting possible migrations ...                                                                                                                                                                                          
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,618] INFO in specter_migrator: Collecting possible migrations ...                                                                                                                                                                                          
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,619] INFO in specter_migrator: No Migrations to execute!                                                                                                                                                                                                   
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,619] INFO in server: Initializing LoginManager                                                                                                                                                                                                             
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,619] INFO in server: Initializing Specter with data-folder /home/specter/.specter                                                                                                                                                                          
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,620] INFO in service_manager: ----> starting service discovery Static                                                                                                                                                                                      
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,632] INFO in reflection:   Found class SwanService                                                                                                                                                                                                         
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,644] INFO in reflection:   Found class LiquidissuerService                                                                                                                                                                                                 
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,656] INFO in reflection:   Found class DevhelpService                                                                                                                                                                                                      
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,825] INFO in reflection:   Found class NotificationsService                                                                                                                                                                                                
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,833] INFO in reflection:   Found class ExfundService                                                                                                                                                                                                       
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,842] INFO in reflection:   Found class FaucetService                                                                                                                                                                                                       
Apr 04 08:19:40 raspberrypi python3[1814934]: [2023-04-04 08:19:40,849] INFO in reflection:   Found class ElectrumService                                                                                                                                                                                                     
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,950] INFO in reflection:   Found class SpectrumService                                                                                                                                                                                                     
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,976] INFO in reflection:   Found class StacktrackService                                                                                                                                                                                                   
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,977] INFO in service_manager: ----> skipping service discovery dynamic                                                                                                                                                                                     
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,977] INFO in service_manager: ----> starting service loading                                                                                                                                                                                               
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,978] INFO in service_manager: Loading Extension SpectrumService from cryptoadvance.specterext.spectrum.service                                                                                                                                             
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,983] INFO in service_manager:   Loading Extension-specific configuration from <class 'cryptoadvance.specterext.spectrum.config.ProductionConfig'>                                                                                                          
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,988] INFO in config_manager: Config loaded from file /home/specter/.specter/config.json                                                                                                                                                                    
Apr 04 08:19:41 raspberrypi python3[1814934]: [2023-04-04 08:19:41,993] INFO in service_manager:   Loading Controller cryptoadvance.specterext.spectrum.controller                                                                                                                                                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,027] INFO in service_manager:   Mounted <Blueprint 'spectrum_endpoint'> to /svc/spectrum                                                                                                                                                                   
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,028] INFO in service_manager: Extension SpectrumService activated (prod)                                                                                                                                                                                   
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,028] INFO in service_manager: Loading Extension ExfundService from cryptoadvance.specterext.exfund.service                                                                                                                                                 
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,032] INFO in service_manager:   Loading Extension-specific configuration from <class 'cryptoadvance.specterext.exfund.config.ProductionConfig'>                                                                                                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,034] INFO in service_manager:   Loading Controller cryptoadvance.specterext.exfund.controller                                                                                                                                                              
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,049] INFO in service_manager:   Mounted <Blueprint 'exfund_endpoint'> to /ext/exfund    
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,050] INFO in service_manager: Extension ExfundService activated (prod)                                                                                                                                                                                     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,050] INFO in service_manager: Extension NotificationsService not activated due to devstatus ( prod > alpha )                                                                                                                                               
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,051] INFO in service_manager: Loading Extension SwanService from cryptoadvance.specterext.swan.service                                                                                                                                                     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,053] INFO in service_manager:   Loading Extension-specific configuration from <class 'cryptoadvance.specterext.swan.config.ProductionConfig'>                                                                                                              
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,055] INFO in service_manager:   Loading Controller cryptoadvance.specterext.swan.controller                                                                                                                                                                
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,087] INFO in service_manager:   Mounted <Blueprint 'swan_endpoint'> to /svc/swan                                                                                                                                                                           
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,087] INFO in service_manager: Extension SwanService activated (prod)                                                                                                                                                                                       
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,088] INFO in service_manager: Extension DevhelpService not activated due to devstatus ( prod > alpha )                                                                                                                                                     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,088] INFO in service_manager: Extension FaucetService not activated due to devstatus ( prod > beta )                                                                                                                                                       
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,088] INFO in service_manager: Loading Extension ElectrumService from cryptoadvance.specterext.electrum.service                                                                                                                                             
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,089] WARNING in service_manager:   Extension electrum does not have a service Configuration! Skipping!                                                                                                                                                     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,090] INFO in service_manager:   Loading Controller cryptoadvance.specterext.electrum.controller                                                                                                                                                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,099] INFO in service_manager:   Mounted <Blueprint 'electrum_endpoint'> to /svc/electrum                                                                                                                                                                   
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,106] INFO in reflection:   Found class Electrum                                                                                                                                                                                                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,106] INFO in service_manager: Extension ElectrumService activated (prod)                                                                                                                                                                                   
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,107] INFO in service_manager: Loading Extension LiquidissuerService from cryptoadvance.specterext.liquidissuer.service                                                                                                                                     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,112] INFO in service_manager:   Loading Extension-specific configuration from <class 'cryptoadvance.specterext.liquidissuer.config.ProductionConfig'>                                                                                                      
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,114] INFO in service_manager:   Loading Controller cryptoadvance.specterext.liquidissuer.controller                                                                                                                                                        
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,218] INFO in service_manager:   Mounted <Blueprint 'liquidissuer_endpoint'> to /svc/liquidissuer                                                                                                                                                           
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,218] INFO in service_manager: Extension LiquidissuerService activated (prod)                                                                                                                                                                               
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,219] INFO in service_manager: Extension StacktrackService not activated due to devstatus ( prod > alpha )                                                                                                                                                  
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,219] INFO in service_manager: ----> finished service processing                                                                                                                                                                                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,224] INFO in specter: Instantiate VersionChecker                                                                                                                                                                                                           
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,229] INFO in specter: Instantiate ConfigManager                                                                                                                                                                                                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,239] INFO in config_manager: Config loaded from file /home/specter/.specter/config.json                                                                                                                                                                    
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,245] INFO in specter: Instantiate NodeManager with node alias: default.                     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,250] ERROR in node_manager: Skipping node default due to dict does not have a python_class  
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,251] INFO in config_manager: Config loaded from file /home/specter/.specter/config.json     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,253] INFO in wallet_manager: starting update of wallet_manager (threading: True , comment: )                                                                                                                                                               
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,254] INFO in wallet_manager: Skipping further update because self.working_folder is None (and data_folder = /home/specter/.specter/wallets)
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,254] WARNING in wallet_manager: Specter seems to be disconnected from Bitcoin Core. Skipping wallets update.
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,254] INFO in checker: Checker health Checking every 600 seconds now                         
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,256] INFO in config_manager: Config loaded from file /home/specter/.specter/config.json     
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,256] INFO in checker: Checker health started with period 600                                
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,257] INFO in checker: Checker price Checking every 600 seconds now                          
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,258] INFO in specter: Instantiate ServiceEncryptedStorageManager                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,258] INFO in specter: Instantiate ServiceUnencryptedStorageManager                          
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,259] INFO in hwi_rpc: Initializing HWI...                                                   
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,260] INFO in checker: Checker health Checking every 20 seconds now                          
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,260] INFO in specter: Changing checker frequency: Every 20 seconds due to (rpc is None: True or initialblockdownload: True )
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,261] INFO in wallet_manager: starting update of wallet_manager (threading: True , comment: via user)
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,261] INFO in wallet_manager: Skipping further update because self.working_folder is None (and data_folder = /home/specter/.specter/wallets)
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,262] WARNING in wallet_manager: Specter seems to be disconnected from Bitcoin Core. Skipping wallets update.
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,262] INFO in checker: Checker health executed within 0.007 seconds. This message won't show again until stopped and started.
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,364] INFO in server: Executing callback specter_added_to_flask_app ...                      
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,364] INFO in service: Intitializing Database in sqlite:////home/specter/.specter/sqlite/db.sqlite
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,454] INFO in server: Login enabled                                                          
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,454] INFO in server: Initializing Controller ...                                            
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,783] INFO in server: ----> starting service callback_after_serverpy_init_app                
Apr 04 08:19:42 raspberrypi python3[1814934]: [2023-04-04 08:19:42,966] INFO in version: version checked, install_type pip curr: v2.0.1 latest: 2.0.1 ==> upgrade: False
Apr 04 08:19:43 raspberrypi python3[1814934]: [2023-04-04 08:19:43,264] INFO in config_manager: Config loaded from file /home/specter/.specter/config.json     
Apr 04 08:19:43 raspberrypi python3[1814934]: [2023-04-04 08:19:43,266] INFO in wallet_manager: starting update of wallet_manager (threading: True , comment: via user)
Apr 04 08:19:43 raspberrypi python3[1814934]: [2023-04-04 08:19:43,267] INFO in wallet_manager: Skipping further update because self.working_folder is None (and data_folder = /home/specter/.specter/wallets)
Apr 04 08:19:43 raspberrypi python3[1814934]: [2023-04-04 08:19:43,268] WARNING in wallet_manager: Specter seems to be disconnected from Bitcoin Core. Skipping wallets update.
Apr 04 08:20:03 raspberrypi python3[1814934]: [2023-04-04 08:20:03,291] INFO in config_manager: Config loaded from file /home/specter/.specter/config.json     

The bitcoin.conf is readable for specter user:

sudo -u specter ls -la /mnt/hdd/bitcoin/bitcoin.conf
-rw-r--r-- 1 bitcoin bitcoin 1624 Apr  3 17:46 /mnt/hdd/bitcoin/bitcoin.conf

Can you help please about how should we change the config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants