Skip to content

Commit

Permalink
use contents of 1 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt committed Jun 12, 2024
1 parent 473caf5 commit 559feca
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 409 deletions.
32 changes: 10 additions & 22 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ func New(
keys[rollappmoduletypes.StoreKey],
keys[rollappmoduletypes.MemStoreKey],
app.GetSubspace(rollappmoduletypes.ModuleName),
app.IBCKeeper.ClientKeeper,
app.IBCKeeper.ChannelKeeper,
app.BankKeeper,
)
Expand All @@ -635,21 +634,6 @@ func New(
scopedTransferKeeper,
)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
transferinject.NewIBCSendMiddleware(app.IBCKeeper.ChannelKeeper, app.RollappKeeper, app.BankKeeper),
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
)

app.RollappKeeper.SetTransferKeeper(app.TransferKeeper)

app.SequencerKeeper = *sequencermodulekeeper.NewKeeper(
appCodec,
keys[sequencermoduletypes.StoreKey],
Expand Down Expand Up @@ -760,13 +744,12 @@ func New(
transferMiddleware := ibctransfer.NewIBCModule(app.TransferKeeper)

var transferStack ibcporttypes.IBCModule
transferStack = bridging_fee.NewIBCMiddleware(
transferStack = bridgingfee.NewIBCModule(
transferMiddleware,
app.IBCKeeper.ChannelKeeper,
app.DelayedAckKeeper,
app.RollappKeeper,
app.TransferKeeper,
app.AccountKeeper.GetModuleAddress(txfeestypes.ModuleName),
app.RollappKeeper,
)

transferStack = packetforwardmiddleware.NewIBCMiddleware(
Expand All @@ -776,8 +759,13 @@ func New(
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)
delayedAckMiddleware := delayedackmodule.NewIBCMiddleware(transferStack, app.DelayedAckKeeper, app.RollappKeeper)
transferStack = transferinject.NewIBCAckMiddleware(delayedAckMiddleware, app.RollappKeeper)

var delayedAckMiddleware ibcporttypes.Middleware
delayedAckMiddleware = delayedackmodule.NewIBCMiddleware(transferStack, app.DelayedAckKeeper, app.RollappKeeper)
transferStack = delayedAckMiddleware
transferStack = transferinject.NewIBCModule(transferStack, app.RollappKeeper)
transferStack = transfergenesis.NewIBCModule(transferStack, app.DelayedAckKeeper, app.RollappKeeper, app.TransferKeeper, app.DenomMetadataKeeper)
transferStack = transfergenesis.NewIBCModuleCanonicalChannelHack(transferStack, app.RollappKeeper, app.IBCKeeper.ChannelKeeper.GetChannelClientState)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand All @@ -789,7 +777,7 @@ func New(
app.RollappKeeper.SetHooks(rollappmoduletypes.NewMultiRollappHooks(
// insert rollapp hooks receivers here
app.SequencerKeeper.RollappHooks(),
delayedAckMiddleware,
delayedAckMiddleware.(delayedackmodule.IBCMiddleware),
))

/**** Module Options ****/
Expand Down
5 changes: 0 additions & 5 deletions testutil/keeper/delayedack.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
Expand Down Expand Up @@ -115,10 +114,6 @@ func (RollappKeeperStub) GetAllRollapps(ctx sdk.Context) (list []rollapptypes.Ro
return []rollapptypes.Rollapp{}
}

func (r RollappKeeperStub) ExtractRollappIDAndTransferPacketFromData(sdk.Context, []byte, string, string) (string, *transfertypes.FungibleTokenPacketData, error) {
return "rollappID", &transfertypes.FungibleTokenPacketData{}, nil
}

type SequencerKeeperStub struct{}

func (SequencerKeeperStub) GetSequencer(ctx sdk.Context, sequencerAddress string) (val sequencertypes.Sequencer, found bool) {
Expand Down
21 changes: 21 additions & 0 deletions utils/ibc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package utils

import (
transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
)

const (
ibcPort = "transfer"
)

func GetForeignIBCDenom(channelId string, denom string) string {
return GetForeignDenomTrace(channelId, denom).IBCDenom()
}

func GetForeignDenomTrace(channelId string, denom string) transfertypes.DenomTrace {
sourcePrefix := transfertypes.GetDenomPrefix(ibcPort, channelId)
// NOTE: sourcePrefix contains the trailing "/"
prefixedDenom := sourcePrefix + denom
// construct the denomination trace from the full raw denomination
return transfertypes.ParseDenomTrace(prefixedDenom)
}
6 changes: 6 additions & 0 deletions x/bridging_fee/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package bridging_fee

const (
EventTypeBridgingFee = "bridging_fee"
AttributeKeyFee = "fee"
)
10 changes: 5 additions & 5 deletions x/delayedack/eibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (w IBCMiddleware) eIBCDemandOrderHandler(ctx sdk.Context, rollappPacket com
var feeMultiplier sdk.Dec
switch t {
case commontypes.RollappPacket_ON_TIMEOUT:
feeMultiplier = im.TimeoutFee(ctx)
feeMultiplier = w.TimeoutFee(ctx)

Check failure on line 46 in x/delayedack/eibc.go

View workflow job for this annotation

GitHub Actions / golangci-lint

w.TimeoutFee undefined (type IBCMiddleware has no field or method TimeoutFee) (typecheck)
case commontypes.RollappPacket_ON_ACK:
feeMultiplier = im.ErrAckFee(ctx)
feeMultiplier = w.ErrAckFee(ctx)

Check failure on line 48 in x/delayedack/eibc.go

View workflow job for this annotation

GitHub Actions / golangci-lint

w.ErrAckFee undefined (type IBCMiddleware has no field or method ErrAckFee) (typecheck)
}
fee := amountDec.Mul(feeMultiplier).TruncateInt()
if !fee.IsPositive() {
Expand All @@ -64,7 +64,7 @@ func (w IBCMiddleware) eIBCDemandOrderHandler(ctx sdk.Context, rollappPacket com
return fmt.Errorf("create eibc demand order: %w", err)
}

err = im.SetDemandOrder(ctx, eibcDemandOrder)
err = w.SetDemandOrder(ctx, eibcDemandOrder)

Check failure on line 67 in x/delayedack/eibc.go

View workflow job for this annotation

GitHub Actions / golangci-lint

w.SetDemandOrder undefined (type IBCMiddleware has no field or method SetDemandOrder) (typecheck)
if err != nil {
return fmt.Errorf("set eibc demand order: %w", err)
}
Expand All @@ -86,7 +86,7 @@ func (w IBCMiddleware) createDemandOrderFromIBCPacket(ctx sdk.Context, fungibleT
return nil, fmt.Errorf("validate eibc metadata: %w", err)
}
// Verify the original recipient is not a blocked sender otherwise could potentially use eibc to bypass it
if im.BlockedAddr(fungibleTokenPacketData.Receiver) {
if w.BlockedAddr(fungibleTokenPacketData.Receiver) {

Check failure on line 89 in x/delayedack/eibc.go

View workflow job for this annotation

GitHub Actions / golangci-lint

w.BlockedAddr undefined (type IBCMiddleware has no field or method BlockedAddr) (typecheck)
return nil, fmt.Errorf("not allowed to receive funds: receiver: %s", fungibleTokenPacketData.Receiver)
}
// Calculate the demand order price and validate it,
Expand Down Expand Up @@ -126,7 +126,7 @@ func (w IBCMiddleware) createDemandOrderFromIBCPacket(ctx sdk.Context, fungibleT
demandOrderDenom = trace.IBCDenom()
demandOrderRecipient = fungibleTokenPacketData.Sender // and who tried to send it (refund because it failed)
case commontypes.RollappPacket_ON_RECV:
bridgingFee := im.BridgingFeeFromAmt(ctx, amt)
bridgingFee := w.BridgingFeeFromAmt(ctx, amt)

Check failure on line 129 in x/delayedack/eibc.go

View workflow job for this annotation

GitHub Actions / golangci-lint

w.BridgingFeeFromAmt undefined (type IBCMiddleware has no field or method BridgingFeeFromAmt) (typecheck)
if bridgingFee.GT(fee) {
// We check that the fee the fulfiller makes is at least as big as the bridging fee they will have to pay later
// this is to improve UX and help fulfillers not lose money.
Expand Down
Loading

0 comments on commit 559feca

Please sign in to comment.