besu icon indicating copy to clipboard operation
besu copied to clipboard

Implement getNearest methods

Open matkt opened this issue 1 year ago • 3 comments

PR description

Add getNearestAfter method needed for verkle and fix getNearestBefore method

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • [ ] Checked out our contribution guidelines?
  • [ ] Considered documentation and added the doc-change-required label to this PR if updates are required.
  • [ ] Considered the changelog and included an update if required.
  • [ ] For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • [ ] unit tests: ./gradlew build
  • [ ] acceptance tests: ./gradlew acceptanceTest
  • [ ] integration tests: ./gradlew integrationTest
  • [ ] reference tests: ./gradlew ethereum:referenceTests:referenceTests

matkt avatar Jun 25 '24 08:06 matkt

Generally LGTM. the rewrite of getNearest seems a little chat-gpt-y to me though

Thanks for the review.. Can you also tell me what bothers so that I can change. Is factorization too hard to understand ?

The use of Min Max on this case is more interesting because it avoids sorting that would be more expensive. This is why this proposal seems to me more interesting for this call. But I can understand that the overall factorization of the method is complex and I can try to simplify by duplicating more

matkt avatar Jun 26 '24 02:06 matkt

@garyschulte did some cleanning in the PR, I also modified the tests in order to check more edgcases, the new tests are comparing directly with rocksdb instead of hardcoding the responses

thanks to that I fixed some new issues

matkt avatar Jun 26 '24 10:06 matkt

The use of Min Max on this case is more interesting because it avoids sorting that would be more expensive.

that makes a lot of sense, min/max will be O(n). 👍

garyschulte avatar Jun 26 '24 22:06 garyschulte

@garyschulte is this GTG?

macfarla avatar Aug 13 '24 02:08 macfarla

yes will fix the PR

matkt avatar Aug 13 '24 09:08 matkt