Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(x/feegrant): Rewrite feegrant ante handler as tx validator #19594

Closed
wants to merge 112 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
bd96d6f
wip
likhita-809 Feb 29, 2024
200bb26
keep fee decorator only
likhita-809 Feb 29, 2024
19c7ed0
wip
likhita-809 Mar 4, 2024
5c541bc
small fix
likhita-809 Mar 6, 2024
e2cbb1f
go mod tidy
likhita-809 Mar 6, 2024
91aac94
add TxValidator for x/circuit
likhita-809 Mar 6, 2024
ddd34f6
update circuit TxValidator
likhita-809 Mar 6, 2024
91daa9e
Merge branch 'server_modular' of https://github.com/cosmos/cosmos-sdk…
likhita-809 Mar 6, 2024
b8f52ac
Fix few tests
likhita-809 Mar 6, 2024
e9ee4b5
wip: move FeeDecorator to auth
likhita-809 Mar 6, 2024
232da2b
address comments
likhita-809 Mar 6, 2024
529423c
update
likhita-809 Mar 6, 2024
0bdfded
wip: move fee decorator to feegrant module
likhita-809 Mar 8, 2024
6925fc6
remove auth dependency on feegrant ante
likhita-809 Mar 8, 2024
252911f
Merge branch 'server_modular' of https://github.com/cosmos/cosmos-sdk…
likhita-809 Mar 13, 2024
eb80d82
fix tests
likhita-809 Mar 13, 2024
db82004
refactor(x/**)!: genesis return errors (#19740)
chixiaowen Mar 13, 2024
7193d88
chore(proto): add module safe query warning (#19743)
tac0turtle Mar 13, 2024
7341ea6
Merge branch 'server_modular' of https://github.com/cosmos/cosmos-sdk…
likhita-809 Mar 13, 2024
069d6cf
build(deps): Bump github.com/cosmos/cosmos-sdk from 0.50.4 to 0.50.5 …
dependabot[bot] Mar 13, 2024
abfd79a
build(deps): Bump github.com/cosmos/cosmos-sdk from 0.50.4 to 0.50.5 …
dependabot[bot] Mar 13, 2024
10c1d7c
build(deps): Bump github.com/cosmos/cosmos-sdk from 0.50.4 to 0.50.5 …
dependabot[bot] Mar 13, 2024
9c47292
feat(x/gov): add expedited proposal quorum param (#19741)
julienrbrt Mar 13, 2024
5424b55
fix(crypto): error if incorrect ledger public key (#19691)
rootulp Mar 13, 2024
3ce9224
feat(x/accounts): Add new lockup account type (#19048)
sontrinh16 Mar 14, 2024
36981e6
test(client/v2): Fix `TestMsg` flakiness (#19753)
likhita-809 Mar 14, 2024
c807aae
refactor!: mv AddressCodecs aliases from runtime -> core (#19747)
kocubinski Mar 14, 2024
1b545a5
chore: fix spelling errors (#19756)
github-prbot Mar 14, 2024
d54335e
refactor: rename core.registry.LegacyRegistry -> core.registry.Interf…
kocubinski Mar 14, 2024
0cdf3cf
refactor(core): remove consensus events (#19757)
tac0turtle Mar 15, 2024
b239590
build(deps): Bump github.com/cometbft/cometbft from 0.38.5 to 0.38.6 …
dependabot[bot] Mar 15, 2024
59c5f6b
address few comments
likhita-809 Mar 15, 2024
6b1e9fc
refactor(store/db): remove unnecessary code and correct error handlin…
0x2d3c Mar 15, 2024
5a733e8
fix(x/upgrade): Stop treating inline JSON as a URL (#19706)
gibson042 Mar 16, 2024
26c1db6
fix: align signer extraction adapter for mempool remove (#19759)
mmsqe Mar 18, 2024
6f1658e
feat(core): match store interfaces (#19762)
tac0turtle Mar 18, 2024
25af567
chore: fix the flaky test in store/snapshots (#19774)
cool-develope Mar 18, 2024
ed6b3ab
fix(client/v2): fix comment parsing (#19377)
julienrbrt Mar 18, 2024
a7f9d92
build(deps): Bump github.com/creachadair/tomledit from 0.0.25 to 0.0.…
dependabot[bot] Mar 19, 2024
65ab253
refactor(x/staking)!: removes the use of Accounts String() method (#1…
JulianToledano Mar 19, 2024
a86c2a9
feat(store/v2): support rocksdb and pebbledb as RawDB (#19607)
alexanderbez Mar 19, 2024
a1bfe5d
feat(x/staking): allow zero unbonding time (#19779)
ocnc Mar 19, 2024
bfa734c
refactor(x/staking,genutil)!: use validatorUpdates (#19754)
chixiaowen Mar 19, 2024
3ed9f7f
build(deps): Bump actions/add-to-project from 0.6.0 to 0.6.1 (#19789)
dependabot[bot] Mar 20, 2024
0c2decd
refactor!: MsgSimulatorFn clean up (#19792)
JulianToledano Mar 20, 2024
0e1d620
build(deps): Bump rtCamp/action-slack-notify from 2.2.1 to 2.3.0 (#19…
dependabot[bot] Mar 20, 2024
fa19df1
refactor(x/authz)!: remove Accounts.String() (#19783)
JulianToledano Mar 20, 2024
3166ebb
store: keys as bytes (#19775)
tac0turtle Mar 20, 2024
4952cb2
chore: bump iavl and store to v1.1.0 (#19799)
tac0turtle Mar 20, 2024
27a231a
feat(store/v2): add the catch up process in the migration (#19454)
cool-develope Mar 20, 2024
3cf87f9
chore: fix typos (#19813)
xiaoxianBoy Mar 21, 2024
d67d145
build(deps): Bump github.com/pelletier/go-toml/v2 from 2.1.1 to 2.2.0…
dependabot[bot] Mar 21, 2024
13db28a
build(deps): Bump cosmossdk.io/store from 1.0.2 to 1.1.0 in /x/eviden…
dependabot[bot] Mar 21, 2024
9933a44
refactor(x/protocol): remove Accounts.String() (#19815)
JulianToledano Mar 21, 2024
8b4081f
fix(store/v2): clean up resources after the migration is completed (#…
cool-develope Mar 21, 2024
632c3f1
docs(collections): fixed typo in `collections/collections.go` (#19814)
meetrick Mar 21, 2024
32d63e0
build(deps): Bump github.com/cosmos/gogoproto from 1.4.11 to 1.4.12 (…
dependabot[bot] Mar 22, 2024
ac61b69
build(deps): Bump github.com/linxGnu/grocksdb from 1.8.12 to 1.8.14 i…
dependabot[bot] Mar 22, 2024
4599439
feat(x/gov): emit proposer address in submit proposal event (#19842)
akaladarshi Mar 24, 2024
ea7bdd1
fix: Do not call Remove during Walk (#19833)
facundomedica Mar 24, 2024
adc3432
fix(x/tx): default to using gogoproto.HybridResolver wherever possibl…
aaronc Mar 25, 2024
00b2b9d
chore: fix spelling errors (#19852)
github-prbot Mar 25, 2024
d1c3547
feat(x/gov): emit depositor in `proposal_deposit` event (#19853)
kienn6034 Mar 25, 2024
138db2b
chore: linting fixes (#19855)
tac0turtle Mar 25, 2024
c466887
chore(api): clean-up protos (#19858)
julienrbrt Mar 25, 2024
a82615b
fix: Do not call Remove during Walk - part 2 (#19851)
facundomedica Mar 25, 2024
160c418
refactor(x/gov)!: remove Accounts.String() (#19850)
JulianToledano Mar 26, 2024
23723be
build(deps): Bump github.com/creachadair/atomicfile from 0.3.3 to 0.3…
dependabot[bot] Mar 26, 2024
6e9528a
test(sims): fix test cases feegrant (#19863)
EmilGeorgiev Mar 26, 2024
6592541
refactor(x/distribution)!: remove Accounts.String() (#19868)
JulianToledano Mar 27, 2024
815c9c5
build(deps): Bump actions/add-to-project from 0.6.1 to 1.0.0 (#19877)
dependabot[bot] Mar 27, 2024
def211d
feat(server): add custom start handler (#19854)
julienrbrt Mar 27, 2024
39808e0
feat(x/tx): add custom type encoder (#19786)
pinosu Mar 27, 2024
8488733
feat(client): replace `event-query-tx-for` with `wait-tx` (#19870)
Pitasi Mar 27, 2024
6972e00
refactor(x/feegrant): remove Address.String() (#19886)
JulianToledano Mar 27, 2024
f630cfb
refactor(simapp): using maps.Clone to simplify codes (#19885)
cuiweixie Mar 28, 2024
705fad6
refactor(store,x/params): using maps.Copy (#19889)
cuiweixie Mar 28, 2024
4ef1209
build(deps): Bump github.com/prometheus/common from 0.50.0 to 0.51.1 …
dependabot[bot] Mar 28, 2024
d54e940
refactor(x/staking): use sdk validator updates (#19788)
julienrbrt Mar 28, 2024
b9c8d60
refactor: bump gogoproto (#19869)
raynaudoe Mar 28, 2024
cb5d34e
fix(x/accounts/defaults/lockup): rename lockup `go.mod` properly (#19…
julienrbrt Mar 28, 2024
80e1a45
chore: remove repetitive words (#19908)
carehabit Apr 1, 2024
f4af84f
refactor(x/group)!: remove Address.String() (#19916)
JulianToledano Apr 2, 2024
319e6e4
feat: Integrate grpc configuration into client.toml (#19905)
lucaslopezf Apr 2, 2024
dbff363
build(deps): Bump github.com/regen-network/gocuke from 1.1.0 to 1.1.1…
dependabot[bot] Apr 3, 2024
1574814
docs(x/mint): Fix inconsistency in mint docs (#19915)
likhita-809 Apr 3, 2024
fad30cd
refactor(x/genutil)!: remove Address.String() (#19926)
JulianToledano Apr 3, 2024
0e7b7fd
build(deps): Bump bufbuild/buf-setup-action from 1.30.0 to 1.30.1 (#1…
dependabot[bot] Apr 4, 2024
1028e27
feat(x/epochs): upstream osmosis epoch module (#19697)
hieuvubk Apr 4, 2024
6c66267
build(deps): Bump cosmossdk.io/store from 1.0.2 to 1.1.0 in /x/epochs…
dependabot[bot] Apr 4, 2024
edd1c71
feat(core): add `TxValidator` interface (#19950)
julienrbrt Apr 4, 2024
649dfaa
refactor(types): loosen module.AppModule interface (#19951)
julienrbrt Apr 4, 2024
15ad85d
fix(x/tx): don't shadow Amino marshalling error messages (#19955)
Pitasi Apr 4, 2024
558c950
chore: fix spelling errors (#19957)
github-prbot Apr 4, 2024
37131cf
build(deps): Bump golang.org/x/crypto from 0.21.0 to 0.22.0 (#19960)
dependabot[bot] Apr 5, 2024
ab45a85
fix(x/authz): non utf-8 characters in logs (#19923)
EmilGeorgiev Apr 5, 2024
6049684
feat(core,runtime): transaction service (exec mode) (#19953)
julienrbrt Apr 5, 2024
a6039bc
fix(x/epochs): Fix init genesis (#19958)
hieuvubk Apr 5, 2024
d881554
build(deps): Bump github.com/prometheus/common from 0.51.1 to 0.52.2 …
dependabot[bot] Apr 5, 2024
c753458
refactor(x/bank)!: remove Address.String() (#19954)
JulianToledano Apr 5, 2024
dcec6ad
test(types/address): add additional unit tests for address.LengthPref…
EmilGeorgiev Apr 5, 2024
cd24915
build(deps): Bump google.golang.org/grpc from 1.62.1 to 1.63.0 (#19929)
dependabot[bot] Apr 5, 2024
5d04deb
build(deps): Bump github.com/decred/dcrd/dcrec/secp256k1/v4 from 4.2.…
dependabot[bot] Apr 5, 2024
e5b0e0e
docs: reword upgrading.md (#19900)
julienrbrt Apr 8, 2024
b2835eb
chore: linting fixes (#19978)
tac0turtle Apr 8, 2024
f8fee96
build(deps): Bump google.golang.org/grpc from 1.63.0 to 1.63.2 (#19982)
dependabot[bot] Apr 9, 2024
9e9cc52
build(ci): Remove staticmajor due to false positives (#19989)
alpe Apr 9, 2024
a5d4c40
fix(simapp): use correct store keys for upgrade (#19987)
alpe Apr 9, 2024
bc4ca0c
docs: clarify gas-prices option (#19980)
turadg Apr 9, 2024
fc3ca2f
docs: fix typo in Contribution guide (#19994)
lukevenediger Apr 9, 2024
24d44b6
build(deps): Bump golang.org/x/sync from 0.6.0 to 0.7.0 (#19961)
dependabot[bot] Apr 10, 2024
a3fe9e3
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Apr 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions x/feegrant/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import (
"context"

"cosmossdk.io/core/address"
"cosmossdk.io/x/auth/ante"
authtypes "cosmossdk.io/x/auth/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// AccountKeeper defines the expected auth Account Keeper (noalias)
type AccountKeeper interface {
ante.AccountKeeper
AddressCodec() address.Codec

GetModuleAddress(moduleName string) sdk.AccAddress
Expand All @@ -22,6 +25,7 @@ type AccountKeeper interface {

// BankKeeper defines the expected supply Keeper (noalias)
type BankKeeper interface {
authtypes.BankKeeper
SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}
31 changes: 23 additions & 8 deletions x/feegrant/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import (
appmodulev2 "cosmossdk.io/core/appmodule/v2"
"cosmossdk.io/core/transaction"
"cosmossdk.io/errors"
"cosmossdk.io/runtime/v2"
"cosmossdk.io/x/auth/ante"
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/feegrant/client/cli"
"cosmossdk.io/x/feegrant/keeper"
"cosmossdk.io/x/tx/decode"

sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)

Expand All @@ -31,10 +35,11 @@ var (
_ module.AppModuleSimulation = AppModule{}
_ module.HasGenesis = AppModule{}

_ appmodulev2.AppModule = AppModule{}
_ appmodulev2.HasEndBlocker = AppModule{}
_ appmodule.HasServices = AppModule{}
_ appmodulev2.HasMigrations = AppModule{}
_ appmodulev2.AppModule = AppModule{}
_ appmodulev2.HasEndBlocker = AppModule{}
_ appmodule.HasServices = AppModule{}
_ appmodulev2.HasMigrations = AppModule{}
_ appmodulev2.HasTxValidation[transaction.Tx] = AppModule{}
)

// AppModule implements an application module for the feegrant module.
Expand Down Expand Up @@ -97,7 +102,7 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
}

// RegisterMigrations registers module migrations.
func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {
func (am AppModule) RegisterMigrations(mr appmodulev2.MigrationRegistrar) error {
m := keeper.NewMigrator(am.keeper)

if err := mr.Register(feegrant.ModuleName, 1, m.Migrate1to2); err != nil {
Expand Down Expand Up @@ -153,7 +158,17 @@ func (am AppModule) EndBlock(ctx context.Context) error {

// TxValidator implements appmodule.HasTxValidation.
// It replaces auth ante handlers for server/v2
func (am AppModule) TxValidator(ctx context.Context, tx transaction.Tx) error {
// TODO in follow-up
return nil
func (am AppModule) TxValidator(ctx context.Context, tx decode.DecodedTx) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)

// supports legacy ante handler
// eventually do the reverse, write ante handler as TxValidator
anteDecorators := []sdk.AnteDecorator{
ante.NewDeductFeeDecorator(am.accountKeeper, am.bankKeeper, &am.keeper, nil),
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
}

anteHandler := sdk.ChainAnteDecorators(anteDecorators...)
_, err := anteHandler(sdkCtx, runtime.ServerTxToSDKTx(tx), sdkCtx.ExecMode() == sdk.ExecModeSimulate)

return err
}
74 changes: 61 additions & 13 deletions x/feegrant/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions x/tx/decode/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"google.golang.org/protobuf/proto"

v1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1"
"cosmossdk.io/core/transaction"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/x/tx/signing"
)
Expand All @@ -21,6 +22,8 @@ type DecodedTx struct {
TxBodyHasUnknownNonCriticals bool
}

var _ transaction.Tx = &DecodedTx{}

// Decoder contains the dependencies required for decoding transactions.
type Decoder struct {
signingCtx *signing.Context
Expand Down Expand Up @@ -129,7 +132,7 @@ func (d *Decoder) Decode(txBytes []byte) (*DecodedTx, error) {
}

// Hash implements the interface for the Tx interface.
func (dtx *DecodedTx) Hash() [32]byte {
func (dtx DecodedTx) Hash() [32]byte {
bz, err := proto.Marshal(dtx.TxRaw)
if err != nil {
panic(err)
Expand All @@ -138,14 +141,18 @@ func (dtx *DecodedTx) Hash() [32]byte {
return sha256.Sum256(bz)
}

func (dtx *DecodedTx) GetGasLimit() uint64 {
func (dtx DecodedTx) GetGasLimit() uint64 {
return dtx.Tx.AuthInfo.Fee.GasLimit
}

func (dtx *DecodedTx) GetMessages() []proto.Message {
func (dtx DecodedTx) GetMessages() []proto.Message {
return dtx.Messages
}

func (dtx *DecodedTx) GetSenders() [][]byte {
func (dtx DecodedTx) GetSenders() [][]byte {
return dtx.Signers
}

func (dtx DecodedTx) Bytes() []byte {
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
return dtx.TxRaw.BodyBytes
}
6 changes: 5 additions & 1 deletion x/tx/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/net v0.21.0 // indirect
Expand All @@ -37,4 +38,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace cosmossdk.io/api => ../../api
replace (
cosmossdk.io/api => ../../api
cosmossdk.io/core => ../../core
)
3 changes: 1 addition & 2 deletions x/tx/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20230509103710-5e5
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20230509103710-5e5b9fdd0180.1/go.mod h1:5GqIYthcy/ASmnKcaT26APpxMhZirnIHXHKki69zjWI=
buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 h1:VooqQ3rklp3PwMTAE890M76w/8Z01OPa7RdgU9posFE=
buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1/go.mod h1:9KmeMJUsSG3IiIwK63Lh1ipZJrwd7KHrWZseJeHukcs=
cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo=
cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
Expand All @@ -12,6 +10,7 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48Od
github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co=
github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g=
github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
Loading