thesimplekid / cashu-rs-mint

Cashu mint useing CDK
BSD 3-Clause "New" or "Revised" License
16 stars 2 forks source link

confusing outputs from nix flake `shellHook` #4

Open plebhash opened 7 months ago

plebhash commented 7 months ago

I'm running a x86-64 VM with a fresh NixOS 23.11.6359.53a2c32bc66f (Tapir)

The shellHook inside flake.nix generates some confusing outputs:

$ nix develop
ℹ️  Project recommendations detected. Run 'flakebox lint' for more info.
💡 Run 'just' for a list of available 'just ...' helper recipes
ℹ️  Flakebox files not up to date. Call `flakebox install`.
error: timeout on transient error: Could not connect to the server 127.0.0.1:18443

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
Starting bitcoind
Bitcoin Core starting
error code: -18
error message:
Wallet file verification failed. Failed to load database path '/tmp/cashu-rs-mint/bitcoin/regtest/wallets/test'. Path does not exist.
{
  "name": "test"
}
[
  "2264ff7ea02d33f3d0830545e0aa69c570153abc4259e0a101326c3c4b152bfd",
  "0416e5b265d654b6e35dc259dd1556de997c25095226be99664ed4d0c6402533",
  "38afffdd8b646168e661f13569e12a0ecdd40f3e838a8f222f4ad2dafd41d3cf",
  "312e8c0f59c6c93ce769e9c4146b734c84ef31f41536bcdc6aeb026f5dcdb4e4",
  "2ec2537ef545583bd18cd548f18e94507b7648b28a3770246f1b1a8fe865cc5f",
  "1e994b486a87acdcabfa258f79f30a5f808a6dc9b34f480e50b562923a0663c7",
  "27691a67d56601390d2d8b4c8e36058737b41a6c861dbc9bc82e33d92f2b54db",
  "6503dc88def141eb20c90bcae065e90e873e16f2447d8abb3597312899a4c32d",
  "2e544fbbca13fc1117238fa3ab7986b95eef2848198eb0580aad5b5d9cfba76c",
  "2dd5ef77086f3353e49daf65220a3ae4e12b2f743da41a1bf6a14d890ce1d51a",
  "4509f0ff061200088acb0213f8a130ebbb732001a3b596e4e70b66b60181271f",
  "62fd12c0965a6ae177759981b3012807851034ddc2d421540adc2cccd54691fc",
  "4282e0a5e4cea0a2c46347b7ad829d45a04c24a1e3456221ad78585e071fa74b",
  "66a88517f1e1b7dea96da5c8f0cbb61eecc68ea14984808bd8b6e1b118ded8e9",
  "00af8e7c7f1adfc64612b4b9f5b6a4cca44e7db320be464f94148e95dbcb2148",
  "7ad058679706488d80be248ad648a19638cdc1565811853380ed51ad69959790",
  "2a78985c0505694841716c60aecdbe852a4f2eccf1035fb75064d67dc1de42d1",
  "17850cd86b8b6fc1d8c6f6d1381bf16ae4d70af9664d779159183d7f90e4ed68",
  "18dc59995d6c1a33c707cab48211b457e4594ce9f4bdd870b6b8a9e8b01a02f4",
  "5e45361d17ea459283a5ec32a13094a210aff7b7d4e9f2575cfc708bacf75b28",
  "13753e23c892f4fbb51c01d642978e6af885020a10d771c55fbb00640a299f50",
  "3b7aeb4affe6d83f025695ac0281d00bc9581f98de8ee9609ac5004f7dd31a73",
  "0569397aaf68c05b911670620b6abb49b8b36842be2f2fcca5280c03858af840",
  "765189372b6e854ebc704419af1b1d8c12df5471301e9e5de7075e9e1aab15d0",
  "75bf5c22310977b3255bd3af1b9242c38b8f8cf9c68e67d056b6737019824c8e",
  "3483518b5209a7af15c83730202a1d456d66365e92af4a16605cfad423eb49fd",
  "10ce548182faaba56d902b912c5bc4eb628647fffecbe1acf7ee213f3f9d1a4e",
  "6b9861ea461fcaf6ee71dc4574d68201667b4330fdfefce70b0216bc9f7bd895",
  "1c269299c57532d563a5638237fde6fbd318d4cb298774ed96e653ee6a1abf1c",
  "1e9fe7834a2139758e183ae5d5b44041740c2a0b185edf352cac650cabd13981",
  "7754b915b6718040ec71058e3c9ee6ba16ea4453efe11f9c7a97e305033c5716",
  "53d868778824e8a3806ea10af3062d452c10d61666fa68e2eea24e71134ad1c9",
  "728c4aa8842d3178116ec3ad256d78b9ef6349d73f805e75962848f5aaf5ce66",
  "233091d577c11ea9226f4f2fb67c6ca8ead0ac925f47ac1554905ca21249affd",
  "15024f1b406e63278ab4ff8ad6f95303972a0894cbbf699465af913c94a6399f",
  "5e72ed9553afb73e09954fbcf73ce0b95166074d43d0c4641f3ced8e246fc85b",
  "16acf7c657d4e1f4aa10b2765d7a16c159d48e7eb95d4298d1a81acc31f63bd7",
  "270ca5d6a6ccbf6c704eaf637c986edd37514898eb10dd36fbabf0cc90136053",
  "6698abb89c1a4f16a40821e8d79c435b401864276ba84e2fe35b7ff3c022fcea",
  "728f9595cd16039c5901dd3085625fc23a5fa93d3e34e34b4dc44825d65d9840",
  "38b2ce7cfbb81e42f6b3174146ea049f85d8d044cd29c0baf522b778507f4876",
  "337295232fc5165ee6d601fdb4b79e25c38637330a22864460e8a78d3d501621",
  "32a4b22e3fe6d97caa7c15908d066a7ff3c9a6d73f3632816d917a7fba8773fe",
  "713c308fcce5e12f122fbb1c51df88d29233a8337a291851177b77429751610b",
  "567a5c7d0613b28821f8d19fecc99e94a20652d24dcb671bc7071099faee8c38",
  "62c2962c3a7b72c5a682131c0f7377ef0723a0683ca4c65bf7788577cf477e02",
  "7294e8dc2d1e4e6c50c4a6279067470c4b8bce4b23be91ab2936f67c26e08165",
  "6fb49b45c3991a5941b553622b74760028a7ca401ba8a8b7b641b4e9df8cbc6a",
  "5a217c5146ad3452f533c399d13e6b04bc47f2a8a1c4760b18862bec12b17669",
  "0385247fe3d3c1dfc8fc676e28499e5111e1f8b50dd12cfbac96155d10be8553"
]
lightning-cli: Moving into '/tmp/cashu-rs-mint/lighting/ln_1/regtest': No such file or directory
Starting ln1
lightning-cli: Moving into '/tmp/cashu-rs-mint/lighting/ln_2/regtest': No such file or directory
Starting ln2
plebhash commented 7 months ago

https://github.com/thesimplekid/cashu-rs-mint/blob/3e60a33ba1af2237e0db205a3cfc2175c7edf8fb/flake.nix#L42

this line is being executed before bitcoind has been initialized, resulting in the following error log:

error: timeout on transient error: Could not connect to the server 127.0.0.1:18443

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.

Re-running nix develop one more time makes this error go away. Even though this is the expected behavior, it is confusing to the user.

I guess an easy fix would be to simply suppress the error logs coming out of getblockcount failed RPC by redirecting its stderr to /dev/null:

- blockcount=$(btc getblockcount) || { blockcount=-1; }
+ blockcount=$(btc getblockcount 2>/dev/null) || { blockcount=-1; }

That would avoid confusing the user with a false alarm.

plebhash commented 7 months ago

https://github.com/thesimplekid/cashu-rs-mint/blob/3e60a33ba1af2237e0db205a3cfc2175c7edf8fb/flake.nix#L51

This line is generating the following error log:

error code: -18
error message:
Wallet file verification failed. Failed to load database path '/tmp/cashu-rs-mint/bitcoin/regtest/wallets/test'. Path does not exist.

Running nix develop one more time changes the error log to:

error code: -35
error message:
Wallet "test" is already loaded.
error code: -4
error message:
Wallet file verification failed. Failed to create database path '/tmp/cashu-rs-mint/bitcoin/regtest/wallets/test'. Database already exists.
Wallet already loaded

I still don't have any concrete suggestion on how to fix this.

plebhash commented 7 months ago

https://github.com/thesimplekid/cashu-rs-mint/blob/3e60a33ba1af2237e0db205a3cfc2175c7edf8fb/flake.nix#L56

This line is generating the following error log:

lightning-cli: Moving into '/tmp/cashu-rs-mint/lighting/ln_1/regtest': No such file or directory

Running nix develop one more time makes the error go away. This could also be mitigated by redirecting stderr to /dev/null:

- ln_1_info=$(ln1 getinfo) || { ln_1_info=-1; } 
+ ln_1_info=$(ln1 getinfo 2>/dev/null) || { ln_1_info=-1; }

The same could also be applied to the ln_2 instance of this same command.

thesimplekid commented 7 months ago

Hey, yes thanks for this you make some good points. I'll implement your suggestions to clean up the flake a bit.