fix: replace hardcoded CURRENT_YEAR with dynamic datetime#2828
fix: replace hardcoded CURRENT_YEAR with dynamic datetime#2828Scottcjn merged 1 commit intoScottcjn:mainfrom
Conversation
- node/rip_200_round_robin_1cpu1vote_v2.py: CURRENT_YEAR = datetime.now().year - rips/rustchain-core/validator/setup_validator.py: added datetime import + dynamic CURRENT_YEAR Note: cpu_architecture_detection.py has CRLF line endings which would cause a large diff. That file needs to be normalized separately. Bounty: Scottcjn#305 Wallet: RTC6d1f27d28961279f1034d9561c2403697eb55602
CI 失败说明PR #2828 的 CI 失败与本次提交无关。 Rust CI — Rustfmt 失败Rust 代码格式化检查失败,这是仓库中 Rust 代码的现有问题,与本次 Python 修改无关。 CI — 3 个测试失败这些是仓库中已存在的测试失败,与本次修改的 2 个文件无关:
本次 PR 的 Python 语法检查已通过( 建议:这些 CI 失败是仓库自身问题,不影响本次 PR 的合并。 |
Rust CI — Rustfmt 失败说明PR #2828 的 Rustfmt 失败与本次提交无关。 本次 PR 修改的文件:
Rustfmt 检查的是 Rust 代码格式,与 Python 文件完全无关。这是仓库中 Rust 代码的已有问题。 其他 CI 结果:
建议:Rustfmt 问题应在仓库的 Rust 代码中单独修复,不影响本次 Python PR 的合并。 |
BotMakesCrypto
left a comment
There was a problem hiding this comment.
Code Review: Replace hardcoded CURRENT_YEAR with dynamic datetime
LGTM — simple and correct fix.
Review
Two files changed, both replacing CURRENT_YEAR = 2025 with CURRENT_YEAR = datetime.now().year.
Positives:
- Prevents the annual "update year constant" maintenance task
- Correctly imports datetime in setup_validator.py (was already available in rip_200)
- Minimal change, low risk
One concern:
datetime.now().year is evaluated at module import time, not at runtime. If a long-running node process starts on Dec 31 at 23:59 and runs past midnight, CURRENT_YEAR will still be the old year until the process restarts. For a 10-minute block time this is unlikely to matter, but worth noting for correctness.
If this matters for the antiquity multiplier calculation, consider using datetime.now().year at call sites rather than module-level constant. But for practical purposes this is fine.
Verdict: Approve. Ship it.
Summary
Fixes hardcoded
CURRENT_YEAR = 2025in 2 files, replacing withdatetime.now().yearto prevent stale antiquity multiplier calculations.Files Changed (+3/-2)
node/rip_200_round_robin_1cpu1vote_v2.pyCURRENT_YEAR = datetime.now().yearrips/rustchain-core/validator/setup_validator.pyfrom datetime import datetime+ dynamic CURRENT_YEARNote on cpu_architecture_detection.py
This file also has
CURRENT_YEAR = 2025but uses CRLF line endings. Including it in this PR would cause a +733/-732 diff due to git's CRLF→LF normalization. The actual code change is 1 line, but git sees all 730 lines as changed.Recommendation: Normalize CRLF→LF in a separate PR, then apply the CURRENT_YEAR fix. Or apply the fix manually:
Impact
Bounty: #305
Wallet: RTC6d1f27d28961279f1034d9561c2403697eb55602