ton-blockchain / ton

Main TON monorepo
Other
3.1k stars 984 forks source link

[lite-client & validator-engine-console] All output in one stderr #243

Closed igroman787 closed 4 years ago

igroman787 commented 4 years ago

The essence of the problem: In program 'lite-client' and 'validator-engine-console': stdout and stderr are output as stderr. It was expected that the output of the message will work the same way as in the 'fift': stdout will be displayed in stdout, and stderr in stderr. Perhaps it would be convenient to use 'td/utils/logging.h' (LOG(INFO) and LOG(ERROR))

Code showing the correct operation of 'fift' (stdout):

ton-svb-css{~/mydir}:/home/ton/build/crypto/fift -I /home/ton/ton/crypto/fift/lib/:/home/ton/ton/crypto/smartcont/ -s show-addr.fif /home/ton/.local/share/mytonctrl/wallets/wallet_003 1>t1 2>t2

ton-svb-css{~/mydir}:cat t1
Loading wallet address from /home/ton/.local/share/mytonctrl/wallets/wallet_003.addr
Source wallet address = -1:e54bb40cf4091e51507668499c4943e997d04e7f66c9228349409165a9b6dda5
Non-bounceable address (for init only): 0f_lS7QM9AkeUVB2aEmcSUPpl9BOf2bJIoNJQJFlqbbdpaBP
Bounceable address (for later access): kf_lS7QM9AkeUVB2aEmcSUPpl9BOf2bJIoNJQJFlqbbdpf2K
Private key available in file /home/ton/.local/share/mytonctrl/wallets/wallet_003.pk

ton-svb-css{~/mydir}:cat t2

Code showing erroneous output of 'stdout' to 'stderr' in lite-client:

ton-svb-css{~/mydir}:/home/ton/build/lite-client/lite-client -C /home/ton/tmpdir/ton-lite-client-test1.config.json --cmd "getaccount -1:e6fa5c3637a2b7165b63929e3c7e0b6decff093afeda7ebf77a7f63867f1f6af" 1>t1 2>t2

ton-svb-css{~/mydir}:cat t1

ton-svb-css{~/mydir}:cat t2
using liteserver 0 with addr [67.207.74.182:4924]
zerostate set to -1:17A3A92992AABEA785A7A090985A265CD31F323D849DA51239737E321FB05569:5E994FCF4D425C0A6CE6A792594B7173205F740A39CD56F537DEFD28B48A0F6E
[ 1][t 2][1581106186.938250065][lite-client.h:201][!testnode]   conn ready
[ 2][t 2][1581106186.996205330][lite-client.cpp:276][!testnode] server version is 1.1, capabilities 7
[ 3][t 2][1581106186.996247053][lite-client.cpp:285][!testnode] server time is 1581106186 (delta 0)
[ 3][t 2][1581106187.054192066][lite-client.cpp:324][!query]    last masterchain block is (-1,8000000000000000,2048794):FC05612A1B838506C49AB01F45C69008214E804FD747685D027CD41BEF45B7B7:C23E7D52DC1D2D7C5FBEC0B93C6AB2CD815DADCDFDFF8248AEFFDCE6033BB3A8
[ 3][t 1][1581106187.054284096][lite-client.cpp:285][!testnode] server time is 1581106187 (delta 0)
latest masterchain block known to server is (-1,8000000000000000,2048794):FC05612A1B838506C49AB01F45C69008214E804FD747685D027CD41BEF45B7B7:C23E7D52DC1D2D7C5FBEC0B93C6AB2CD815DADCDFDFF8248AEFFDCE6033BB3A8 created at 1581106183 (4 seconds ago)
BLK#1 = (-1,8000000000000000,2048794):FC05612A1B838506C49AB01F45C69008214E804FD747685D027CD41BEF45B7B7:C23E7D52DC1D2D7C5FBEC0B93C6AB2CD815DADCDFDFF8248AEFFDCE6033BB3A8
BLK#2 = (-1,8000000000000000,0):17A3A92992AABEA785A7A090985A265CD31F323D849DA51239737E321FB05569:5E994FCF4D425C0A6CE6A792594B7173205F740A39CD56F537DEFD28B48A0F6E
[ 3][t 2][1581106187.114828825][lite-client.cpp:396][!query]    obtained block (-1,8000000000000000,2048794):FC05612A1B838506C49AB01F45C69008214E804FD747685D027CD41BEF45B7B7:C23E7D52DC1D2D7C5FBEC0B93C6AB2CD815DADCDFDFF8248AEFFDCE6033BB3A8 from server
[ 3][t 1][1581106187.114872456][lite-client.cpp:434][!testnode] obtained 13480 data bytes for block (-1,8000000000000000,2048794):FC05612A1B838506C49AB01F45C69008214E804FD747685D027CD41BEF45B7B7:C23E7D52DC1D2D7C5FBEC0B93C6AB2CD815DADCDFDFF8248AEFFDCE6033BB3A8
[ 3][t 1][1581106187.114928484][lite-client.cpp:999][!testnode] requesting account state for -1:E6FA5C3637A2B7165B63929E3C7E0B6DECFF093AFEDA7EBF77A7F63867F1F6AF with respect to (-1,8000000000000000,2048794):FC05612A1B838506C49AB01F45C69008214E804FD747685D027CD41BEF45B7B7:C23E7D52DC1D2D7C5FBEC0B93C6AB2CD815DADCDFDFF8248AEFFDCE6033BB3A8 with savefile `` and mode -1
[ 3][t 2][1581106187.174595356][lite-client.cpp:1172][!testnode]        got account state for -1:E6FA5C3637A2B7165B63929E3C7E0B6DECFF093AFEDA7EBF77A7F63867F1F6AF with respect to blocks (-1,8000000000000000,2048794):FC05612A1B838506C49AB01F45C69008214E804FD747685D027CD41BEF45B7B7:C23E7D52DC1D2D7C5FBEC0B93C6AB2CD815DADCDFDFF8248AEFFDCE6033BB3A8
account state is (account
  addr:(addr_std
    anycast:nothing workchain_id:-1 address:xE6FA5C3637A2B7165B63929E3C7E0B6DECFF093AFEDA7EBF77A7F63867F1F6AF)
  storage_stat:(storage_info
    used:(storage_used
      cells:(var_uint len:1 value:3)
      bits:(var_uint len:2 value:1139)
      public_cells:(var_uint len:0 value:0)) last_paid:1580913882
    due_payment:nothing)
  storage:(account_storage last_trans_lt:2931373000002
    balance:(currencies
      grams:(nanograms
        amount:(var_uint len:4 value:2956201073))
      other:(extra_currencies
        dict:hme_empty))
    state:(account_active
      (
        split_depth:nothing
        special:nothing
        code:(just
          value:(raw@^Cell
            x{}
             x{FF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54}
            ))
        data:(just
          value:(raw@^Cell
            x{}
             x{00000001441C12B5D708CECB2840138A82C5CAB579099D85B509EDF84AC02BCE9762716A}
            ))
        library:hme_empty))))
x{CFFE6FA5C3637A2B7165B63929E3C7E0B6DECFF093AFEDA7EBF77A7F63867F1F6AF206811CC2F1D6A6D000000AAA0DC915092C0D031C534_}
 x{FF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54}
 x{00000001441C12B5D708CECB2840138A82C5CAB579099D85B509EDF84AC02BCE9762716A}
last transaction lt = 2931373000001 hash = 3D03AE19711C74C027F3AF0B2A73725809EB1D5FB0098CF6F188B95304CF6288
account balance is 2956201073ng

Code showing erroneous output of 'stdout' to 'stderr' in validator-engine-console:

ton-svb-css{~/mydir}:/home/ton/build/validator-engine-console/validator-engine-console -k /home/ton/mydir/client -p /home/ton/mydir/server.pub -a 127.0.0.1:10101 --cmd help 1>t1 2>t2

ton-svb-css{~/mydir}:cat t1

ton-svb-css{~/mydir}:cat t2
connecting to [127.0.0.1:10101]
local key: 089D70F8B6F4EAE3FAD4841DCACF35B98AF9C3E315EA105422D7E5719CCF4014
remote key: 94E337BC6B95D5A5697161AB2E48F6A090145F10718C07E7896C4E9203F048CF
conn ready
list of available commands:
addaddr <ip> {cats...} {priocats...}    adds ip address to address list
addadnl <keyhash> <category>    use key as ADNL addr
adddht <keyhash>        create DHT node with specified ADNL addr
addliteserver <port> <keyhash>  add liteserver
addpermkey <keyhash> <election-date> <expire-at>        add validator permanent key
addproxyaddr <inip> <outid> <secret> {cats...} {priocats...}    adds ip address to address list
addtempkey <permkeyhash> <keyhash> <expireat>   add validator temp key
addvalidatoraddr <permkeyhash> <keyhash> <expireat>     add validator ADNL addr
changefullnodeaddr <keyhash>    changes fullnode ADNL address
checkdht <adnlid>       checks, which root DHT servers are accessible from this ADNL addr
createelectionbid <date> <elector> <wallet> <fname>     create election bid
deladnl <keyhash>       del unused ADNL addr
deldht <keyhash>        del unused DHT node
delpermkey <keyhash>    force del unused validator permanent key
deltempkey <permkeyhash> <keyhash>      force del unused validator temp key
delvalidatoraddr <permkeyhash> <keyhash>        force del unused validator ADNL addr
exportpub <keyhash>     exports public key by key hash
exportpubf <keyhash> <filename> exports public key by key hash
getconfig       downloads current config
getstats        prints stats
gettime shows current server unixtime
help [command]  shows help
importf <filename>      import private key
license shows license info
newkey  generates new key pair on server
quit    closes client
setverbosity <value>    changes verbosity level
sign <keyhash> <data>   signs bytestring with privkey
signf <keyhash> <infile> <outfile>      signs bytestring with privkey
ton-blockchain commented 4 years ago

This should be fixed in commit #a73d202ba2, when the utilities are started with readline disabled or with a --cmd command line option. Please check.

igroman787 commented 4 years ago

Yes, the problem has been resolved, thanks!