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

LSM #708

Merged
merged 110 commits into from
Aug 25, 2023
Merged

LSM #708

Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
4c35885
[LSM] Scaffolding (#706)
sampocs Apr 6, 2023
6542bb5
Merge branch 'main' into lsm
sampocs Apr 7, 2023
85e3b86
core lsm deposit keeper functions with unit tests
ethan-stride Apr 10, 2023
8f9427c
adding implementations for helpers
ethan-stride Apr 11, 2023
e8bc7c8
using testing framework, fixing small errors
ethan-stride Apr 11, 2023
112f85f
Merge branch 'ethan/lsm-keeper-core' into ethan/lsm-keeper-helpers
ethan-stride Apr 11, 2023
c6bd1af
added unit test for AddLSMTokenDeposit
ethan-stride Apr 11, 2023
0e0f1d2
[LSM] Interchainquery Callback Data and Unique ID (#709)
sampocs Apr 11, 2023
f7f91f1
cleaner error messages
ethan-stride Apr 12, 2023
ec198c1
Merge branch 'ethan/lsm-keeper-core' into ethan/lsm-keeper-helpers
ethan-stride Apr 12, 2023
606efb3
core lsm deposit keeper functions with unit tests (#711)
ethan-stride Apr 12, 2023
d966781
added test for get all deposits based on chainid/status
ethan-stride Apr 13, 2023
ac6b1b6
simplifying test setup functions
ethan-stride Apr 13, 2023
5885255
creating query protos and grpc endpoints
ethan-stride Apr 13, 2023
be1bd99
addressing comments, cleaner names, comments, ordering
ethan-stride Apr 13, 2023
0310504
adding the grpc implementation
ethan-stride Apr 13, 2023
cd42d92
Merge branch 'ethan/lsm-keeper-helpers' into ethan/lsm-deposit-queries
ethan-stride Apr 13, 2023
7dfbb12
added cli commands
ethan-stride Apr 13, 2023
de91ed5
[LSM] ICA DetokenizeShares and Callback (#715)
sampocs Apr 14, 2023
2d23d41
Ethan/lsm keeper helpers (#718)
ethan-stride Apr 14, 2023
bf2847a
Merge branch 'lsm' into ethan/lsm-deposit-queries
sampocs Apr 14, 2023
49fe093
[LSM] Removed Unnecessary Overflow Check (#721)
sampocs Apr 14, 2023
a4f83aa
[LSM] End Blocker and Restore ICA Account (#720)
sampocs Apr 14, 2023
9a49a30
[LSM] LSMLiquidStake Transaction (#713)
sampocs Apr 15, 2023
d74ac67
fixed lint errors
sampocs Apr 15, 2023
f497196
changed CLI and web commands, avoiding optionals
ethan-stride Apr 15, 2023
6d09e95
Merge branch 'ethan/lsm-deposit-queries' of github.com:Stride-Labs/st…
ethan-stride Apr 15, 2023
f42ab66
fixing PR comments
ethan-stride Apr 18, 2023
1228d2d
[LSM] Rename Host Zone Address to Deposit Address (#716)
sampocs Apr 18, 2023
e052a6c
[LSM] Renamed ICA Accounts in Host Zone (#727)
sampocs Apr 18, 2023
b71d084
fixed integrations tests and lint errors
sampocs Apr 18, 2023
3a7b4dd
added unit tests on the grpc_query keepers
ethan-stride Apr 18, 2023
7c04d36
removing basic type getters for direct attributes
ethan-stride Apr 18, 2023
768954c
adding more comments, tests
ethan-stride Apr 18, 2023
8e9c167
adding error messages to checks
ethan-stride Apr 19, 2023
4e09114
adding test case description to error message
ethan-stride Apr 19, 2023
b3a953a
nit bug
ethan-stride Apr 19, 2023
c6f58ab
Ethan/lsm deposit queries (#719)
ethan-stride Apr 19, 2023
55fbff2
Ethan/lsm validate basic (#731)
ethan-stride Apr 19, 2023
0527935
[LSM] Unbonding Frequency to Unbonding Period (#724)
sampocs Apr 21, 2023
19325c0
[LSM] Update Redemption Rate Calculation (#723)
sampocs Apr 21, 2023
c79ac0e
Merge branch 'main' into lsm
sampocs Apr 23, 2023
44b086e
fixed integration tests
sampocs Apr 23, 2023
5cb0f86
[LSM] Move LSMTokenDeposit to records (#737)
sampocs Apr 26, 2023
0a0b9d0
[LSM] LSM Token Transfer Callback (#738)
sampocs Apr 26, 2023
dc0908c
added new status type to tests (#740)
ethan-stride Apr 26, 2023
61309da
[LSM] Remove Unbalanced Delegation (#739)
sampocs Apr 26, 2023
e4e2a6d
remove add lsm deposit, enforce single record per denom (#741)
ethan-stride Apr 26, 2023
d2f1b59
[LSM] Rebalance LSM Delegations (#726)
sampocs Apr 27, 2023
4f80e8a
[LSM] Batching ICA rebalance calls into smaller groups (#747)
ethan-stride May 2, 2023
a61aae7
[LSM] Move token escrow out of StartLSMLiquidStake (#742)
sampocs May 2, 2023
ae89407
[LSM] Increment Validator Slash Query Progress (#752)
sampocs May 5, 2023
9545cf0
[LSM] LSM Dockernet Host (#755)
sampocs May 5, 2023
91a28e2
[LSM] Slash Query Callbacks (#745)
sampocs May 6, 2023
ad2ed2d
[LSM] Unbonding (#751)
sampocs May 6, 2023
f731947
[LSM] Updated Delegation in Detokenize Callback (#756)
sampocs May 6, 2023
e80d296
[LSM] Added unit test for RebalanceDelegationsForHostZone (#758)
sampocs May 6, 2023
cf7c297
[LSM] Retry Interchain Queries (#757)
sampocs May 6, 2023
230d6ca
[LSM] Detokenization ICA/ICQ Overlap Check (#759)
sampocs May 7, 2023
2debf64
[LSM] Query validator exchange rate after adding validator (#762)
sampocs May 8, 2023
e914d41
[LSM] Slash Query Interval Check Relative to TVL (#760)
sampocs May 8, 2023
a41faa3
[LSM] Misc changes after local tests (#761)
sampocs May 9, 2023
1581523
[LSM] Move LSM Token transfer to end blocker (#768)
sampocs May 11, 2023
79f5eb7
nit changes, removed print statement and re-ordered unit tests
sampocs May 11, 2023
c130e94
kept same query ID during retry
sampocs May 12, 2023
2ba7baf
[LSM] Add delegation_changes_in_progress counter on validator (#772)
sampocs May 15, 2023
13f40e9
[LSM] Move rebalance trigger to stride epoch (#773)
sampocs May 19, 2023
ed05443
fixed unit tests
sampocs May 20, 2023
010a0a9
[LSM] Documentation around error case in transfer callback (#766)
sampocs May 24, 2023
ea573a9
[LSM] LSMLiquidStakeEnabled flag on host zone (#777)
sampocs May 25, 2023
20e1e93
[LSM] Persistent LSM Integration Test (#778)
sampocs May 27, 2023
5b54779
[LSM] Discard partial state changes with failed FinishLSMLiquidStake …
sampocs Jun 2, 2023
9072c52
[LSM] Remove cap on number of validators (#813)
sampocs Jun 6, 2023
46e681a
[LSM] Added unit test for setting the slash query checkpoint (#832)
sampocs Jun 27, 2023
5e41812
[LSM] Replace LSM dockernet host with gaia and lsm support (#857)
sampocs Jul 18, 2023
ff83f42
[LSM] Fail liquid stake on slash query timeout (#837)
sampocs Jul 20, 2023
c0597cf
[LSM] Red team small issues (#851)
ethan-stride Jul 26, 2023
795a78d
[LSM] LSMLiquidStake events for frontend (#866)
sampocs Jul 26, 2023
23d585b
[LSM] Updated stToken and redemption rate calculation (LSM Token now …
sampocs Jul 26, 2023
722f54a
[LSM] Rename validator exchange rate to sharesToTokens rate (#865)
sampocs Jul 26, 2023
f85ad5f
[LSM] Prevent ICAs to validator's with slash query in progress (#844)
sampocs Aug 1, 2023
8da5ed5
Merge branch 'main' into lsm
sampocs Aug 4, 2023
e89bd36
fixed build errors after merge
sampocs Aug 4, 2023
f6e59d1
fixed unit tests
sampocs Aug 4, 2023
f083f6e
fixed integration tests
sampocs Aug 4, 2023
f2a0878
reverted proto to gogoproto in migration files
sampocs Aug 7, 2023
657043f
refreshed old stakeibc types
sampocs Aug 7, 2023
5b3be25
Merge branch 'main' into lsm
sampocs Aug 15, 2023
5cbaffb
fixed conflicts after merge
sampocs Aug 15, 2023
29c1f72
updated to latest sdk+lsm version
sampocs Aug 15, 2023
f8ce0be
nit slash error message
sampocs Aug 16, 2023
7a90e15
lint
sampocs Aug 16, 2023
4b102c5
updated gaia to first RC
sampocs Aug 16, 2023
5d5e3bb
updated go relayer to fork of 2.4.1 with hard coded unbonding time
sampocs Aug 16, 2023
63b75fd
integrated frontend changes to testing script
sampocs Aug 16, 2023
b5fde25
added delegations to other validators in the setup script
sampocs Aug 16, 2023
42700ae
nit
sampocs Aug 17, 2023
b19c2c9
upgraded gaia to v12-rc0
sampocs Aug 18, 2023
bdb2155
removed exit from setup script
sampocs Aug 18, 2023
2c28cc1
small changes to setup scripts
sampocs Aug 18, 2023
5919a21
nit typo in readme
sampocs Aug 18, 2023
653d52f
added rebalance logs
sampocs Aug 22, 2023
dff54da
Remove max slash safety check (#900)
sampocs Aug 23, 2023
f1afdab
[LSM] Remove slash query admin gate (#902)
sampocs Aug 24, 2023
64dee57
[LSM] Verify proof height during ICQ submission (#907)
sampocs Aug 25, 2023
c31a9b2
fixed records import/export genesis
sampocs Aug 25, 2023
af71c49
reverted config.sh
sampocs Aug 25, 2023
ebce98b
lint
sampocs Aug 25, 2023
d660b20
nit changes after final skim
sampocs Aug 25, 2023
10a328d
fix gosec lint error
sampocs Aug 25, 2023
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
12 changes: 9 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
# Commit: v1.5.1
path = deps/hermes
url = https://github.com/informalsystems/ibc-rs.git
# TODO [LSM]: Revert
# [submodule "deps/relayer"]
# # Commit: v2.3.1
# path = deps/relayer
# url = https://github.com/cosmos/relayer.git
[submodule "deps/relayer"]
# Commit: e95dd80608536c31d37354bdd7f7ec46a2172009
# Branch: sam/lsm-poc
# Commit: 0136134766142f133f263f3bba72d7077e7bc2c1
path = deps/relayer
url = https://github.com/cosmos/relayer.git
url = https://github.com/Stride-Labs/relayer.git
[submodule "deps/gaia"]
# Commit: v9.1.0
# Commit: v12.0.0-rc0
path = deps/gaia
url = https://github.com/cosmos/gaia.git
[submodule "deps/juno"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can optionally pass build arguments to specify which binary to rebuild
3. `j` This will re-build the Juno binary
4. `o` This will re-build the Osmo binary
5. `t` This will re-build the Stargaze binary
6. `t` This will re-build the Evmos binary
6. `e` This will re-build the Evmos binary
7. `r` This will re-build the Go Relayer binary
8. `h` This will re-build the Hermes binary

Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
stakeibcclient.AddValidatorsProposalHandler,
stakeibcclient.ToggleLSMProposalHandler,
ratelimitclient.AddRateLimitProposalHandler,
ratelimitclient.UpdateRateLimitProposalHandler,
ratelimitclient.RemoveRateLimitProposalHandler,
Expand Down
124 changes: 112 additions & 12 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
"time"

abci "github.com/cometbft/cometbft/abci/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ccvprovidertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"

"github.com/cometbft/cometbft/crypto/ed25519"
tmtypesproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
Expand All @@ -20,15 +16,19 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/gogoproto/proto"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"

tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/cosmos/ibc-go/v7/testing/simapp"
appProvider "github.com/cosmos/interchain-security/v3/app/provider"
ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing"
icstestingutils "github.com/cosmos/interchain-security/v3/testutil/ibc_testing"
e2e "github.com/cosmos/interchain-security/v3/testutil/integration"
ccvprovidertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

Expand All @@ -39,6 +39,7 @@ import (
var (
StrideChainID = "STRIDE"
ProviderChainID = "PROVIDER"
FirstClientId = "07-tendermint-0"

TestIcaVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{
Version: icatypes.Version,
Expand Down Expand Up @@ -225,7 +226,7 @@ func (s *AppTestHelper) CreateTransferChannel(hostChainID string) {

// Creates an ICA channel through ibctesting
// Also creates a transfer channel is if hasn't been done yet
func (s *AppTestHelper) CreateICAChannel(owner string) string {
func (s *AppTestHelper) CreateICAChannel(owner string) (channelID, portID string) {
// If we have yet to create a client/connection (through creating a transfer channel), do that here
_, transferChannelExists := s.App.IBCKeeper.ChannelKeeper.GetChannel(s.Ctx, ibctesting.TransferPort, ibctesting.FirstChannelID)
if !transferChannelExists {
Expand All @@ -249,17 +250,14 @@ func (s *AppTestHelper) CreateICAChannel(owner string) string {
err = icaPath.EndpointA.ChanOpenAck()
s.Require().NoError(err, "ChanOpenAck error")

// err = s.App.ICAControllerKeeper.RegisterInterchainAccount(s.Ctx, icaPath.EndpointA.ConnectionID, owner, TestIcaVersion)
// s.Require().NoError(err, "register interchain account error")

err = icaPath.EndpointB.ChanOpenConfirm()
s.Require().NoError(err, "ChanOpenConfirm error")

s.Ctx = s.StrideChain.GetContext()

// Confirm the ICA channel was created properly
portID := icaPath.EndpointA.ChannelConfig.PortID
channelID := icaPath.EndpointA.ChannelID
portID = icaPath.EndpointA.ChannelConfig.PortID
channelID = icaPath.EndpointA.ChannelID
_, found := s.App.IBCKeeper.ChannelKeeper.GetChannel(s.Ctx, portID, channelID)
s.Require().True(found, "Channel not found after creation, PortID: %s, ChannelID: %s", portID, channelID)

Expand All @@ -271,7 +269,7 @@ func (s *AppTestHelper) CreateICAChannel(owner string) string {
// Finally set the active channel
s.App.ICAControllerKeeper.SetActiveChannelID(s.Ctx, ibctesting.FirstConnectionID, portID, channelID)

return channelID
return channelID, portID
}

// Register's a new ICA account on the next channel available
Expand Down Expand Up @@ -411,11 +409,34 @@ func (s *AppTestHelper) GetIBCDenomTrace(denom string) transfertypes.DenomTrace
return transfertypes.ParseDenomTrace(prefixedDenom)
}

// Creates and stores an IBC denom from a base denom on transfer channel-0
// This is only required for tests that use the transfer keeper and require that the IBC
// denom is present in the store
//
// Returns the IBC hash
func (s *AppTestHelper) CreateAndStoreIBCDenom(baseDenom string) (ibcDenom string) {
denomTrace := s.GetIBCDenomTrace(baseDenom)
s.App.TransferKeeper.SetDenomTrace(s.Ctx, denomTrace)
return denomTrace.IBCDenom()
}

func (s *AppTestHelper) MarshalledICS20PacketData() sdk.AccAddress {
data := ibctransfertypes.FungibleTokenPacketData{}
return data.GetBytes()
}

// Helper function to mock out a connection, client, and revision height
func (s *AppTestHelper) MockClientLatestHeight(height uint64) {
clientState := tendermint.ClientState{
LatestHeight: clienttypes.NewHeight(1, height),
}
connection := connectiontypes.ConnectionEnd{
ClientId: FirstClientId,
}
s.App.IBCKeeper.ConnectionKeeper.SetConnection(s.Ctx, ibctesting.FirstConnectionID, connection)
s.App.IBCKeeper.ClientKeeper.SetClientState(s.Ctx, FirstClientId, &clientState)
}

func (s *AppTestHelper) ConfirmUpgradeSucceededs(upgradeName string, upgradeHeight int64) {
s.Ctx = s.Ctx.WithBlockHeight(upgradeHeight - 1)
plan := upgradetypes.Plan{Name: upgradeName, Height: upgradeHeight}
Expand Down Expand Up @@ -451,3 +472,82 @@ func GetAdminAddress() (address string, ok bool) {
func SetupConfig() {
app.SetupConfig()
}

// Searches for an event using the current context
func (s *AppTestHelper) getEventsFromEventType(eventType string) (events []sdk.Event) {
for _, event := range s.Ctx.EventManager().Events() {
if event.Type == eventType {
events = append(events, event)
}
}
return events
}

// Searches for an event attribute, given an event
// Returns the value if found
func (s *AppTestHelper) getEventValuesFromAttribute(event sdk.Event, attributeKey string) (values []string) {
for _, attribute := range event.Attributes {
if string(attribute.Key) == attributeKey {
values = append(values, string(attribute.Value))
}
}
return values
}

// Searches for an event that has an attribute value matching the expected value
// Returns whether there was a match, as well as a list for all the values found
// for that attribute (for the error message)
func (s *AppTestHelper) checkEventAttributeValueMatch(
events []sdk.Event,
attributeKey,
expectedValue string,
) (allValues []string, found bool) {
for _, event := range events {
allValues = append(allValues, s.getEventValuesFromAttribute(event, attributeKey)...)
for _, actualValue := range allValues {
if actualValue == expectedValue {
found = true
}
}
}
return allValues, found
}

// Checks if an event was emitted
func (s *AppTestHelper) CheckEventTypeEmitted(eventType string) []sdk.Event {
events := s.getEventsFromEventType(eventType)
eventEmitted := len(events) > 0
s.Require().True(eventEmitted, "%s event should have been emitted", eventType)
return events
}

// Checks that an event was not emitted
func (s *AppTestHelper) CheckEventTypeNotEmitted(eventType string) {
events := s.getEventsFromEventType(eventType)
eventNotEmitted := len(events) == 0
s.Require().True(eventNotEmitted, "%s event should not have been emitted", eventType)
}

// Checks that an event was emitted and that the value matches expectations
func (s *AppTestHelper) CheckEventValueEmitted(eventType, attributeKey, expectedValue string) {
events := s.CheckEventTypeEmitted(eventType)

// Check all events and attributes for a match
allValues, valueFound := s.checkEventAttributeValueMatch(events, attributeKey, expectedValue)
s.Require().True(valueFound, "attribute %s with value %s should have been found in event %s. Values emitted for attribute: %+v",
attributeKey, expectedValue, eventType, allValues)
}

// Checks that there was no event emitted that matches the event type, attribute, and value
func (s *AppTestHelper) CheckEventValueNotEmitted(eventType, attributeKey, expectedValue string) {
// Check that either the event or attribute were not emitted
events := s.getEventsFromEventType(eventType)
if len(events) == 0 {
return
}

// Check all events and attributes to make sure there's no match
allValues, valueFound := s.checkEventAttributeValueMatch(events, attributeKey, expectedValue)
s.Require().False(valueFound, "attribute %s with value %s should not have been found in event %s. Values emitted for attribute: %+v",
attributeKey, expectedValue, eventType, allValues)
}
2 changes: 0 additions & 2 deletions app/proposals_whitelisting.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ var WhitelistedParams = map[ccvgov.ParamChangeKey]struct{}{
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyDefaultMinRedemptionRateThreshold)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyDefaultMaxRedemptionRateThreshold)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyIBCTransferTimeoutNanos)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeySafetyNumValidators)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeySafetyMaxSlashPercent)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyMaxRedemptionRates)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyMinRedemptionRates)}: {},
//ica
Expand Down
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) {
app.ICAHostKeeper,
app.MintKeeper,
app.StakeibcKeeper,
app.keys[stakeibctypes.StoreKey],
),
)

Expand Down
12 changes: 6 additions & 6 deletions app/upgrades/v10/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func MigrateCallbackData(ctx sdk.Context, k icacallbackskeeper.Keeper) error {
newCallbackArgsBz, err = reserializeCallback(oldCallbackArgsBz, &stakeibctypes.ReinvestCallback{})
case stakeibckeeper.ICACallbackID_Undelegate:
newCallbackArgsBz, err = reserializeCallback(oldCallbackArgsBz, &stakeibctypes.UndelegateCallback{})
case recordskeeper.TRANSFER:
case recordskeeper.IBCCallbacksID_NativeTransfer:
newCallbackArgsBz, err = reserializeCallback(oldCallbackArgsBz, &recordstypes.TransferCallback{})
}
if err != nil {
Expand Down Expand Up @@ -343,21 +343,21 @@ func EnableRateLimits(
return errorsmod.Wrapf(err, "unable to add rate limit for %s", denom)
}

if hostZone.DelegationAccount == nil || hostZone.DelegationAccount.Address == "" {
if hostZone.DelegationIcaAddress == "" {
return stakeibctypes.ErrICAAccountNotFound
}
if hostZone.FeeAccount == nil || hostZone.FeeAccount.Address == "" {
if hostZone.FeeIcaAddress == "" {
return stakeibctypes.ErrICAAccountNotFound
}

ratelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
Sender: hostZone.Address,
Receiver: hostZone.DelegationAccount.Address,
Sender: hostZone.DepositAddress,
Receiver: hostZone.DelegationIcaAddress,
})

rewardCollectorAddress := accountKeeper.GetModuleAccount(ctx, stakeibctypes.RewardCollectorName).GetAddress()
ratelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
Sender: hostZone.FeeAccount.Address,
Sender: hostZone.FeeIcaAddress,
Receiver: rewardCollectorAddress.String(),
})
}
Expand Down
20 changes: 8 additions & 12 deletions app/upgrades/v10/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (s *UpgradeTestSuite) TestMigrateCallbackData() {
s.createCallbackData(stakeibckeeper.ICACallbackID_Redemption, &initialRedemptionCallbackArgs),
s.createCallbackData(stakeibckeeper.ICACallbackID_Reinvest, &initialReinvestCallbackArgs),
s.createCallbackData(stakeibckeeper.ICACallbackID_Undelegate, &initialUndelegateCallbackArgs),
s.createCallbackData(recordskeeper.TRANSFER, &initialTransferCallbackArgs),
s.createCallbackData(recordskeeper.IBCCallbacksID_NativeTransfer, &initialTransferCallbackArgs),
}
for i := range initialCallbackData {
initialCallbackData[i].CallbackKey = fmt.Sprintf("key-%d", i)
Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *UpgradeTestSuite) TestMigrateCallbackData() {
s.mustUnmarshalCallback(finalCallback.CallbackArgs, &finalCallbackArgs)
s.Require().Equal(initialUndelegateCallbackArgs, finalCallbackArgs, "undelegate callback")

case recordskeeper.TRANSFER:
case recordskeeper.IBCCallbacksID_NativeTransfer:
var finalCallbackArgs recordstypes.TransferCallback
s.mustUnmarshalCallback(finalCallback.CallbackArgs, &finalCallbackArgs)
s.Require().Equal(initialTransferCallbackArgs, finalCallbackArgs, "transfer callback")
Expand Down Expand Up @@ -349,16 +349,12 @@ func (s *UpgradeTestSuite) createRewardCollectorModuleAccount() string {
func (s *UpgradeTestSuite) setupRateLimitedHostZone(chainId, stDenom, channelId string) {
// Store host zone in stakeibc
s.App.StakeibcKeeper.SetHostZone(s.Ctx, stakeibctypes.HostZone{
ChainId: chainId,
HostDenom: strings.ReplaceAll(stDenom, "st", ""),
TransferChannelId: channelId,
Address: chainId + ".STAKEIBC",
FeeAccount: &stakeibctypes.ICAAccount{
Address: chainId + ".FEE",
},
DelegationAccount: &stakeibctypes.ICAAccount{
Address: chainId + ".DELEGATION",
},
ChainId: chainId,
HostDenom: strings.ReplaceAll(stDenom, "st", ""),
TransferChannelId: channelId,
DepositAddress: chainId + ".STAKEIBC",
FeeIcaAddress: chainId + ".FEE",
DelegationIcaAddress: chainId + ".DELEGATION",
})

// Create the transfer channel
Expand Down
Loading