Info

Download ZIP (180 KB)

Testing and Issues

You can test this entry and submit issues during the testing period of the TON Trustless Bridge Challenge contest.

Entries with serious issues will not be able to win the contest, but even minor issues might be important for overall results.

Voting

44
by rating

Issues

Hey, good job.

Finally someone paid attention to storing the next validator set! It’s necessary to keep the bridge trustless; otherwise, the current validator set could submit a new key block with an arbitrary next validator set.
macOS
1
In function `loadValidatorSet` you load and then save all validator set, but you should take only first `main` validators.
In function `validateSignatures` you take into account all of them.
1
Merry Gnu Feb 8 at 18:19
I was not sure about total vs main. So, decided to use them all and fix it if i'll have more time. Surprise, there was no time in future :)
lite-client code looks so concise and clean.

Potential Issues:
1. no tests
2. lite-client stores prev, cur and next validator sets (not sure if that's a problem, there submissions who only store cur set or even just a hash of cur set)
3. It looks like whole block is sent to lite-client (no pruned branches)
Windows 10
Merry Gnu Feb 5 at 14:21
Hey! Thanks for your report :)
1. There is an E2E test that checks the happy-path user_request -> transaction_checker -> block_checker -> transaction_checker -> user_response.
2. I've decided to make it more flexible because there are edge cases when you need to know not only the current set. Additionally, the task description contains "currently known epoch," so I decided that if we have a key_block, we know not only one epoch and we need to cover them all.
3. Yep, unfortunately, I had no time to move to the pruned branches approach. The task description contains "may have all unused branches pruned," so this means that they may have or may not have.

This is a very interesting challenge, but unfortunately, this was my first time with smart-contracts in my life and I have a main job, so I had about zero time to make it perfect :(
Very clean code, lovely! Good work on the hashmap implementation

Some things I found
- I think you made it extra hard for yourself by using utime for epoch checking, checking block's prev_key_block_seqno would've probably been enough. To me it still seems correct, though it has some extra limitations.
- No need to create signed `data` every iteration in signature checking
- Transaction checker doesn't handle bounced messages to lite client, so might keep growing on check block failure
Merry Gnu Feb 8 at 18:27
Thanks, nice points :)
In function `validateGenTime` it's incorrect:
```
require(genTime > prevSince && genTime < currenUntil, "keyBlock relates to the epoch we don't know");
```
Because if `try_elect` failed (or was pauses in network), then current validator set will work even after `utimeUntil` moment.
https://github.com/ton-blockchain/ton/blob/master/crypto/smartcont/elector-code.fc#L843-L848
Merry Gnu Feb 8 at 18:08
Thank you for your report, I appreciate it. Unfortunately, I realised this only after the submission deadline has happened :)
A lot of questions was answered while doing this task, a lot of questions still not answered :D
In Lite-client contract you don't use opcodes for exotic cell. You load cell as ordinary cell.
Merry Gnu Feb 8 at 17:59
Hey. This is because I've used normal block, without pruned branches.
Gas usage:
1) In function `loadHashmap` you use loop `while (...) {...}` to parse labels of hash_map_aug. It can be done by one opcode: LDONES, UBITSIZE, etc.
2) In function `loadHashmap` you store all keys/values from hash_map_aug to "normal" hash_map. It's too expensive. Creating one cell takes about 500 units of gas.
Merry Gnu Feb 8 at 18:22
Yeah, GAS optimization was the most interesting thing for me, but unfortunately I had near to zero spare time to do this.
Btw, are there any simple ways to iterate hashmapaug with something built-in?
It's good that you clean queries in Transaction-checker contract. But you delete ALL of them at once.
Merry Gnu Feb 8 at 18:20
Yep, I realized this too late :) Kind of synchronous transaction checker at this moment
Implemented basic functionality in Tact with an issue: no max_main_validators logic. No global_id/prev_keyblock checks (minor). In tx_checker full tx scan. Combination of Tact and full scan makes solution quite gas expensive.

More info on issues: https://contest.com/docs/TrustlessBridgeChallengeAssessment
Nobody added any issues yet...