Skip to content

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

Open
cmdenney wants to merge 2 commits into
crewAIInc:mainfrom
cmdenney:feat/logicnodes-integration
Open

feat: add requireLogicNodes() on-chain agent verification helper#5955
cmdenney wants to merge 2 commits 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 on-chain LogicNodes registry (defaults to Base mainnet).
    • Normalizes addresses to checksum format and checks chain ID before verifying registration.
    • Includes a strict mode that raises errors for verification failures; default behavior returns false on failures.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a1499eec-24eb-4e20-b3b0-be3a2c18f262

📥 Commits

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

📒 Files selected for processing (1)
  • src/crewai/utilities/logicnodes_helper.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/crewai/utilities/logicnodes_helper.py

📝 Walkthrough

Walkthrough

Adds a new helper module logicnodes_helper.py that queries the LogicNodes on-chain registry on Base mainnet via Web3 to verify whether a given Ethereum agent address is registered; returns a boolean or raises on failures when strict mode is enabled.

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 LogicNodes registry address, default Base mainnet RPC URL, and chain ID (8453), and adds a minimal contract ABI including isRegistered(address).
Registration check implementation
src/crewai/utilities/logicnodes_helper.py
Adds requireLogicNodes(agent_address, rpc_url=..., registry=..., strict=False) that builds a Web3 client, checks chain id, checksum-normalizes addresses, calls the registry's isRegistered view, returns True when registered, returns False on failures by default, and raises RuntimeError when strict=True.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped to the chain, nose to the code,
A checksum here, a Web3 road,
I asked the registry, quiet and wise,
"Is this agent one of LogicNodes' ties?"
It nodded True — then I munched a byte. 🥕

🚥 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 clearly and specifically describes the main change: adding a new requireLogicNodes() 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 thread src/crewai/utilities/logicnodes_helper.py Outdated
Comment thread 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
@cmdenney
Copy link
Copy Markdown
Author

Thanks for the review @coderabbitai. I've addressed both requested changes:

  1. ✅ Fixed import paths in all docstrings: from logicnodes_helper import requireLogicNodesfrom crewai.utilities.logicnodes_helper import requireLogicNodes
  2. ✅ Added chain ID enforcement after Web3 instantiation — raises RuntimeError if network is not Base mainnet (chain ID 8453)

Ready for re-review.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

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.py

Length of output: 3114



@cmdenney Both fixes are confirmed ✅ — the import path and chain ID enforcement are correctly in place. Good work on the quick turnaround.

There is one remaining issue worth addressing before merge: the chain ID RuntimeError is raised inside the try block, so it gets caught by the broad except Exception as exc handler and re-wrapped as "LogicNodes check failed: Unexpected chain ID …". The original, clear message gets buried, and the behaviour is semantically wrong — a wrong-chain condition is not the same kind of failure as a network error.

The simplest fix is to let the chain ID check escape the try/except by re-raising RuntimeError directly (it is already a RuntimeError, not a generic network/import error), or by restructuring the block:

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 registered

Also, the Raises section in the docstring should be updated to cover all three RuntimeError paths (chain ID mismatch, import/network failure, not registered).

@arian-gogani
Copy link
Copy Markdown

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

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.

2 participants