bitcart / bitcart

https://bitcart.ai
MIT License
544 stars 115 forks source link

[BUG] ImportError: Failed to load libsecp256k1 #428

Closed CarlSinclair closed 2 months ago

CarlSinclair commented 5 months ago

Describe the bug I know RHEL isn't officially supported, but docker comes with its own set of problems in general, especially on RHEL. So I've been trying to adapt the Deb-based instructions and I got all the way to starting the daemons, but I can't get passed this.

To Reproduce Attempt a manual build on a RHEL-based system.

Expected behavior OpenSSL includes secp256 by default, so this shouldn't even be a problem. I still installed 3 different versions of it via python in the main python directory as well as the one within the directory. None of them is being recognized/accepted.

Screenshots image

Desktop (please complete the following information):

Additional Context

MrNaif2018 commented 2 months ago

Hi, technically this instruction can be used? https://github.com/spesmilo/electrum/issues/6353#issuecomment-655385839 Or do you want us to add it to manual deployment docs?

CarlSinclair commented 2 months ago

Hi @MrNaif2018, I referenced the issue you're referencing for additional context. The solution you're linking to isn't working, and shouldn't be needed at all because like I said, recent versions of OpenSSL include libsecp256k1 by default. The problem is that it's expected to be found separately, which it won't be. It's also not finding the custom built versions of it that I've tried installing, as I said, both by following the suggestion you linked to and also using other methods.

MrNaif2018 commented 2 months ago

https://github.com/spesmilo/electrum-docs/blob/master/libsecp256k1-linux.rst

Apparently if to symlink/put it into /usr/lib it might work

What electrum executes is this: import ctypes; ctypes.cdll.LoadLibrary('libsecp256k1.so.0')

CarlSinclair commented 2 months ago

It's been some time since I tried this so I followed the manual deployment documentation again and when I reached that error I compiled libsecp256k1.so and created symlinks to where it's looking for it (along with *.0, *.1 and *.2 symlinks) and it worked. But xmr.py won't run, apparently because it expects the entire XMR blockchain to be installed and running.

The gunicorn process is running, but failing shortly thereafter.

[root@home bitcart]# gunicorn -c gunicorn.conf.py main:app
[2024-08-21 17:17:19 -0300] [2368270] [INFO] Starting gunicorn 23.0.0
[2024-08-21 17:17:19 -0300] [2368270] [INFO] Listening at: http://0.0.0.0:8000 (2368270)
[2024-08-21 17:17:19 -0300] [2368270] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2024-08-21 17:17:19 -0300] [2368272] [INFO] Booting worker with pid: 2368272
[2024-08-21 17:17:19 -0300] [2368273] [INFO] Booting worker with pid: 2368273
[2024-08-21 17:17:19 -0300] [2368274] [INFO] Booting worker with pid: 2368274
[2024-08-21 17:17:19 -0300] [2368275] [INFO] Booting worker with pid: 2368275
[2024-08-21 17:17:19 -0300] [2368278] [INFO] Booting worker with pid: 2368278
[2024-08-21 17:17:33 -0300] [2368272] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.9/site-packages/uvicorn/workers.py", line 75, in init_process
    super().init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 135, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 66, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 370, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/root/bitcart/main.py", line 102, in <module>
    app = get_app()
  File "/root/bitcart/main.py", line 41, in get_app
    settings = Settings()
  File "/root/bitcart/api/settings.py", line 238, in __init__
    super().__init__(**data)
  File "/usr/local/lib/python3.9/site-packages/pydantic_settings/main.py", line 144, in __init__
    super().__init__(
  File "/usr/local/lib/python3.9/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings
BITCART_HTTPS_ENABLED
  Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/bool_parsing
[2024-08-21 17:17:33 -0300] [2368272] [INFO] Worker exiting (pid: 2368272)
[2024-08-21 17:17:35 -0300] [2368274] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.9/site-packages/uvicorn/workers.py", line 75, in init_process
    super().init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 135, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 66, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 370, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/root/bitcart/main.py", line 102, in <module>
    app = get_app()
  File "/root/bitcart/main.py", line 41, in get_app
    settings = Settings()
  File "/root/bitcart/api/settings.py", line 238, in __init__
    super().__init__(**data)
  File "/usr/local/lib/python3.9/site-packages/pydantic_settings/main.py", line 144, in __init__
    super().__init__(
  File "/usr/local/lib/python3.9/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings
BITCART_HTTPS_ENABLED
  Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/bool_parsing
[2024-08-21 17:17:35 -0300] [2368274] [INFO] Worker exiting (pid: 2368274)
[2024-08-21 17:17:35 -0300] [2368275] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.9/site-packages/uvicorn/workers.py", line 75, in init_process
    super().init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 135, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 66, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 370, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/root/bitcart/main.py", line 102, in <module>
    app = get_app()
  File "/root/bitcart/main.py", line 41, in get_app
    settings = Settings()
  File "/root/bitcart/api/settings.py", line 238, in __init__
    super().__init__(**data)
  File "/usr/local/lib/python3.9/site-packages/pydantic_settings/main.py", line 144, in __init__
    super().__init__(
  File "/usr/local/lib/python3.9/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings
BITCART_HTTPS_ENABLED
  Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/bool_parsing
[2024-08-21 17:17:35 -0300] [2368275] [INFO] Worker exiting (pid: 2368275)
[2024-08-21 17:17:35 -0300] [2368278] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.9/site-packages/uvicorn/workers.py", line 75, in init_process
    super().init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 135, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 66, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 370, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/root/bitcart/main.py", line 102, in <module>
    app = get_app()
  File "/root/bitcart/main.py", line 41, in get_app
    settings = Settings()
  File "/root/bitcart/api/settings.py", line 238, in __init__
    super().__init__(**data)
  File "/usr/local/lib/python3.9/site-packages/pydantic_settings/main.py", line 144, in __init__
    super().__init__(
  File "/usr/local/lib/python3.9/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings
BITCART_HTTPS_ENABLED
  Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/bool_parsing
[2024-08-21 17:17:35 -0300] [2368278] [INFO] Worker exiting (pid: 2368278)
[2024-08-21 17:17:36 -0300] [2368270] [ERROR] Worker (pid:2368272) exited with code 3
[2024-08-21 17:17:36 -0300] [2368270] [ERROR] Worker (pid:2368273) was sent SIGTERM!
[2024-08-21 17:17:36 -0300] [2368270] [ERROR] Worker (pid:2368275) was sent SIGTERM!
[2024-08-21 17:17:36 -0300] [2368270] [ERROR] Worker (pid:2368278) was sent SIGTERM!
[2024-08-21 17:17:36 -0300] [2368270] [ERROR] Worker (pid:2368274) was sent SIGTERM!
[2024-08-21 17:17:36 -0300] [2368270] [ERROR] Shutting down: Master
[2024-08-21 17:17:36 -0300] [2368270] [ERROR] Reason: Worker failed to boot.
[root@home bitcart]# python3 worker.py
Traceback (most recent call last):
  File "/root/bitcart/worker.py", line 74, in <module>
    settings = Settings()
  File "/root/bitcart/api/settings.py", line 238, in __init__
    super().__init__(**data)
  File "/usr/local/lib/python3.9/site-packages/pydantic_settings/main.py", line 144, in __init__
    super().__init__(
  File "/usr/local/lib/python3.9/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings
BITCART_HTTPS_ENABLED
  Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/bool_parsing

I manually added a BITCART_HTTPS_ENABLED=true line to conf/.env, but that doesn't seem to have helped.

MrNaif2018 commented 2 months ago

That looks like a bug since our update to pydantic v2, I'll look into it, thanks As for XMR: the default servers are provided only in docker config, for manual deployment you need to set XMR_SERVER env var Pick any node here: https://monero.fail/ Default node used in docker: https://github.com/bitcart/bitcart-docker/blob/31beb97070eba79ac30e76336c045608136e761e/generator/docker-components/monero.yml#L7

CarlSinclair commented 2 months ago

I'm guessing Bitcart doesn't have a built-in ramp to accept fiat, right? The reason I ask is because it's too complex to be simply creating a QR code with the amount and the wallet address.

Edit: I found the answer to my question.

Currently, Bitcart is a processor without fiat conversion capabilities. However, a fiat conversion feature is on the roadmap for Bitcart.

I also read that it's possible to setup separate stores (or integrations with existing eCommerce stores) to use my Bitcart server. Would I be able to charge them a transaction fee for the use of my resources?

MrNaif2018 commented 2 months ago

I manually added a BITCART_HTTPS_ENABLED=true line to conf/.env, but that doesn't seem to have helped.

Hmm, how did you get this? Because from my testing this error occurs only if you have this env var set, and equal to empty value (empty string)

As for the charging fee for use of resources no, unless you develop a custom plugin for that

CarlSinclair commented 2 months ago

I got that property from the error message itself. That's why I added it. I found this using grep -r:

api/settings.py: https_enabled: bool = Field(False, validation_alias="BITCART_HTTPS_ENABLED")

I reran it again with the HTTPS line commented out and got an error about Redis not being accessible on the default port, which makes sense because I have it running on a custom port. So I added that to the config file and the same HTTPS error was back. Removing the HTTPS line still throws the HTTPS error.

I think it's a red herring because I didn't change anything since yesterday and randomly got the Redis error once instead of the HTTPS error.

Here's my complete conf/.env, minus the comments:

# comma-separated list of currencies to enable, defaults to btc
BITCART_CRYPTOS=btc,xmr
# github api url for the updates check, defaults to None, set in docker. Update check turned off if unset.
UPDATE_URL=https://api.github.com/repos/bitcart/bitcart/releases/latest
# torrc file, defaults to None. Parsed to get hidden services config. Tor functionality turned off if unset.
TORRC_FILE=/usr/local/etc/tor/torrc-2
# directory where to store logs, defaults to None (no logs stored)
LOG_DIR=logs

### Daemons connection settings ###
BTC_HOST=localhost
BTC_PORT=5000
BTC_NETWORK=mainnet
BTC_LIGHTNING=true
#BITCART_HTTPS_ENABLED=true
BTC_LOGIN=[redacted]
BTC_PASSWORD=[redacted]
XMR_NETWORK=mainnet
XMR_SERVER=https://moneronode.org
XMR_DEBUG=true

### Less important settings ###
REDIS_HOST=redis://localhost
REDIS_PORT=[redacted]
DB_DATABASE=[redacted]
DB_USER=[redacted]
DB_PASSWORD=[redacted]
DB_HOST=127.0.0.1
DB_PORT=[redacted]
# whether the app is running in docker environment, defaults to false
IN_DOCKER=false
# whether to use test database or not: for testing only, defaults to false, enabled automatically by pytest
TEST=false

btc.py runs correctly with this config file, but xmr.py throws the following error:

  raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 405, message='Attempt to decode JSON with unexpected mimetype: text/html', url='https://moneronode.org/json_rpc'

Maybe I need to add the same properties for XMR as BTC like password, port, etc. But even trying it with just BTC is throwing the HTTPS error which is the bigger issue.

MrNaif2018 commented 2 months ago

Can you try something like env | grep BITCART_HTTPS_ENABLED does it output anything as for xmr, it may be invalid rpc url Btw maybe you can join our community chat and we continue the troubleshooting there as it's faster? As the original issue was resolved and it's the following ones

MrNaif2018 commented 2 months ago

Issue about loading empty env vars fixed in 0381b643a0139dd266e844e041eade2791c61919