-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor komodo_state::NPOINTS #481
Conversation
Note: The method implementations should be moved to komodo_structs.cpp if #476 gets merged in before this one. |
now the TestEvents.komodo_faststateinit_test seems to work okay |
@jmjatlanta From one side, i highly appreciate your efforts and work on komodod core refactoring, also i like the idea with using
I mean Thinking this way in trying to save original logic seems we have 3 options:
My test program for #481 is in https://github.com/DeckerSU/events-refactor-test in |
@DeckerSU Thank you for your deep efforts in testing. And I agree that we are changing code that affects very sensitive areas. I will take what you have done and work to resolve this issue. Here are my thoughts and opinions on how to proceed with such refactoring:
In this case I failed at many of these points. Coincidentally last week I began walking through the notary code to gain a better understanding of how it works. I deployed a testnet with the hope to system test notary changes, among other things. I agree that not refactoring is not an option. Rewriting from scratch is an option, but often impractical. If you would like a short read, check out Migrating Legacy Systems I'll get started figuring out what I did wrong and report back. Thanks again for your detailed efforts. |
@DeckerSU I have modified the code your tests were running to fix the indexing problems that you found. You may take a look at https://github.com/DeckerSU/events-refactor-test/compare/fixtry...jmjatlanta:fixtry?expand=1 . I also took your tests and turned them into a gtest in this PR. The new tests take time to run due to the old linear search, but it checks every entry and then some extra at the end for bounds checking. It also takes extra time to compile in debug mode due to variable following. |
As per the suggestions of @dimxy and @DeckerSU boost::multi_index was removed in favor of std::vector. This may lead to longer search times compared to an indexed search, but it is thought that the increased complexity is not worth the risk of introducing bugs. In the end, the search times have probably not increased over the original code. What has changed is that the code uses far less pointers and no malloc/calloc/realloc. In addition, methods that modify the vector have been moved to within the komodo_state object itself. |
696879f
to
71b3f3e
Compare
I almost finished the review of this PR, tested all the changed functions:
And corresponding changes in methods of Thank you very much, @jmjatlanta for your work and prompt handling of all changes. p.s. I have only two small questions remained which i want to discuss:
Also, inside the My own opinion - let's leave it as is for now (for this PR may be), but in future should we try to make these places "more thread-safe"? |
Backport of @jmjatlanta work from KomodoPlatform/komodo#481 excluded tests and binary data (for tests).
We never used this function and as I can see currently it does nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now, the only thing - i guess we should reduce size of test/notarizationdata.tst
to leave there only few data needed for tests executions (some key points, not all values). My offer is leave only data of notarized checkpoints for the heights:
{ 2524224, 2524223, 2524210, 2524209, 2524200, 2524190, 2524171, 2524170 }
and probably +/- 1 for the each of values.
I was thinking of this this morning. While the size should be reduced, I am thinking of adding a few more combinations. Overlapping depths was the first thing I thought of. I also would like to work through the MoMoM stuff. I have yet to see where that is used and walk through it. IMO a future PR can reduce its size once we believe the edge cases are covered. |
Backport of @jmjatlanta work from KomodoPlatform/komodo#481 excluded tests and binary data (for tests). Related links: - 4322dae - KomodoPlatform/komodo#481
Part of #479
The NPOINTS array required linear searches and never released memory. This PR make NPOINTS a boost::multi_index collection which solves those two issues. In addition, access to the collection is done through member methods of the komodo_state object.