Skip to content

[Bug] _encode_add_transaction_data uses fragile >= 6 check to detect ABI version, will break with ABI updates #310

@zakaziko86

Description

@zakaziko86

Description

In genlayer_py/contracts/actions.py:375-376, the function detects whether to include valid_until by checking if the ABI has 6 or more arguments:

if len(contract_fn.argument_types) >= 6:
    add_transaction_args.append(valid_until)

Impact

  • If addTransaction ABI is updated to 7+ arguments, only 6 will be supplied, causing TypeError: Mismatched argument count.
  • The consensus contract ABI is fetched dynamically from RPC and could change without a library update.
  • Current code works accidentally — Bradbury has exactly 6 args and Asimov has 5.

Suggested Fix

# Option A: Exact match
if len(contract_fn.argument_types) == 6:
    add_transaction_args.append(valid_until)

# Option B: Named parameter check
if "valid_until" in [inp["name"] for inp in contract_fn.abi["inputs"]]:
    add_transaction_args.append(valid_until)

Notes

  • Current >= 6 check is accidental correctness.
  • A future protocol upgrade adding a 7th argument will silently break transaction encoding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions