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

Fix ContextualNetAddress parsing #433

Merged
merged 7 commits into from
Mar 21, 2024

Conversation

orgr
Copy link
Contributor

@orgr orgr commented Mar 13, 2024

No description provided.

@coderofstuff
Copy link
Collaborator

This fixes rpclisten only. Have you checked if the other params rpclisten_borsh and rpclisten_json also need the same fix? Some other params like listen or anything that takes in contextualnetaddress or something like a netaddress may also need attention. Please see if those need attention as well.

Overall, we need to ensure that all the parameters can be passed in somehow, so it'd be great to just cover every param and try setting them via config and cli to see that they all still work.

@callid0n
Copy link

for some reason it doesn't like the line appdir="K:\Testnet11\Data"
below is what I'm testing, I commented out params until I found the one that was failing

testnet=true
utxoindex=true
disable-upnp=true
perf-metrics=true
appdir="K:\Testnet11\Data"
#testnet-suffix=11
#rpclisten="0.0.0.0:16310"
#listen="0.0.0.0:16311"
#ram-scale=1.5
#addpeer="192.168.3.170:16311"
#log-level="info,kaspad_lib::daemon=trace"

.\kaspad.exe --configfile "K:\Testnet11\Binaries\configfile.toml"
error: failed parsing config file, reason: invalid escape sequence
expected b, f, n, r, t, u, U, , "

seems like a double backslash does work as the backslash may be an escape character

this works

appdir="K:\\Testnet11\\Data"

@callid0n
Copy link

All the below will run, except add-peers="192.168.3.170:16311"...it throws this error

\kaspad.exe  --configfile "K:\Testnet11\Binaries\configfile.toml"
error: failed parsing config file, reason: invalid type: string "192.168.3.170:16311", expected a sequence

testnet=true
utxoindex=true
disable-upnp=true
perf-metrics=true
appdir="K:\\Testnet11\\Data"
testnet-suffix=11
rpclisten="0.0.0.0:16310"
listen="0.0.0.0:16311"
ram-scale=1.5
add-peers="192.168.3.170:16311"
log-level="info,kaspad_lib::daemon=trace"

...however, not seeing the perf metrics displayed, so looks like it's accepting the config file, but not applying and showing metrics.

here is the equivalent CLI. Note that in order to show --perf-metrics, it must also be used with --loglevel=info,kaspad_lib::daemon=trace

./kaspad.exe --testnet --netsuffix=11 --utxoindex --disable-upnp --perf-metrics --appdir "K:\Testnet11\Data" --rpclisten="0.0.0.0:16310" --listen="0.0.0.0:16311" --ram-scale=1.5 --addpeer=192.168.3.170:16311 --loglevel=info,kaspad_lib::daemon=trace

@orgr
Copy link
Contributor Author

orgr commented Mar 16, 2024

add-peers expects an array so it would be

add-peers = ["123.4.5.6", "192.168.1.1"]

or single value ["123.4.5.6"]

Maybe ini format is closer to what you're expecting, I'll check the library aspect mentioned

@orgr
Copy link
Contributor Author

orgr commented Mar 18, 2024

the perf-meters issue is because of an issue with the log-level,
@callid0n should be working now, any more sneaky options I might have missed?

TODO

  • align Args struct names with CLI arg names

@callid0n
Copy link

callid0n commented Mar 19, 2024

tested the following and they're accepted in the config file and seem to be working. Perf metrics are showing and "add-peers" is accepting single and multiple with port number and connecting. Need to run some additional tests over time to verify that the "ram-scale" is applying correctly and limiting RAM to the value provided.

testnet=true
utxoindex=true
disable-upnp=true
perf-metrics=true
appdir="K:\\Testnet11\\Data"
testnet-suffix=11
rpclisten="0.0.0.0:16310"
listen="0.0.0.0:16311"
ram-scale=1.5
add-peers=["192.168.3.208:16311","192.168.3.170:16311"]
log-level="info,kaspad_lib::daemon=trace"

@orgr orgr force-pushed the config-file-support-addr-fix branch from 9242160 to c976d4d Compare March 19, 2024 06:50
@michaelsutton
Copy link
Contributor

michaelsutton commented Mar 19, 2024

Perhaps serde rename should be applied to:

inbound_limit -> maxinpeers
outbound_target -> outpeers

and perhaps other fields I'm missing. Ideally we find a way to avoid maintaining these multiple renames (both on args definition and serde attributes), but that can be a future fix

@callid0n
Copy link

callid0n commented Mar 19, 2024

This works.

connect-peers=["192.168.3.170:16311"]

coderofstuff
coderofstuff previously approved these changes Mar 20, 2024
Copy link
Collaborator

@coderofstuff coderofstuff left a comment

Choose a reason for hiding this comment

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

Looks good to me

README.md Outdated
@@ -259,7 +259,7 @@ cargo run --release --bin kaspad -- --configfile /path/to/configfile.toml
# or
cargo run --release --bin kaspad -- -C /path/to/configfile.toml
```
The config file should be a list of \<CLI argument\> = \<value\> separated by newlines.
The config file should be a list of \<CLI argument\> = \<value\> separated by newlines, values with special characters like '.' or '=' will require quoting the value i.e \<CLI argument\> = "\<value\>".
Copy link
Contributor

Choose a reason for hiding this comment

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

The readme should reflect the latest changes. Should add a list example + fix the arg names (like testnet-suffix -> netsuffix). Title of this section should be "Using a configuration file"

Copy link
Contributor

Choose a reason for hiding this comment

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

Also remove the sentence "and some use kebab-case", no?

@orgr orgr force-pushed the config-file-support-addr-fix branch from 49ae850 to 478c420 Compare March 21, 2024 12:08
@coderofstuff coderofstuff merged commit d7ecfa2 into kaspanet:master Mar 21, 2024
6 checks passed
smartgoo pushed a commit to smartgoo/rusty-kaspa that referenced this pull request Jun 18, 2024
* Fix ContextualNetAddress parsing

* fix kaspanet#434

* Fix handling for all addresses + arrays

* Fix log-level taking default instead of config file

* Align Args deserialize names to CLI flag names

* More renames to align deserialize struct like cli

* update README
D-Stacks pushed a commit to D-Stacks/rusty-kaspa that referenced this pull request Jul 12, 2024
* Fix ContextualNetAddress parsing

* fix kaspanet#434

* Fix handling for all addresses + arrays

* Fix log-level taking default instead of config file

* Align Args deserialize names to CLI flag names

* More renames to align deserialize struct like cli

* update README
D-Stacks pushed a commit to D-Stacks/rusty-kaspa that referenced this pull request Jul 17, 2024
* Fix ContextualNetAddress parsing

* fix kaspanet#434

* Fix handling for all addresses + arrays

* Fix log-level taking default instead of config file

* Align Args deserialize names to CLI flag names

* More renames to align deserialize struct like cli

* update README
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.

4 participants