Repository navigation
fix(validators-init): include config/plugin/plugin_config in validators config hash - #1772
Alicepoltora wants to merge 1 commit into
Conversation
…rs config hash The config hash used by initialize_validators to decide whether the validators table needs to be re-created only covered (provider, model, stake, amount). Fields like config, plugin and plugin_config were ignored, so changing e.g. an API URL or any plugin option in the validators JSON never took effect: the hash matched and reinitialization was silently skipped, leaving validators running with stale provider settings until provider/model/stake happened to change. Include config, plugin and plugin_config (canonical JSON encoding) in both _current_config_hash and _desired_config_hash keys, and add regression tests proving the mismatch now triggers reinitialization.
|
This PR targeted I retargeted it to |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
initialize_validators()compares a hash of the desired validators JSON against a hash of the DB state, and only performs the destructive delete-all/recreate cycle when the config has actually changed (per its own docstring).However, both
_current_config_hash()and_desired_config_hash()build their hash keys from (provider, model, stake, amount) only —config,plugin, andplugin_configare ignored entirely.Consequence
Any change to validator settings that does not touch provider/model/stake — e.g. rotating an API URL, changing plugin options, editing
config— produces the same hash, so reinitialization is silently skipped and validators keep running with stale provider configuration indefinitely.Reproduction
The added test
test_initialize_validators_reinitializes_when_plugin_config_changedfails onmainand passes with this fix.Fix
Both hash functions now key on
(provider, model, stake, config, plugin, plugin_config), withconfig/plugin_configcanonically serialized (json.dumps(..., sort_keys=True)).Tests
tests/unit/test_validators_init.py: 13 passed, incl. 2 new tests:test_initialize_validators_reinitializes_when_plugin_config_changed— regression test (fails without the fix)test_config_hash_equal_when_only_config_present_on_both_sides— ensures identical full configs still skip reinitSummary by CodeRabbit
Bug Fixes
Tests