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: QOL GetDefaultFeatures #413

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions internal/api/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func ReleaseCache(cache Cache) {
C.release_cache(cache.ptr)
}

func GetDefaultFeatures() string {
return "cosmwasm_1_1,cosmwasm_1_2"
}

func StoreCode(cache Cache, wasm []byte) ([]byte, error) {
w := makeView(wasm)
defer runtime.KeepAlive(wasm)
Expand Down
3 changes: 2 additions & 1 deletion internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
"github.com/CosmWasm/wasmvm/types"
)

var TESTING_FEATURES = "staking,stargate,iterator," + GetDefaultFeatures()

const (
TESTING_FEATURES = "staking,stargate,iterator,cosmwasm_1_1,cosmwasm_1_2"
Copy link
Member

@webmaster128 webmaster128 Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to rename this variable to capabilities (see https://github.com/CosmWasm/cosmwasm/blob/main/docs/CAPABILITIES.md for more on that)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TESTING_PRINT_DEBUG = false
TESTING_GAS_LIMIT = uint64(500_000_000_000) // ~0.5ms
TESTING_MEMORY_LIMIT = 32 // MiB
Expand Down
6 changes: 6 additions & 0 deletions lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ func NewVM(dataDir string, supportedFeatures string, memoryLimit uint32, printDe
return &VM{cache: cache, printDebug: printDebug}, nil
}

// GetDefaultFeatures is called app.go to auto enable new features
// on wasmvm upgrade.
func GetDefaultFeatures() string {
return api.GetDefaultFeatures()
}

// Cleanup should be called when no longer using this to free resources on the rust-side
func (vm *VM) Cleanup() {
api.ReleaseCache(vm.cache)
Expand Down