Skip to content

Refactor Transition#1212

Merged
otherview merged 38 commits into
release/hayabusafrom
pedro/hayabusa/refact_Transition
Aug 4, 2025
Merged

Refactor Transition#1212
otherview merged 38 commits into
release/hayabusafrom
pedro/hayabusa/refact_Transition

Conversation

@otherview

@otherview otherview commented Jul 30, 2025

Copy link
Copy Markdown
Member

Description

This PR introduces significant architectural improvements to the staker contract's transition logic, focusing on better separation of concerns, improved testability, and cleaner state management.

Key Changes

  • Added transition.go: Introduces a dedicated Transition() method that handles PoS activation logic
  • Reused epoch transition pattern: Transition now leverages the same epoch transition approach used in housekeeping for consistency
  • Method visibility changes: Made computeEpochTransition() and applyEpochTransition() private for better encapsulation
  • Improved state management: Enhanced EpochTransition struct to better represent state changes
  • Cleaner transition flow: Streamlined the housekeeping process with better error handling
  • Removed public AddLeaderGroup(): Eliminated direct external access to leader group manipulation

Breaking Changes

  • ActivateNextValidator() method is now private (activateNextValidator())
  • AddLeaderGroup() method removed from public API
  • ComputeEpochTransition() method is now private (computeEpochTransition())

Fixes # (issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing E2E tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have not added any vulnerable dependencies to my code

@codecov-commenter

codecov-commenter commented Jul 30, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 26.47059% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.28%. Comparing base (49c5904) to head (58f37f0).
⚠️ Report is 2 commits behind head on release/hayabusa.

Files with missing lines Patch % Lines
builtin/staker/validation/service.go 0.00% 48 Missing ⚠️
builtin/staker/transition.go 40.00% 16 Missing and 8 partials ⚠️
builtin/staker/housekeep.go 80.00% 0 Missing and 2 partials ⚠️
builtin/staker/validation/linked_list.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           release/hayabusa    #1212      +/-   ##
====================================================
+ Coverage             58.24%   58.28%   +0.04%     
====================================================
  Files                   273      274       +1     
  Lines                 28966    28968       +2     
====================================================
+ Hits                  16870    16885      +15     
- Misses                10629    10647      +18     
+ Partials               1467     1436      -31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@otherview
otherview force-pushed the pedro/hayabusa/refact_Transition branch from 4ac8430 to c5d8247 Compare July 30, 2025 15:34
Base automatically changed from pedro/hayabusa/refact_housekeep to release/hayabusa July 30, 2025 15:54
Comment thread builtin/staker/validation/service.go
@otherview
otherview marked this pull request as ready for review July 31, 2025 08:55
@otherview
otherview requested a review from a team as a code owner July 31, 2025 08:55
Comment thread builtin/staker/validation/service.go Outdated
Comment thread builtin/staker/validation/service.go
Comment thread builtin/staker/transition.go Outdated
Comment thread builtin/staker/transition.go Outdated
otherview and others added 2 commits August 4, 2025 15:49
Co-authored-by: Paolo Galli <paolo.galli@vechain.org>
@otherview
otherview force-pushed the pedro/hayabusa/refact_Transition branch from a2a94a8 to 58f37f0 Compare August 4, 2025 15:09
@otherview
otherview merged commit dee8191 into release/hayabusa Aug 4, 2025
25 checks passed
@otherview
otherview deleted the pedro/hayabusa/refact_Transition branch August 4, 2025 15:21
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.

4 participants