ton-blockchain / ton

Main TON monorepo
Other
2.95k stars 891 forks source link

Inspect possible errors when StateInit message was successfully sent #121

Open Tynik opened 4 years ago

Tynik commented 4 years ago

Hello! Where could I see the list of errors or why a smart contract was not inited if even it has Grams and an external message was successfully sent, but smart contract has state:account_uninit(address 0f_bzFaKdHtV8mTEB_4JcR-ZAyufXk4e9zWeibQtHHcksbSg) The following commands which I used:

> sendfile multi-sign-wallet-query.boc
[ 1][t 1][1570728598.633116961][lite-client.cpp:973][!testnode] sending query from file multi-sign-wallet-query.boc
[ 3][t 1][1570728598.679722071][lite-client.cpp:983][!query]    external message status is 1
>
last
getaccount 0f_bzFaKdHtV8mTEB_4JcR-ZAyufXk4e9zWeibQtHHcksbSg

I assume that the external message is not correct, but is there a way to see more detailed errors?

Regno commented 4 years ago

Hi. I have same issue. I suppose an external message have a wrong signature. I think have some kind of message status would be really useful.

gurobokum commented 4 years ago

+1 I've spend the most time on debugging external initializion message cause there is no way to see what is going on. What I've found at this point:

  1. Hash of the StateInit should match the account address, mentioned in the pdf
  2. What I haven't found in the pdfs: Transation in compute phase runs vm with contract code with stack pointed there. So if it fails - transaction is rejected. In my case external Message X body should contain valid data as in_msg slice I use such test for vaildating that case, where code is my scm
    
    dup constant code
    -1 0x1111111111111111111111111111111111111111111111111111111111111111 2constant addr
    "./tests/test.pk" load-generate-keypair constant wallet_pk constant public_key
    <b 0 32 u,  public_key B, 0 3 u, b> constant data
    <b b{001} s, code ref, b{1} s, data ref, b{0} s, b> constant state_init
    <b 0 32 u, b> constant seqno
    seqno hash wallet_pk ed25519_sign_uint constant signing_bin

// stack.push_int(balance.grams); 0 // stack.push_int(msg_balance_remaining.grams); 0 // stack.push_cell(in_msg); <b b{1000100} s, addr addr, 0 Gram, b{11} s, state_init ref, // body:(Either X ^X) b{0} s, 0 32 u, signing_bin B, seqno <s s, // THIS IS SECTION OF MESSAGE X BODY b> // stack.push_cellslice(in_msg_body); <b 0 32 u, signing_bin B, seqno <s s, b> <s // COPY OF MESSAGE X BODY // stack.push_bool(in_msg_extern); -1 code <s data runvm drop .s 0 <> { 1 halt } if

gurobokum commented 4 years ago

What I haven't found in the pdfs

The behavior has naming as Tentative execution and covered in TON.pdf#2.4.6

Tynik commented 4 years ago

@JIoJIaJIu hello! Thank you for the possible option to run code in VM from fift, I did not think so)