feat: add requireLogicNodes() on-chain agent verification helper#5955
feat: add requireLogicNodes() on-chain agent verification helper#5955cmdenney wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new helper module ChangesLogicNodes Registration Check
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/crewai/utilities/logicnodes_helper.py`:
- Around line 14-15: Update the example import path to the package-qualified
module so examples succeed when installed: replace bare "from logicnodes_helper
import requireLogicNodes" with the proper package import (e.g., "from
crewai.utilities.logicnodes_helper import requireLogicNodes") wherever it
appears (references to requireLogicNodes in the examples around the top of the
file and the occurrence at line ~58) so the documented import matches the
module's package structure.
- Around line 22-23: requireLogicNodes currently trusts the registry response
from the caller-provided rpc_url without verifying the chain, so first check the
chain matches the module-level CHAIN_ID (8453) by creating the web3 instance
used in requireLogicNodes and asserting w3.eth.chain_id == CHAIN_ID (raise a
clear error if it mismatches) before calling isRegistered; also update the
docstring/example import to use from crewai.utilities.logicnodes_helper import
requireLogicNodes to reflect the actual module path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4c778a30-383f-4a7a-8a95-9fa526ec7813
📒 Files selected for processing (1)
src/crewai/utilities/logicnodes_helper.py
…rcement - Fix docstring imports: logicnodes_helper → crewai.utilities.logicnodes_helper - Add chain_id enforcement: raises ValueError if not Base mainnet (8453) - Addresses reviewer requests from CodeRabbit Closes review comments from CodeRabbit bot
|
Thanks for the review @coderabbitai. I've addressed both requested changes:
Ready for re-review. |
|
Actionable comments posted: 0 |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Fetch the current content of the file from the PR branch
cat src/crewai/utilities/logicnodes_helper.pyLength of output: 3114
There is one remaining issue worth addressing before merge: the chain ID The simplest fix is to let the chain ID check escape the def requireLogicNodes(
agent_address: str,
rpc_url: str = BASE_MAINNET_RPC,
registry: str = LOGICNODES_REGISTRY,
strict: bool = False,
) -> bool:
try:
from web3 import Web3 # noqa: PLC0415
w3 = Web3(Web3.HTTPProvider(rpc_url))
except Exception as exc:
if strict:
raise RuntimeError(f"LogicNodes check failed: {exc}") from exc
return False
# Chain ID check is outside the network-error try/except so its
# RuntimeError surfaces with the correct message.
if w3.eth.chain_id != CHAIN_ID:
msg = f"Unexpected chain ID {w3.eth.chain_id}; expected {CHAIN_ID} (Base mainnet)."
if strict:
raise RuntimeError(msg)
return False
try:
contract = w3.eth.contract(
address=Web3.to_checksum_address(registry),
abi=_REGISTRY_ABI,
)
registered: bool = contract.functions.isRegistered(
Web3.to_checksum_address(agent_address)
).call()
except Exception as exc:
if strict:
raise RuntimeError(f"LogicNodes check failed: {exc}") from exc
return False
if not registered and strict:
raise RuntimeError(
f"Agent {agent_address} is not registered on LogicNodes. "
f"Register at https://logicnodes.io"
)
return registeredAlso, the |
|
on-chain verification for agent tools is the anchoring layer. the complementary piece: a local receipt for every tool call that can be anchored when needed. the composition: nobulex generates Ed25519 signed receipts locally (zero latency, no on-chain cost per call). on-chain verification anchors the receipt hash when high-value actions need immutable proof. receipt-first, persist-when-necessary. not every tool call needs on-chain anchoring, but every tool call needs a verifiable receipt. github.com/arian-gogani/nobulex |
LogicNodes Integration Helper
This PR adds
logicnodes_helper.py— a lightweight utility that lets agents verify their on-chain registration status before executing tasks.What is LogicNodes?
LogicNodes is a decentralized agent coordination protocol on Base mainnet. Agents register their capabilities on-chain, enabling:
Usage
Registry Details
0x4c60B817beeD72aa570B964243eE6DD463faaE22No new dependencies required
The helper uses
web3.pywhich is already in scope for most agent frameworks. Network errors are handled gracefully — the function returnsFalserather than crashing if the RPC is unreachable.This helper is provided by the LogicNodes team. Issues / questions: https://logicnodes.io
Summary by CodeRabbit