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

Update to cosmwasm 2.0.0-beta.0 #487

Merged
merged 4 commits into from
Jan 4, 2024
Merged
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
9 changes: 9 additions & 0 deletions internal/api/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,16 @@ typedef struct UnmanagedVector {
* from Go this is done via `C.destroy_unmanaged_vector`.
*/
typedef struct AnalysisReport {
/**
* `true` if and only if all required ibc exports exist as exported functions.
* This does not guarantee they are functional or even have the correct signatures.
*/
bool has_ibc_entry_points;
/**
* A UTF-8 encoded comma separated list of all entrypoints that
* are exported by the contract.
*/
struct UnmanagedVector entrypoints;
/**
* An UTF-8 encoded comma separated list of reqired capabilities.
* This is never None/nil.
Expand Down
19 changes: 9 additions & 10 deletions internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func TestGetMetrics(t *testing.T) {
require.Equal(t, uint32(0), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
t.Log(t, metrics.SizeMemoryCache)
require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25)

// Instantiate 2
Expand Down Expand Up @@ -362,7 +361,7 @@ func TestInstantiate(t *testing.T) {
res, cost, err := Instantiate(cache, checksum, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x13a78a36c), cost.UsedInternally)
assert.Equal(t, uint64(0x5088ea), cost.UsedInternally)

var result types.ContractResult
err = json.Unmarshal(res, &result)
Expand Down Expand Up @@ -393,7 +392,7 @@ func TestExecute(t *testing.T) {
diff := time.Since(start)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x13a78a36c), cost.UsedInternally)
assert.Equal(t, uint64(0x5088ea), cost.UsedInternally)
t.Logf("Time (%d gas): %s\n", cost.UsedInternally, diff)

// execute with the same store
Expand All @@ -406,7 +405,7 @@ func TestExecute(t *testing.T) {
res, cost, err = Execute(cache, checksum, env, info, []byte(`{"release":{}}`), &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
diff = time.Since(start)
require.NoError(t, err)
assert.Equal(t, uint64(0x222892d70), cost.UsedInternally)
assert.Equal(t, uint64(0x8be9c6), cost.UsedInternally)
t.Logf("Time (%d gas): %s\n", cost.UsedInternally, diff)

// make sure it read the balance properly and we got 250 atoms
Expand Down Expand Up @@ -514,7 +513,7 @@ func TestExecuteCpuLoop(t *testing.T) {
diff := time.Since(start)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0xd45091d0), cost.UsedInternally)
assert.Equal(t, uint64(0x365a42), cost.UsedInternally)
t.Logf("Time (%d gas): %s\n", cost.UsedInternally, diff)

// execute a cpu loop
Expand Down Expand Up @@ -665,7 +664,7 @@ func TestMultipleInstances(t *testing.T) {
require.NoError(t, err)
requireOkResponse(t, res, 0)
// we now count wasm gas charges and db writes
assert.Equal(t, uint64(0x138559c5c), cost.UsedInternally)
assert.Equal(t, uint64(0x4ffce0), cost.UsedInternally)

// instance2 controlled by mary
gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -676,14 +675,14 @@ func TestMultipleInstances(t *testing.T) {
res, cost, err = Instantiate(cache, checksum, env, info, msg, &igasMeter2, store2, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x1399177bc), cost.UsedInternally)
assert.Equal(t, uint64(0x504dbc), cost.UsedInternally)

// fail to execute store1 with mary
resp := exec(t, cache, checksum, "mary", store1, api, querier, 0x1218ff5d0)
resp := exec(t, cache, checksum, "mary", store1, api, querier, 0x4a20c2)
require.Equal(t, "Unauthorized", resp.Err)

// succeed to execute store1 with fred
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x22188d470)
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x8ba826)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes := resp.Ok.Attributes
Expand All @@ -692,7 +691,7 @@ func TestMultipleInstances(t *testing.T) {
require.Equal(t, "bob", attributes[1].Value)

// succeed to execute store2 with mary
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0x2220900f0)
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0x8bc8f6)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes = resp.Ok.Attributes
Expand Down
1 change: 1 addition & 0 deletions lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func TestGetMetrics(t *testing.T) {
require.Equal(t, uint32(0), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
t.Log(metrics.SizeMemoryCache)
require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25)

// Instantiate 2
Expand Down
50 changes: 40 additions & 10 deletions libwasmvm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions libwasmvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ default = []
backtraces = []

[dependencies]
cosmwasm-std = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v1.5.0", features = ["staking", "stargate", "iterator"] }
cosmwasm-vm = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v1.5.0", features = ["staking", "stargate", "iterator"] }
cosmwasm-std = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v2.0.0-beta.0", features = ["staking", "stargate", "iterator"] }
cosmwasm-vm = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v2.0.0-beta.0", features = ["staking", "stargate", "iterator"] }
errno = "0.2"
serde_json = "1.0.91"
thiserror = "1.0.38"
Expand Down
9 changes: 9 additions & 0 deletions libwasmvm/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,16 @@ typedef struct UnmanagedVector {
* from Go this is done via `C.destroy_unmanaged_vector`.
*/
typedef struct AnalysisReport {
/**
* `true` if and only if all required ibc exports exist as exported functions.
* This does not guarantee they are functional or even have the correct signatures.
*/
bool has_ibc_entry_points;
/**
* A UTF-8 encoded comma separated list of all entrypoints that
* are exported by the contract.
*/
struct UnmanagedVector entrypoints;
/**
* An UTF-8 encoded comma separated list of reqired capabilities.
* This is never None/nil.
Expand Down
Loading