Safe_network testnet command

Note: I suggest this as a topic for all Q&A related to the testnet command.

I’m running local test networks using the testnet command and having trouble getting the logs to contain anything other than INFO or WARN messages. I tried the following which made no difference.
RUST_LOG=safe_network=trace testnet
RUST_LOG=sn_node=trace testnet

Using RUST_LOG=trace testnet causes a panic which reports that sn_node was passed -vv which is equivalent to info!

Is there a way to get TRACE output in the logs when using testnet?

UPDATE:
The following does in fact work (as @joshuef says it should).

RUST_LOG=sn_node=trace testnet

Though in full I was doing this for each run:

pkill sn_node;rm -rf ~/.safe/node/local-test-network/;RUST_LOG=safe_network=trace target/debug/testnet

My problem appears to have been my system caching the files for a terminal window, possibly because I had removed the current directory for that terminal. The directory listing was still showing the files from yesterday until I changed directory and I guess commands in that window were seeing cached files rather than the new directories and their contents.

12 Likes

Yep. What you have there should work. That’s what we use on CI eg. :thinking:

I just checked locally (im on mac) and after a build w/ cargo --release --bin testnet:

RUST_LOG=safe_network=trace ./target/release/testnet i get trace logs.


Just as a (perhaps related?) aside, here is the full command I’m favouring at the moment, which I run from root of the safe_network repo:

killall sn_node ||true && rm -rf ~/.safe/node/local-test-network || true && RUST_LOG=safe_network=trace cargo run --release --bin testnet

The above ensures any existing nodes are killed, and data relted to that is cleaned up too.

4 Likes

Thanks @joshuef, I’m running a very similar combo command so odd that I’m not getting the same result. Will try again later. Just to confirm, the text ‘TRACE’ should appear in the logs?

3 Likes

yup

 TRACE 2022-01-26T10:43:05.303016Z [sn/src/prefix_map/mod.rs:L152]:
	 ➤ Attempting to update prefixmap for Prefix()

2 Likes

Cool, I wasn’t aware of this command…

Perhaps someone could explain a little more about the command and its background? Is it much different from make run-local-baby-fleming or using sn_launch_tool?

2 Likes

The proliferation of options here may potentially be more confusing. I personally don’t think there’s really a need for both sn_launch_tool and the CLI mechanism for launching a local network, and possibly not testnet either.

I wanted to do some work in making things a bit more uniform. Should hopefully be able to soon.

7 Likes

as things stand, testnet uses sn_launch_tool, as does run_local_baby... .

Testnet I think is currently a bit more flexible of the two, you can eg add more nodes on to an existing network using that.

testnet is what’s used (at least by me), routinely in core testing (has no dep on cli eg).


as @chriso sez though, this could be smoothed out a fair chunk, so looking forward to that :+1:

9 Likes

I can feel the maidsafe’s fire!!

7 Likes

Problem solved, as noted in the OP here.

4 Likes

ok so I tried to safe files put and I get that files is not a command, run safe --help and it is not listed there. I remember that you need to use otlp feature, how to enable that with testnet?

I am on windows bytheway…

cargo build --release --features otlp --bins this didnt do the trick…

:sweat_smile: otlp is for the telemetry… what is the feature for data network again?

i knew we discussed it:

1 Like

why there is no --public-addr?

cargo flamegraph --bin sn_node --root -- --first --help
    Finished release [optimized] target(s) in 0.38s
warning: the following packages contain code that will be rejected by a future version of Rust: ntapi v0.3.7, quick-xml v0.22.0
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 8`

WARNING: profiling without debuginfo. Enable symbol information by adding the following lines to Cargo.toml:

[profile.release]
debug = true

Or set this environment variable:

CARGO_PROFILE_RELEASE_DEBUG=true

sn_node 0.78.4
Node configuration

USAGE:
    sn_node [OPTIONS]

OPTIONS:
        --clear-data
            Delete all data from a previous node running on the same PC

        --completions <COMPLETIONS>
            dump shell completions for: [bash, fish, zsh, powershell, elvish]

        --first <FIRST>
            Make this the node the first on the network. This requires an address where it's
            reachable for by other nodes. This address will be put in the network contacts file.

            If the port is `0`, then the will be equal to whatever port we will locally bind to.

    -h, --help
            Print help information

    -j, --json-logs
            Outputs logs in json format for easier processing

        --local-addr <LOCAL_ADDR>
            Local address to be used for the node.

            When unspecified, the node will listen on `0.0.0.0` with a random unused port. If you're
            running a local-only network, you should set this to `127.0.0.1:0` to prevent any
            external traffic from reaching the node (but note that the node will also be unable to
            connect to non-local nodes).

        --log-dir <LOG_DIR>
            Send logs to a file within the specified directory

        --logs-max-bytes <LOGS_MAX_BYTES>
            Maximum bytes per log file

            [default: 10485760]

        --logs-max-lines <LOGS_MAX_LINES>
            Maximum lines per log file (overrides logs_max_bytes)

            [default: 0]

        --logs-retained <LOGS_RETAINED>
            Number of rotated log files to keep (0 to keep all)

            [default: 0]

        --logs-uncompressed <LOGS_UNCOMPRESSED>
            Number of rotated files left not compressed

            [default: 100]

    -n, --network-contacts-file <NETWORK_CONTACTS_FILE>
            File with initial network contacts to bootstrap to if this node is not the first on the
            network. This argument and the `--first` flag are mutually exclusive.

            This shall be set to the file path where a valid `SectionTree` can be read from.

    -r, --root-dir <ROOT_DIR>
            Root directory for dbs and cached state. If not set, it defaults to "root_dir" within
            the sn_node project data directory, located at: Linux: $HOME/.safe/node/root_dir
            Windows: {FOLDERID_Profile}/.safe/node/root_dir MacOS: $HOME/.safe/node/root_dir

        --resource-logs
            print node resourse usage to stdout

        --update
            Update sn_node to the latest available version

    -v, --verbose
            Verbose output. `-v` is equivalent to logging with `warn`, `-vv` to `info`, `-vvv` to
            `debug`, `-vvvv` to `trace`. This is overridden by the `RUST_LOG` environment variable

    -V, --version
            Print version information

    -w, --wallet-id <WALLET_ID>
            The address to be credited when this node farms SafeCoin. A hex formatted BLS public key

    -y, --no-confirm
            Do not prompt to confirm the update
writing flamegraph to "flamegraph.svg"

its like you dont want us to launch comnets? that is without using Digital Ocean and sn_testnet_tool

@Southside do you have a script to create a “public” testnet? I am getting a bit uneasy that I cant make a smoothnet…

See my answers in the other threads. I would advise waiting a few days on this, until the release of the new testnet binary.

5 Likes