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

Add fee grant module #8061

Merged
merged 240 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
abce938
Add docs
ethanfrey Oct 16, 2019
ea6fe7d
Add BasicFeeAllowance implementation
ethanfrey Oct 16, 2019
c46153c
Add expiration structs and complete basic fee
ethanfrey Oct 16, 2019
42c17f5
Add delegation messages, add validation logic
ethanfrey Oct 16, 2019
0c137cb
Add keeper and helper structs
ethanfrey Oct 16, 2019
67cb830
Add alias and handler to top level
ethanfrey Oct 16, 2019
f6ba9bc
Add delegation module
ethanfrey Oct 16, 2019
a002366
Add basic querier
ethanfrey Oct 16, 2019
15c6361
Add types tests
ethanfrey Oct 16, 2019
410d1f1
Add types tests
ethanfrey Oct 16, 2019
f65db09
More internal test coverage
ethanfrey Oct 16, 2019
e0f6327
Solid internal test coverage
ethanfrey Oct 16, 2019
93c9b7e
Expose Querier to top level module
ethanfrey Oct 16, 2019
7968441
Add FeeAccount to auth/types, like StdTx, SignDoc
ethanfrey Oct 16, 2019
7e82fb8
Fix all tests in x/auth
ethanfrey Oct 16, 2019
64d5159
All tests pass
ethanfrey Oct 16, 2019
8b2b64b
Appease the Golang Linter
ethanfrey Oct 16, 2019
4e22edd
Merge remote-tracking branch 'origin/master' into cg-key-management/f…
ethanfrey Oct 16, 2019
be12b44
Add fee-account command line flag
ethanfrey Oct 16, 2019
c703e59
Start on DelegatedDeductFeeDecorator
ethanfrey Oct 17, 2019
907776f
Cleanup the Decorator
ethanfrey Oct 17, 2019
005afd9
Wire up delegation module in simapp
ethanfrey Oct 17, 2019
45c64d2
add basic test for decorator (no delegation)
ethanfrey Oct 17, 2019
87fd0ce
Table tests for deduct fees
ethanfrey Oct 17, 2019
d03c650
Table tests over all conditions of delegated fee decorator
ethanfrey Oct 17, 2019
e476c03
Build full ante handler stack and test it
ethanfrey Oct 17, 2019
182eb34
Start genesis
ethanfrey Oct 17, 2019
071e111
Implement Genesis
ethanfrey Oct 17, 2019
0a362b8
Merge branch 'master' into cg-key-management/fee-delegation-new
alexanderbez Oct 17, 2019
98b88a3
Rename package delegation to subkeys
ethanfrey Oct 18, 2019
376e9cd
Clarify antes test cases, handle empty account w/o fees
ethanfrey Oct 18, 2019
529764f
Allow paying delegated fees with no account
ethanfrey Oct 18, 2019
d293aae
Pull mempool into delegated ante, for control on StdFee
ethanfrey Oct 18, 2019
a8b3e31
Use custom DelegatedTx, DelegatedFee for subkeys
ethanfrey Oct 18, 2019
e939e98
Revert all changes to x/auth.StdTx
ethanfrey Oct 18, 2019
6aef5c8
Appease scopelint
ethanfrey Oct 18, 2019
1212772
Register DelegatedTx with codec
ethanfrey Oct 18, 2019
f688116
Merge branch 'master' into cg-key-management/fee-delegation-new
alexanderbez Oct 18, 2019
61df0c6
Address PR comments
ethanfrey Oct 21, 2019
d684f92
Remove unnecessary DelegatedMempoolFeeDecorator
ethanfrey Oct 21, 2019
aacf6fb
Cleaned up errors in querier
ethanfrey Oct 21, 2019
92f64cc
Clean up message sign bytes
ethanfrey Oct 21, 2019
4daf4af
Minor PR comments
ethanfrey Oct 24, 2019
a497575
Replace GetAllFees... with Iterator variants
ethanfrey Oct 24, 2019
73eab92
PrepareForExport adjusts grant expiration height
ethanfrey Oct 24, 2019
546fa8f
Panic on de/serialization error in keeper
ethanfrey Oct 24, 2019
5f9e391
Move custom ante handler chain to tests, update docs
ethanfrey Oct 24, 2019
c45dc71
More cleanup
ethanfrey Oct 24, 2019
2be48ef
More doc cleanup
ethanfrey Oct 24, 2019
e8a624f
Renamed subkeys module to fee_grant
ethanfrey Oct 24, 2019
6756099
Rename subkeys/delegation to fee grant in all strings
ethanfrey Oct 24, 2019
320bad4
Modify Msg and Keeper methods to use Grant not Delegate
ethanfrey Oct 24, 2019
a625fd0
Merge remote-tracking branch 'origin/master' into cg-key-management/f…
ethanfrey Oct 24, 2019
4b4391b
Add PeriodicFeeAllowance
ethanfrey Oct 29, 2019
9ec284b
Update aliases
ethanfrey Oct 29, 2019
4b34cf6
Cover all accept cases for PeriodicFeeAllowance
ethanfrey Oct 29, 2019
78f1f7a
Et tu scopelint?
ethanfrey Oct 29, 2019
a1951b4
Update docs as requested
ethanfrey Nov 7, 2019
17c39ca
Remove error return from GetFeeGrant
ethanfrey Nov 7, 2019
9c399bb
Code cleanup as requested by PR
ethanfrey Nov 7, 2019
6b9e06e
Merge remote-tracking branch 'origin/master' into cg-key-management/f…
ethanfrey Nov 7, 2019
21b0ac5
Updated all errors to use new sdk/errors package
ethanfrey Nov 7, 2019
2222d0e
Use test suite for keeper tests
ethanfrey Nov 7, 2019
eda42d4
Clean up alias.go file
ethanfrey Nov 7, 2019
a56b472
Define expected interfaces in exported, rather than importing from ac…
ethanfrey Nov 7, 2019
be29328
Remove dependency on auth/ante
ethanfrey Nov 7, 2019
786bf01
Improve godoc, Logger
ethanfrey Nov 7, 2019
5f2bcb5
Cleaned up ExpiresAt
ethanfrey Nov 7, 2019
314b099
Improve error reporting with UseGrantedFee
ethanfrey Nov 7, 2019
29958e0
Enforce period limit subset of basic limit
ethanfrey Nov 7, 2019
fb5b97a
Add events
ethanfrey Nov 7, 2019
eedb8d8
Rename fee_grant to feegrant
ethanfrey Nov 7, 2019
88df255
Ensure KeeperTestSuite actually runs
ethanfrey Nov 7, 2019
dbf3578
Move types/tx to types
ethanfrey Nov 7, 2019
375f114
Update alias file, include ante
ethanfrey Nov 7, 2019
9af9f43
I do need nolint in alias.go
ethanfrey Nov 7, 2019
3c390e5
Properly emit events in the handler. Use cosmos-sdk in amino types
ethanfrey Nov 7, 2019
de694c5
Merge branch 'master' into bez/enable-fee-auth
alexanderbez Mar 9, 2020
720e9f4
Update godoc
alexanderbez Mar 9, 2020
eb46dd0
Linting...
alexanderbez Mar 9, 2020
63cca04
Update errors
alexanderbez Mar 9, 2020
8eddbb7
Update pkg doc and fix ante-handler order
alexanderbez Mar 9, 2020
f32db1d
Merge PR #5782: Migrate x/feegrant to proto
sahith-narahari Apr 7, 2020
8dc477a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into bez/enable…
sahith-narahari May 27, 2020
b8038ee
Merge branch 'master' of github.com:cosmos/cosmos-sdk into bez/enable…
sahith-narahari Jun 8, 2020
c34217a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Nov 25, 2020
bd0443c
fix errors
atheeshp Nov 25, 2020
3d72df8
proto changes
atheeshp Nov 26, 2020
8d42ee1
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Nov 26, 2020
2e51274
proto changes
atheeshp Nov 26, 2020
1617e5a
fix errors
atheeshp Nov 26, 2020
76c38ec
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Nov 26, 2020
13f503e
fix errors
atheeshp Nov 26, 2020
cb10556
genesis state changed to proto
atheeshp Dec 1, 2020
ea8492c
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 1, 2020
7ed4d95
fix keeper tests
atheeshp Dec 1, 2020
c89db6d
fix test
atheeshp Dec 1, 2020
37aa0c1
fixed tests
atheeshp Dec 2, 2020
aad466a
fix tests
atheeshp Dec 2, 2020
d8962c2
updated expected keepers
atheeshp Dec 2, 2020
a96d5a5
updated ante tests
atheeshp Dec 2, 2020
550086e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 2, 2020
2c1902b
lint
atheeshp Dec 2, 2020
6c16146
deleted alias.go
atheeshp Dec 3, 2020
755da02
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 3, 2020
1892a3d
tx updated to proto tx
atheeshp Dec 5, 2020
13eea6e
remove explicit signmode
atheeshp Dec 5, 2020
07847ab
tests
atheeshp Dec 7, 2020
29a1fc1
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 7, 2020
85cd87e
Added `cli/query.go`
atheeshp Dec 7, 2020
24b1c9a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 7, 2020
d838333
Added tx.go in cli
atheeshp Dec 7, 2020
0a258ac
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 7, 2020
695b143
updated `module.go`
atheeshp Dec 7, 2020
e59e303
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 7, 2020
9ea89d9
resolve errors in tx.go
atheeshp Dec 7, 2020
debec04
Add fee payer gentx func
atheeshp Dec 8, 2020
fc4543d
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 8, 2020
865f70e
updated tx
atheeshp Dec 8, 2020
3b43fef
fixed error
atheeshp Dec 9, 2020
3c69591
WIP: cli tests
atheeshp Dec 9, 2020
5eb8f22
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 9, 2020
ec9dad3
fix query error
atheeshp Dec 9, 2020
f69d5dd
fix tests
atheeshp Dec 11, 2020
e424be4
Unused types and funcs
atheeshp Dec 11, 2020
1d54333
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 11, 2020
a5483f9
fix tests
atheeshp Dec 13, 2020
1907c0c
rename helper func to create tx
atheeshp Dec 13, 2020
eedc5a5
remove unused
atheeshp Dec 13, 2020
182507f
update tx cfg
atheeshp Dec 13, 2020
bab66dd
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 13, 2020
3e00831
fix cli tests
atheeshp Dec 14, 2020
922a437
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 14, 2020
dc6eeb6
added simulations
atheeshp Dec 15, 2020
738bdd0
Add `decoder.go`
atheeshp Dec 15, 2020
d06fb86
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 15, 2020
c5abc6e
fix build fail
atheeshp Dec 16, 2020
9f74c5d
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 16, 2020
5adf5fe
added init genesis code
atheeshp Dec 16, 2020
d2f494c
update tx.go
atheeshp Dec 16, 2020
14f6183
fixed LGTM alert
atheeshp Dec 16, 2020
5f69caa
modified cli
atheeshp Dec 16, 2020
bd96862
remove gogoproto extensions
aleem1314 Dec 16, 2020
07da6b0
change acc address type to string
aleem1314 Dec 16, 2020
eba8213
lint
aleem1314 Dec 16, 2020
287b6ac
fix simulations
aleem1314 Dec 16, 2020
8b11072
Add gen simulations
atheeshp Dec 16, 2020
4ca4304
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 16, 2020
5aaf0c5
Merge branch 'atheesh/x-fee-grant' of github.com:cosmos/cosmos-sdk in…
atheeshp Dec 16, 2020
1884fb7
remove legacy querier
aleem1314 Dec 17, 2020
5ffc768
remove legacy code
aleem1314 Dec 17, 2020
e735ad8
add grpc queries tests
aleem1314 Dec 17, 2020
9600bbf
Merge branch 'master' into atheesh/x-fee-grant
aleem1314 Dec 17, 2020
dff0c63
fix simulations
aleem1314 Dec 19, 2020
b8f2f02
update module.go
aleem1314 Dec 19, 2020
79e71ad
lint
aleem1314 Dec 19, 2020
2a62fb9
Merge branch 'master' into atheesh/x-fee-grant
aleem1314 Dec 19, 2020
7e74e35
register feegrant NewSimulationManager
aleem1314 Dec 19, 2020
ad3d8c4
Merge branch 'atheesh/x-fee-grant' of https://github.com/cosmos/cosmo…
aleem1314 Dec 19, 2020
8061f2d
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 21, 2020
1ea308a
fix sims
atheeshp Dec 21, 2020
38ff641
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 21, 2020
89ef367
fix sims
atheeshp Dec 21, 2020
9bd77ae
add genesis test
aleem1314 Dec 22, 2020
980b7db
Merge branch 'master' into atheesh/x-fee-grant
aleem1314 Dec 22, 2020
0e48652
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 22, 2020
c9d5f81
Merge branch 'atheesh/x-fee-grant' of github.com:cosmos/cosmos-sdk in…
atheeshp Dec 22, 2020
26238b2
add periodic grant
atheeshp Dec 23, 2020
0225e2d
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Dec 23, 2020
bef09b7
updated cmd
atheeshp Dec 23, 2020
d8fd446
changed times
atheeshp Dec 23, 2020
d7c63fb
updated flags
atheeshp Dec 23, 2020
b656a14
removed days as period clock
atheeshp Dec 23, 2020
458e76e
added condition for period and exp
atheeshp Dec 23, 2020
d5d948c
add periodic fee cli tests
atheeshp Dec 23, 2020
fc9b0dc
udpated tests
atheeshp Dec 23, 2020
35fe6a7
fix lint
atheeshp Dec 23, 2020
db78a92
fix tests
atheeshp Dec 23, 2020
0692eb0
fix sims
atheeshp Dec 23, 2020
a153873
renaming to `fee_grant`
atheeshp Jan 11, 2021
cf547d9
review changes
atheeshp Jan 11, 2021
ba0f83a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 11, 2021
a893e92
fix test
atheeshp Jan 12, 2021
ba9dd4a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 12, 2021
9a68d51
add condition for duplicate grants
atheeshp Jan 12, 2021
90c3e7f
fix tests
atheeshp Jan 12, 2021
1a056a9
add `genTxWithFeeGranter` in tests
atheeshp Jan 12, 2021
bfeb2d9
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 12, 2021
ec5129a
fix simulation
atheeshp Jan 12, 2021
24fbc1a
Merge branch 'master' into atheesh/x-fee-grant
atheeshp Jan 13, 2021
de83e01
one of changes & test fixes
atheeshp Jan 18, 2021
5b5a0fc
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 18, 2021
7131468
Merge branch 'atheesh/x-fee-grant' of github.com:cosmos/cosmos-sdk in…
atheeshp Jan 18, 2021
35bd132
fix test
atheeshp Jan 18, 2021
b0299a4
fix lint
atheeshp Jan 18, 2021
3031218
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 19, 2021
6701433
changed package name `feegrant` to `fee_grant`
atheeshp Jan 19, 2021
f484c58
review comments
atheeshp Jan 19, 2021
a05a4c6
review changes
atheeshp Jan 19, 2021
fa5b4f2
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 19, 2021
25f18d8
review change
atheeshp Jan 19, 2021
b283eb7
review changes
atheeshp Jan 20, 2021
7bf2195
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 20, 2021
958715e
Merge branch 'master' into atheesh/x-fee-grant
anilcse Jan 21, 2021
96bc2ae
added fee-account in flags
atheeshp Jan 21, 2021
6716ffa
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 21, 2021
99c65bd
Merge branch 'atheesh/x-fee-grant' of github.com:cosmos/cosmos-sdk in…
atheeshp Jan 21, 2021
b0d5f7d
address review changes
atheeshp Jan 22, 2021
f40ed08
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 22, 2021
c234b1a
read fee granter from cli
atheeshp Jan 25, 2021
605b530
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 25, 2021
35d9fb1
updated create account with mnemonic
atheeshp Jan 25, 2021
f5fae0f
Address review comments
atheeshp Jan 25, 2021
f2998e7
move `simapp/ante` file to `feegrant/ante`
atheeshp Jan 25, 2021
a22c736
update keeper logic to create account
atheeshp Jan 25, 2021
9efd541
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 25, 2021
27c9182
update docs
atheeshp Jan 25, 2021
d3423bf
fix tests
atheeshp Jan 25, 2021
0ff9ade
update `serviceMsgClientConn` from `msgservice`
atheeshp Jan 25, 2021
a0d67bd
review changes
atheeshp Jan 27, 2021
3497817
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 27, 2021
65547e7
add test case for using more fees than allowed
atheeshp Jan 27, 2021
fa01503
eliminate panic checks from keeper
atheeshp Jan 27, 2021
4c091fd
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 27, 2021
86714f1
fix lint
atheeshp Jan 27, 2021
1d6f9cf
change store keys string to bytes
atheeshp Jan 27, 2021
e908652
fix tests
atheeshp Jan 27, 2021
e5d2610
review changes
atheeshp Jan 27, 2021
0ffebce
review changes
atheeshp Jan 27, 2021
fa37825
udpate docs
atheeshp Jan 27, 2021
f2b616f
make spend limit optional
atheeshp Jan 28, 2021
d2cc66e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/x-…
atheeshp Jan 28, 2021
c172cca
fix tests
atheeshp Jan 28, 2021
8d8f137
fix tests
atheeshp Jan 28, 2021
3dfb3ab
review changes
atheeshp Jan 28, 2021
3398c46
add norace tag
atheeshp Jan 28, 2021
a344c78
proto-docs
atheeshp Jan 28, 2021
6509b55
add docs
atheeshp Jan 28, 2021
fc5b9e1
Merge branch 'master' into atheesh/x-fee-grant
atheeshp Jan 29, 2021
4987bd0
Merge branch 'master' into atheesh/x-fee-grant
mergify[bot] Jan 29, 2021
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
13 changes: 13 additions & 0 deletions client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
clientCtx = clientCtx.WithSignModeStr(signModeStr)
}

if clientCtx.FeeGranter == nil || flagSet.Changed(flags.FlagFeeAccount) {
granter, _ := flagSet.GetString(flags.FlagFeeAccount)

if granter != "" {
granterAcc, err := sdk.AccAddressFromBech32(granter)
if err != nil {
return clientCtx, err
}

clientCtx = clientCtx.WithFeeGranterAddress(granterAcc)
}
}

if clientCtx.From == "" || flagSet.Changed(flags.FlagFrom) {
from, _ := flagSet.GetString(flags.FlagFrom)
fromAddr, fromName, keyType, err := GetFromFields(clientCtx.Keyring, from, clientCtx.GenerateOnly)
Expand Down
8 changes: 8 additions & 0 deletions client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Context struct {
TxConfig TxConfig
AccountRetriever AccountRetriever
NodeURI string
FeeGranter sdk.AccAddress

// TODO: Deprecated (remove).
LegacyAmino *codec.LegacyAmino
Expand Down Expand Up @@ -166,6 +167,13 @@ func (ctx Context) WithFromAddress(addr sdk.AccAddress) Context {
return ctx
}

// WithFeeGranterAddress returns a copy of the context with an updated fee granter account
// address.
func (ctx Context) WithFeeGranterAddress(addr sdk.AccAddress) Context {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (ctx Context) WithFeeGranterAddress(addr sdk.AccAddress) Context {
func (ctx Context) WithFeeGranter(addr sdk.AccAddress) Context {

ctx.FeeGranter = addr
return ctx
}

// WithBroadcastMode returns a copy of the context with an updated broadcast
// mode.
func (ctx Context) WithBroadcastMode(mode string) Context {
Expand Down
2 changes: 2 additions & 0 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
FlagCountTotal = "count-total"
FlagTimeoutHeight = "timeout-height"
FlagKeyAlgorithm = "algo"
FlagFeeAccount = "fee-account"

// Tendermint logging flags
FlagLogLevel = "log_level"
Expand Down Expand Up @@ -112,6 +113,7 @@ func AddTxFlagsToCmd(cmd *cobra.Command) {
cmd.Flags().String(FlagKeyringBackend, DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)")
cmd.Flags().String(FlagSignMode, "", "Choose sign mode (direct|amino-json), this is an advanced feature")
cmd.Flags().Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height")
cmd.Flags().String(FlagFeeAccount, "", "Fee account pays fees for the transaction instead of deducting from the signer")

// --gas can accept integers and "auto"
cmd.Flags().String(FlagGas, "", fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically (default %d)", GasFlagAuto, DefaultGasLimit))
Expand Down
5 changes: 5 additions & 0 deletions client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func (ctx Context) GetFromAddress() sdk.AccAddress {
return ctx.FromAddress
}

// GetFeeGranterAddress returns the fee granter address from the context
func (ctx Context) GetFeeGranterAddress() sdk.AccAddress {
return ctx.FeeGranter
}

// GetFromName returns the key name for the current context.
func (ctx Context) GetFromName() string {
return ctx.FromName
Expand Down
1 change: 1 addition & 0 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
}
}

tx.SetFeeGranter(clientCtx.GetFeeGranterAddress())
err = Sign(txf, clientCtx.GetFromName(), tx, true)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions client/tx_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ type (
SetFeeAmount(amount sdk.Coins)
SetGasLimit(limit uint64)
SetTimeoutHeight(height uint64)
SetFeeGranter(feeGranter sdk.AccAddress)
}
)
7,596 changes: 3,964 additions & 3,632 deletions docs/core/proto-docs.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions proto/cosmos/feegrant/v1beta1/feegrant.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
syntax = "proto3";
package cosmos.feegrant.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";

// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens
// that optionally expires. The delegatee can use up to SpendLimit to cover fees.
message BasicFeeAllowance {
option (cosmos_proto.implements_interface) = "FeeAllowanceI";

// spend_limit specifies the maximum amount of tokens that can be spent
// by this allowance and will be updated as tokens are spent. If it is
// empty, there is no spend limit and any amount of coins can be spent.
repeated cosmos.base.v1beta1.Coin spend_limit = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];

// expiration specifies an optional time when this allowance expires
ExpiresAt expiration = 2 [(gogoproto.nullable) = false];
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
}

// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap,
// as well as a limit per time period.
message PeriodicFeeAllowance {
option (cosmos_proto.implements_interface) = "FeeAllowanceI";

// basic specifies a struct of `BasicFeeAllowance`
BasicFeeAllowance basic = 1 [(gogoproto.nullable) = false];

// period specifies the time duration in which period_spend_limit coins can
// be spent before that allowance is reset
Duration period = 2 [(gogoproto.nullable) = false];

// period_spend_limit specifies the maximum number of coins that can be spent
// in the period
repeated cosmos.base.v1beta1.Coin period_spend_limit = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];

// period_can_spend is the number of coins left to be spent before the period_reset time
repeated cosmos.base.v1beta1.Coin period_can_spend = 4
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];

// period_reset is the time at which this period resets and a new one begins,
// it is calculated from the start time of the first transaction after the
// last period ended
ExpiresAt period_reset = 5 [(gogoproto.nullable) = false];
}

// Duration is a span of a clock time or number of blocks.
// This is designed to be added to an ExpiresAt struct.
message Duration {
// sum is the oneof that represents either duration or block
oneof sum {
google.protobuf.Duration duration = 1 [(gogoproto.stdduration) = true];
uint64 blocks = 2;
}
}

// ExpiresAt is a point in time where something expires.
// It may be *either* block time or block height
message ExpiresAt {
// sum is the oneof that represents either time or height
oneof sum {
google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true];
int64 height = 2;
}
}

// FeeAllowanceGrant is stored in the KVStore to record a grant with full context
message FeeAllowanceGrant {

string granter = 1;
string grantee = 2;
google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"];
}
12 changes: 12 additions & 0 deletions proto/cosmos/feegrant/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package cosmos.feegrant.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/feegrant/v1beta1/feegrant.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";

// GenesisState contains a set of fee allowances, persisted from the store
message GenesisState {
repeated FeeAllowanceGrant fee_allowances = 1 [(gogoproto.nullable) = false];
}
52 changes: 52 additions & 0 deletions proto/cosmos/feegrant/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";
package cosmos.feegrant.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/feegrant/v1beta1/feegrant.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";

// Query defines the gRPC querier service.
service Query {

// FeeAllowance returns fee granted to the grantee by the granter.
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) {
option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}";
}

// FeeAllowances returns all the grants for address.
rpc FeeAllowances(QueryFeeAllowancesRequest) returns (QueryFeeAllowancesResponse) {
option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowances/{grantee}";
}
}

// QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method.
message QueryFeeAllowanceRequest {
string granter = 1;
string grantee = 2;
}

// QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method.
message QueryFeeAllowanceResponse {
// fee_allowance is a fee_allowance granted for grantee by granter.
cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowance = 1;
}

// QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method.
message QueryFeeAllowancesRequest {
string grantee = 1;

// pagination defines an pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method.
message QueryFeeAllowancesResponse {
// fee_allowances are fee_allowance's granted for grantee by granter.
repeated cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowances = 1;

// pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
40 changes: 40 additions & 0 deletions proto/cosmos/feegrant/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
syntax = "proto3";
package cosmos.feegrant.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";

// Msg defines the feegrant msg service.
service Msg {

// GrantFeeAllowance grants fee allowance to the grantee on the granter's
// account with the provided expiration time.
rpc GrantFeeAllowance(MsgGrantFeeAllowance) returns (MsgGrantFeeAllowanceResponse);

// RevokeFeeAllowance revokes any fee allowance of granter's account that
// has been granted to the grantee.
rpc RevokeFeeAllowance(MsgRevokeFeeAllowance) returns (MsgRevokeFeeAllowanceResponse);
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
}

// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance
// of fees from the account of Granter.
message MsgGrantFeeAllowance {
string granter = 1;
string grantee = 2;
google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"];
}

// MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type.
message MsgGrantFeeAllowanceResponse {}

// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee.
message MsgRevokeFeeAllowance {
string granter = 1;
string grantee = 2;
}

// MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type.
message MsgRevokeFeeAllowanceResponse {}
17 changes: 14 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ import (
"github.com/cosmos/cosmos-sdk/x/evidence"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
feegrant "github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantante "github.com/cosmos/cosmos-sdk/x/feegrant/ante"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
Expand Down Expand Up @@ -120,6 +124,7 @@ var (
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
feegrant.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
Expand Down Expand Up @@ -181,6 +186,7 @@ type SimApp struct {
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -222,7 +228,7 @@ func NewSimApp(
keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegranttypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
authztypes.StoreKey,
)
Expand Down Expand Up @@ -277,6 +283,8 @@ func NewSimApp(
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegranttypes.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath)

// register the staking hooks
Expand Down Expand Up @@ -347,6 +355,7 @@ func NewSimApp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down Expand Up @@ -379,6 +388,7 @@ func NewSimApp(
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authztypes.ModuleName, ibctransfertypes.ModuleName,
feegranttypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand All @@ -396,6 +406,7 @@ func NewSimApp(
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
Expand All @@ -419,8 +430,8 @@ func NewSimApp(
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetAnteHandler(
ante.NewAnteHandler(
app.AccountKeeper, app.BankKeeper, ante.DefaultSigVerificationGasConsumer,
feegrantante.NewAnteHandler(
app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, ante.DefaultSigVerificationGasConsumer,
encodingConfig.TxConfig.SignModeHandler(),
),
)
Expand Down
4 changes: 4 additions & 0 deletions simapp/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ const (
DefaultWeightCommunitySpendProposal int = 5
DefaultWeightTextProposal int = 5
DefaultWeightParamChangeProposal int = 5

// feegrant
DefaultWeightGrantFeeAllowance int = 100
DefaultWeightRevokeFeeAllowance int = 100
)
3 changes: 3 additions & 0 deletions x/auth/legacy/legacytx/stdtx_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (s *StdTxBuilder) SetTimeoutHeight(height uint64) {
s.TimeoutHeight = height
}

// SetFeeGranter does nothing for stdtx
func (s *StdTxBuilder) SetFeeGranter(_ sdk.AccAddress) {}

// StdTxConfig is a context.TxConfig for StdTx
type StdTxConfig struct {
Cdc *codec.LegacyAmino
Expand Down
Loading