Skip to content

feat: add requireLogicNodes() on-chain agent verification helper#5955

Open
cmdenney wants to merge 1 commit into
crewAIInc:mainfrom
cmdenney:feat/logicnodes-integration
Open

feat: add requireLogicNodes() on-chain agent verification helper#5955
cmdenney wants to merge 1 commit into
crewAIInc:mainfrom
cmdenney:feat/logicnodes-integration

Conversation

@cmdenney
Copy link
Copy Markdown

@cmdenney cmdenney commented May 27, 2026

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:

  • Verifiable identity — cryptographic proof of agent existence
  • Capability discovery — other agents and protocols can find and trust registered agents
  • Revenue routing — fee-sharing infrastructure for agent-to-agent (A2A) services

Usage

from logicnodes_helper import requireLogicNodes

# Soft check (returns bool)
if requireLogicNodes("0xYourAgentAddress"):
    print("Agent verified on LogicNodes registry")

# Strict check (raises RuntimeError if not registered)
requireLogicNodes("0xYourAgentAddress", strict=True)

Registry Details

Field Value
Contract 0x4c60B817beeD72aa570B964243eE6DD463faaE22
Chain Base Mainnet (8453)
Explorer Basescan

No new dependencies required

The helper uses web3.py which is already in scope for most agent frameworks. Network errors are handled gracefully — the function returns False rather than crashing if the RPC is unreachable.


This helper is provided by the LogicNodes team. Issues / questions: https://logicnodes.io

Summary by CodeRabbit

  • New Features
    • Added Ethereum agent registration verification against the LogicNodes on-chain registry.
    • Supports strict validation mode that enforces registration requirements with error handling for verification failures.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

Adds a new helper module logicnodes_helper.py that verifies whether an Ethereum agent address is registered in the LogicNodes on-chain registry. The function calls the registry contract on Base mainnet via Web3, returns a boolean indicating registration status, and optionally raises errors in strict mode.

Changes

LogicNodes Registration Check

Layer / File(s) Summary
LogicNodes registry constants and ABI
src/crewai/utilities/logicnodes_helper.py
Defines module-level constants for the registry address (0x4c60B817...), Base mainnet RPC URL, and chain ID (8453), along with a minimal contract ABI containing the isRegistered(address) view function signature.
Registration check implementation
src/crewai/utilities/logicnodes_helper.py
Implements requireLogicNodes() that constructs a Web3 client, calls the registry contract with a checksum-normalized address, returns True if registered or False if unregistered; in strict mode, raises RuntimeError on network/import errors or if the agent is not registered.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A registry check, swift and clean,
Web3 calls to Base, on-chain scene,
Agents verified with constants neat,
LogicNodes helper, code complete! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add requireLogicNodes() on-chain agent verification helper' accurately and concisely describes the main change: introducing a new helper function for on-chain agent verification.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between c5ea415 and 2597691.

📒 Files selected for processing (1)
  • src/crewai/utilities/logicnodes_helper.py

Comment on lines +14 to +15
from logicnodes_helper import requireLogicNodes
requireLogicNodes(agent_address="0xYourAgent...")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix example import path in module docs.

The examples use from logicnodes_helper import requireLogicNodes, which will fail for the packaged module path in this repo.

📝 Suggested fix
-    from logicnodes_helper import requireLogicNodes
+    from crewai.utilities.logicnodes_helper import requireLogicNodes
...
-        from logicnodes_helper import requireLogicNodes
+        from crewai.utilities.logicnodes_helper import requireLogicNodes

Also applies to: 58-58

🤖 Prompt for 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.

In `@src/crewai/utilities/logicnodes_helper.py` around lines 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.

Comment on lines +22 to +23
CHAIN_ID = 8453

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Identify the file and show the relevant parts around CHAIN_ID / requireLogicNodes
FILE="src/crewai/utilities/logicnodes_helper.py"

echo "== File existence =="
ls -l "$FILE" || true

echo
echo "== Lines 1-120 =="
nl -ba "$FILE" | sed -n '1,120p'

echo
echo "== Search for CHAIN_ID usage =="
rg -n "CHAIN_ID" "$FILE" || true

echo
echo "== Search for requireLogicNodes definition and body =="
rg -n "def requireLogicNodes|requireLogicNodes\s*\(" "$FILE" || true

echo
echo "== Lines around requireLogicNodes (entire function) =="
# Print a bit more aggressively around the function definition
START=$(rg -n "def requireLogicNodes" "$FILE" | cut -d: -f1 | head -n1)
if [ -n "${START:-}" ]; then
  START=$((START-10))
  END=$((START+140))
  nl -ba "$FILE" | sed -n "${START},${END}p"
fi

echo
echo "== Search for docstring example imports =="
rg -n "from .*logicnodes_helper import requireLogicNodes|logicnodes_helper import requireLogicNodes|requireLogicNodes.*logicnodes_helper" "$FILE" || true

echo
echo "== Search for HTTPProvider / chain_id comparisons =="
rg -n "HTTPProvider|eth\.chain_id|chain_id" "$FILE" || true

Repository: crewAIInc/crewAI

Length of output: 253


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/crewai/utilities/logicnodes_helper.py"

echo "== File existence =="
ls -l "$FILE" || true

echo
echo "== Lines 1-160 (with line numbers) =="
awk '{printf "%5d  %s\n", NR, $0}' "$FILE" | sed -n '1,160p'

echo
echo "== Search for CHAIN_ID usage =="
rg -n "CHAIN_ID" "$FILE" || true

echo
echo "== Search for requireLogicNodes definition =="
rg -n "def requireLogicNodes" "$FILE" || true

echo
echo "== Lines around requireLogicNodes body =="
LINE=$(rg -n "def requireLogicNodes" "$FILE" | head -n1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
  START=$((LINE-10))
  END=$((LINE+200))
  awk '{printf "%5d  %s\n", NR, $0}' "$FILE" | sed -n "${START},${END}p"
fi

echo
echo "== Search for docstring example imports =="
rg -n "from .*logicnodes_helper import requireLogicNodes|logicnodes_helper import requireLogicNodes" "$FILE" || true

echo
echo "== Search for chain_id checks in file =="
rg -n "HTTPProvider|eth\.chain_id|chain_id" "$FILE" || true

Repository: crewAIInc/crewAI

Length of output: 6360


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# List nearby package files to see how module is exposed
echo "== Files under src/crewai/utilities =="
find src/crewai/utilities -maxdepth 1 -type f -print | sed 's#^./##' || true

echo
echo "== Search for requireLogicNodes imports/usages =="
rg -n "requireLogicNodes" src || true

echo
echo "== Search for logicnodes_helper import patterns =="
rg -n "logicnodes_helper" src || true

echo
echo "== Check for __init__.py in relevant directories =="
find src/crewai -maxdepth 3 -type f -name "__init__.py" -print | sed 's#^./##' || true

echo
echo "== Contents of src/crewai/utilities/__init__.py (if exists) =="
if [ -f src/crewai/utilities/__init__.py ]; then
  sed -n '1,200p' src/crewai/utilities/__init__.py
else
  echo "(no src/crewai/utilities/__init__.py)"
fi

Repository: crewAIInc/crewAI

Length of output: 1181


Enforce Base chain ID in requireLogicNodes before trusting isRegistered.

CHAIN_ID (8453) is defined but never checked; requireLogicNodes() calls the registry using the caller-provided rpc_url without verifying w3.eth.chain_id, so responses from the wrong chain/RPC can yield misleading results (lines 22-23, ~66-73).

🔧 Suggested fix
         w3 = Web3(Web3.HTTPProvider(rpc_url))
+        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
+
         contract = w3.eth.contract(
             address=Web3.to_checksum_address(registry),
             abi=_REGISTRY_ABI,
         )

Docstring example imports from logicnodes_helper import requireLogicNodes, but the module is located at src/crewai/utilities/logicnodes_helper.py; update the example to from crewai.utilities.logicnodes_helper import requireLogicNodes (lines ~14, ~58).

🤖 Prompt for 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.

In `@src/crewai/utilities/logicnodes_helper.py` around lines 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.

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