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

[move] Disable debug printing on nodes #8795

Merged
merged 6 commits into from
Mar 3, 2023
Merged

[move] Disable debug printing on nodes #8795

merged 6 commits into from
Mar 3, 2023

Conversation

amnn
Copy link
Member

@amnn amnn commented Mar 2, 2023

Description

Disable outputting debug::print to stderr on full nodes and validators, to prevent user code from spamming our logs, while still enabling output for calls via CLI (e.g. to sui move test). Removes a dependency from sui-framework to move-unit-test to make this work, by:

  • Moving cost_calib module to sui-move.
  • Moving integration of sui-framework Move unit tests into Rust tests into its own crate.

Test Plan

With the following Move package:

# Move.toml
[package]
name = "MovePkg"
version = "0.0.0"

[dependencies]
MoveStdlib = { local = "..." }

[addresses]
example = "0x0"
module example::example {
    use std::debug;

    struct DebugPrintTest has drop {}

    public entry fun test_debug_print() {
        debug::print(&DebugPrintTest {});
    }

    #[test]
    fun test_during_testing() {
        test_debug_print();
    }
}

Build sui CLI and sui-node separately so that Cargo does not unify features, and start-up the validators embedded in the CLI, and a separate fullnode (in separate terminal sessions):

sui$ cargo build -p sui-node && cargo build -p sui
sui$ rm -rf ~/.sui && ~/sui/target/debug/sui genesis -f && ~/sui/target/debug/sui start --no-full-node
sui$ ~/sui/target/debug/sui-node --config-path ~/.sui/sui_config/fullnode.yaml

Running the tests will print the debug output, and publishing and running transactions will produce debug output in the embedded validator, but not the dedicated fullnode:

move-pkg$ ~/sui/target/debug/sui move test # prints debug output
move-pkg$ ~/sui/target/debug/sui client publish --gas-budget 10000
move-pkg$ while true; do; 
  ~/sui/target/debug/sui client call \
    --package <package> \
    --module "example" \
    --function "test_debug_print" \
    --gas-budget 1000; 
done

@amnn amnn requested a review from bmwill March 2, 2023 20:03
@amnn amnn self-assigned this Mar 2, 2023
@vercel
Copy link

vercel bot commented Mar 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated
explorer ⬜️ Ignored (Inspect) Mar 3, 2023 at 11:47AM (UTC)
explorer-storybook ⬜️ Ignored (Inspect) Mar 3, 2023 at 11:47AM (UTC)
wallet-adapter ⬜️ Ignored (Inspect) Mar 3, 2023 at 11:47AM (UTC)

@bmwill bmwill force-pushed the amnn/no-move-debug branch from 4add03e to 5f14fcf Compare March 2, 2023 21:24
Copy link
Contributor

@bmwill bmwill left a comment

Choose a reason for hiding this comment

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

Ok I've done the necessary fixes with hakari to eliminate the testing feature from being turned on by workspace-hack packages. One thing to note is that if sui-node is built together with another target that does enabling the testing feature, then it'll get turned on in the final build but at least now it wont be enabled if its built by itself.

@amnn amnn force-pushed the amnn/no-move-debug branch from 5f14fcf to 74d942c Compare March 3, 2023 00:03
@amnn amnn marked this pull request as ready for review March 3, 2023 00:05
@amnn amnn force-pushed the amnn/no-move-debug branch from 74d942c to ccf8c0f Compare March 3, 2023 00:06
@amnn amnn force-pushed the amnn/no-move-debug branch from ccf8c0f to 2839613 Compare March 3, 2023 11:27
@amnn amnn merged commit 27b7f0e into main Mar 3, 2023
@amnn amnn deleted the amnn/no-move-debug branch March 3, 2023 12:31
amnn added a commit that referenced this pull request Apr 8, 2023
Despite trying to disable printing using feature flags in #8795, it
came back because of the additive nature of `feature`s.  This time,
disable debug printing on validators and full nodes for good, by
controlling their inclusion using a flag passed in during native
function creation, that controls whether to link against a silent
version of the debug print functions or not.

Unit tests, and other CLI usages of the VM typically link against the
unsilenced native functions, and the version used by validators is
silenced.

Test Plan:

Run all existing tests:

```
$ cargo simtest
$ env SUI_SKIP_SIMTESTS=1 cargo nextest run
```

Create a test move package with the following content:

```
module test::test {
    struct ImALittleTeapot has copy, drop, store {}
    public entry fun print() {
        std::debug::print(&ImALittleTeapot {});
    }

    #[test]
    fun test_printing() {
        print();
    }
}
```

And confirm that the following does print debug output

```
sui$ cargo build --bin sui --release
sui$ cargo build --bin sui-node --release
sui$ ./target/release/sui move test -p $PKG
```

While publishing to a local network and repeatedly calling `print`
does not pollute the validator or fullnode logs.
amnn added a commit that referenced this pull request Apr 8, 2023
## Description

Despite trying to disable printing using feature flags in #8795, it came
back because of the additive nature of `feature`s. This time, disable
debug printing on validators and full nodes for good, by controlling
their inclusion using a flag passed in during native function creation,
that controls whether to link against a silent version of the debug
print functions or not.

Unit tests, and other CLI usages of the VM typically link against the
unsilenced native functions, and the version used by validators is
silenced.

## Test Plan

Run all existing tests:

```
$ cargo simtest
$ env SUI_SKIP_SIMTESTS=1 cargo nextest run
```

Create a test move package with the following content:

```
module test::test {
    struct ImALittleTeapot has copy, drop, store {}
    public entry fun print() {
        std::debug::print(&ImALittleTeapot {});
    }

    #[test]
    fun test_printing() {
        print();
    }
}
```

And confirm that the following does print debug output

```
sui$ cargo build --bin sui --release
sui$ cargo build --bin sui-node --release
sui$ ./target/release/sui move test -p $PKG
```

While publishing to a local network and repeatedly calling `print` does
not pollute the validator or fullnode logs.
sblackshear pushed a commit to sblackshear/sui that referenced this pull request Apr 10, 2023
## Description

Despite trying to disable printing using feature flags in MystenLabs#8795, it came
back because of the additive nature of `feature`s. This time, disable
debug printing on validators and full nodes for good, by controlling
their inclusion using a flag passed in during native function creation,
that controls whether to link against a silent version of the debug
print functions or not.

Unit tests, and other CLI usages of the VM typically link against the
unsilenced native functions, and the version used by validators is
silenced.

## Test Plan

Run all existing tests:

```
$ cargo simtest
$ env SUI_SKIP_SIMTESTS=1 cargo nextest run
```

Create a test move package with the following content:

```
module test::test {
    struct ImALittleTeapot has copy, drop, store {}
    public entry fun print() {
        std::debug::print(&ImALittleTeapot {});
    }

    #[test]
    fun test_printing() {
        print();
    }
}
```

And confirm that the following does print debug output

```
sui$ cargo build --bin sui --release
sui$ cargo build --bin sui-node --release
sui$ ./target/release/sui move test -p $PKG
```

While publishing to a local network and repeatedly calling `print` does
not pollute the validator or fullnode logs.
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.

2 participants