Skip to content

Commit

Permalink
fix for feegrants (#1256)
Browse files Browse the repository at this point in the history
* Feegrant support

* Test case for address caching bugfix

* Bugfix for SDK account prefix. Feegrant test passing.

* Mutex for signer expanded to include feegrantees

* Cleaned up feegrant test case

* Cleaned up feegrant test case

* Cleaned up feegrant test case

* check round robin feegrant behavior by counting number of TXs each grantee signer

* module updates from merge

* v0.47.0 with bech32 address cache fix

* Move SetAddrCacheEnabled to NewRelayer func for full coverage

* Do not hardcode chain id in feegrant test case

* Wait more blocks for ibc transfers

* disable cosmos SDK bech32 address cache for rly start command

* Fix sloppy comments/remove unnecessary code

* Faster acc caching unit test

* Penumbra provider feegrant support

* Merge upstream

* Fixed merge issue where feegrant config wasn't being written to file

* feegrant patch for cosmos-sdk v0.47.1

* merge from main

* Update to cosmos-sdk v0.47.2

* Increase test case blocks to wait

* Fixed data race by moving test parallelization after relayer wallet build

* Increased TestScenarioICAChannelClose timeout height

* Cleanup feegrant test case

* Fixed race condition in sequence guard w/ mutex

* Automatic retry for TX lookup in feegrant test case

* Disable cosmos SDK address cache on app initialization via main package init()

* Added docs for feegrant in the advanced usage guide

* Removed commented out code

* Removed commented out code

* Added detail to feegrant docs, fixed minor issue with test case

* Added detail to feegrant docs, fixed minor issue with test case

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
Co-authored-by: Kyle <kyle@strange.love>
  • Loading branch information
3 people authored Aug 15, 2023
1 parent a63cd79 commit 4598b0e
Show file tree
Hide file tree
Showing 6 changed files with 462 additions and 411 deletions.
20 changes: 18 additions & 2 deletions cmd/feegrant.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func feegrantConfigureBaseCmd(a *appState) *cobra.Command {
func feegrantConfigureBasicCmd(a *appState) *cobra.Command {
var numGrantees int
var update bool
var delete bool
var updateGrantees bool
var grantees []string

Expand Down Expand Up @@ -61,6 +62,19 @@ func feegrantConfigureBasicCmd(a *appState) *cobra.Command {
return fmt.Errorf("could not get granter key from '%s'", granterKeyOrAddr)
}

if delete {
fmt.Printf("Deleting %s feegrant configuration\n", chain)

cfgErr := a.performConfigLockingOperation(cmd.Context(), func() error {
chain := a.config.Chains[chain]
oldProv := chain.ChainProvider.(*cosmos.CosmosProvider)
oldProv.PCfg.FeeGrants = nil
return nil
})
cobra.CheckErr(cfgErr)
return nil
}

if prov.PCfg.FeeGrants != nil && granterKey != prov.PCfg.FeeGrants.GranterKey && !update {
return fmt.Errorf("you specified granter '%s' which is different than configured feegranter '%s', but you did not specify the --overwrite-granter flag", granterKeyOrAddr, prov.PCfg.FeeGrants.GranterKey)
} else if prov.PCfg.FeeGrants != nil && granterKey != prov.PCfg.FeeGrants.GranterKey && update {
Expand Down Expand Up @@ -126,11 +140,13 @@ func feegrantConfigureBasicCmd(a *appState) *cobra.Command {
return nil
},
}

cmd.Flags().BoolVar(&delete, "delete", false, "delete the feegrant configuration")
cmd.Flags().BoolVar(&update, "overwrite-granter", false, "allow overwriting the existing granter")
cmd.Flags().BoolVar(&updateGrantees, "overwrite-grantees", false, "allow overwriting existing grantees")
cmd.Flags().IntVar(&numGrantees, "num-grantees", 10, "number of grantees that will be feegranted with basic allowances")
cmd.Flags().StringSliceVar(&grantees, "grantees", []string{}, "comma separated list of grantee key names (keys are created if they do not exist)")
cmd.MarkFlagsMutuallyExclusive("num-grantees", "grantees")
cmd.Flags().StringSliceVar(&grantees, "grantees", nil, "comma separated list of grantee key names (keys are created if they do not exist)")
cmd.MarkFlagsMutuallyExclusive("num-grantees", "grantees", "delete")

memoFlag(a.viper, cmd)
return cmd
Expand Down
28 changes: 27 additions & 1 deletion docs/advanced_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,33 @@ Use cases for configuring the `--time-threshold` flag:

\* It is not mandatory for relayers to include the `MsgUpdateClient` when relaying packets, however most, if not all relayers currently do.

---
## Feegrants

Feegrant configurations can be applied to each chain in the relayer. Note that Osmosis does not support Feegrants.

- When feegrants are enabled, TXs will be signed in round robin by the grantees.
- Feegrants reduce sequencing error rates by using many signing addresses instead of a single signer, especially when broadcast-mode is set to single.
- Feegrants are especially useful when relaying on multiple paths with the same wallet.
- Funds are held on a single address, the "granter".

For example, configure feegrants for Kujira:
- `rly chains configure feegrant basicallowance kujira default --num-grantees 10`
- Note: above, `default` is the key that will need to contain funds (the granter)
- 10 grantees will be configured, so those 10 address will sign TXs in round robin order.


You may also choose to specify the exact names of your grantees:
- `rly chains configure feegrant basicallowance kujira default --grantees "kuji1,kuji2,kuji3"`

Rerunning the feegrant command will simply confirm your configuration is correct, e.g. "Valid grant found for granter `addr` and grantee `addr2`" but will not create additional TXs on chain. Rerunning the feegrant command can therefore be a good way to check what addresses exist.


To remove the feegrant configuration:
- `rly chains configure feegrant basicallowance kujira --delete`




---

[<-- Create Path Across Chains](create-path-across-chain.md) - [Troubleshooting -->](./troubleshooting.md)
3 changes: 1 addition & 2 deletions interchaintest/acc_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"testing"

"github.com/cometbft/cometbft/crypto/ed25519"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
)
Expand All @@ -14,7 +13,7 @@ import (
// This will cause the AccAddress.String() to print out unexpected prefixes.
// If this function fails you are on an unsafe SDK version that should NOT be used with the relayer.
func TestAccCacheBugfix(t *testing.T) {
types.SetAddrCacheEnabled(false)
sdk.SetAddrCacheEnabled(false)

// Use a random key
priv := ed25519.GenPrivKey()
Expand Down
Loading

0 comments on commit 4598b0e

Please sign in to comment.