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

grin-wallet to node communication error because of wrongly created paths in grin-wallet.toml when using the Top Level Directory option. #3803

Open
Anynomouss opened this issue Jan 14, 2025 · 17 comments

Comments

@Anynomouss
Copy link

Running latest node (5.4.0. alpha) and wallet (5.4.0 alpha1). I setup a wallet for both testnet or mainnet, results when running 'info' command.

grin-wallet.exe -t wallet1/ info

See log below, results are the same for testnet and mainnet wallets. I always had issues with grin node and wallet on Windows although this is on a new clean machine. I will test if it also happens on Linux.

20250114 11:27:35.280 WARN grin_wallet_libwallet::api_impl::owner_updater - This wallet has not been scanned against the current chain. Beginning full scan... (this first scan may take a while, but subsequent scans will be much quicker)
20250114 11:27:35.280 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20250114 11:27:35.283 ERROR grin_wallet_impls::node_clients::http - Response { result: None, error: Some(RpcError { code: -32601, message: "Method not supported", data: None }), id: Number(1), jsonrpc: Some("2.0") }
20250114 11:27:35.284 ERROR grin_wallet_impls::node_clients::http - Unable to parse response for get_pmmr_indices: RPC error response: RpcError { code: -32601, message: "Method not supported", data: None }
Wallet command failed: LibWallet Error: Client Callback Error: Unable to parse response for get_pmmr_indices: RPC error response: RpcError { code: -32601, message: "Method not supported", data: None }

@mimblewimble mimblewimble deleted a comment Jan 14, 2025
@yeastplume
Copy link
Member

Beware phishing attempt above, deleted and reported

@martinthonon
Copy link

Can you provide the build steps so we can try to get the logs too?

@Anynomouss
Copy link
Author

Anynomouss commented Jan 14, 2025

This is not a specific build, just the normal Windows release.

Just to be certain I retried any combination of local builds of grin node and grin-wallet and created a new wallet directory to be certain there was no form of corruption.
All results with the local wallet build and node build are exactly the same as initially reported.

@Anynomouss
Copy link
Author

Ok, just noticed I did something stupid, I had Grin++ running in the back and it interferes with the IP binding.

2P server failed with erorr: Connection(Os { code: 10048, kind: AddrInUse, message: "Only one usage of each socket address (protocol/network address/port) is normally permitted." })
20250114 15:25:26.577 ERROR grin_util::logger -
thread 'apis' panicked at 'error binding to 127.0.0.1:3413: error creating server listener: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)': C:\Users\anyno.cargo\registry\src\index.crates.io-6f17d22bba15001f\hyper-0.13.10\src\server\mod.rs:124 0:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14: BaseThreadInitThunk
15: RtlUserThreadStart

Still getting some errors, but at least a balance is shown. Will restart my machine to start clean from there

@Anynomouss
Copy link
Author

Anynomouss commented Jan 14, 2025

Ok, this after making sure I am not running multiple instances or Grin++ which interfers since it uses the same IP and ports and grin node. Still getting errors and failing to verify against the chain:

20250114 15:50:03.238 ERROR grin_wallet_impls::node_clients::http - Error calling get_version: ResponseError error: Cannot parse response
20250114 15:50:03.238 ERROR grin_wallet_impls::node_clients::http - Unable to contact Node to get version info: Client Callback Error: Error calling get_version: ResponseError error: Cannot parse response
Password:

20250114 15:50:07.429 ERROR grin_wallet_impls::node_clients::http - Error calling get_tip: ResponseError error: Cannot parse response
20250114 15:50:07.430 WARN grin_wallet_libwallet::api_impl::owner_updater - Updater Thread unable to contact node

____ Wallet Summary Info - Account 'default' as of height 3145327 ____

Confirmed Total | 0.000000000
Awaiting Confirmation (< 10) | 0.000000000
Awaiting Finalization | 0.000000000

Locked by previous transaction 0.000000000
Currently Spendable 0.000000000

When I look at node log, there is nothing much interesting there, the wallet log basically repeats the errors it reported back via the TUI:

20250114 15:53:54.339 INFO grin_wallet - This is Grin Wallet version 5.4.0-alpha.1 (git v5.4.0-alpha.1), built for x86_64-pc-windows-msvc by rustc 1.84.0 (9fc6b4312 2025-01-07).
20250114 15:53:54.343 ERROR grin_wallet_impls::node_clients::http - Error calling get_version: ResponseError error: Cannot parse response
20250114 15:53:54.344 ERROR grin_wallet_impls::node_clients::http - Unable to contact Node to get version info: Client Callback Error: Error calling get_version: ResponseError error: Cannot parse response

@martinthonon
Copy link

Does your node is running and up to date ?

@Anynomouss
Copy link
Author

Anynomouss commented Jan 14, 2025

Yes, the node is fully synced and running (status is running). At moment I am using both wallet and node software build specifically on/for my machine. Everything is clean, no changes to any of the default settings, antivirus turned of to also rule out that option,

@Anynomouss
Copy link
Author

Anynomouss commented Jan 14, 2025

Ok, I did run it again setting log level to "Trace" for both node and wallet, perhaps the output is useful for you.
Note that the wallet directory says contract branch, but it just the normal main wallet and grin node I am testing so ignore that.
:

grin-wallet-own_build.exe -t contract_branch/wallet4_main/ info

20250114 16:01:45.722 INFO grin_util::logger - log4rs is initialized, file level: Trace, stdout level: Trace, min. level: Trace
20250114 16:01:45.723 INFO grin_wallet - Using wallet configuration file at contract_branch/wallet4_main/grin-wallet.toml
20250114 16:01:45.724 INFO grin_wallet - This is Grin Wallet version 5.4.0-alpha.1 (git v5.4.0-alpha.1), built for x86_64-pc-windows-msvc by rustc 1.84.0 (9fc6b4312 2025-01-07).
20250114 16:01:45.724 DEBUG grin_wallet - Built with profile "release", features "".
20250114 16:01:45.728 ERROR grin_wallet_impls::node_clients::http - Error calling get_version: ResponseError error: Cannot parse response
20250114 16:01:45.728 ERROR grin_wallet_impls::node_clients::http - Unable to contact Node to get version info: Client Callback Error: Error calling get_version: ResponseError error: Cannot parse response
Password:

20250114 16:02:04.507 DEBUG grin_store::lmdb - DB Mapsize for contract_branch/wallet4_main/wallet_data\db/lmdb is 134217728
20250114 16:02:04.507 TRACE grin_store::lmdb - DB map size: 134217728
20250114 16:02:04.509 TRACE grin_store::lmdb - Space used: 40960
20250114 16:02:04.509 TRACE grin_store::lmdb - Space remaining: 134176768
20250114 16:02:04.509 TRACE grin_store::lmdb - Percent used: 0.0003 Percent threshold: 0.9000
20250114 16:02:04.510 TRACE grin_store::lmdb - Resize threshold not met (percent-based)
20250114 16:02:04.512 DEBUG grin_wallet_impls::lifecycle::seed - Using wallet seed file at: contract_branch/wallet4_main/wallet_data\wallet.seed
20250114 16:02:04.522 DEBUG grin_wallet_libwallet::api_impl::owner_updater - Updating outputs from node
20250114 16:02:04.523 ERROR grin_wallet_impls::node_clients::http - Error calling get_tip: ResponseError error: Cannot parse response
20250114 16:02:04.523 WARN grin_wallet_libwallet::api_impl::owner_updater - Updater Thread unable to contact node
20250114 16:02:04.523 TRACE grin_store::lmdb - DB map size: 134217728
20250114 16:02:04.523 TRACE grin_store::lmdb - Space used: 40960
20250114 16:02:04.524 TRACE grin_store::lmdb - Space remaining: 134176768
20250114 16:02:04.524 TRACE grin_store::lmdb - Percent used: 0.0003 Percent threshold: 0.9000
20250114 16:02:04.524 TRACE grin_store::lmdb - Resize threshold not met (percent-based)

____ Wallet Summary Info - Account 'default' as of height 3145327 ____

Confirmed Total | 0.000000000
Awaiting Confirmation (< 10) | 0.000000000
Awaiting Finalization | 0.000000000

Locked by previous transaction 0.000000000
Currently Spendable 0.000000000

WARNING: Wallet failed to verify data against a live chain. The above is from local cache and only valid up to the given height! (is your grin server offline or broken?)
Command 'info' completed successfully

@aglkm
Copy link
Contributor

aglkm commented Jan 14, 2025

Open grin-wallet.toml file and correct the paths to node's API secrets:
20250114 16:01:45.723 INFO grin_wallet - Using wallet configuration file at contract_branch/wallet4_main/grin-wallet.toml

@martinthonon
Copy link

Did the http server started in log section of your grin-node ?

You should see something like this :

20250114 16:28:06.958 WARN grin::cmd::server - Starting GRIN in UI mode...

20250114 16:28:44.066 WARN grin_api::handlers - Starting HTTP Node APIs server at 127.0.0.1:3413.

20250114 16:28:44.066 WARN grin_api::handlers - HTTP Node listener started.

20250114 16:28:44.066 WARN grin_servers::grin::server - Grin server started

@Anynomouss
Copy link
Author

@aglkm the path to the API secret appears to be correct:
node_api_secret_path = "C:\grin\contract_branch/wallet4_main\.foreign_api_secret"

@martinthonon The HTTP node listerner is started like normal

20250114 16:45:26.153 INFO grin_servers::grin::server - Starting rest apis at: 127.0.0.1:3413
20250114 16:45:26.154 WARN grin_api::handlers - Starting HTTP Node APIs server at 127.0.0.1:3413.
20250114 16:45:26.154 WARN grin_api::handlers - HTTP Node listener started.
20250114 16:45:26.154 INFO grin_servers::grin::server - Starting dandelion monitor: 127.0.0.1:3413
20250114 16:45:26.154 DEBUG grin_servers::grin::dandelion_monitor - Started Dandelion transaction monitor.
20250114 16:45:26.154 WARN grin_servers::grin::server - Grin server started.

@aglkm
Copy link
Contributor

aglkm commented Jan 14, 2025

Are you sure that the API secrets files are really exists in "C:\grin\contract_branch/wallet4_main" directory?

I don't know what is the default location on Windows, but on Linux that's home directory: "/home/user/.grin/main/"

@Anynomouss
Copy link
Author

Anynomouss commented Jan 15, 2025

I tried again today using the default wallet directory, so not specifying the top level directory for the wallet using -t .
Everything worked as expected.

Therefore I specifically looked at what happened when I did set the top level directory, since there must be a mistake there and indeed there is. It has to do with directories and slashes. When using the command
grin.exe -t wallet1 it will correctly set the paths to:

node_api_secret_path = "C:\grin\wallet1\.foreign_api_secret"

When I would for example specify the directory as
grin.exe -t wallet2/ it will wrongly set the paths to:

node_api_secret_path = "C:\grin\wallet2/.foreign_api_secret"

Using longer paths obviously also creates wrong settings:

grin.exe -t contract_branch/wallet3/ it will wrongly set the paths to:

node_api_secret_path = "C:\grin\contract_branch/wallet3/.foreign_api_secret"

Solution:
First parse the top level directory path given by the user, replace all "/" with "\" and replace all "" with "\", optionally trim any "\" on the left, depending on how the full path is constructed. I think the later substitution already is happening, the first substitution is not yet happening.

I will update the description of the error to match the problem. What surprised me is that the path is correctly used to create the wallet directory when running for example grin.exe -t wallet1/ init, it is only not properly stored in grin-wallet.toml and therefore only comes to the surface when running grin.exe -t wallet1/ info Because the wallet directory is created correctly, only the path in the settings is stored wrongly. This is extra confusing to the user since the path specified appears to be correct and accepted when initiating the wallet. Anyhow, it is easily fixed.

@Anynomouss Anynomouss changed the title Communication between wallet and node not working on Windows 10, Unable to parse response for get_pmmr_indices: RPC error grin-wallet to node communication error because of wrongly created paths in grin-wallet-toml when using the Top Level Directory option. Jan 15, 2025
@Anynomouss Anynomouss changed the title grin-wallet to node communication error because of wrongly created paths in grin-wallet-toml when using the Top Level Directory option. grin-wallet to node communication error because of wrongly created paths in grin-wallet.toml when using the Top Level Directory option. Jan 15, 2025
@aglkm
Copy link
Contributor

aglkm commented Jan 15, 2025

The root cause of the issue is not slashes, Windows should understand both types correctly. The reason is that your API secrets are located in the default node's path, but when you are creating a wallet in non default location it will also point non-default paths to the secrets. I opened an issue some time ago, when encountered the same: mimblewimble/grin-wallet#728

@Anynomouss
Copy link
Author

Anynomouss commented Jan 15, 2025

Actually, a new secret is created correctly where you would expect it when using th -t flag. So If I run:
grin.exe -t wallet1 , or even grin.exe -t wallet1/

In both cases it will create the wallet directory wallet1, it will in both cases create wallet1/.foreign_api_secret and wallet1/.owner_api_secret. Only in first cases it will correctly set the path in grin-wallet.toml, in the second case it would store the wrong path with the exrtra slash and will be unable to connect when running grin.exe -t wallet1 info

So I think the issue is that rust can handle both forward and backward slashes, but not mixed case. Also in the toml file it will use double slashes for whatever reason. So the solution is to just substitute and use only one kind of slashes, '/' '' should be replaced with "\ " and triple slashes "\ \ " that might be created by such a replacement can again be again substituted to "\ ". In that way no matter what the user tries, it will work and it will be uniform use of slashes

UPDATE: @aglkm I get what you means .api_secret is still created in the default directory. And even if the paths to the foreign_api_secret and owner_api_secret are set correctly in the grin-wallet.toml, it can not communicate to the node since it requires the .api_secret which is not create in the specified directory when using either -h or -t

@Anynomouss
Copy link
Author

I reopened the issue, since it is not solved, only the problem identified.

@Anynomouss Anynomouss reopened this Jan 15, 2025
@Anynomouss
Copy link
Author

Anynomouss commented Jan 24, 2025

There are two thing I can do:

  1. I can use https://docs.rs/regex/latest/regex/ package to replace '/' in the path with '\' to make sure the paths are nice and uniform using double backslashes in the path. I can make the changes, no problem.
  2. Close this ticket and do nothing, since having a mix of '/' and '\' in the path is handled fine by rust std::path has no problems with mixed forward and backward slashes in the path. The issue I encountered was cause by A minor issue with using "-h" option to run the wallet in current directory grin-wallet#728, so that is the one I do have solve.

I am inclined to go for option 2) to keep the dependencies minimal, what do you think @yeastplume as well as others who have an opinion on this

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

No branches or pull requests

4 participants