Skip to content

fix: add missing chainId to inference transaction in _send_tx_with_revert_handling()#234

Open
amathxbt wants to merge 1 commit intoOpenGradient:mainfrom
amathxbt:fix/alpha-infer-missing-chainid
Open

fix: add missing chainId to inference transaction in _send_tx_with_revert_handling()#234
amathxbt wants to merge 1 commit intoOpenGradient:mainfrom
amathxbt:fix/alpha-infer-missing-chainid

Conversation

@amathxbt
Copy link
Copy Markdown
Contributor

@amathxbt amathxbt commented Apr 3, 2026

Bug Fix: Missing chainId in _send_tx_with_revert_handling() — affects all infer() calls

Summary

_send_tx_with_revert_handling() in alpha.py is missing chainId when building the inference transaction. Every other transaction in the same file includes it — this method was the only exception.


The Bug

# BEFORE — _send_tx_with_revert_handling (used by infer())
transaction = run_function.build_transaction(
    {
        "from": self._wallet_account.address,
        "nonce": nonce,
        "gas": gas_limit,
        "gasPrice": self._blockchain.eth.gas_price,
        # ❌ chainId missing
    }
)

Compare with every other transaction in the same file:

# new_workflow ✅
transaction = contract.constructor(*constructor_args).build_transaction(
    {
        ...
        "chainId": self._blockchain.eth.chain_id,  # ✅ present
    }
)

# run_workflow ✅
transaction = run_function.build_transaction(
    {
        ...
        "chainId": self._blockchain.eth.chain_id,  # ✅ present
    }
)

# _register_with_scheduler ✅
scheduler_tx = scheduler_contract.functions.registerTask(...).build_transaction(
    {
        ...
        "chainId": self._blockchain.eth.chain_id,  # ✅ present
    }
)

Impact

  • _send_tx_with_revert_handling is called by infer() — the primary and most commonly used Alpha Testnet method
  • Without chainId, Web3.py signs the transaction without EIP-155 replay protection
  • Some RPC nodes reject transactions that lack chainId; others silently accept them but the transaction may be replayable on other chains
  • This is an inconsistency that makes infer() behave differently from every other transaction in alpha.py

Fix

# AFTER ✅
transaction = run_function.build_transaction(
    {
        "from": self._wallet_account.address,
        "nonce": nonce,
        "gas": gas_limit,
        "gasPrice": self._blockchain.eth.gas_price,
        "chainId": self._blockchain.eth.chain_id,  # ✅ added
    }
)

@adambalogh @kylexqian — one-line fix that makes infer() consistent with every other transaction in the same file. 🙏

…rt_handling

Every other transaction built in alpha.py (new_workflow, run_workflow,
_register_with_scheduler) correctly includes chainId in the transaction dict.
_send_tx_with_revert_handling — which handles the primary infer() path —
was the only method missing it.

Without chainId, Web3.py signs transactions without EIP-155 replay
protection. This can cause RPC nodes to reject the transaction or
behave unexpectedly in multi-chain/testnet environments.
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