diff --git a/CHANGELOG.md b/CHANGELOG.md index a13d5d22..d0d04a3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ Contains all the PRs that improved the code without changing the behaviors. - [#538](https://github.com/archway-network/archway/pull/538) - Fixing the interchain test gh workflow failing cuz rc tags were not recognized - [#539](https://github.com/archway-network/archway/pull/539) - Remediations for x/callback audit - [#552](https://github.com/archway-network/archway/pull/552) - Fix issue with x/callback callback error code was not identified correctly when setting cwerrors +- [#559](https://github.com/archway-network/archway/pull/559) - Fixing wrong bond denom being considered for x/callback and x/cwerrors fees ## [v6.0.0](https://github.com/archway-network/archway/releases/tag/v6.0.0) diff --git a/app/upgrades/7_0_0/upgrades.go b/app/upgrades/7_0_0/upgrades.go index d7215470..4cfceae9 100644 --- a/app/upgrades/7_0_0/upgrades.go +++ b/app/upgrades/7_0_0/upgrades.go @@ -38,6 +38,7 @@ var Upgrade = upgrades.Upgrade{ } ctx.Logger().Info("Setting default params for the new modules") + bondDenom := keepers.StakingKeeper.BondDenom(ctx) // Setting callback params callbackParams, err := keepers.CallbackKeeper.GetParams(ctx) if err != nil { @@ -58,9 +59,9 @@ var Upgrade = upgrades.Upgrade{ if err != nil { return nil, err } - cwerrorsParams.ErrorStoredTime = 302400 // roughly 21 days - cwerrorsParams.SubscriptionFee = sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000000000000000) // 1 ARCH (1e18 attoarch) - cwerrorsParams.SubscriptionPeriod = 302400 // roughly 21 days + cwerrorsParams.ErrorStoredTime = 302400 // roughly 21 days + cwerrorsParams.SubscriptionFee = sdk.NewInt64Coin(bondDenom, 1000000000000000000) // 1 ARCH (1e18 attoarch) + cwerrorsParams.SubscriptionPeriod = 302400 // roughly 21 days err = keepers.CWErrorsKeeper.SetParams(ctx, cwerrorsParams) if err != nil { return nil, err diff --git a/x/callback/keeper/fees.go b/x/callback/keeper/fees.go index 912bfbce..21c02029 100644 --- a/x/callback/keeper/fees.go +++ b/x/callback/keeper/fees.go @@ -29,7 +29,6 @@ func (k Keeper) EstimateCallbackFees(ctx sdk.Context, blockHeight int64) (sdk.Co } // futureReservationFeeMultiplies * (requestBlockHeight - currentBlockHeight) futureReservationFeesAmount := params.FutureReservationFeeMultiplier.MulInt64((blockHeight - ctx.BlockHeight())) - futureReservationFee := sdk.NewCoin(sdk.DefaultBondDenom, futureReservationFeesAmount.RoundInt()) // Calculates the fees based on how many callbacks are registered at the given block height callbacksForHeight, err := k.GetCallbacksByHeight(ctx, blockHeight) @@ -42,15 +41,17 @@ func (k Keeper) EstimateCallbackFees(ctx sdk.Context, blockHeight int64) (sdk.Co } // blockReservationFeeMultiplier * totalCallbacksRegistered blockReservationFeesAmount := params.BlockReservationFeeMultiplier.MulInt64(int64(totalCallbacks)) - blockReservationFee := sdk.NewCoin(sdk.DefaultBondDenom, blockReservationFeesAmount.RoundInt()) // Calculates the fees based on the max gas limit of the callback and current price of gas transactionFee := k.CalculateTransactionFees(ctx, params.GetCallbackGasLimit()) + futureReservationFee := sdk.NewCoin(transactionFee.Denom, futureReservationFeesAmount.RoundInt()) + blockReservationFee := sdk.NewCoin(transactionFee.Denom, blockReservationFeesAmount.RoundInt()) return futureReservationFee, blockReservationFee, transactionFee, nil } func (k Keeper) CalculateTransactionFees(ctx sdk.Context, gasAmount uint64) sdk.Coin { - transactionFeeAmount := k.rewardsKeeper.ComputationalPriceOfGas(ctx).Amount.MulInt64(int64(gasAmount)) - transactionFee := sdk.NewCoin(sdk.DefaultBondDenom, transactionFeeAmount.RoundInt()) + computationPriceOfGas := k.rewardsKeeper.ComputationalPriceOfGas(ctx) + transactionFeeAmount := computationPriceOfGas.Amount.MulInt64(int64(gasAmount)) + transactionFee := sdk.NewCoin(computationPriceOfGas.Denom, transactionFeeAmount.RoundInt()) return transactionFee } diff --git a/x/callback/types/msg.go b/x/callback/types/msg.go index ff5f67de..66f47777 100644 --- a/x/callback/types/msg.go +++ b/x/callback/types/msg.go @@ -46,9 +46,6 @@ func (m MsgRequestCallback) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.ContractAddress); err != nil { return errorsmod.Wrapf(sdkErrors.ErrInvalidAddress, "invalid contract address: %v", err) } - if m.Fees.Denom != sdk.DefaultBondDenom { - return errorsmod.Wrapf(sdkErrors.ErrInvalidCoins, "invalid fees denom: %v", m.Fees.Denom) - } return nil }