Add temporary fix for memory leak in marine (#110)

This commit is contained in:
Valery Antopol 2022-06-28 18:00:25 +03:00 committed by GitHub
parent d4fcadeba0
commit 00493147b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 137 deletions

156
service/Cargo.lock generated
View File

@ -248,15 +248,6 @@ dependencies = [
"bitflags",
]
[[package]]
name = "cmake"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a"
dependencies = [
"cc",
]
[[package]]
name = "cmd_lib"
version = "0.7.8"
@ -384,9 +375,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.9"
version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978"
checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
dependencies = [
"cfg-if 1.0.0",
"once_cell",
@ -701,7 +692,7 @@ dependencies = [
"ed25519-dalek",
"eyre",
"lazy_static",
"libp2p-core 0.32.1",
"libp2p-core",
"libsecp256k1 0.3.5",
"rand 0.7.3",
"ring",
@ -954,12 +945,6 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]]
name = "hermit-abi"
version = "0.1.19"
@ -1048,9 +1033,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "1.9.0"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c6392766afd7964e2531940894cffe4bd8d7d17dbc3c1c4857040fd4b33bdb3"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown 0.12.1",
@ -1204,46 +1189,11 @@ dependencies = [
"multistream-select",
"parking_lot 0.12.1",
"pin-project 1.0.10",
"prost 0.9.0",
"prost-build 0.9.0",
"prost",
"prost-build",
"rand 0.8.5",
"ring",
"rw-stream-sink 0.2.1",
"sha2 0.10.2",
"smallvec",
"thiserror",
"unsigned-varint",
"void",
"zeroize",
]
[[package]]
name = "libp2p-core"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42d46fca305dee6757022e2f5a4f6c023315084d0ed7441c3ab244e76666d979"
dependencies = [
"asn1_der 0.7.5",
"bs58 0.4.0",
"ed25519-dalek",
"either",
"fnv",
"futures",
"futures-timer",
"instant",
"lazy_static",
"libsecp256k1 0.7.0",
"log",
"multiaddr",
"multihash",
"multistream-select",
"parking_lot 0.12.0",
"pin-project 1.0.10",
"prost 0.10.4",
"prost-build 0.10.4",
"rand 0.8.5",
"ring",
"rw-stream-sink 0.3.0",
"rw-stream-sink",
"sha2 0.10.2",
"smallvec",
"thiserror",
@ -2033,17 +1983,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
dependencies = [
"bytes",
"prost-derive 0.9.0",
]
[[package]]
name = "prost"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71adf41db68aa0daaefc69bb30bcd68ded9b9abaad5d1fbb6304c4fb390e083e"
dependencies = [
"bytes",
"prost-derive 0.10.1",
"prost-derive",
]
[[package]]
@ -2053,36 +1993,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
dependencies = [
"bytes",
"heck 0.3.3",
"heck",
"itertools 0.10.3",
"lazy_static",
"log",
"multimap",
"petgraph",
"prost 0.9.0",
"prost-types 0.9.0",
"regex",
"tempfile",
"which",
]
[[package]]
name = "prost-build"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae5a4388762d5815a9fc0dea33c56b021cdc8dde0c55e0c9ca57197254b0cab"
dependencies = [
"bytes",
"cfg-if 1.0.0",
"cmake",
"heck 0.4.0",
"itertools 0.10.3",
"lazy_static",
"log",
"multimap",
"petgraph",
"prost 0.10.4",
"prost-types 0.10.1",
"prost",
"prost-types",
"regex",
"tempfile",
"which",
@ -2101,19 +2019,6 @@ dependencies = [
"syn",
]
[[package]]
name = "prost-derive"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b670f45da57fb8542ebdbb6105a925fe571b67f9e7ed9f47a06a84e72b4e7cc"
dependencies = [
"anyhow",
"itertools 0.10.3",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "prost-types"
version = "0.9.0"
@ -2121,17 +2026,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
dependencies = [
"bytes",
"prost 0.9.0",
]
[[package]]
name = "prost-types"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d0a014229361011dc8e69c8a1ec6c2e8d0f2af7c91e3ea3f5b2170298461e68"
dependencies = [
"bytes",
"prost 0.10.4",
"prost",
]
[[package]]
@ -2294,13 +2189,13 @@ checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
[[package]]
name = "registry"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"boolinator",
"bs58 0.4.0",
"fluence-keypair",
"fstrings",
"libp2p-core 0.33.0",
"libp2p-core",
"marine-rs-sdk",
"marine-rs-sdk-test",
"marine-sqlite-connector",
@ -2370,17 +2265,6 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "rw-stream-sink"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04"
dependencies = [
"futures",
"pin-project 1.0.10",
"static_assertions",
]
[[package]]
name = "ryu"
version = "1.0.10"
@ -2554,9 +2438,9 @@ checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]]
name = "smallvec"
version = "1.8.0"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2"
[[package]]
name = "spin"
@ -2736,9 +2620,9 @@ checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "unicode-normalization"
version = "0.1.19"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
checksum = "81dee68f85cab8cf68dec42158baf3a79a1cdc065a8b103025965d6ccb7f6cbd"
dependencies = [
"tinyvec",
]
@ -2836,7 +2720,7 @@ version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c2bb690b44cb1b0fdcc54d4998d21f8bdaf706b93775425e440b174f39ad16"
dependencies = [
"heck 0.3.3",
"heck",
"proc-macro2",
"quote",
"syn",

View File

@ -1,6 +1,6 @@
[package]
name = "registry"
version = "0.2.0"
version = "0.2.1"
authors = ["Fluence Labs"]
edition = "2018"
publish = false

View File

@ -39,6 +39,28 @@ mod tetraplets_checkers;
#[macro_use]
extern crate fstrings;
/*
_initialize function that calls __wasm_call_ctors is required to mitigade memory leak
that is described in https://github.com/WebAssembly/wasi-libc/issues/298
In short, without this code rust wraps every export function
with __wasm_call_ctors/__wasm_call_dtors calls. This causes memory leaks. When compiler sees
an explicit call to __wasm_call_ctors in _initialize function, it disables export wrapping.
TODO: remove when updating to marine-rs-sdk with fix
*/
extern "C" {
pub fn __wasm_call_ctors();
}
#[no_mangle]
fn _initialize() {
unsafe {
__wasm_call_ctors();
}
}
//------------------------------
module_manifest!();
pub fn wrapped_try<F, T>(func: F) -> T
@ -58,6 +80,7 @@ pub struct WeightResult {
}
fn main() {
_initialize(); // As __wasm_call_ctors still does necessary work, we call it at the start of the module
let storage = get_storage().unwrap();
storage.create_key_tables();
storage.create_values_table();