Info

Download ZIP (600.2 KB)

Testing and Issues

You can test this entry and submit issues during the testing period of the TON Block Validation 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

11

Comments

I noticed that everyone used unordered_map. I was aware of it too :))), but I avoided it due to potential "hash collisions", which can be critical in a system like TON (when it's PoS and validator may lose so much money ...) . However, seeing that others used it, I now feel I might have made a mistake by not including it :)))

Additionally, I skipped some other assumptions(that was helpful in my taskflow idea ... to parallelizing) because, in a critical system like TON, ensuring consistency should be the top priority.

It was a good code review, and I also added some other approaches to the readme that I've tried.
1
You have not added any comments yet...
by rating

Issues

It's not really an issue. Just to say that collisions ocurring in the hash map don't cause any critical problems. If there is a collision, then the keys are compared. So map and unordered_map have the same behavior. Both are completely safe
1
Mighty Deer Feb 12 at 09:10
Actually, we don’t have unlimited memory in the real world. If a rehash triggers memory allocation and it fails, unexpected behavior occurs—boom! The validator gets punished, which is unacceptable. If hash maps were truly safe with just a simple check (even at the cost of performance), everyone would use them instead of tree maps. But it’s not just about collisions or rehashing—you have to consider all aspects!

For cases where you’re dealing with an NP-hard problem and the choice of method doesn’t impact correctness—only performance—hash maps can be useful. But in critical systems, where failure comes at a high cost, relying on them is a bad idea. The risks outweigh the benefits when stability and predictability are paramount.

I know if we talk about this we should have some assumptions that was not available in the problem description, they also said it should be consistent with original solution and ...

Thanks for the points.
I'm not sure a hash map requires more memory than a tree map. In a tree map you have to store two children for each node. In a hash map, the numbers of buckets is usually approximately the number of elements in the map and each element point to its next element in the same bucket. So hash maps also use approximately two integers/pointers per element.

Tree maps are still very useful because elements are ordered inside. This could be very useful in many algorithms. As long as you don't need ordering it's usually better to use hash maps.
FINAL TESTING RESULTS for entry6341
Passed 11841/11841 tests
Real time: 975.913252s
CPU time: 898.289571s
Baseline real time: 975.120982s
Baseline CPU time: 897.583775s
Nobody added any issues yet...