SecretNetwork icon indicating copy to clipboard operation
SecretNetwork copied to clipboard

'secretd export' prints info logs to STDOUT not STDERR when initializing the enclave.

Open blockpane opened this issue 2 years ago • 3 comments

Because the JSON is also sent to STDOUT it results in invalid formatting when using a shell redirect.

Think these are the lines in question:

https://github.com/scrtlabs/SecretNetwork/blob/master/cosmwasm/packages/sgx-vm/src/enclave.rs#L106 https://github.com/scrtlabs/SecretNetwork/blob/master/cosmwasm/packages/sgx-vm/src/seed.rs#L103 (also line 112)

Sorry, I'd normally attach a PR for this because I know it's a super-simple fix, but I don't know Rust.

blockpane avatar Jun 14 '22 19:06 blockpane

That is kind of annoying indeed.

I'm not sure what's the right approach here. iirc cosmos-sdk output defaults to stderr, but we changed it in secretd to stdout. Maybe we should change it back to stderr? Another option is to redirect enclave logs to stderr, but I'm not sure this is a good idea because iirc all other tendermint block execution logs are going to stdout.

What do you think? @assafmo @reuvenpo

toml01 avatar Jun 16 '22 09:06 toml01

I think that all those various logs should be going to stderr, and never to stdout. In rust the change is simple - change println! to eprintln!. In Go change calls to the various fmt.*Print* functions with just println() (not from the fmt package). The only things going to stdout should be main outputs of commands, such as tx jsons, query results, etc.

reuvenpo avatar Jun 19 '22 07:06 reuvenpo

Yes logs should go to stderr

assafmo avatar Jun 19 '22 08:06 assafmo

Also, now 'secretd export' is now always exports the json into a file https://github.com/scrtlabs/cosmos-sdk/pull/185

liorbond avatar Aug 23 '22 16:08 liorbond

Yep ^ so closing this

toml01 avatar Aug 24 '22 11:08 toml01