feat: implement sim call rpc endpoint#1195
Conversation
|
""" WalkthroughThe changes introduce conditional logic in Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Endpoint (gen_call)
participant ValidatorsManager
Client->>Endpoint (gen_call): Call with params (may include provider/model)
alt provider and model specified
Endpoint->>ValidatorsManager: temporal_snapshot([custom validator])
ValidatorsManager-->>Endpoint: Custom Snapshot
else
Endpoint->>ValidatorsManager: snapshot()
ValidatorsManager-->>Endpoint: Default Snapshot
end
Endpoint->>ValidatorsManager: Check snapshot.validators
Endpoint->>Endpoint: _gen_call_with_validator(...)
Endpoint-->>Client: Return result
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (4)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
2444dc2 to
6c204c5
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
backend/validators/__init__.py (1)
142-151: 🛠️ Refactor suggestionGuard against missing
plugin_configfields to avoidKeyError
_get_snap_from_validatorsindexes straight intoval.llmprovider.plugin_config[...].
Ifplugin_configisNoneor simply lacks"mock_response", this blows up the whole snapshot creation path.- if "mock_response" in val.llmprovider.plugin_config: - host_data["mock_response"] = val.llmprovider.plugin_config[ - "mock_response" - ] + plugin_cfg = val.llmprovider.plugin_config or {} + if "mock_response" in plugin_cfg: + host_data["mock_response"] = plugin_cfg["mock_response"]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/protocol_rpc/endpoints.py(1 hunks)backend/validators/__init__.py(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
backend/protocol_rpc/endpoints.py (4)
backend/node/create_nodes/providers.py (1)
get_default_provider_for(88-99)backend/database_handler/accounts_manager.py (1)
create_new_account(24-31)backend/domain/types.py (1)
Validator(37-77)backend/validators/__init__.py (2)
snapshot_with_custom_validators(168-177)snapshot(154-165)
backend/validators/__init__.py (3)
backend/domain/types.py (3)
Validator(37-77)from_dict(45-60)from_dict(150-181)backend/validators/web.py (1)
verify_for_read(67-71)backend/validators/llm.py (1)
verify_for_read(88-92)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Load Tests / load-test
- GitHub Check: hardhat-test
- GitHub Check: test
- GitHub Check: backend-unit-tests
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
backend/protocol_rpc/endpoints.py (1)
441-446: Chain the originalValueError& surface it with anInvalid paramscodeCatching the
ValueErroris good, but two tiny issues remain:
- Ruff’s B904 hint – re-raise the wrapped error with
from eto preserve the traceback.- Spec‐wise, a bad provider/model pair is an “Invalid params” condition →
-32602, not a generic “Server error” (-32000).- except ValueError as e: - raise JSONRPCError(code=-32000, message=str(e)) + except ValueError as e: + # Propagate root cause and use the standard invalid-params code + raise JSONRPCError(code=-32602, message=str(e), data={}) from e🧰 Tools
🪛 Ruff (0.11.9)
445-445: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/protocol_rpc/endpoints.py(1 hunks)backend/validators/__init__.py(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- backend/validators/init.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/protocol_rpc/endpoints.py (4)
backend/node/create_nodes/providers.py (1)
get_default_provider_for(88-99)backend/database_handler/accounts_manager.py (1)
create_new_account(24-31)backend/domain/types.py (1)
Validator(37-77)backend/validators/__init__.py (2)
temporal_snapshot(168-185)snapshot(154-165)
🪛 Ruff (0.11.9)
backend/protocol_rpc/endpoints.py
445-445: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
(B904)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Load Tests / load-test
- GitHub Check: hardhat-test
- GitHub Check: test
- GitHub Check: backend-unit-tests
🔇 Additional comments (1)
backend/protocol_rpc/endpoints.py (1)
450-455: Confirm that a zero-stake validator is acceptable to downstream logic
stake=0makes the ad-hoc validator completely weightless.
If any later path (e.g. consensus weighting, rewards, slashing) assumes strictly-positive stake, this may blow up in less-obvious places.Please double-check invariants or add an explicit comment / validation guard.
259f02f to
b514044
Compare
6e59ab1 to
4b2252a
Compare
3585868 to
69fa467
Compare
|


What
gen_callparamsWhy
gen_callendpointTesting done
Decisions made
Checks
Reviewing tips
User facing release notes
Summary by CodeRabbit