Skip to content

fix(validators-init): include config/plugin/plugin_config in validators config hash - #1772

Open
Alicepoltora wants to merge 1 commit into
genlayerlabs:v0.123-devfrom
Alicepoltora:fix/validators-config-hash
Open

Alicepoltora wants to merge 1 commit into
genlayerlabs:v0.123-devfrom
Alicepoltora:fix/validators-config-hash

Conversation

@Alicepoltora

@Alicepoltora Alicepoltora commented Sep 22, 2026 •

Copy link
Copy Markdown

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, and plugin_config are 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

# hash with old api_url
old = _desired_config_hash(
    '[{"stake":100,"provider":"openai","model":"gpt-4",'
    '"plugin":"openai","plugin_config":{"api_url":"https://api.old.example"}}]'
)
# hash with new api_url — must differ, but was identical before this fix
new = _desired_config_hash(
    '[{"stake":100,"provider":"openai","model":"gpt-4",'
    '"plugin":"openai","plugin_config":{"api_url":"https://api.new.example"}}]'
)
assert old != new  # FAILED before this fix

The added test test_initialize_validators_reinitializes_when_plugin_config_changed fails on main and passes with this fix.

Fix

Both hash functions now key on (provider, model, stake, config, plugin, plugin_config), with config/plugin_config canonically 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 reinit

Summary by CodeRabbit

  • Bug Fixes

    • Validator updates now detect changes to provider settings, API URLs, models, plugins, and plugin options.
    • Validators are automatically reinitialized when their configuration changes.
    • Unchanged validator configurations no longer trigger unnecessary reinitialization.
  • Tests

    • Added coverage for configuration changes that require validator replacement.
    • Added coverage confirming identical configurations are preserved without replacement.

…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.
@github-actions
github-actions Bot changed the base branch from main to v0.123-dev September 22, 2026 10:37
@github-actions

Copy link
Copy Markdown
Contributor

This PR targeted main, which is only the default/static branch.

I retargeted it to v0.123-dev, the active development branch. Pushes to v0.123-dev automatically fast-forward main.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4d8ac600-104c-4d08-89bb-73cd85c98500

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant