Skip to content

Commit

Permalink
fix: audit fix (#245)
Browse files Browse the repository at this point in the history
* fix autocli

* rename SpotPrice to QuoteSpotPrice with rounding correction

* fix to handle with_json at cosmos message handler

* remove unused zero gas limit checking

* recover panic at reward withdrawal to prevent chain halt

* use single operation

* remove redundant functions

* fix naming consistency

* fix to use proper variable for class prefix

* use minimum replace

* bump go version
  • Loading branch information
beer-1 authored Aug 9, 2024
1 parent 91cfb35 commit d488e00
Show file tree
Hide file tree
Showing 26 changed files with 257 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-darwin-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.4"
go-version: "1.22.5"
- name: Set environment variables
run: |
L1_NETWORK_NAME="initiation-1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-darwin-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.4"
go-version: "1.22.5"
- name: Set environment variables
run: |
L1_NETWORK_NAME="initiation-1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-linux-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.4"
go-version: "1.22.5"

- name: Set environment variables
run: |
Expand Down
19 changes: 9 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.4.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/gogo/protobuf v1.3.3
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.1
Expand Down Expand Up @@ -217,27 +217,26 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

// initia custom
replace (
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

// use custom version for
// - https://github.com/initia-labs/cometbft/commit/cb3ed4ca9be4d6c55df7df2d927e9b92153bc3e2
github.com/cometbft/cometbft => github.com/initia-labs/cometbft v0.0.0-20240802022359-e0a5ce0336b6
// use v1.1.4 for
// - https://github.com/cosmos/iavl/commit/021433c2ed0b64223f90315a3421eb645e1f08fe
github.com/cosmos/iavl => github.com/cosmos/iavl v1.1.4
)

// cosmos replaces
replace (
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2

// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1

github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

// Downgraded to avoid bugs in following commits which caused simulations to fail.
// replace broken goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
13 changes: 10 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG
github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0=
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4=
Expand Down Expand Up @@ -757,6 +763,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
Expand Down Expand Up @@ -951,8 +959,6 @@ github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Ung
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4=
github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down Expand Up @@ -1417,8 +1423,10 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
Expand Down Expand Up @@ -1569,7 +1577,6 @@ google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfG
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
Expand Down
8 changes: 4 additions & 4 deletions x/ibc/nft-transfer/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func (suite *KeeperTestSuite) CreateNftClass(
ctx,
vmtypes.TestAddress,
vmtypes.StdAddress,
movetypes.MoveModuleNameSimpleNft,
movetypes.FunctionNameSimpleNftInitialize,
movetypes.MoveModuleNameInitiaNft,
movetypes.FunctionNameInitiaNftCreateCollection,
[]vmtypes.TypeTag{},
[][]byte{descBz, {0}, nameBz, uriBz, {0}, {0}, {0}, {0}, {0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
)
Expand Down Expand Up @@ -75,8 +75,8 @@ func (suite *KeeperTestSuite) MintNft(
endpoint.Chain.GetContext(),
vmtypes.TestAddress,
vmtypes.StdAddress,
movetypes.MoveModuleNameSimpleNft,
movetypes.FunctionNameSimpleNftMint,
movetypes.MoveModuleNameInitiaNft,
movetypes.FunctionNameInitiaNftMint,
[]vmtypes.TypeTag{},
[][]byte{classNameBz, dataBz, idBz, uriBz, {1}, append([]byte{1}, receiverAddr[:]...)},
)
Expand Down
4 changes: 2 additions & 2 deletions x/move/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper, vc address.Codec) error
return err
}

rewardPools, err := k.WithdrawRewards(ctx, valAddr)
rewardPools, err := k.SafeWithdrawRewards(ctx, valAddr)
if err != nil {
return err
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper, vc address.Codec) error
vmtypes.StdAddress,
vmtypes.StdAddress,
types.MoveModuleNameStaking,
types.FunctionNameStakingDepositReward,
types.FunctionNameStakingDepositRewardForChain,
[]vmtypes.TypeTag{},
args,
); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions x/move/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Test_BeginBlocker(t *testing.T) {
Sender: addr2.String(),
ModuleAddress: types.StdAddr.String(),
ModuleName: types.MoveModuleNameStaking,
FunctionName: types.FunctionNameStakingDelegate,
FunctionName: types.FunctionNameStakingDelegateScript,
TypeArgs: []string{},
Args: [][]byte{metadataLP[:], valAddrArg, amountArg},
}
Expand Down Expand Up @@ -98,7 +98,7 @@ func Test_BeginBlocker(t *testing.T) {
Sender: addr2.String(),
ModuleAddress: types.StdAddr.String(),
ModuleName: types.MoveModuleNameStaking,
FunctionName: types.FunctionNameStakingUndelegate,
FunctionName: types.FunctionNameStakingUndelegateScript,
TypeArgs: []string{},
Args: [][]byte{metadataLP[:], valAddrArg, amountArg},
}
Expand Down
2 changes: 1 addition & 1 deletion x/move/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (fc MempoolFeeChecker) fetchPrice(ctx sdk.Context, baseDenom, quoteDenom st
return math.LegacyZeroDec(), nil
}

if quotePrice, err := fc.keeper.GetPoolSpotPrice(ctx, quoteDenom); err != nil {
if quotePrice, err := fc.keeper.GetQuoteSpotPrice(ctx, quoteDenom); err != nil {
return math.LegacyZeroDec(), err
} else {
return quotePrice, nil
Expand Down
8 changes: 4 additions & 4 deletions x/move/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (k TestAnteKeeper) HasDexPair(_ context.Context, denomQuote string) (bool,
return true, nil
}

func (k TestAnteKeeper) GetPoolSpotPrice(_ context.Context, denomQuote string) (quotePrice math.LegacyDec, err error) {
func (k TestAnteKeeper) GetQuoteSpotPrice(_ context.Context, denomQuote string) (quotePrice math.LegacyDec, err error) {
balances, found := k.pools[denomQuote]
if !found {
return math.LegacyZeroDec(), fmt.Errorf("not found")
Expand All @@ -49,7 +49,7 @@ func (k TestAnteKeeper) GetPoolSpotPrice(_ context.Context, denomQuote string) (
return math.LegacyZeroDec(), fmt.Errorf("not found")
}

return types.GetPoolSpotPrice(balances[0], balances[1], weights[0], weights[1]), nil
return types.GetQuoteSpotPrice(balances[0], balances[1], weights[0], weights[1]), nil
}

func (k TestAnteKeeper) BaseDenom(_ context.Context) (string, error) {
Expand All @@ -66,8 +66,8 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() {

dexPools := make(map[string][]math.Int)
dexPools["atom"] = []math.Int{
math.NewInt(1), // base
math.NewInt(2), // quote
math.NewInt(10), // base
math.NewInt(20), // quote
}

dexWeights := make(map[string][]math.LegacyDec)
Expand Down
18 changes: 1 addition & 17 deletions x/move/keeper/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ func NewCodeKeeper(k *Keeper) CodeKeeper {
return CodeKeeper{k}
}

// Load the code params from the move store
func (k CodeKeeper) GetParams(ctx context.Context) ([]vmtypes.AccountAddress, error) {
bz, err := k.GetResourceBytes(ctx, vmtypes.StdAddress, vmtypes.StructTag{
Address: vmtypes.StdAddress,
Module: vmtypes.Identifier(types.MoveModuleNameCode),
Name: vmtypes.Identifier(types.ResourceNameModuleStore),
TypeArgs: []vmtypes.TypeTag{},
})
if err != nil {
return nil, err
}

return types.ReadCodeModuleStore(bz)
}

// Load the allowed_publishers from the move store
func (k CodeKeeper) GetAllowedPublishers(ctx context.Context) ([]vmtypes.AccountAddress, error) {
bz, err := k.GetResourceBytes(ctx, vmtypes.StdAddress, vmtypes.StructTag{
Expand All @@ -43,8 +28,7 @@ func (k CodeKeeper) GetAllowedPublishers(ctx context.Context) ([]vmtypes.Account
return nil, err
}

allowedPublishers, err := types.ReadCodeModuleStore(bz)
return allowedPublishers, err
return types.ReadCodeModuleStore(bz)
}

// Store the allowed_publishers to move store.
Expand Down
6 changes: 3 additions & 3 deletions x/move/keeper/code_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
"github.com/stretchr/testify/require"
)

func Test_CodeKeeper_GetParams(t *testing.T) {
func Test_CodeKeeper_GetAllowedPublishers(t *testing.T) {
ctx, input := createDefaultTestInput(t)

allowedPublishers, err := keeper.NewCodeKeeper(&input.MoveKeeper).GetParams(ctx)
allowedPublishers, err := keeper.NewCodeKeeper(&input.MoveKeeper).GetAllowedPublishers(ctx)
require.NoError(t, err)
require.Empty(t, allowedPublishers)
}

func Test_CodeKeeper_SetParams(t *testing.T) {
func Test_CodeKeeper_SetAllowedPublishers(t *testing.T) {
ctx, input := createDefaultTestInput(t)
codeKeeper := keeper.NewCodeKeeper(&input.MoveKeeper)

Expand Down
28 changes: 28 additions & 0 deletions x/move/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,21 @@ func (router TestMsgRouter) HandlerByTypeURL(typeURL string) baseapp.MsgServiceH
sdk.NewAttribute("args", strings.Join(argStrs, ",")),
))

return sdk.WrapServiceResult(ctx, &stakingtypes.MsgDelegateResponse{}, nil)
}
case sdk.MsgTypeURL(&movetypes.MsgExecuteJSON{}):
return func(ctx sdk.Context, _msg sdk.Msg) (*sdk.Result, error) {
msg := _msg.(*movetypes.MsgExecuteJSON)

ctx.EventManager().EmitEvent(sdk.NewEvent("move_execute_with_json",
sdk.NewAttribute("sender", msg.Sender),
sdk.NewAttribute("module_addr", msg.ModuleAddress),
sdk.NewAttribute("module_name", msg.ModuleName),
sdk.NewAttribute("function_name", msg.FunctionName),
sdk.NewAttribute("type_args", strings.Join(msg.TypeArgs, ",")),
sdk.NewAttribute("args", strings.Join(msg.Args, ",")),
))

return sdk.WrapServiceResult(ctx, &stakingtypes.MsgDelegateResponse{}, nil)
}
case sdk.MsgTypeURL(&movetypes.MsgScript{}):
Expand All @@ -558,6 +573,19 @@ func (router TestMsgRouter) HandlerByTypeURL(typeURL string) baseapp.MsgServiceH
sdk.NewAttribute("args", strings.Join(argStrs, ",")),
))

return sdk.WrapServiceResult(ctx, &stakingtypes.MsgDelegateResponse{}, nil)
}
case sdk.MsgTypeURL(&movetypes.MsgScriptJSON{}):
return func(ctx sdk.Context, _msg sdk.Msg) (*sdk.Result, error) {
msg := _msg.(*movetypes.MsgScriptJSON)

ctx.EventManager().EmitEvent(sdk.NewEvent("move_script_with_json",
sdk.NewAttribute("sender", msg.Sender),
sdk.NewAttribute("code_bytes", hex.EncodeToString(msg.CodeBytes)),
sdk.NewAttribute("type_args", strings.Join(msg.TypeArgs, ",")),
sdk.NewAttribute("args", strings.Join(msg.Args, ",")),
))

return sdk.WrapServiceResult(ctx, &stakingtypes.MsgDelegateResponse{}, nil)
}
case sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}):
Expand Down
8 changes: 4 additions & 4 deletions x/move/keeper/dex.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ func (k Keeper) getMetadataLP(
return vmtypes.NewAccountAddressFromBytes(bz)
}

// GetPoolSpotPrice return quote price in base unit
// GetQuoteSpotPrice return quote price in base unit
// `price` * `quote_amount` == `quote_value_in_base_unit`
func (k DexKeeper) GetPoolSpotPrice(
func (k DexKeeper) GetQuoteSpotPrice(
ctx context.Context,
denomQuote string,
) (math.LegacyDec, error) {
Expand All @@ -150,7 +150,7 @@ func (k DexKeeper) GetPoolSpotPrice(
return math.LegacyZeroDec(), err
}

return types.GetPoolSpotPrice(balanceBase, balanceQuote, weightBase, weightQuote), nil
return types.GetQuoteSpotPrice(balanceBase, balanceQuote, weightBase, weightQuote), nil
}

func (k DexKeeper) getPoolInfo(ctx context.Context, metadataLP vmtypes.AccountAddress) (
Expand Down Expand Up @@ -346,7 +346,7 @@ func (k DexKeeper) SwapToBase(
vmAddr,
vmtypes.StdAddress,
types.MoveModuleNameDex,
types.FunctionNameDexSwap,
types.FunctionNameDexSwapScript,
[]vmtypes.TypeTag{},
[][]byte{metadataLP[:], metadataQuote[:], offerAmountBz, {0}},
)
Expand Down
4 changes: 2 additions & 2 deletions x/move/keeper/dex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func Test_ReadWeights(t *testing.T) {
require.Equal(t, math.LegacyNewDecWithPrec(2, 1), weightQuote)
}

func Test_GetPoolSpotPrice(t *testing.T) {
func Test_GetQuoteSpotPrice(t *testing.T) {
ctx, input := createDefaultTestInput(t)
dexKeeper := keeper.NewDexKeeper(&input.MoveKeeper)

Expand All @@ -191,7 +191,7 @@ func Test_GetPoolSpotPrice(t *testing.T) {
})
require.NoError(t, err)

quotePrice, err := dexKeeper.GetPoolSpotPrice(ctx, denomQuote)
quotePrice, err := dexKeeper.GetQuoteSpotPrice(ctx, denomQuote)
require.NoError(t, err)
require.Equal(t, math.LegacyOneDec(), quotePrice)
}
Expand Down
7 changes: 0 additions & 7 deletions x/move/keeper/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/hex"
"encoding/json"
"errors"
"math"
"strings"
"unsafe"

Expand Down Expand Up @@ -194,9 +193,6 @@ func (k Keeper) executeEntryFunction(

if isSimulation(ctx) {
gasForRuntime = k.config.ContractSimulationGasLimit
} else if gasMeter.Limit() == 0 {
// infinite gas meter
gasForRuntime = math.MaxUint64
}

// delegate gas metering to move vm
Expand Down Expand Up @@ -310,9 +306,6 @@ func (k Keeper) executeScript(

if isSimulation(ctx) {
gasForRuntime = k.config.ContractSimulationGasLimit
} else if gasMeter.Limit() == 0 {
// infinite gas meter
gasForRuntime = math.MaxUint64
}

// delegate gas metering to move vm
Expand Down
Loading

0 comments on commit d488e00

Please sign in to comment.