Skip to content

fix: replace manual ABI decoding with web3.py in GovernanceEthereum#2069

Closed
Wanbogang wants to merge 10 commits intoOpenMind:mainfrom
Wanbogang:fix/ethereum-decode-abi
Closed

fix: replace manual ABI decoding with web3.py in GovernanceEthereum#2069
Wanbogang wants to merge 10 commits intoOpenMind:mainfrom
Wanbogang:fix/ethereum-decode-abi

Conversation

@Wanbogang
Copy link
Copy Markdown
Contributor

@Wanbogang Wanbogang commented Feb 3, 2026

This pull request fixes the fragility and testability issues identified in issue #1824.

Problem

The previous implementation used manual hex parsing in decode_eth_response which was:

  • Fragile to minor data format variations
  • Difficult to test reliably
  • Prone to silent failures

Solution

Replaced manual ABI decoding with web3.py contract calls:

  • Removed fragile decode_eth_response function with manual hex parsing
  • Use web3.py contract.functions.getRuleSet().call() for robust ABI decoding
  • Defined minimal ABI for the getRuleSet function
  • Added comprehensive error handling for BadFunctionCallOutput and ContractLogicError

Improved test coverage:

  • Achieved 100% code coverage with 22 comprehensive tests
  • Mocked web3.py interactions properly
  • Added tests for error scenarios and edge cases
  • Added integration tests for full workflow

@Wanbogang Wanbogang requested review from a team as code owners February 3, 2026 04:16
@github-actions github-actions Bot added robotics Robotics code changes python Python code tests Test files labels Feb 3, 2026
@OpenMind OpenMind deleted a comment from codecov Bot Feb 3, 2026
@OpenMind OpenMind deleted a comment from codecov Bot Feb 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@openminddev
Copy link
Copy Markdown
Contributor

Please don't change the test file name

@Wanbogang
Copy link
Copy Markdown
Contributor Author

Please don't change the test file name

noted
OK, I will do it

- Replace manual ABI decoding with web3.py library
- Add minimal ABI definition for getRuleSet function
- Update tests to mock web3.py interactions
- Improve error handling for blockchain calls

Fixes OpenMind#1824
@Wanbogang Wanbogang force-pushed the fix/ethereum-decode-abi branch 2 times, most recently from 96b73fe to 0bc2d98 Compare February 9, 2026 05:33
@Wanbogang Wanbogang changed the title Refactor GovernanceEthereum to use web3.py for ABI decoding fix: replace manual ABI decoding with web3.py in GovernanceEthereum Feb 9, 2026
@Wanbogang
Copy link
Copy Markdown
Contributor Author

Wanbogang commented Feb 10, 2026

Hi @openminddev

tests/inputs/
├── base/
│ ├── init.py
│ └── test_governance_ethereum.py ← The file that has an error in CI/CD
└── plugins/
├── init.py
└── test_ethereum_governance.py ← The files I updated

I have a question regarding the test structure for ethereum_governance.py:

Current situation:

  • Source file: src/inputs/plugins/ethereum_governance.py
  • Test file 1: tests/inputs/plugins/test_ethereum_governance.py
  • Test file 2: tests/inputs/base/test_governance_ethereum.py

Both test files import and test the same GovernanceEthereum class.

My questions:

  1. Should the correct test location be tests/inputs/plugins/? (following the standard mirror structure of source code)
  2. Why does CI/CD also run tests from tests/inputs/base/?
  3. Are these two test files intentionally separate (for different purposes), or is this an accidental duplication across folders?

Current PR status:

  • I've updated tests/inputs/plugins/test_ethereum_governance.py with web3.py implementation and 100% coverage
  • The file in tests/inputs/base/ still expects the old implementation (aiohttp, decode_eth_response)
  • This causes CI/CD failures because it tests non-existent attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants