Skip to content

refactor: consolidate duplicate block-time and fee divisor constants#51

Closed
fansilas wants to merge 1 commit intoentrius:testfrom
fansilas:refactor/consolidate-constants
Closed

refactor: consolidate duplicate block-time and fee divisor constants#51
fansilas wants to merge 1 commit intoentrius:testfrom
fansilas:refactor/consolidate-constants

Conversation

@fansilas
Copy link
Copy Markdown
Contributor

Summary

Two numeric constants were defined in more than one place. This collapses each to a single source of truth without any behavior change.

  • SECONDS_PER_BLOCK = 12 in allways/cli/swap_commands/helpers.py duplicated SUBTENSOR_BLOCK_SECONDS = 12 already defined in allways/chains.py. Eight CLI modules imported from helpers; they now import the canonical constant
    from chains.py.
  • fee_divisor: int = 100 was hardcoded as a default argument in SwapFulfiller.__init__ and SwapVerifier.__init__ while FEE_DIVISOR = 100 already existed in allways/constants.py. Both defaults now reference the constant.
  • display_receipt in swap.py had an inline fee_divisor = 100 # 1% fee that drifted from the same source. Replaced with FEE_DIVISOR, matching the existing pattern at swap.py:634 and quote.py:61.

Changes

  • allways/cli/swap_commands/helpers.py: drop SECONDS_PER_BLOCK
  • allways/cli/swap_commands/{view,post_tx,swap,admin,status,resume,collateral}.py: import SUBTENSOR_BLOCK_SECONDS from allways.chains, rename usages
  • allways/cli/swap_commands/swap.py: display_receipt uses FEE_DIVISOR instead of the inline 100
  • allways/miner/fulfillment.py: SwapFulfiller default fee_divisor = FEE_DIVISOR
  • allways/validator/chain_verification.py: SwapVerifier default fee_divisor = FEE_DIVISOR

Testing

  • All 267 tests pass (pytest)
  • ruff check allways/ clean
  • ruff format --check allways/ clean

No behavior change since FEE_DIVISOR == 100 and SUBTENSOR_BLOCK_SECONDS == 12.
Runtime defaults verified: both SwapFulfiller and SwapVerifier still resolve fee_divisor to 100.

@LandynDev
Copy link
Copy Markdown
Collaborator

Thanks for this, at the time of your contribution we were landing a planned post-V1 cleanup (#46) which consolidated constants. FEE_DIVISOR is single-source in allways/constants.py and block-time constants are no longer duplicated. Great contribution with clearly same vision.

@LandynDev LandynDev closed this Apr 17, 2026
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.

2 participants