mirror of
https://github.com/fluencelabs/trust-graph
synced 2024-12-04 15:20:19 +00:00
Add memory leak temporary mitigation (#42)
This commit is contained in:
parent
b9fbbbcafb
commit
aa72fdab64
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2672,7 +2672,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "trust-graph-wasm"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {trusted_computation} from "./generated/computation";
|
||||
import { trusted_computation } from "./generated/computation";
|
||||
import * as tg from "./generated/export";
|
||||
import {Fluence, FluencePeer, KeyPair} from "@fluencelabs/fluence";
|
||||
import {krasnodar, Node, testNet, stage} from "@fluencelabs/fluence-network-environment";
|
||||
import { Fluence, FluencePeer, KeyPair } from "@fluencelabs/fluence";
|
||||
import { krasnodar, Node, testNet, stage } from "@fluencelabs/fluence-network-environment";
|
||||
import assert from "assert";
|
||||
const bs58 = require('bs58');
|
||||
|
||||
@ -92,7 +92,7 @@ async function main() {
|
||||
let builtins_keypair = await KeyPair.fromEd25519SK(sk);
|
||||
|
||||
let relay = local[0];
|
||||
await Fluence.start({ connectTo: relay, KeyPair: builtins_keypair});
|
||||
await Fluence.start({ connectTo: relay, KeyPair: builtins_keypair });
|
||||
console.log(
|
||||
"📗 created a fluence peer %s with relay %s",
|
||||
Fluence.getStatus().peerId,
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "trust-graph-wasm"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
description = "trust graph wasm"
|
||||
|
@ -13,10 +13,31 @@ mod results;
|
||||
mod service_api;
|
||||
mod storage_impl;
|
||||
mod tests;
|
||||
/*
|
||||
_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();
|
||||
}
|
||||
}
|
||||
//------------------------------
|
||||
pub static TRUSTED_TIMESTAMP: (&str, &str) = ("peer", "timestamp_sec");
|
||||
|
||||
pub fn main() {
|
||||
_initialize(); // As __wasm_call_ctors still does necessary work, we call it at the start of the module
|
||||
WasmLoggerBuilder::new()
|
||||
.with_log_level(log::LevelFilter::Trace)
|
||||
.build()
|
||||
|
Loading…
Reference in New Issue
Block a user