Skip to content

fix: replace hardcoded CURRENT_YEAR with dynamic datetime#2828

Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom
BossChaos:fix/current-year-only
May 1, 2026
Merged

fix: replace hardcoded CURRENT_YEAR with dynamic datetime#2828
Scottcjn merged 1 commit intoScottcjn:mainfrom
BossChaos:fix/current-year-only

Conversation

@BossChaos
Copy link
Copy Markdown
Contributor

Summary

Fixes hardcoded CURRENT_YEAR = 2025 in 2 files, replacing with datetime.now().year to prevent stale antiquity multiplier calculations.

Files Changed (+3/-2)

File Change
node/rip_200_round_robin_1cpu1vote_v2.py CURRENT_YEAR = datetime.now().year
rips/rustchain-core/validator/setup_validator.py Added from datetime import datetime + dynamic CURRENT_YEAR

Note on cpu_architecture_detection.py

This file also has CURRENT_YEAR = 2025 but 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:

# Line 23 of cpu_architecture_detection.py
CURRENT_YEAR = datetime.now().year  # was: CURRENT_YEAR = 2025

Impact

  • Antiquity multipliers now correctly reflect the current year
  • No breaking changes — only year resolution is dynamic

Bounty: #305
Wallet: RTC6d1f27d28961279f1034d9561c2403697eb55602

- 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
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/XS PR: 1-10 lines labels May 1, 2026
@BossChaos
Copy link
Copy Markdown
Contributor Author

CI 失败说明

PR #2828 的 CI 失败与本次提交无关

Rust CI — Rustfmt 失败

Rust 代码格式化检查失败,这是仓库中 Rust 代码的现有问题,与本次 Python 修改无关。

CI — 3 个测试失败

FAILED tests/security_audit/test_security_findings_2867.py::test_mempool_add_manage_tx_undefined
FAILED tests/security_audit/test_security_findings_2867.py::test_pncounter_max_merge_inflation
FAILED tests/test_beacon_atlas_behavior.py::test_bounty_lifecycle_workflow

这些是仓库中已存在的测试失败,与本次修改的 2 个文件无关:

  • node/rip_200_round_robin_1cpu1vote_v2.py — 仅改 CURRENT_YEAR
  • rips/rustchain-core/validator/setup_validator.py — 添加 datetime import + CURRENT_YEAR

本次 PR 的 Python 语法检查已通过py_compile 验证),lint 检查也通过了。

建议:这些 CI 失败是仓库自身问题,不影响本次 PR 的合并。

@BossChaos
Copy link
Copy Markdown
Contributor Author

Rust CI — Rustfmt 失败说明

PR #2828 的 Rustfmt 失败与本次提交无关

本次 PR 修改的文件:

  • node/rip_200_round_robin_1cpu1vote_v2.py (Python)
  • rips/rustchain-core/validator/setup_validator.py (Python)

Rustfmt 检查的是 Rust 代码格式,与 Python 文件完全无关。这是仓库中 Rust 代码的已有问题。

其他 CI 结果:

  • ✅ Documentation — Succeeded
  • ✅ Test (ubuntu-latest) — Succeeded
  • ✅ Test (macos-latest) — Succeeded
  • ✅ Test (windows-latest) — Succeeded
  • ✅ Clippy — Succeeded
  • ✅ Security Audit — Succeeded

建议:Rustfmt 问题应在仓库的 Rust 代码中单独修复,不影响本次 Python PR 的合并。

Copy link
Copy Markdown

@BotMakesCrypto BotMakesCrypto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Scottcjn Scottcjn merged commit e8630aa into Scottcjn:main May 1, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/XS PR: 1-10 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants