Skip to content

Commit

Permalink
Merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 27, 2024
2 parents 0e90633 + 9c7b57f commit db104f1
Show file tree
Hide file tree
Showing 25 changed files with 3,372 additions and 78 deletions.
1,714 changes: 1,689 additions & 25 deletions api/band/tunnel/v1beta1/route.pulsar.go

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import (
"github.com/bandprotocol/chain/v3/x/tss"
tsskeeper "github.com/bandprotocol/chain/v3/x/tss/keeper"
tsstypes "github.com/bandprotocol/chain/v3/x/tss/types"
"github.com/bandprotocol/chain/v3/x/tunnel"
tunnelkeeper "github.com/bandprotocol/chain/v3/x/tunnel/keeper"
tunneltypes "github.com/bandprotocol/chain/v3/x/tunnel/types"
)
Expand Down Expand Up @@ -137,6 +138,7 @@ type AppKeepers struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedOracleKeeper capabilitykeeper.ScopedKeeper
ScopedTunnelKeeper capabilitykeeper.ScopedKeeper
}

func NewAppKeeper(
Expand Down Expand Up @@ -197,6 +199,7 @@ func NewAppKeeper(
appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
appKeepers.ScopedOracleKeeper = appKeepers.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName)
appKeepers.ScopedTunnelKeeper = appKeepers.CapabilityKeeper.ScopeToModule(tunneltypes.ModuleName)

// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
// their scoped modules in `NewApp` with `ScopeToModule`
Expand Down Expand Up @@ -498,6 +501,9 @@ func NewAppKeeper(
appKeepers.BankKeeper,
appKeepers.FeedsKeeper,
appKeepers.BandtssKeeper,
appKeepers.IBCFeeKeeper,
appKeepers.IBCKeeper.PortKeeper,
appKeepers.ScopedTunnelKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

Expand Down Expand Up @@ -534,9 +540,13 @@ func NewAppKeeper(
// Create Oracle Stack
var oracleStack porttypes.IBCModule = oracle.NewIBCModule(appKeepers.OracleKeeper)

// Create Tunnel Stack
var tunnelStack porttypes.IBCModule = tunnel.NewIBCModule(appKeepers.TunnelKeeper)

ibcRouter := porttypes.NewRouter().AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(oracletypes.ModuleName, oracleStack)
AddRoute(oracletypes.ModuleName, oracleStack).
AddRoute(tunneltypes.ModuleName, tunnelStack)

appKeepers.IBCKeeper.SetRouter(ibcRouter)

Expand Down
30 changes: 30 additions & 0 deletions proto/band/tunnel/v1beta1/route.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package band.tunnel.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

import "band/feeds/v1beta1/feeds.proto";

option go_package = "github.com/bandprotocol/chain/v3/x/tunnel/types";
option (gogoproto.equal_all) = true;

Expand All @@ -27,3 +29,31 @@ message TSSPacketReceipt {
(gogoproto.casttype) = "github.com/bandprotocol/chain/v3/x/bandtss/types.SigningID"
];
}

// IBCRoute is the type for an IBC route
message IBCRoute {
option (cosmos_proto.implements_interface) = "Route";

// channel_id is the IBC channel ID
string channel_id = 1 [(gogoproto.customname) = "ChannelID"];
}

// IBCPacketReceipt represents a receipt for a IBC packet and implements the PacketReceiptI interface.
message IBCPacketReceipt {
option (cosmos_proto.implements_interface) = "PacketContentI";

// sequence is representing the sequence of the IBC packet.
uint64 sequence = 1;
}

// TunnelPricesPacketData represents the IBC packet payload for the tunnel packet.
message TunnelPricesPacketData {
// tunnel_id is the tunnel ID
uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
// sequence is representing the sequence of the tunnel packet.
uint64 sequence = 2;
// prices is the list of prices information from feeds module.
repeated band.feeds.v1beta1.Price prices = 3 [(gogoproto.nullable) = false];
// created_at is the timestamp when the packet is created
int64 created_at = 4;
}
1 change: 1 addition & 0 deletions scripts/tunnel/create_ibc_tunnel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bandd tx tunnel create-tunnel ibc channel-0 1 1uband 120 ./scripts/tunnel/signal_deviations.json --from requester --keyring-backend test --gas-prices 0.0025uband -y --chain-id bandchain
2 changes: 1 addition & 1 deletion x/oracle/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (im IBCModule) OnChanOpenAck(
ctx sdk.Context,
portID,
channelID string,
_ string,
counterpartyChannelID string,
counterpartyVersion string,
) error {
if counterpartyVersion != types.Version {
Expand Down
53 changes: 52 additions & 1 deletion x/tunnel/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func GetTxCmdCreateTunnel() *cobra.Command {
}

// add create tunnel subcommands
txCmd.AddCommand(GetTxCmdCreateTSSTunnel())
txCmd.AddCommand(GetTxCmdCreateTSSTunnel(), GetTxCmdCreateIBCTunnel())

return txCmd
}
Expand Down Expand Up @@ -104,6 +104,57 @@ func GetTxCmdCreateTSSTunnel() *cobra.Command {
return cmd
}

func GetTxCmdCreateIBCTunnel() *cobra.Command {
cmd := &cobra.Command{
Use: "ibc [channel-id] [encoder] [initial-deposit] [interval] [signalInfos-json-file]",
Short: "Create a new IBC tunnel",
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

encoder, err := strconv.ParseInt(args[1], 10, 32)
if err != nil {
return err
}

initialDeposit, err := sdk.ParseCoinsNormalized(args[2])
if err != nil {
return err
}

interval, err := strconv.ParseUint(args[3], 10, 64)
if err != nil {
return err
}

signalInfos, err := parseSignalDeviations(args[4])
if err != nil {
return err
}

msg, err := types.NewMsgCreateIBCTunnel(
signalInfos.ToSignalDeviations(),
interval,
args[0],
feedstypes.Encoder(encoder),
initialDeposit,
clientCtx.GetFromAddress(),
)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)
return cmd
}

func GetTxCmdUpdateAndResetTunnel() *cobra.Command {
cmd := &cobra.Command{
Use: "update-and-reset-tunnel [tunnel-id] [interval] [signalDeviations-json-file] ",
Expand Down
Loading

0 comments on commit db104f1

Please sign in to comment.