Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
codehans committed Mar 26, 2024
2 parents d31cc07 + 9dcf692 commit 3963a4e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
2 changes: 1 addition & 1 deletion x/batch/wasm/interface_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type BatchMsg struct {
// Contracts can withdraw all rewards for the delegations from the contract.
WithdrawAllDelegatorRewards *WithdrawAllDelegatorRewards `json:"withdrawAllDelegatorRewards,omitempty"`
WithdrawAllDelegatorRewards *WithdrawAllDelegatorRewards `json:"withdraw_all_delegator_rewards,omitempty"`
}

type WithdrawAllDelegatorRewards struct{}
Expand Down
50 changes: 45 additions & 5 deletions x/cw-ica/keeper/ibc_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"strings"

"cosmossdk.io/errors"
"github.com/Team-Kujira/core/x/cw-ica/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/Team-Kujira/core/x/cw-ica/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
)

Expand Down Expand Up @@ -63,6 +62,8 @@ func (k *Keeper) createCachedContext(ctx sdk.Context) (sdk.Context, func(), sdk.
}

gasMeter = sdk.NewGasMeter(newLimit)
} else {
gasMeter = sdk.NewInfiniteGasMeter()
}

cacheCtx = cacheCtx.WithGasMeter(gasMeter)
Expand Down Expand Up @@ -101,7 +102,20 @@ func (k *Keeper) HandleAcknowledgement(ctx sdk.Context, packet channeltypes.Pack
}

if err != nil {
k.Logger(ctx).Debug("HandleAcknowledgement: failed to Sudo contract on packet acknowledgement", "error", err)
k.Logger(ctx).Debug(
"HandleAcknowledgement: failed to Sudo contract on packet acknowledgement",
"source_port", packet.SourcePort,
"source_channel", packet.SourceChannel,
"sequence", packet.Sequence,
"error", err)
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeICATxCallbackFailure,
sdk.NewAttribute(types.AttributePacketSourcePort, packet.SourcePort),
sdk.NewAttribute(types.AttributePacketSourceChannel, packet.SourceChannel),
sdk.NewAttribute(types.AttributePacketSequence, fmt.Sprintf("%d", packet.Sequence)),
),
})
} else {
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
writeFn()
Expand All @@ -124,7 +138,20 @@ func (k *Keeper) HandleTimeout(ctx sdk.Context, packet channeltypes.Packet, _ sd
Timeout: &types.IcaCallbackTimeout{},
})
if err != nil {
k.Logger(ctx).Error("HandleTimeout: failed to Sudo contract on packet timeout", "port", packet.SourcePort, "error", err)
k.Logger(ctx).Debug(
"HandleTimeout: failed to Sudo contract on packet timeout",
"source_port", packet.SourcePort,
"source_channel", packet.SourceChannel,
"sequence", packet.Sequence,
"error", err)
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeICATimeoutCallbackFailure,
sdk.NewAttribute(types.AttributePacketSourcePort, packet.SourcePort),
sdk.NewAttribute(types.AttributePacketSourceChannel, packet.SourceChannel),
sdk.NewAttribute(types.AttributePacketSequence, fmt.Sprintf("%d", packet.Sequence)),
),
})
} else {
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
writeFn()
Expand Down Expand Up @@ -165,10 +192,23 @@ func (k *Keeper) HandleChanOpenAck(
},
})
if err != nil {
k.Logger(ctx).Error("SudoCallback failure", "error", err)
k.Logger(ctx).Error(
"HandleChanOpenAck: failed to Sudo contract on packet ChanOpenAck",
"port", portID,
"channel", channelID,
"error", err)
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeICARegisterCallbackFailure,
sdk.NewAttribute(types.AttributePacketSourcePort, portID),
sdk.NewAttribute(types.AttributePacketSourceChannel, channelID),
),
})
} else {
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
writeFn()
}
ctx.GasMeter().ConsumeGas(newGasMeter.GasConsumed(), "consume from cached context")

// remove the callback data
k.RemoveCallbackData(ctx, callbackDataKey)
Expand Down
14 changes: 14 additions & 0 deletions x/cw-ica/types/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package types

const (
EventTypeICATxCallbackFailure = "ica_tx_callback_failure"
EventTypeICARegisterCallbackFailure = "ica_register_callback_failure"
EventTypeICATimeoutCallbackFailure = "ica_timeout_callback_failure"
)

// event attributes returned
const (
AttributePacketSourcePort = "source_port"
AttributePacketSourceChannel = "source_channel"
AttributePacketSequence = "sequence"
)

0 comments on commit 3963a4e

Please sign in to comment.