diff --git a/x/crosschain/keeper/abci.go b/x/crosschain/keeper/abci.go index 1a5dcee81b..d74a524bd7 100644 --- a/x/crosschain/keeper/abci.go +++ b/x/crosschain/keeper/abci.go @@ -120,7 +120,7 @@ func CheckAndUpdateCctxGasPrice( // compute gas price increase chainID := cctx.GetCurrentOutboundParam().ReceiverChainId - medianGasPrice, priorityFee, isFound := k.GetMedianGasPriceInUint(ctx, chainID) + medianGasPrice, priorityFee, isFound := k.GetMedianGasValues(ctx, chainID) if !isFound { return math.ZeroUint(), math.ZeroUint(), cosmoserrors.Wrap( types.ErrUnableToGetGasPrice, diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index 70a15d183f..7c6a1056f7 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -116,6 +116,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) { flags observertypes.GasPriceIncreaseFlags blockTimestamp time.Time medianGasPrice uint64 + medianPriorityFee uint64 withdrawFromGasStabilityPoolReturn error expectWithdrawFromGasStabilityPoolCall bool expectedGasPriceIncrease math.Uint @@ -140,6 +141,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) { flags: observertypes.DefaultGasPriceIncreaseFlags, blockTimestamp: retryIntervalReached, medianGasPrice: 50, + medianPriorityFee: 60, withdrawFromGasStabilityPoolReturn: nil, expectWithdrawFromGasStabilityPoolCall: true, expectedGasPriceIncrease: math.NewUint(50), // 100% medianGasPrice @@ -354,15 +356,17 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) { // set median gas price if not zero if tc.medianGasPrice != 0 { k.SetGasPrice(ctx, types.GasPrice{ - ChainId: chainID, - Prices: []uint64{tc.medianGasPrice}, - MedianIndex: 0, + ChainId: chainID, + Prices: []uint64{tc.medianGasPrice}, + PriorityFees: []uint64{tc.medianPriorityFee}, + MedianIndex: 0, }) // ensure median gas price is set - medianGasPrice, _, isFound := k.GetMedianGasPriceInUint(ctx, chainID) + medianGasPrice, medianPriorityFee, isFound := k.GetMedianGasValues(ctx, chainID) require.True(t, isFound) require.True(t, medianGasPrice.Equal(math.NewUint(tc.medianGasPrice))) + require.True(t, medianPriorityFee.Equal(math.NewUint(tc.medianPriorityFee))) } // set block timestamp diff --git a/x/crosschain/keeper/cctx_gateway_observers.go b/x/crosschain/keeper/cctx_gateway_observers.go index 8df278c54f..c8ae0d718e 100644 --- a/x/crosschain/keeper/cctx_gateway_observers.go +++ b/x/crosschain/keeper/cctx_gateway_observers.go @@ -63,7 +63,7 @@ func (c CCTXGatewayObservers) InitiateOutbound( return err } } else { - gasPrice, priorityFee, found := c.crosschainKeeper.GetMedianGasPriceInUint(ctx, config.CCTX.GetCurrentOutboundParam().ReceiverChainId) + gasPrice, priorityFee, found := c.crosschainKeeper.GetMedianGasValues(ctx, config.CCTX.GetCurrentOutboundParam().ReceiverChainId) if !found { return fmt.Errorf("gasprice not found for %d", config.CCTX.GetCurrentOutboundParam().ReceiverChainId) } diff --git a/x/crosschain/keeper/gas_payment.go b/x/crosschain/keeper/gas_payment.go index 92949d8d6d..9d40ae4553 100644 --- a/x/crosschain/keeper/gas_payment.go +++ b/x/crosschain/keeper/gas_payment.go @@ -81,7 +81,7 @@ func (k Keeper) ChainGasParams(ctx sdk.Context, chainID int64) (ChainGasParams, } // get the gas price - gasPrice, priorityFee, isFound := k.GetMedianGasPriceInUint(ctx, chainID) + gasPrice, priorityFee, isFound := k.GetMedianGasValues(ctx, chainID) if !isFound { return ChainGasParams{}, types.ErrUnableToGetGasPrice } @@ -330,7 +330,7 @@ func (k Keeper) PayGasInZetaAndUpdateCctx( } // get the gas price - gasPrice, priorityFee, isFound := k.GetMedianGasPriceInUint(ctx, chainID) + gasPrice, priorityFee, isFound := k.GetMedianGasValues(ctx, chainID) if !isFound { return cosmoserrors.Wrapf(types.ErrUnableToGetGasPrice, "chain %d; identifiers %q", diff --git a/x/crosschain/keeper/gas_price.go b/x/crosschain/keeper/gas_price.go index d5857b7820..322aee53f5 100644 --- a/x/crosschain/keeper/gas_price.go +++ b/x/crosschain/keeper/gas_price.go @@ -34,9 +34,8 @@ func (k Keeper) GetGasPrice(ctx sdk.Context, chainID int64) (types.GasPrice, boo return val, true } -// GetMedianGasPriceInUint returns the median gas price (and median priority fee) from the store -// or false if it doesn't exist. -func (k Keeper) GetMedianGasPriceInUint(ctx sdk.Context, chainID int64) (math.Uint, math.Uint, bool) { +// GetMedianGasValues returns *median* gas price and priority fee (for EIP-1559) from the store or false if it doesn't exist. +func (k Keeper) GetMedianGasValues(ctx sdk.Context, chainID int64) (math.Uint, math.Uint, bool) { entity, found := k.GetGasPrice(ctx, chainID) if !found { return math.ZeroUint(), math.ZeroUint(), false diff --git a/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go b/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go index 143469099f..6c8974db5d 100644 --- a/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go +++ b/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go @@ -25,7 +25,7 @@ func (k Keeper) ConvertGasToZeta( return nil, zetaObserverTypes.ErrSupportedChains } - medianGasPrice, _, isFound := k.GetMedianGasPriceInUint(ctx, chain.ChainId) + medianGasPrice, _, isFound := k.GetMedianGasValues(ctx, chain.ChainId) if !isFound { return nil, status.Error(codes.InvalidArgument, "invalid request: param chain") } diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds.go b/x/crosschain/keeper/msg_server_migrate_tss_funds.go index 590dc14c77..4428420b8c 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds.go @@ -89,7 +89,7 @@ func (k Keeper) MigrateTSSFundsForChain( ) error { // Always migrate to the latest TSS if multiple TSS addresses have been generated newTss := tssList[len(tssList)-1] - medianGasPrice, priorityFee, isFound := k.GetMedianGasPriceInUint(ctx, chainID) + medianGasPrice, priorityFee, isFound := k.GetMedianGasValues(ctx, chainID) if !isFound { return types.ErrUnableToGetGasPrice } diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go index c1db1816ae..0c35af8772 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go @@ -100,7 +100,7 @@ func TestKeeper_MigrateTSSFundsForChain(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) indexString, _ := setupTssMigrationParams(zk, k, ctx, chain, amount, true, true) - gp, priorityFee, found := k.GetMedianGasPriceInUint(ctx, chain.ChainId) + gp, priorityFee, found := k.GetMedianGasValues(ctx, chain.ChainId) require.True(t, found) msg := crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -134,7 +134,7 @@ func TestKeeper_MigrateTSSFundsForChain(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) indexString, _ := setupTssMigrationParams(zk, k, ctx, chain, amount, true, true) - gp, priorityFee, found := k.GetMedianGasPriceInUint(ctx, chain.ChainId) + gp, priorityFee, found := k.GetMedianGasValues(ctx, chain.ChainId) require.True(t, found) msg := crosschaintypes.MsgMigrateTssFunds{ diff --git a/x/crosschain/keeper/msg_server_whitelist_erc20.go b/x/crosschain/keeper/msg_server_whitelist_erc20.go index 42850804e9..8590361c13 100644 --- a/x/crosschain/keeper/msg_server_whitelist_erc20.go +++ b/x/crosschain/keeper/msg_server_whitelist_erc20.go @@ -105,7 +105,7 @@ func (k msgServer) WhitelistERC20( if !found { return nil, errorsmod.Wrapf(types.ErrInvalidChainID, "chain params not found for chain id (%d)", msg.ChainId) } - medianGasPrice, priorityFee, isFound := k.GetMedianGasPriceInUint(ctx, msg.ChainId) + medianGasPrice, priorityFee, isFound := k.GetMedianGasValues(ctx, msg.ChainId) if !isFound { return nil, errorsmod.Wrapf( types.ErrUnableToGetGasPrice,