1
0
mirror of https://github.com/danog/toncontest.git synced 2024-11-26 12:04:50 +01:00
This commit is contained in:
Daniil Gentili 2019-10-06 20:34:05 +02:00
parent 4a505a6bd6
commit 8f3424b08a
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
9 changed files with 54 additions and 12 deletions

24
test/README.md Normal file
View File

@ -0,0 +1,24 @@
From https://github.com/ton-blockchain/ton/issues/96:
Errors triggered by code inside a coroutine currently being called by the `times` loop keyword surface with an invalid line number, as if the error was triggered by the `times` keyword, instead of the actual keyword that originated the exception (basically, we're missing full stack traces here).
```
[daniil@daniil-arch test]$ cat test.fif
{ abort"This is an error thrown inside a times loop" } : throw
{
."Printing stuff at line 4" cr
."Printing stuff at line 5" cr
throw // line 6
."Printing stuff at line 7" cr
} 3 times // line 8
[daniil@daniil-arch test]$ fift -s test.fif
Printing stuff at line 4
Printing stuff at line 5
[ 1][t 0][1570377741.616638660][words.cpp:2804] test.fif:8: times: stack underflow
[ 1][t 0][1570377741.616738081][fift-main.cpp:198] Error interpreting file `test.fif`: error interpreting included file `test.fif` : test.fif:8: times: stack underflow
```
Fift indicates that the error was thrown at line 8 by the `times` keyword (`test.fif:8: times:`): while it is true that the exception surfaced at that point in the code, the rest of the stack trace is missing, making it hard to debug exceptions thrown inside loops.
It would be nice to have a full stack trace, for example indicating that the error was first thrown in `test.fif:1: abort`, then surfaced in `test.fif:6: throw`, finally surfacing as `test.fif:8: times`.

8
test/test.fif Normal file
View File

@ -0,0 +1,8 @@
{ abort"This is an error thrown inside a times loop" } : throw
{
."Printing stuff at line 4" cr
."Printing stuff at line 5" cr
throw // line 6
."Printing stuff at line 7" cr
} 3 times // line 8

1
wallet/a.pubkey Normal file
View File

@ -0,0 +1 @@
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

1
wallet/b.pubkey Normal file
View File

@ -0,0 +1 @@
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

1
wallet/c.pubkey Normal file
View File

@ -0,0 +1 @@
cccccccccccccccccccccccccccccccc

1
wallet/d.pubkey Normal file
View File

@ -0,0 +1 @@
dddddddddddddddddddddddddddddddd

1
wallet/e.pubkey Normal file
View File

@ -0,0 +1 @@
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

View File

@ -216,4 +216,3 @@ PROGRAM{
32 PLDU
}>
}END>c
2 boc+>B "RS" B>file

View File

@ -10,11 +10,12 @@
file>B B>boc
} : load-boc
{ ."usage: " @' $0 type ." <workchain-id> <wallet-name> <n> <k> [<key1> <key2> ...] [<boc1> <boc2>]" cr cr
."Creates a new multisignature wallet in specified workchain composed of <n> (1-10) public keys." cr
{ ."usage: " @' $0 type ." <workchain-id> <wallet-name> <n> <k> <privkey1> [<pubkey2> ...] [<boc1> <boc2>]" cr cr
."Creates a new multisignature wallet in specified workchain composed of <n> (1-10) keys." cr
."The first of the keys must be a private key (pre-existing or not), used to generate the wallet; the rest MUST be public keys." cr
."Create or generate public key files from private keys using gen-pub.fif privkey" cr cr
."Min <k> (1-10) signatures required to send an order; load <n> pre-existing public keys from files <key1...n>." cr
."Optionally load a number of pre-generated partially signed orders <boc1...m> to preload into the contract." cr cr
."Create or generate public key files from private keys using gen-pub.fif key" cr cr
1 halt
} : usage
$# 5 < ' usage if
@ -31,7 +32,9 @@ k n <= not abort"<k> must smaller than or equal to <n>"
$# 4 n + < abort"Not enough keys were provided in args!"
5 { dup $() +".pubkey" load-pubkey swap 1+ } n times drop
$5 +".pk" load-generate-keypair { 256 B>u@ swap } 2 times const privkey
6 { dup $() +".pubkey" load-pubkey swap 1+ } n 1- times drop
n tuple constant keys
5 n + { dup $() +".boc" load-boc swap 1+ } m times drop
@ -108,7 +111,7 @@ dictnew
messages swap [] // Get n-th value v
dup <b swap ref, // ~
swap hash // Get x
swap hashu // Get x
3 roll // Get dictionary s
256 // Get n
@ -123,19 +126,22 @@ dictnew
// data
// storage$_ seqno:uint32 minSigs:(## 4) n:(## 4) keys:[ ^PubKeys ] messages:(HashmapE 256 ^(MultiSigWrapperStorage X))
// { minSigs > 0 } { n >= minSigs } { n <= 10 } { minSigs <= 10 } = Storage X;
<b 0 32 u,
k 4 u,
nCells 4 u,
keyCells explode roll { swap ref, } nCells times
messages-dict <s s,
messages-dict dict,
b>
// no libraries
null
// create StateInit
// _ split_depth:(Maybe (## 5)) special:(Maybe TickTock)
// code:(Maybe ^Cell) data:(Maybe ^Cell)
// library:(HashmapE 256 SimpleLib) = StateInit;
// split_depth 0 special 0 code 1 data 1
//
<b b{0011} s, 3 roll ref, rot ref, swap dict, b>
dup ."StateInit: " <s csr. cr
dup hash wc swap 2dup 2constant wallet_addr
."new wallet address = " 2dup .addr cr
@ -144,7 +150,7 @@ dup hash wc swap 2dup 2constant wallet_addr
."Bounceable address (for later access): " 6 .Addr cr
<b 0 32 u, -1 32 i, b>
dup ."signing message: " <s csr. cr
dup hash wallet_pk ed25519_sign_uint rot
dup hash privkey ed25519_sign_uint rot
<b b{1000100} s, wallet_addr addr, b{000010} s, swap <s s, b{0} s, swap B, swap <s s, b>
dup ."External message for initialization is " <s csr. cr
2 boc+>B dup Bx. cr