Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bump movevm and point #248

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG TARGETARCH
ARG GOARCH

# See https://github.com/initia-labs/movevm/releases
ENV LIBMOVEVM_VERSION=v0.3.4
ENV LIBMOVEVM_VERSION=v0.4.0

# Install necessary packages
RUN set -eux; apk add --no-cache ca-certificates build-base git cmake
Expand Down
16 changes: 16 additions & 0 deletions cmd/move/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
flagFetchDepsOnly = "fetch-deps-only"
flagSkipFetchLatestGitDeps = "skip-fetch-latest-git-deps"
flagBytecodeVersion = "bytecode-version"
flagCompilerVersion = "compiler-version"
flagLanguageVersion = "language-version"
/* test options */
flagGasLimit = "gas-limit"
flagGasLimitShorthand = "g"
Expand Down Expand Up @@ -613,6 +615,8 @@ the 'tests' directory`)
cmd.Flags().Bool(flagVerbose, false, "Print additional diagnostics if available")
cmd.Flags().Bool(flagSkipFetchLatestGitDeps, false, "Skip fetching latest git dependencies")
cmd.Flags().Uint32(flagBytecodeVersion, 0, "Specify the version of the bytecode the compiler is going to emit")
cmd.Flags().Uint32(flagCompilerVersion, 1, "Specify the version of the compiler to use")
cmd.Flags().Uint32(flagLanguageVersion, 1, "Specify the version of the language to use")
}

func addMoveTestFlags(cmd *cobra.Command) {
Expand Down Expand Up @@ -720,6 +724,18 @@ func getBuildConfig(cmd *cobra.Command) (*buildtypes.BuildConfig, error) {
}
options = append(options, buildtypes.WithBytecodeVersion(bytecodeVersion))

compilerVersion, err := cmd.Flags().GetUint32(flagCompilerVersion)
if err != nil {
return nil, err
}
options = append(options, buildtypes.WithCompilerVersion(compilerVersion))

languageVersion, err := cmd.Flags().GetUint32(flagLanguageVersion)
if err != nil {
return nil, err
}
options = append(options, buildtypes.WithLanguageVersion(languageVersion))

bc := buildtypes.NewBuildConfig(options...)

return &bc, nil
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ require (
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-metrics v0.5.3
github.com/initia-labs/OPinit v0.4.1
// we also need to update `LIBMOVEVM_VERSION` of Dockerfile#5
github.com/initia-labs/movevm v0.3.4
github.com/initia-labs/OPinit v0.4.2
// we also need to update `LIBMOVEVM_VERSION` of Dockerfile#9
github.com/initia-labs/movevm v0.4.0
github.com/noble-assets/forwarding/v2 v2.0.0-20240521090705-86712c4c9e43
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,14 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/initia-labs/OPinit v0.4.1 h1:g6IVEAOe2X31pgjk/q0zg4R1GfNj2QP3q5s3HMcWm8w=
github.com/initia-labs/OPinit v0.4.1/go.mod h1:n0eqwOnVGE1vuTnW+3jzyEXfE4ndTM0vCRGmPu9VvUc=
github.com/initia-labs/OPinit v0.4.2 h1:cfE6LXb3EquDK1/UTDT62o9c2HOQL0E9pWTr5BWAf8g=
github.com/initia-labs/OPinit v0.4.2/go.mod h1:bM+tav+ER4uC6U84PB5vgnRUNyjc/phNgHGYQX9ALhg=
github.com/initia-labs/OPinit/api v0.4.1 h1:Q8etW92LiwekKZxzDYVFdiHF3uOpEA4nyajy8zpcxB0=
github.com/initia-labs/OPinit/api v0.4.1/go.mod h1:Xy/Nt3ubXLQ4zKn0m7RuQOM1sj8TVdlNNyek21TGYR0=
github.com/initia-labs/cometbft v0.0.0-20240802022359-e0a5ce0336b6 h1:ObKvj9nGiKE+MWZ/LnH3rPcXsnBVVn4c30/iw+fMsd4=
github.com/initia-labs/cometbft v0.0.0-20240802022359-e0a5ce0336b6/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc=
github.com/initia-labs/movevm v0.3.4 h1:kzqs6uzTq0f5peZJNzLq/1qgnmAFfC+I9eCyPBducxM=
github.com/initia-labs/movevm v0.3.4/go.mod h1:6MxR4GP5zH3JUc1IMgfqAe1e483mZVS7fshPknZPJ30=
github.com/initia-labs/movevm v0.4.0 h1:nqEa4b5ujmCf0hTrqst8M9N/MCMg5eU8BZYMkMa7tYc=
github.com/initia-labs/movevm v0.4.0/go.mod h1:6MxR4GP5zH3JUc1IMgfqAe1e483mZVS7fshPknZPJ30=
github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls=
github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
Expand Down
12 changes: 6 additions & 6 deletions x/ibc-hooks/move-hooks/ack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Test_onAckPacket_memo(t *testing.T) {
require.NoError(t, err)

// check the contract state
queryRes, err := input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand All @@ -94,7 +94,7 @@ func Test_onAckPacket_memo(t *testing.T) {
require.NoError(t, err)

// check the contract state; increased by 99 if ack is success
queryRes, err = input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err = input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand All @@ -111,7 +111,7 @@ func Test_onAckPacket_memo(t *testing.T) {
}, failedAckBz, addr)
require.NoError(t, err)

queryRes, err = input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err = input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand Down Expand Up @@ -189,7 +189,7 @@ func Test_onAckPacket_memo_ICS721(t *testing.T) {
require.NoError(t, err)

// check the contract state
queryRes, err := input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand All @@ -210,7 +210,7 @@ func Test_onAckPacket_memo_ICS721(t *testing.T) {
require.NoError(t, err)

// check the contract state; increased by 99 if ack is success
queryRes, err = input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err = input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand All @@ -227,7 +227,7 @@ func Test_onAckPacket_memo_ICS721(t *testing.T) {
}, failedAckBz, addr)
require.NoError(t, err)

queryRes, err = input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err = input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand Down
12 changes: 8 additions & 4 deletions x/ibc-hooks/move-hooks/receive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ func Test_OnReceivePacketWithoutMemo(t *testing.T) {
Amount: "10000",
Sender: addr.String(),
Receiver: addr2.String(),
Memo: "",
Memo: `{
"move": {
"message": null
}
}`,
}

dataBz, err := json.Marshal(&data)
Expand Down Expand Up @@ -76,7 +80,7 @@ func Test_onReceiveIcs20Packet_memo(t *testing.T) {
require.True(t, ack.Success())

// check the contract state
queryRes, err := input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand Down Expand Up @@ -158,7 +162,7 @@ func Test_onReceivePacket_memo_ICS721(t *testing.T) {
require.True(t, ack.Success())

// check the contract state
queryRes, err := input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand Down Expand Up @@ -215,7 +219,7 @@ func Test_onReceivePacket_memo_ICS721_Wasm(t *testing.T) {
require.True(t, ack.Success())

// check the contract state
queryRes, err := input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand Down
8 changes: 4 additions & 4 deletions x/ibc-hooks/move-hooks/timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_onTimeoutPacket_memo(t *testing.T) {
require.NoError(t, err)

// check the contract state
queryRes, err := input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand All @@ -87,7 +87,7 @@ func Test_onTimeoutPacket_memo(t *testing.T) {
require.NoError(t, err)

// check the contract state; increased by 99
queryRes, err = input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err = input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand Down Expand Up @@ -159,7 +159,7 @@ func Test_onTimeoutPacket_memo_ICS721(t *testing.T) {
require.NoError(t, err)

// check the contract state
queryRes, err := input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand All @@ -180,7 +180,7 @@ func Test_onTimeoutPacket_memo_ICS721(t *testing.T) {
require.NoError(t, err)

// check the contract state; increased by 99 if ack is success
queryRes, err = input.MoveKeeper.ExecuteViewFunction(
queryRes, _, err = input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"Counter",
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/nft-transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (suite *KeeperTestSuite) GetNFTOwner(ctx context.Context, k *keeper.Keeper,
ta, err := tokenAddr.BcsSerialize()
suite.Require().NoError(err)

res, err := moveKeeper.ExecuteViewFunction(ctx, moduleAddr, "object", "owner", typeTags, [][]byte{ta})
res, _, err := moveKeeper.ExecuteViewFunction(ctx, moduleAddr, "object", "owner", typeTags, [][]byte{ta})
suite.Require().NoError(err)

strAddr := strings.Trim(res.Ret, "\"")
Expand Down
24 changes: 0 additions & 24 deletions x/move/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,34 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
)

// DefaultModuleCacheCapacity the number of modules can be stay in module cache
const DefaultModuleCacheCapacity = uint64(500)

// DefaultScriptCacheCapacity the number of modules can be stay in module cache
const DefaultScriptCacheCapacity = uint64(100)

// DefaultContractSimulationGasLimit - default max simulation gas
const DefaultContractSimulationGasLimit = uint64(3_000_000)

const (
flagModuleCacheCapacity = "move.module-cache-capacity"
flagScriptCacheCapacity = "move.script-cache-capacity"
flagContractSimulationGasLimit = "move.contract-simulation-gas-limit"
)

// MoveConfig is the extra config required for move
type MoveConfig struct {
ModuleCacheCapacity uint64 `mapstructure:"module-cache-capacity"`
ScriptCacheCapacity uint64 `mapstructure:"script-cache-capacity"`
ContractSimulationGasLimit uint64 `mapstructure:"contract-simulation-gas-limit"`
}

// DefaultMoveConfig returns the default settings for MoveConfig
func DefaultMoveConfig() MoveConfig {
return MoveConfig{
ModuleCacheCapacity: DefaultModuleCacheCapacity,
ScriptCacheCapacity: DefaultScriptCacheCapacity,
ContractSimulationGasLimit: DefaultContractSimulationGasLimit,
}
}

// GetConfig load config values from the app options
func GetConfig(appOpts servertypes.AppOptions) MoveConfig {
return MoveConfig{
ModuleCacheCapacity: cast.ToUint64(appOpts.Get(flagModuleCacheCapacity)),
ScriptCacheCapacity: cast.ToUint64(appOpts.Get(flagScriptCacheCapacity)),
ContractSimulationGasLimit: cast.ToUint64(appOpts.Get(flagContractSimulationGasLimit)),
}
}

// AddConfigFlags implements servertypes.MoveConfigFlags interface.
func AddConfigFlags(startCmd *cobra.Command) {
startCmd.Flags().Uint64(flagModuleCacheCapacity, DefaultModuleCacheCapacity, "Set the number of modules which can stay in the cache")
startCmd.Flags().Uint64(flagScriptCacheCapacity, DefaultScriptCacheCapacity, "Set the number of scripts which can stay in the cache")
startCmd.Flags().Uint64(flagContractSimulationGasLimit, DefaultContractSimulationGasLimit, "Set the max simulation gas for move contract execution")
}

Expand All @@ -61,14 +45,6 @@ const DefaultConfigTemplate = `
###############################################################################

[move]
# in-memory cache for Move modules.
# The value is in MiB not bytes.
module-cache-capacity = "{{ .MoveConfig.ModuleCacheCapacity }}"

# in-memory cache for Move scripts.
# The value is in MiB not bytes.
script-cache-capacity = "{{ .MoveConfig.ScriptCacheCapacity }}"

# The maximum gas amount can be used in a tx simulation call.
contract-simulation-gas-limit = "{{ .MoveConfig.ContractSimulationGasLimit }}"
`
6 changes: 3 additions & 3 deletions x/move/keeper/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func Test_GetPrice(t *testing.T) {
pairIdArg, err := vmtypes.SerializeString(pairId)
require.NoError(t, err)

res, err := input.MoveKeeper.ExecuteViewFunction(
res, _, err := input.MoveKeeper.ExecuteViewFunction(
ctx,
vmtypes.StdAddress,
"oracle",
Expand Down Expand Up @@ -287,14 +287,14 @@ func Test_API_CustomQuery(t *testing.T) {
require.NoError(t, err)

// to sdk
res, err := input.MoveKeeper.ExecuteViewFunction(ctx, vmtypes.TestAddress, "TestAddress", "to_sdk", []vmtypes.TypeTag{}, [][]byte{vmAddr.Bytes()})
res, _, err := input.MoveKeeper.ExecuteViewFunction(ctx, vmtypes.TestAddress, "TestAddress", "to_sdk", []vmtypes.TypeTag{}, [][]byte{vmAddr.Bytes()})
require.NoError(t, err)
require.Equal(t, fmt.Sprintf("\"%s\"", addrs[0].String()), res.Ret)

// from sdk
inputBz, err := vmtypes.SerializeString(addrs[0].String())
require.NoError(t, err)
res, err = input.MoveKeeper.ExecuteViewFunction(ctx, vmtypes.TestAddress, "TestAddress", "from_sdk", []vmtypes.TypeTag{}, [][]byte{inputBz})
res, _, err = input.MoveKeeper.ExecuteViewFunction(ctx, vmtypes.TestAddress, "TestAddress", "from_sdk", []vmtypes.TypeTag{}, [][]byte{inputBz})
require.NoError(t, err)
require.Equal(t, fmt.Sprintf("\"%s\"", vmAddr.String()), res.Ret)
}
2 changes: 1 addition & 1 deletion x/move/keeper/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func Test_BurnCoins(t *testing.T) {
vmtypes.TestAddress,
vmtypes.StdAddress,
"managed_coin",
"mint",
"mint_to",
[]vmtypes.TypeTag{},
[]string{fmt.Sprintf("\"%s\"", vmtypes.TestAddress.String()), fmt.Sprintf("\"%s\"", barMetadata.String()), `"1000000"`},
)
Expand Down
Loading
Loading