feat(precompiles): expose module Query rpcs as precompile methods#3767
Draft
codchen wants to merge 2 commits into
Draft
feat(precompiles): expose module Query rpcs as precompile methods#3767codchen wants to merge 2 commits into
codchen wants to merge 2 commits into
Conversation
Add query counterparts for Cosmos module Query rpcs that had no EVM precompile surface: - bank: spendableBalances, totalSupply, params, denomMetadata, denomsMetadata - distribution: params, validatorOutstandingRewards, validatorCommission, validatorSlashes, delegationRewards, delegatorValidators, delegatorWithdrawAddress, communityPool - gov: proposal, proposals, vote, votes, params, deposit, deposits, tallyResult New query-only precompiles: auth (0x100D), authz (0x100E), evidence (0x100F), feegrant (0x1010), mint (0x1012), params (0x1013), slashing (0x1014), upgrade (0x1015). Querier interfaces and codec plumbing are added to precompiles/utils and wired in app/precompiles.go. Any-typed response fields (gov content, authz authorizations, evidence, feegrant allowances) are returned as registry-resolved JSON bytes for use with the json precompile. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3767 +/- ##
==========================================
- Coverage 59.88% 59.02% -0.86%
==========================================
Files 2288 2217 -71
Lines 190023 181666 -8357
==========================================
- Hits 113786 107226 -6560
+ Misses 66091 64903 -1188
+ Partials 10146 9537 -609
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Overloading the vote/deposit transaction methods breaks tooling that resolves functions by name (ethers.js rejects ambiguous names with INVALID_ARGUMENT). Rename the query variants instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
An audit of all
rpcdefs inservice Query(query.proto) andservice Msg(tx.proto) under/protoand/sei-cosmos/protofound that many module Query rpcs have no EVM precompile counterpart: bank/distribution were partial, gov was write-only, and auth, authz, evidence, feegrant, mint, params, slashing, and upgrade had no precompile at all.Changes
Extended existing precompiles (new
viewmethods, head version only)spendableBalances,totalSupply(paginated all-denoms; existingsupply(denom)unchanged),params,denomMetadata,denomsMetadataparams,validatorOutstandingRewards,validatorCommission,validatorSlashes,delegationRewards,delegatorValidators,delegatorWithdrawAddress,communityPoolproposal,proposals(status/voter/depositor filters),getVote,votes,params(voting+deposit+tallying merged),getDeposit,deposits,tallyResult—getVote(uint64,address)/getDeposit(uint64,address)(named to avoid overloading the tx methods, which breaks ethers.js name resolution)New query-only precompiles
0x…100Daccount,accounts,params,nextAccountNumber0x…100Egrants,granterGrants,granteeGrants0x…100Fevidence,allEvidence0x…1010allowance,allowances,allowancesByGranter0x…1012params,minter0x…1013params(subspace, key)0x…1014params,signingInfo,signingInfos0x…1015currentPlan,appliedPlan,upgradedConsensusState,moduleVersions(
0x…1011is already p256.) Each new precompile follows the oracle-style DynamicGasPrecompile shape withabi.json, a Solidity interface, aversionsfile (singlev6.6entry), and a generated-stylesetup.go, soscripts/bump_versionmanages them going forward.Plumbing
StakingQuerierpattern) plusCodec()added toprecompiles/utils/expected_keepers.go, wired to concrete keepers inapp/precompiles.go(mint viamintkeeper.NewQuerier; others implement their gRPC QueryServers directly)Dec/Int→ string, times → Unix seconds, durations → seconds, pagination viabytes pageKey+nextKeyAny-typed response fields (gov proposal content, authz authorizations, evidence, feegrant allowances) are returned as registry-resolved JSON bytes ({"@type": …}), consumable on-chain with thejsonprecompileNotes for reviewers
v6.6). Ifv6.6is already live, they should ride the next upgrade tag — thebump_versionflow handles archival when the tag is added.addressand require address association (consistent with existing bank/staking/distribution precompiles); validator/consensus addresses are bech32 strings.precompiles/setup.goregisters the new precompiles inGetCustomPrecompilesonly (same assolo), not in the legacyInitializePrecompilesglobal-VM path.Testing
go build ./...cleango test ./precompiles/... -count=1— all 22 precompile packages pass, including new tests covering happy paths, pagination, error paths (unassociated address, not-found), and exact packed-output assertionsgo test ./x/evm/keeper/ -run TestGetCustomPrecompilespassesgo vetclean; all touched filesgofmt -s/goimportscompliant🤖 Generated with Claude Code