Commit 6b07f11
committed
Problem: geth abi library is not suitable for precompile
Solution:
- use go-abi for much better efficiency and error handling
update go-abi stdlib support
fix: convert interface{} to generated statically typed structs in precompile tests
Refactored test files to use generated statically typed structs from go-abi
instead of interface{}:
- gov/types_test.go: Updated 5 test functions
* TestNewMsgDeposit → DepositCall
* TestNewMsgCancelProposal → CancelProposalCall
* TestNewMsgVote → VoteCall
* TestParseVoteArgs → GetVoteCall
* TestParseDepositArgs → GetDepositCall
- distribution/types_test.go: Updated 8 test functions
* TestNewMsgSetWithdrawAddress → SetWithdrawAddressCall
* TestNewMsgWithdrawDelegatorReward → WithdrawDelegatorRewardsCall
* TestNewMsgFundCommunityPool → FundCommunityPoolCall
* TestNewMsgDepositValidatorRewardsPool → DepositValidatorRewardsPoolCall
* TestNewDelegationRewardsRequest → DelegationRewardsCall
* TestNewDelegationTotalRewardsRequest → DelegationTotalRewardsCall
* TestNewDelegatorValidatorsRequest → DelegatorValidatorsCall
* TestNewDelegatorWithdrawAddressRequest → DelegatorWithdrawAddressCall
- slashing/types_test.go: Updated 1 test function
* TestParseSigningInfoArgs: Simplified to remove unnecessary type checks
Removed type validation test cases (now handled by Go's type system)
and kept only business logic tests. Removed unused fmt imports where applicable.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
fix test
fix: convert interface{} to generated statically typed structs in precompile tests
Convert all precompile test files to use generated statically typed structs
instead of []interface{}, providing better type safety and developer experience.
Changes:
- distribution/types_test.go: Convert test arguments from []interface{} to generated structs
- staking/types_test.go: Convert all test cases to use generated statically typed structs:
* CreateValidatorCall, DelegateCall, UndelegateCall, RedelegateCall
* CancelUnbondingDelegationCall, DelegationCall, UnbondingDelegationCall
* Updated struct field names to match generated types (Commission → CommissionRates)
* Removed unused imports
- slashing/types_test.go: Convert test arguments from []interface{} to GetSigningInfoCall
- slashing/query.go: Updated query functions to use generated struct types
- slashing/tx.go: Updated transaction functions to use generated struct types
- slashing/types.go: Updated ParseSigningInfoArgs and ParseSigningInfosArgs
- slashing/slashing.go: Added PageRequest mapping to go:generate directive
- slashing/slashing.abi.go: Regenerated to use cmn.PageRequest instead of duplicate type
Results:
- All tests pass successfully
- 517 lines of code removed
- Type safety improved with compile-time checking
- Better IDE autocomplete and type hints
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
perf: remove redundant *Output structs and move FromResponse to *Return structs
Refactor precompile code to remove redundant *Output structs (SigningInfoOutput,
SigningInfosOutput, ParamsOutput) and their corresponding custom types. The
FromResponse methods now directly populate the generated *Return structs.
Benefits:
- Removed 78 lines of redundant code
- Eliminated type duplication between *Output and *Return structs
- Simplified query functions by removing unnecessary conversions
- Direct use of generated statically typed structs
Changes in slashing precompile:
- Deleted SlashingSigningInfo, SigningInfoOutput, SigningInfosOutput structs
- Deleted SlashingParams, ParamsOutput structs
- Moved FromResponse method receivers to *GetSigningInfoReturn, *GetSigningInfosReturn, *GetParamsReturn
- Simplified query.go functions to directly use *Return structs
- All tests pass successfully
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
feat: migrate remaining precompiles to use generated statically typed structs
Convert bank, bech32, erc20, and werc20 precompiles to use generated
statically typed structs instead of []interface{}, following the pattern
established in staking, distribution, and slashing precompiles.
Changes:
- bank/types.go: Removed unused ParseBalancesArgs and ParseSupplyOfArgs functions
- bech32/methods.go: Updated HexToBech32 and Bech32ToHex to use generated Call/Return structs
- bech32/bech32.go: Updated Run function to decode args directly using generated structs
- erc20/approve.go: Updated Approve to use ApproveCall and ApproveReturn
- erc20/erc20.go: Updated Execute to use cmn.Run and cmn.RunWithStateDB with ID constants
- erc20/query.go: Converted all query functions to use generated return types
- erc20/tx.go: Updated Transfer/TransferFrom to use generated Call/Return structs
- erc20/types.go: Removed all Parse*Args functions (replaced by generated structs)
- werc20/tx.go: Updated Withdraw to use WithdrawCall and WithdrawReturn
- werc20/werc20.go: Updated Execute and IsTransaction to use ID constants
Benefits:
- ~500+ lines of code removed across all precompiles
- Type safety improved with compile-time checking
- Better IDE autocomplete and type hints
- Consistent patterns across all precompiles
Build Status:
✅ All migrated precompiles build successfully
✅ All tests pass (staking, distribution, slashing)
Note: ics20 precompile deferred (already builds successfully but uses old pattern)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
update go-abi
cleanup
changelog
fix build
feat: migrate bank precompile integration tests to go-abi
Migrate bank precompile tests from go-ethereum ABI to custom go-abi library:
- Updated ContractData struct to remove precompileABI field
- Replaced UnpackIntoInterface/Unpack calls with manual decoding helpers
- Updated getTxAndCallArgs to use EncodeWithSelector() for direct precompile calls
- Rewrote test_query.go unit tests to use typed call structs (BalancesCall, SupplyOfCall, TotalSupplyCall)
- Created decoder helper functions for type-safe result decoding
- Tests now use fully type-safe generated types instead of reflection
Created comprehensive MIGRATION_GUIDE.md with step-by-step instructions
for migrating other precompile tests to go-abi.
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
feat: migrate bech32 and slashing precompile integration tests to go-abi
Migrated bech32 and slashing precompile tests from go-ethereum ABI to custom go-abi library:
Bech32 precompile (tests/integration/precompiles/bech32/):
- Updated all test cases to use typed call structs (HexToBech32Call, Bech32ToHexCall)
- Replaced Pack() calls with EncodeWithSelector() for input encoding
- Replaced Unpack() calls with direct Decode() on result types
- Rewrote unit tests to use direct precompile methods instead of generic interface
Slashing precompile (tests/integration/precompiles/slashing/):
- Updated TestGetSigningInfo to use GetSigningInfoCall with ConsAddress field
- Updated TestGetSigningInfos to use GetSigningInfosCall with Pagination field
- Updated TestGetParams to use GetParamsCall with EmptyTuple
- Replaced all UnpackIntoInterface calls with direct result type decoding
- Tests now use fully type-safe generated types instead of reflection
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
cleanup bank test
refactor tests
fix tests
fix: update factory to use abi.Method from CallArgs
Update ExecuteContractCall and QueryContract to use callArgs.Method
instead of callArgs directly to match the new GenerateContractCallArgs
signature that expects abi.Method interface.
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
docs: update MIGRATION_GUIDE.md with status and troubleshooting
- Added migration status table for all 10 precompiles
- Updated decode examples to show recommended approach (direct Decode)
- Added troubleshooting section with common issues and solutions:
* s.precompile.Methods undefined
* s.precompile.ABI undefined
* Too many arguments in calls
* Factory calls with CallArgs
- Added references to Bech32 and Slashing migrations
- Updated examples to be more comprehensive
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
fix: variable declarations in BeforeEach blocks
- Use short declaration operator (:=) in BeforeEach blocks instead of separate var declarations
- Fix DepositEvent and WithdrawalEvent to use pointers: &werc20.DepositEvent{}
- Fix ERC20 return type field access (Field1 instead of Balance, Name, Symbol, Decimals)
- Remove unused crypto import from test_events.go
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
fix gov tests
fix gov events test
fix gov test build
remove unused methods
fix build bank tests
fix: migrate distribution and erc20 precompiles to go-abi
Migrate precompile tests from go-ethereum to go-abi following the gov precompile pattern.
Changes:
- Distribution precompile: Regenerated ABI and updated test files to use new go-abi encoding pattern
- ERC20 precompile: Updated test files to use new call struct pattern and method interface
- Updated imports from ethereum/accounts/abi to yihuang/go-abi
- Replaced precompile.Methods[] and Pack() with call structs and EncodeWithSelector()
- Updated IsTransaction() calls to use method.GetMethodID()
This enables the precompiles to build successfully with the new go-abi framework.
🤖 Generated with [Claude Code](https://claude.ai/claude-code)
Co-Authored-By: Claude <[email protected]>
fix: migrate slashing precompile to go-abi
Migrate slashing precompile tests from go-ethereum to go-abi following the established pattern.
Changes:
- test_tx.go: Updated to use new call struct pattern (UnjailCall) instead of Methods[] and Pack()
- test_query.go: Updated to use common.PageRequest and slashing.PageResponse types
- Fixed method signatures to use pointer receivers for call structs
- Removed unused imports (fmt, testutil)
This enables the slashing precompile main test files to build successfully with the new go-abi framework.
🤖 Generated with [Claude Code](https://claude.ai/claude-code)
Co-Authored-By: Claude <[email protected]>
temp
fix erc20 tests
temp1 parent f6d50b4 commit 6b07f11
File tree
127 files changed
+38531
-7099
lines changed- evmd
- precompiles
- bank
- bech32
- callbacks
- common
- distribution
- erc20
- testdata
- gov
- ics20
- slashing
- staking
- testutil
- contracts
- counter
- distcaller
- flashloan
- govcaller
- ics20caller
- werc20
- tests/integration
- eip7702
- precompiles
- bank
- bech32
- distribution
- erc20
- gov
- slashing
- staking
- werc20
- x/vm
- testutil
- integration/evm
- factory
- utils
- types
- x
- erc20
- keeper
- types
- ibc/callbacks
- keeper
- types
- vm/keeper
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
127 files changed
+38531
-7099
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
244 | 245 | | |
245 | 246 | | |
246 | 247 | | |
| |||
0 commit comments