-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add channel halt feature from the permissioned relayers (#256)
* add channel halt feature from the permissioned relayers * fix linter
- Loading branch information
Showing
31 changed files
with
2,122 additions
and
864 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,34 @@ | ||
package keeper | ||
|
||
import ( | ||
"cosmossdk.io/collections" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/initia-labs/initia/x/ibc/perm/types" | ||
) | ||
|
||
// InitGenesis initializes the ibc-perm state. | ||
func (k Keeper) InitGenesis(ctx sdk.Context, genesisState types.GenesisState) { | ||
|
||
for _, relayersByChannel := range genesisState.PermissionedRelayers { | ||
var channelRelayers []string | ||
for _, channelRelayer := range relayersByChannel.Relayers { | ||
_, err := k.ac.StringToBytes(channelRelayer) | ||
if err != nil { | ||
panic(err) | ||
} | ||
channelRelayers = append(channelRelayers, channelRelayer) | ||
} | ||
if err := k.PermissionedRelayers.Set(ctx, collections.Join(relayersByChannel.PortId, relayersByChannel.ChannelId), types.PermissionedRelayersList{ | ||
Relayers: channelRelayers, | ||
}); err != nil { | ||
for _, channelState := range genesisState.ChannelStates { | ||
err := k.SetChannelState(ctx, channelState) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
} | ||
|
||
// ExportGenesis exports ibc-perm module's channel relayers. | ||
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { | ||
channelRelayerSets := []types.PermissionedRelayers{} | ||
err := k.IteratePermissionedRelayers(ctx, func(channelRelayer types.PermissionedRelayers) (bool, error) { | ||
channelRelayerSets = append(channelRelayerSets, channelRelayer) | ||
channelStates := []types.ChannelState{} | ||
err := k.IterateChannelStates(ctx, func(channelRelayer types.ChannelState) (bool, error) { | ||
channelStates = append(channelStates, channelRelayer) | ||
return false, nil | ||
}) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return &types.GenesisState{ | ||
PermissionedRelayers: channelRelayerSets, | ||
ChannelStates: channelStates, | ||
} | ||
} |
Oops, something went wrong.