Skip to content

refactor(lib-blockchain): Move difficulty adjustment ownership to lib-consensus #632

@umwelt

Description

@umwelt

Description

Part of issue #605: Adaptive Difficulty Adjustment for PoUW Consensus

Architectural improvement: Move difficulty adjustment policy ownership from lib-blockchain to lib-consensus, following the principle "consensus engine should own difficulty policy".

Current State

  • Difficulty adjustment logic in lib-blockchain::blockchain.rs
  • DAO proposal system in lib-consensus
  • Parameter governance split between two crates

Desired State

  • lib-consensus owns difficulty adjustment algorithm
  • lib-consensus owns DifficultyConfig
  • lib-blockchain calls lib-consensus::adjust_difficulty()
  • lib-consensus manages DAO parameter updates
  • Clear separation of concerns

Acceptance Criteria

  • Create lib-consensus::difficulty_manager module
  • Move DifficultyConfig from lib-blockchain to lib-consensus
  • Create DifficultyManager struct in lib-consensus
  • Implement adjust_difficulty() in DifficultyManager
  • Update BlockchainConsensusCoordinator to manage difficulty updates
  • Update lib-blockchain to call lib-consensus::DifficultyManager
  • All existing tests pass after refactoring
  • Add integration tests between crates
  • Update documentation to reflect architecture

Priority

Related

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions