refactor: consolidate duplicate block-time and fee divisor constants#51
Closed
fansilas wants to merge 1 commit intoentrius:testfrom
Closed
refactor: consolidate duplicate block-time and fee divisor constants#51fansilas wants to merge 1 commit intoentrius:testfrom
fansilas wants to merge 1 commit intoentrius:testfrom
Conversation
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 = 12inallways/cli/swap_commands/helpers.pyduplicatedSUBTENSOR_BLOCK_SECONDS = 12already defined inallways/chains.py. Eight CLI modules imported fromhelpers; they now import the canonical constantfrom
chains.py.fee_divisor: int = 100was hardcoded as a default argument inSwapFulfiller.__init__andSwapVerifier.__init__whileFEE_DIVISOR = 100already existed inallways/constants.py. Both defaults now reference the constant.display_receiptinswap.pyhad an inlinefee_divisor = 100 # 1% feethat drifted from the same source. Replaced withFEE_DIVISOR, matching the existing pattern atswap.py:634andquote.py:61.Changes
allways/cli/swap_commands/helpers.py: dropSECONDS_PER_BLOCKallways/cli/swap_commands/{view,post_tx,swap,admin,status,resume,collateral}.py: importSUBTENSOR_BLOCK_SECONDSfromallways.chains, rename usagesallways/cli/swap_commands/swap.py:display_receiptusesFEE_DIVISORinstead of the inline100allways/miner/fulfillment.py:SwapFulfillerdefaultfee_divisor = FEE_DIVISORallways/validator/chain_verification.py:SwapVerifierdefaultfee_divisor = FEE_DIVISORTesting
pytest)ruff check allways/cleanruff format --check allways/cleanNo behavior change since
FEE_DIVISOR == 100andSUBTENSOR_BLOCK_SECONDS == 12.Runtime defaults verified: both
SwapFulfillerandSwapVerifierstill resolvefee_divisorto100.