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