Skip to content
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

feat: (Reorg Support) Perform Reorg internally with blocktx statuses #580

Merged
merged 11 commits into from
Sep 5, 2024

Conversation

kuba-4chain
Copy link
Collaborator

@kuba-4chain kuba-4chain commented Sep 4, 2024

Description of Changes

Whenever a block that extends the competing chain arrives, with the greatest chainwork, the internal reorg is performed:

  1. A common ancestor is found between these two competing chains.
  2. All STALE blocks from the common ancestor, up to the tip of competing chain, are marked as LONGEST
  3. All previously LONGEST blocks from the common ancestor, up to the previous longest tip are marked as STALE.
  4. Everything is being saved in db.

An integration test was updated to ensure a proper flow between blocktx processor logic and updates in blocktx store.

Linked Issues / Tickets

ARCO-177

Testing Procedure

Describe the tests you've added or any testing steps you've taken.

  • I have added new unit tests
  • All tests pass locally
  • I have tested manually in my local environment

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have updated CHANGELOG.md with my changes

@kuba-4chain kuba-4chain marked this pull request as ready for review September 4, 2024 12:06
internal/blocktx/processor.go Outdated Show resolved Hide resolved
internal/blocktx/store/postgresql/get_longest_chain.go Outdated Show resolved Hide resolved
internal/blocktx/processor.go Outdated Show resolved Hide resolved
internal/blocktx/processor.go Outdated Show resolved Hide resolved
Copy link

sonarqubecloud bot commented Sep 5, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@kuba-4chain kuba-4chain merged commit b51638e into main Sep 5, 2024
5 of 6 checks passed
@kuba-4chain kuba-4chain deleted the arco-177-perform-reorg branch September 5, 2024 11:47
github-actions bot pushed a commit that referenced this pull request Sep 5, 2024
…580)

* feat: reorg template

* feat: query for stale and longest blocks

* feat: perform reorg in database and update integration test

* feat: update tests to new utils

* feat: add one test

* feat: comment get_stale_blocks function and fix cammelCase variables

* feat: fix indentation

* fix: int64 to uint64 in logs

* feat: comment explaining the recursive query

* feat: change update status to perform one query instead of two

* feat: rename index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants