diff --git a/internal/api/bindings.h b/internal/api/bindings.h index 5b38b7736..6bb960b4d 100644 --- a/internal/api/bindings.h +++ b/internal/api/bindings.h @@ -254,12 +254,22 @@ typedef struct iterator_t { } iterator_t; typedef struct Iterator_vtable { - int32_t (*next_db)(struct iterator_t, - struct gas_meter_t*, - uint64_t*, - struct UnmanagedVector*, - struct UnmanagedVector*, - struct UnmanagedVector*); + int32_t (*next)(struct iterator_t, + struct gas_meter_t*, + uint64_t*, + struct UnmanagedVector*, + struct UnmanagedVector*, + struct UnmanagedVector*); + int32_t (*next_key)(struct iterator_t, + struct gas_meter_t*, + uint64_t*, + struct UnmanagedVector*, + struct UnmanagedVector*); + int32_t (*next_value)(struct iterator_t, + struct gas_meter_t*, + uint64_t*, + struct UnmanagedVector*, + struct UnmanagedVector*); } Iterator_vtable; typedef struct GoIter { diff --git a/internal/api/callbacks.go b/internal/api/callbacks.go index 0f0cdcce9..fd06b8ca4 100644 --- a/internal/api/callbacks.go +++ b/internal/api/callbacks.go @@ -12,7 +12,9 @@ typedef GoError (*write_db_fn)(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used typedef GoError (*remove_db_fn)(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, U8SliceView key, UnmanagedVector *errOut); typedef GoError (*scan_db_fn)(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, U8SliceView start, U8SliceView end, int32_t order, GoIter *out, UnmanagedVector *errOut); // iterator -typedef GoError (*next_db_fn)(iterator_t idx, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *val, UnmanagedVector *errOut); +typedef GoError (*db_next)(iterator_t idx, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *val, UnmanagedVector *errOut); +typedef GoError (*db_next_key)(iterator_t idx, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *errOut); +typedef GoError (*db_next_value)(iterator_t idx, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *val, UnmanagedVector *errOut); // and api typedef GoError (*humanize_address_fn)(api_t *ptr, U8SliceView src, UnmanagedVector *dest, UnmanagedVector *errOut, uint64_t *used_gas); typedef GoError (*canonicalize_address_fn)(api_t *ptr, U8SliceView src, UnmanagedVector *dest, UnmanagedVector *errOut, uint64_t *used_gas); @@ -25,6 +27,8 @@ GoError cDelete_cgo(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, U8Sli GoError cScan_cgo(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, U8SliceView start, U8SliceView end, int32_t order, GoIter *out, UnmanagedVector *errOut); // iterator GoError cNext_cgo(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *val, UnmanagedVector *errOut); +GoError cNextKey_cgo(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *errOut); +GoError cNextValue_cgo(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *val, UnmanagedVector *errOut); // api GoError cHumanAddress_cgo(api_t *ptr, U8SliceView src, UnmanagedVector *dest, UnmanagedVector *errOut, uint64_t *used_gas); GoError cCanonicalAddress_cgo(api_t *ptr, U8SliceView src, UnmanagedVector *dest, UnmanagedVector *errOut, uint64_t *used_gas); @@ -128,7 +132,9 @@ func buildDB(state *DBState, gm *types.GasMeter) C.Db { } var iterator_vtable = C.Iterator_vtable{ - next_db: (C.next_db_fn)(C.cNext_cgo), + next: (C.db_next)(C.cNext_cgo), + next_key: (C.db_next_key)(C.cNextKey_cgo), + next_value: (C.db_next_value)(C.cNextValue_cgo), } // An iterator including referenced objects is 117 bytes large (calculated using https://github.com/DmitriyVTitov/size). @@ -310,6 +316,55 @@ func cNext(ref C.iterator_t, gasMeter *C.gas_meter_t, usedGas *cu64, key *C.Unma return C.GoError_None } +//export cNextKey +func cNextKey(ref C.iterator_t, gasMeter *C.gas_meter_t, usedGas *cu64, key *C.UnmanagedVector, errOut *C.UnmanagedVector) (ret C.GoError) { + return nextPart(ref, gasMeter, usedGas, key, errOut, func(iter types.Iterator) []byte { return iter.Key() }) +} + +//export cNextValue +func cNextValue(ref C.iterator_t, gasMeter *C.gas_meter_t, usedGas *cu64, value *C.UnmanagedVector, errOut *C.UnmanagedVector) (ret C.GoError) { + return nextPart(ref, gasMeter, usedGas, value, errOut, func(iter types.Iterator) []byte { return iter.Value() }) +} + +// nextPart is a helper function that contains the shared code for key- and value-only iteration. +func nextPart(ref C.iterator_t, gasMeter *C.gas_meter_t, usedGas *cu64, output *C.UnmanagedVector, errOut *C.UnmanagedVector, valFn func(types.Iterator) []byte) (ret C.GoError) { + // typical usage of iterator + // for ; itr.Valid(); itr.Next() { + // k, v := itr.Key(); itr.Value() + // ... + // } + + defer recoverPanic(&ret) + if ref.call_id == 0 || gasMeter == nil || usedGas == nil || output == nil || errOut == nil { + // we received an invalid pointer + return C.GoError_BadArgument + } + if !(*output).is_none || !(*errOut).is_none { + panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.") + } + + gm := *(*types.GasMeter)(unsafe.Pointer(gasMeter)) + iter := retrieveIterator(uint64(ref.call_id), uint64(ref.iterator_index)) + if iter == nil { + panic("Unable to retrieve iterator.") + } + if !iter.Valid() { + // end of iterator, return as no-op, nil `output` is considered end + return C.GoError_None + } + + gasBefore := gm.GasConsumed() + // call Next at the end, upon creation we have first data loaded + out := valFn(iter) + // check iter.Error() ???? + iter.Next() + gasAfter := gm.GasConsumed() + *usedGas = (cu64)(gasAfter - gasBefore) + + *output = newUnmanagedVector(out) + return C.GoError_None +} + var api_vtable = C.GoApi_vtable{ humanize_address: (C.humanize_address_fn)(C.cHumanAddress_cgo), canonicalize_address: (C.canonicalize_address_fn)(C.cCanonicalAddress_cgo), diff --git a/internal/api/callbacks_cgo.go b/internal/api/callbacks_cgo.go index 6cc036324..343c890a9 100644 --- a/internal/api/callbacks_cgo.go +++ b/internal/api/callbacks_cgo.go @@ -11,6 +11,8 @@ GoError cDelete(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, U8SliceVi GoError cScan(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, U8SliceView start, U8SliceView end, int32_t order, GoIter *out, UnmanagedVector *errOut); // imports (iterator) GoError cNext(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *val, UnmanagedVector *errOut); +GoError cNextKey(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *errOut); +GoError cNextValue(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *value, UnmanagedVector *errOut); // imports (api) GoError cHumanAddress(api_t *ptr, U8SliceView src, UnmanagedVector *dest, UnmanagedVector *errOut, uint64_t *used_gas); GoError cCanonicalAddress(api_t *ptr, U8SliceView src, UnmanagedVector *dest, UnmanagedVector *errOut, uint64_t *used_gas); @@ -35,6 +37,12 @@ GoError cScan_cgo(db_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, U8Slice GoError cNext_cgo(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *val, UnmanagedVector *errOut) { return cNext(ptr, gas_meter, used_gas, key, val, errOut); } +GoError cNextKey_cgo(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *key, UnmanagedVector *errOut) { + return cNextKey(ptr, gas_meter, used_gas, key, errOut); +} +GoError cNextValue_cgo(iterator_t *ptr, gas_meter_t *gas_meter, uint64_t *used_gas, UnmanagedVector *val, UnmanagedVector *errOut) { + return cNextValue(ptr, gas_meter, used_gas, val, errOut); +} // Gateway functions (api) GoError cCanonicalAddress_cgo(api_t *ptr, U8SliceView src, UnmanagedVector *dest, UnmanagedVector *errOut, uint64_t *used_gas) { diff --git a/internal/api/lib_test.go b/internal/api/lib_test.go index e4d926f40..e967ce48e 100644 --- a/internal/api/lib_test.go +++ b/internal/api/lib_test.go @@ -260,7 +260,8 @@ 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) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + t.Log(t, metrics.SizeMemoryCache) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Instantiate 2 msg2 := []byte(`{"verifier": "fred", "beneficiary": "susi"}`) @@ -273,7 +274,7 @@ func TestGetMetrics(t *testing.T) { require.Equal(t, uint32(1), metrics.HitsMemoryCache) require.Equal(t, uint32(1), metrics.HitsFsCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Pin err = Pin(cache, checksum) @@ -282,12 +283,12 @@ func TestGetMetrics(t *testing.T) { // GetMetrics 5 metrics, err = GetMetrics(cache) assert.NoError(t, err) - require.Equal(t, uint32(2), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(1), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizePinnedMemoryCache, 0.25) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Instantiate 3 msg3 := []byte(`{"verifier": "fred", "beneficiary": "bert"}`) @@ -298,12 +299,12 @@ func TestGetMetrics(t *testing.T) { metrics, err = GetMetrics(cache) assert.NoError(t, err) require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache) - require.Equal(t, uint32(2), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(1), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizePinnedMemoryCache, 0.25) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Unpin err = Unpin(cache, checksum) @@ -313,12 +314,12 @@ func TestGetMetrics(t *testing.T) { metrics, err = GetMetrics(cache) assert.NoError(t, err) require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache) - require.Equal(t, uint32(2), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(1), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Instantiate 4 msg4 := []byte(`{"verifier": "fred", "beneficiary": "jeff"}`) @@ -329,12 +330,12 @@ func TestGetMetrics(t *testing.T) { metrics, err = GetMetrics(cache) assert.NoError(t, err) require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache) - require.Equal(t, uint32(3), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(2), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) } func TestInstantiate(t *testing.T) { diff --git a/lib_test.go b/lib_test.go index 0f8055b2b..e955f52df 100644 --- a/lib_test.go +++ b/lib_test.go @@ -75,7 +75,7 @@ func TestStoreCode(t *testing.T) { wasm := []byte{0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00} _, err := vm.StoreCode(wasm) - require.ErrorContains(t, err, "Error during static Wasm validation: Wasm contract doesn't have a memory section") + require.ErrorContains(t, err, "Error during static Wasm validation: Wasm contract must contain exactly one memory") } // No Wasm @@ -270,7 +270,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) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Instantiate 2 msg2 := []byte(`{"verifier": "fred", "beneficiary": "susi"}`) @@ -284,7 +284,7 @@ func TestGetMetrics(t *testing.T) { require.Equal(t, uint32(1), metrics.HitsMemoryCache) require.Equal(t, uint32(1), metrics.HitsFsCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Pin err = vm.Pin(checksum) @@ -293,12 +293,12 @@ func TestGetMetrics(t *testing.T) { // GetMetrics 5 metrics, err = vm.GetMetrics() assert.NoError(t, err) - require.Equal(t, uint32(2), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(1), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizePinnedMemoryCache, 0.25) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Instantiate 3 msg3 := []byte(`{"verifier": "fred", "beneficiary": "bert"}`) @@ -310,12 +310,12 @@ func TestGetMetrics(t *testing.T) { metrics, err = vm.GetMetrics() assert.NoError(t, err) require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache) - require.Equal(t, uint32(2), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(1), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizePinnedMemoryCache, 0.25) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Unpin err = vm.Unpin(checksum) @@ -325,12 +325,12 @@ func TestGetMetrics(t *testing.T) { metrics, err = vm.GetMetrics() assert.NoError(t, err) require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache) - require.Equal(t, uint32(2), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(1), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) // Instantiate 4 msg4 := []byte(`{"verifier": "fred", "beneficiary": "jeff"}`) @@ -342,10 +342,10 @@ func TestGetMetrics(t *testing.T) { metrics, err = vm.GetMetrics() assert.NoError(t, err) require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache) - require.Equal(t, uint32(3), metrics.HitsMemoryCache) - require.Equal(t, uint32(1), metrics.HitsFsCache) + require.Equal(t, uint32(2), metrics.HitsMemoryCache) + require.Equal(t, uint32(2), metrics.HitsFsCache) require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache) require.Equal(t, uint64(1), metrics.ElementsMemoryCache) require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache) - require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2) + require.InEpsilon(t, 2832576, metrics.SizeMemoryCache, 0.25) } diff --git a/libwasmvm/Cargo.lock b/libwasmvm/Cargo.lock index 772fb4364..93e95df97 100644 --- a/libwasmvm/Cargo.lock +++ b/libwasmvm/Cargo.lock @@ -28,6 +28,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "atty" version = "0.2.14" @@ -56,21 +62,21 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object 0.30.4", + "object", "rustc-demangle", ] [[package]] name = "base16ct" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.13.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" @@ -116,9 +122,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "845141a4fade3f790628b7daaaa298a25b204fb28907eb54febe5142db6ce653" +checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" [[package]] name = "bumpalo" @@ -154,6 +160,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + [[package]] name = "cbindgen" version = "0.24.5" @@ -236,8 +248,8 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.0" -source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.3.0#f3d57ce2a92c55495267c426e3c9c0364bf98596" +version = "1.4.0-beta.1" +source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.4.0-beta.1#1dc5552daee498ed9e7ea5026e5fdf433e904b63" dependencies = [ "digest 0.10.7", "ed25519-zebra", @@ -248,16 +260,16 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.0" -source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.3.0#f3d57ce2a92c55495267c426e3c9c0364bf98596" +version = "1.4.0-beta.1" +source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.4.0-beta.1#1dc5552daee498ed9e7ea5026e5fdf433e904b63" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-std" -version = "1.3.0" -source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.3.0#f3d57ce2a92c55495267c426e3c9c0364bf98596" +version = "1.4.0-beta.1" +source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.4.0-beta.1#1dc5552daee498ed9e7ea5026e5fdf433e904b63" dependencies = [ "base64", "bnum", @@ -275,19 +287,19 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "1.3.0" -source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.3.0#f3d57ce2a92c55495267c426e3c9c0364bf98596" +version = "1.4.0-beta.1" +source = "git+https://github.com/CosmWasm/cosmwasm.git?rev=v1.4.0-beta.1#1dc5552daee498ed9e7ea5026e5fdf433e904b63" dependencies = [ "bitflags", "bytecheck", + "bytes", "clru", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", + "derivative", "enumset", "hex", - "loupe", - "parity-wasm", "schemars", "serde", "serde_json", @@ -308,56 +320,74 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" +checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" +checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" dependencies = [ + "arrayvec", + "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-egraph", "cranelift-entity", + "cranelift-isle", "gimli 0.26.2", "log", - "regalloc", + "regalloc2", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" +checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" +checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" + +[[package]] +name = "cranelift-egraph" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown 0.12.3", + "indexmap", + "log", + "smallvec", +] [[package]] name = "cranelift-entity" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" +checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" [[package]] name = "cranelift-frontend" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" +checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" dependencies = [ "cranelift-codegen", "log", @@ -365,6 +395,12 @@ dependencies = [ "target-lexicon", ] +[[package]] +name = "cranelift-isle" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" + [[package]] name = "crc32fast" version = "1.3.2" @@ -419,9 +455,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.4.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -486,11 +522,24 @@ dependencies = [ "syn 2.0.22", ] +[[package]] +name = "dashmap" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd72493923899c6f10c641bdbdeddc7183d6396641d99c1a0d1597f37f92e28" +dependencies = [ + "cfg-if", + "hashbrown 0.14.0", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "der" -version = "0.6.1" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", "zeroize", @@ -523,6 +572,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -561,14 +611,16 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.14.8" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ "der", + "digest 0.10.7", "elliptic-curve", "rfc6979", "signature", + "spki", ] [[package]] @@ -594,13 +646,12 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" -version = "0.12.3" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ "base16ct", "crypto-bigint", - "der", "digest 0.10.7", "ff", "generic-array", @@ -702,9 +753,9 @@ dependencies = [ [[package]] name = "ff" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", "subtle", @@ -716,6 +767,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + [[package]] name = "forward_ref" version = "1.0.0" @@ -728,6 +788,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -736,6 +805,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -768,9 +838,9 @@ checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "group" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", @@ -779,21 +849,18 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", ] [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] name = "heck" @@ -846,6 +913,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -854,7 +931,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde", ] [[package]] @@ -894,14 +970,16 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "once_cell", "sha2 0.10.7", + "signature", ] [[package]] @@ -922,16 +1000,6 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -939,31 +1007,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] -name = "log" -version = "0.4.19" +name = "lock_api" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", + "autocfg", + "scopeguard", ] [[package]] -name = "loupe-derive" -version = "0.1.3" +name = "log" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn 1.0.109", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "mach" @@ -991,9 +1048,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ "autocfg", ] @@ -1032,18 +1089,6 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" -dependencies = [ - "crc32fast", - "hashbrown 0.11.2", - "indexmap", - "memchr", -] - [[package]] name = "object" version = "0.30.4" @@ -1072,10 +1117,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] -name = "parity-wasm" -version = "0.45.0" +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1085,9 +1143,9 @@ checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", "spki", @@ -1208,13 +1266,14 @@ dependencies = [ ] [[package]] -name = "regalloc" -version = "0.0.34" +name = "regalloc2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" +checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" dependencies = [ + "fxhash", "log", - "rustc-hash", + "slice-group-by", "smallvec", ] @@ -1241,13 +1300,12 @@ dependencies = [ [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "crypto-bigint", "hmac", - "zeroize", + "subtle", ] [[package]] @@ -1259,6 +1317,7 @@ dependencies = [ "bitvec", "bytecheck", "hashbrown 0.12.3", + "indexmap", "ptr_meta", "rend", "rkyv_derive", @@ -1284,12 +1343,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustix" version = "0.37.20" @@ -1304,12 +1357,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rustversion" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" - [[package]] name = "ryu" version = "1.0.13" @@ -1354,9 +1401,9 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "sec1" -version = "0.3.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", @@ -1385,12 +1432,14 @@ dependencies = [ ] [[package]] -name = "serde_bytes" -version = "0.11.9" +name = "serde-wasm-bindgen" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" +checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf" dependencies = [ + "js-sys", "serde", + "wasm-bindgen", ] [[package]] @@ -1452,9 +1501,9 @@ dependencies = [ [[package]] name = "signature" -version = "1.6.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.7", "rand_core 0.6.4", @@ -1466,6 +1515,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + [[package]] name = "smallvec" version = "1.10.0" @@ -1474,9 +1529,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "spki" -version = "0.6.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", "der", @@ -1614,7 +1669,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1646,12 +1700,38 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "uuid" version = "1.4.0" @@ -1695,6 +1775,29 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-downcast" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dac026d43bcca6e7ce1c0956ba68f59edf6403e8e930a5d891be72c31a44340" +dependencies = [ + "js-sys", + "once_cell", + "wasm-bindgen", + "wasm-bindgen-downcast-macros", +] + +[[package]] +name = "wasm-bindgen-downcast-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.87" @@ -1726,73 +1829,65 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasmer" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8d8361c9d006ea3d7797de7bd6b1492ffd0f91a22430cfda6c1658ad57bedf" +checksum = "fc7142dbb91ede83cc0aef2301fa75fcc7e0c9e5a7d5358e3c4f3a7249fe9ce8" dependencies = [ + "bytes", "cfg-if", + "derivative", "indexmap", "js-sys", - "loupe", "more-asserts", + "rustc-demangle", + "serde", + "serde-wasm-bindgen", "target-lexicon", "thiserror", "wasm-bindgen", - "wasmer-artifact", + "wasm-bindgen-downcast", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", - "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", "wasmer-types", "wasmer-vm", "winapi", ] -[[package]] -name = "wasmer-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aaf9428c29c1d8ad2ac0e45889ba8a568a835e33fd058964e5e500f2f7ce325" -dependencies = [ - "enumset", - "loupe", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - [[package]] name = "wasmer-compiler" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67a6cd866aed456656db2cfea96c18baabbd33f676578482b85c51e1ee19d2c" +checksum = "e5b99c70711ec7631b602a9fc95577c40df21e8f3916159c9d80c3fb4f77abdc" dependencies = [ + "backtrace", + "cfg-if", + "enum-iterator", "enumset", - "loupe", - "rkyv", - "serde", - "serde_bytes", + "lazy_static", + "leb128", + "memmap2", + "more-asserts", + "region", "smallvec", - "target-lexicon", "thiserror", "wasmer-types", + "wasmer-vm", "wasmparser", + "winapi", ] [[package]] name = "wasmer-compiler-cranelift" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48be2f9f6495f08649e4f8b946a2cbbe119faf5a654aa1457f9504a99d23dae0" +checksum = "52aef2ef35513a04fed54de9a7dc9c469d4742a5c2e378a5f7e2a79b1327e3bd" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", "gimli 0.26.2", - "loupe", "more-asserts", "rayon", "smallvec", @@ -1804,16 +1899,16 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ca2a35204d8befa85062bc7aac259a8db8070b801b8a783770ba58231d729e" +checksum = "ebfd019aa98b19fea0fb1d8db9b539145c9416d183ce4cda4e8e024b2c890aac" dependencies = [ "byteorder", "dynasm", "dynasmrt", + "enumset", "gimli 0.26.2", "lazy_static", - "loupe", "more-asserts", "rayon", "smallvec", @@ -1823,9 +1918,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e50405cc2a2f74ff574584710a5f2c1d5c93744acce2ca0866084739284b51" +checksum = "25bb1425c9e4dc3e2d3aacd6e82e22e27a3127379e0d09bcbdf25ff376229162" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1833,164 +1928,69 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "wasmer-engine" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f98f010978c244db431b392aeab0661df7ea0822343334f8f2a920763548e45" -dependencies = [ - "backtrace", - "enumset", - "lazy_static", - "loupe", - "memmap2", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-engine-dylib" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0358af9c154724587731175553805648d9acb8f6657880d165e378672b7e53" -dependencies = [ - "cfg-if", - "enum-iterator", - "enumset", - "leb128", - "libloading", - "loupe", - "object 0.28.4", - "rkyv", - "serde", - "tempfile", - "tracing", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-engine", - "wasmer-object", - "wasmer-types", - "wasmer-vm", - "which", -] - -[[package]] -name = "wasmer-engine-universal" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440dc3d93c9ca47865a4f4edd037ea81bf983b5796b59b3d712d844b32dbef15" -dependencies = [ - "cfg-if", - "enumset", - "leb128", - "loupe", - "region", - "rkyv", - "wasmer-compiler", - "wasmer-engine", - "wasmer-engine-universal-artifact", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-engine-universal-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f1db3f54152657eb6e86c44b66525ff7801dad8328fe677da48dd06af9ad41" -dependencies = [ - "enum-iterator", - "enumset", - "loupe", - "rkyv", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", -] - [[package]] name = "wasmer-middlewares" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7812438ed2f37203a37007cdb5332b8475cb2b16e15d51299b2647894e9ed3a" +checksum = "acfc08fb8e2e1511f1d69302d7406ace6c0ec0c90e103f8c0a5aa81ecb9fe81f" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", ] -[[package]] -name = "wasmer-object" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d831335ff3a44ecf451303f6f891175c642488036b92ceceb24ac8623a8fa8b" -dependencies = [ - "object 0.28.4", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - [[package]] name = "wasmer-types" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39df01ea05dc0a9bab67e054c7cb01521e53b35a7bb90bd02eca564ed0b2667f" +checksum = "d7e32ed799fa8c0d96ca9615d9ea8006857a0f0c18e7c2ed8082bd5c63a9ea70" dependencies = [ - "backtrace", + "bytecheck", "enum-iterator", + "enumset", "indexmap", - "loupe", "more-asserts", "rkyv", - "serde", + "target-lexicon", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.3.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d965fa61f4dc4cdb35a54daaf7ecec3563fbb94154a6c35433f879466247dd" +checksum = "0847513cb176b5d62a6f65d6ae474594935e726a10e9e3387177d9cbf8b8cda0" dependencies = [ "backtrace", "cc", "cfg-if", "corosensei", + "dashmap", + "derivative", "enum-iterator", + "fnv", "indexmap", "lazy_static", "libc", - "loupe", "mach", - "memoffset 0.6.5", + "memoffset 0.8.0", "more-asserts", "region", - "rkyv", "scopeguard", - "serde", "thiserror", - "wasmer-artifact", "wasmer-types", "winapi", ] [[package]] name = "wasmparser" -version = "0.83.0" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" +checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" +dependencies = [ + "indexmap", + "url", +] [[package]] name = "wasmvm" @@ -2007,17 +2007,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "which" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" -dependencies = [ - "either", - "libc", - "once_cell", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/libwasmvm/Cargo.toml b/libwasmvm/Cargo.toml index 92f0a0eea..f89ca95fe 100644 --- a/libwasmvm/Cargo.toml +++ b/libwasmvm/Cargo.toml @@ -26,8 +26,8 @@ default = [] backtraces = [] [dependencies] -cosmwasm-std = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v1.3.0", features = ["staking", "stargate", "iterator"] } -cosmwasm-vm = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v1.3.0", features = ["staking", "stargate", "iterator"] } +cosmwasm-std = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v1.4.0-beta.1", features = ["staking", "stargate", "iterator"] } +cosmwasm-vm = { git = "https://github.com/CosmWasm/cosmwasm.git", rev = "v1.4.0-beta.1", features = ["staking", "stargate", "iterator"] } errno = "0.2" serde_json = "1.0.91" thiserror = "1.0.38" diff --git a/libwasmvm/bindings.h b/libwasmvm/bindings.h index 5b38b7736..6bb960b4d 100644 --- a/libwasmvm/bindings.h +++ b/libwasmvm/bindings.h @@ -254,12 +254,22 @@ typedef struct iterator_t { } iterator_t; typedef struct Iterator_vtable { - int32_t (*next_db)(struct iterator_t, - struct gas_meter_t*, - uint64_t*, - struct UnmanagedVector*, - struct UnmanagedVector*, - struct UnmanagedVector*); + int32_t (*next)(struct iterator_t, + struct gas_meter_t*, + uint64_t*, + struct UnmanagedVector*, + struct UnmanagedVector*, + struct UnmanagedVector*); + int32_t (*next_key)(struct iterator_t, + struct gas_meter_t*, + uint64_t*, + struct UnmanagedVector*, + struct UnmanagedVector*); + int32_t (*next_value)(struct iterator_t, + struct gas_meter_t*, + uint64_t*, + struct UnmanagedVector*, + struct UnmanagedVector*); } Iterator_vtable; typedef struct GoIter { diff --git a/libwasmvm/src/cache.rs b/libwasmvm/src/cache.rs index 736392187..2a5a0c74d 100644 --- a/libwasmvm/src/cache.rs +++ b/libwasmvm/src/cache.rs @@ -839,7 +839,7 @@ mod tests { assert_eq!(elements_memory_cache, 0); assert_approx_eq!( size_pinned_memory_cache, - 4075417, + 2282344, "0.2", "size_pinned_memory_cache: {size_pinned_memory_cache}" ); diff --git a/libwasmvm/src/iterator.rs b/libwasmvm/src/iterator.rs index 565b9d1d6..00b350e29 100644 --- a/libwasmvm/src/iterator.rs +++ b/libwasmvm/src/iterator.rs @@ -19,7 +19,7 @@ pub struct iterator_t { #[repr(C)] #[derive(Default)] pub struct Iterator_vtable { - pub next_db: Option< + pub next: Option< extern "C" fn( iterator_t, *mut gas_meter_t, @@ -29,6 +29,24 @@ pub struct Iterator_vtable { *mut UnmanagedVector, // error message output ) -> i32, >, + pub next_key: Option< + extern "C" fn( + iterator_t, + *mut gas_meter_t, + *mut u64, + *mut UnmanagedVector, // key output + *mut UnmanagedVector, // error message output + ) -> i32, + >, + pub next_value: Option< + extern "C" fn( + iterator_t, + *mut gas_meter_t, + *mut u64, + *mut UnmanagedVector, // value output + *mut UnmanagedVector, // error message output + ) -> i32, + >, } #[repr(C)] @@ -48,19 +66,18 @@ impl GoIter { } pub fn next(&mut self) -> BackendResult> { - let next_db = match self.vtable.next_db { - Some(f) => f, - None => { - let result = Err(BackendError::unknown("iterator vtable not set")); - return (result, GasInfo::free()); - } + let Some(next) = self.vtable.next else { + let result = Err(BackendError::unknown( + "iterator vtable function 'next' not set", + )); + return (result, GasInfo::free()); }; let mut output_key = UnmanagedVector::default(); let mut output_value = UnmanagedVector::default(); let mut error_msg = UnmanagedVector::default(); let mut used_gas = 0_u64; - let go_result: GoError = (next_db)( + let go_result: GoError = (next)( self.state, self.gas_meter, &mut used_gas as *mut u64, @@ -97,4 +114,62 @@ impl GoIter { }; (result, gas_info) } + + pub fn next_key(&mut self) -> BackendResult>> { + let Some(next_key) = self.vtable.next_key else { + let result = Err(BackendError::unknown( + "iterator vtable function 'next_key' not set", + )); + return (result, GasInfo::free()); + }; + self.next_key_or_val(next_key) + } + + pub fn next_value(&mut self) -> BackendResult>> { + let Some(next_value) = self.vtable.next_value else { + let result = Err(BackendError::unknown( + "iterator vtable function 'next_value' not set", + )); + return (result, GasInfo::free()); + }; + self.next_key_or_val(next_value) + } + + #[inline(always)] + fn next_key_or_val( + &mut self, + next: extern "C" fn( + iterator_t, + *mut gas_meter_t, + *mut u64, + *mut UnmanagedVector, // output + *mut UnmanagedVector, // error message output + ) -> i32, + ) -> BackendResult>> { + let mut output = UnmanagedVector::default(); + let mut error_msg = UnmanagedVector::default(); + let mut used_gas = 0_u64; + let go_result: GoError = (next)( + self.state, + self.gas_meter, + &mut used_gas as *mut u64, + &mut output as *mut UnmanagedVector, + &mut error_msg as *mut UnmanagedVector, + ) + .into(); + // We destruct the `UnmanagedVector`s here, no matter if we need the data. + let output = output.consume(); + + let gas_info = GasInfo::with_externally_used(used_gas); + + // return complete error message (reading from buffer for GoError::Other) + let default = || "Failed to fetch next item from iterator".to_string(); + unsafe { + if let Err(err) = go_result.into_result(error_msg, default) { + return (Err(err), gas_info); + } + } + + (Ok(output), gas_info) + } } diff --git a/libwasmvm/src/storage.rs b/libwasmvm/src/storage.rs index aafa19f60..fc7a75046 100644 --- a/libwasmvm/src/storage.rs +++ b/libwasmvm/src/storage.rs @@ -104,18 +104,37 @@ impl Storage for GoStorage { } fn next(&mut self, iterator_id: u32) -> BackendResult> { - let iterator = match self.iterators.get_mut(&iterator_id) { - Some(i) => i, - None => { - return ( - Err(BackendError::iterator_does_not_exist(iterator_id)), - GasInfo::free(), - ) - } + let Some(iterator) = self.iterators.get_mut(&iterator_id) else { + return ( + Err(BackendError::iterator_does_not_exist(iterator_id)), + GasInfo::free(), + ); }; iterator.next() } + fn next_key(&mut self, iterator_id: u32) -> BackendResult>> { + let Some(iterator) = self.iterators.get_mut(&iterator_id) else { + return ( + Err(BackendError::iterator_does_not_exist(iterator_id)), + GasInfo::free(), + ); + }; + + iterator.next_key() + } + + fn next_value(&mut self, iterator_id: u32) -> BackendResult>> { + let Some(iterator) = self.iterators.get_mut(&iterator_id) else { + return ( + Err(BackendError::iterator_does_not_exist(iterator_id)), + GasInfo::free(), + ); + }; + + iterator.next_value() + } + fn set(&mut self, key: &[u8], value: &[u8]) -> BackendResult<()> { let mut error_msg = UnmanagedVector::default(); let mut used_gas = 0_u64;