Skip to content

Conversation

yihuang
Copy link
Contributor

@yihuang yihuang commented Aug 30, 2025

Description

Closes: #578

Solution:

  • refactor the precompiles code with (hopefully) equivalent transformations.
    • decouple ABI logics from native state handling.
    • create NativeExecutor interface to abstract native state logics.
    • share the wrapping code around the NativeExecutor that prepare the native context and handling gas metering.
    • Load ABI json at init function instead of runtime.

One side effect of this refactor is the order of ABI input parsing and SDK context preparation is switched, other than that, the behavior should be same as before.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

@yihuang yihuang requested review from a team as code owners August 30, 2025 19:14
@yihuang yihuang changed the title Problem: stateful precompiles have many boilerplate code feat: remove boilerplate code from stateful precompiles Aug 30, 2025
Solution:
- refactor the precompiles code with (hopefully) equivalent transformations.

changelog

cleanup

handle balance handler error return

cleanup

avoid naked return

fix lint

fix werc20

fix staking precompile

fix panic recovery return error

fix staking test case

NewPrecompile don't return error
@aljo242 aljo242 changed the title feat: remove boilerplate code from stateful precompiles feat!: remove boilerplate code from stateful precompiles Sep 2, 2025
@aljo242
Copy link
Contributor

aljo242 commented Sep 15, 2025

@vladjdk will take a look soon!

@yihuang yihuang mentioned this pull request Sep 16, 2025
3 tasks
@vladjdk
Copy link
Member

vladjdk commented Sep 17, 2025

@yihuang a few conflicts. Apologies for that!

Copy link
Member

@vladjdk vladjdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihuang LGTM. Let's just add the API BREAKING header in the changelog and fix the conflicts. Feel free to merge when ready.

@yihuang yihuang enabled auto-merge September 22, 2025 04:21
@yihuang yihuang added this pull request to the merge queue Sep 22, 2025
Merged via the queue into cosmos:main with commit 04dac0d Sep 22, 2025
19 of 20 checks passed
@yihuang yihuang deleted the fix-boilerplates branch September 22, 2025 04:28
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.

feat: stateful precompiles have too many boilerplates
3 participants