mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
Deduplicate SecuityTetraplet with marine-rs-sdk (#164)
This commit is contained in:
parent
653f42167a
commit
d9f10cb26d
48
Cargo.lock
generated
48
Cargo.lock
generated
@ -681,9 +681,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.2.7"
|
version = "0.2.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe"
|
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"errno-dragonfly",
|
"errno-dragonfly",
|
||||||
"libc",
|
"libc",
|
||||||
@ -867,9 +867,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "half"
|
name = "half"
|
||||||
version = "1.8.0"
|
version = "1.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac5956d4e63858efaec57e0d6c1c2f6a41e1487f830314a324ccd7e2223a7ca0"
|
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
@ -1074,9 +1074,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.104"
|
version = "0.2.106"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce"
|
checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
@ -1160,18 +1160,19 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "marine-macro"
|
name = "marine-macro"
|
||||||
version = "0.6.14"
|
version = "0.6.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94b05da94255c230b7bf139c39c04447677b5d238579bf38ca7b3fcdc3e04993"
|
checksum = "dfc907943772cf966ebe2a2d462d09bc79e898ef102ed065ba3d3abcc93fbb71"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"marine-macro-impl",
|
"marine-macro-impl",
|
||||||
|
"marine-rs-sdk-main",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "marine-macro-impl"
|
name = "marine-macro-impl"
|
||||||
version = "0.6.14"
|
version = "0.6.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7846a749f35186f923f71b3132a15add0735376e73978f41f552b92e9d43cbab"
|
checksum = "bfdbed3a10ae9b22df06bee8cd0023255358935aae8e8daf9d1a006cfaeeb11e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1217,24 +1218,24 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "marine-rs-sdk"
|
name = "marine-rs-sdk"
|
||||||
version = "0.6.14"
|
version = "0.6.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b349c8b5a09045a2a509f7ee5106a52c70ef6782febe9be6748044c6f8c477a"
|
checksum = "4d17d44016675abdf18caf3ac1bdd4437cc17ec0db019da141bb06a9ea991726"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"marine-macro",
|
"marine-macro",
|
||||||
"marine-rs-sdk-main",
|
"marine-rs-sdk-main",
|
||||||
"marine-timestamp-macro",
|
"marine-timestamp-macro",
|
||||||
|
"polyplets",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "marine-rs-sdk-main"
|
name = "marine-rs-sdk-main"
|
||||||
version = "0.6.14"
|
version = "0.6.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e9d9b9ecd87f0dfa8ad9ee594e71f71d8b4f0b819d3b025632a1a6597063088"
|
checksum = "8ff262801664ce22f9d274504d6e8088c217034aba0ca431eca8d0258f3699c6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"marine-macro",
|
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1270,9 +1271,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "marine-timestamp-macro"
|
name = "marine-timestamp-macro"
|
||||||
version = "0.6.14"
|
version = "0.6.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb6e81c03cc0c2f546680bf21e10f3514f69acfa4d4d84a8f2b17b2fcebe8ce9"
|
checksum = "85a9f5b1adeff98ac5a14cfc5fa814185a807ba4a0d3849c9f9e9fd868b27d1f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1542,9 +1543,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polyplets"
|
name = "polyplets"
|
||||||
version = "0.1.2"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"marine-rs-sdk",
|
"marine-macro",
|
||||||
|
"marine-rs-sdk-main",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1574,9 +1576,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.30"
|
version = "1.0.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70"
|
checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
@ -1901,9 +1903,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.80"
|
version = "1.0.81"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"
|
checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -29,3 +29,6 @@ debug = true
|
|||||||
overflow-checks = true
|
overflow-checks = true
|
||||||
debug-assertions = false
|
debug-assertions = false
|
||||||
panic = "unwind"
|
panic = "unwind"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
polyplets = { path = "crates/air-lib/polyplets" }
|
||||||
|
@ -21,7 +21,7 @@ path = "src/marine.rs"
|
|||||||
air = { path = "../air" }
|
air = { path = "../air" }
|
||||||
air-log-targets = { path = "../crates/air-lib/log-targets" }
|
air-log-targets = { path = "../crates/air-lib/log-targets" }
|
||||||
|
|
||||||
marine-rs-sdk = { version = "0.6.11", features = ["logger"] }
|
marine-rs-sdk = { version = "0.6.15", features = ["logger"] }
|
||||||
|
|
||||||
# Keep 0.2.65 until this is resolved https://github.com/rustwasm/wasm-pack/issues/886
|
# Keep 0.2.65 until this is resolved https://github.com/rustwasm/wasm-pack/issues/886
|
||||||
wasm-bindgen = "=0.2.65"
|
wasm-bindgen = "=0.2.65"
|
||||||
|
@ -24,7 +24,7 @@ air-lambda-ast = { path = "../crates/air-lib/lambda/ast" }
|
|||||||
air-lambda-parser = { path = "../crates/air-lib/lambda/parser" }
|
air-lambda-parser = { path = "../crates/air-lib/lambda/parser" }
|
||||||
air-trace-handler = { path = "../crates/air-lib/trace-handler" }
|
air-trace-handler = { path = "../crates/air-lib/trace-handler" }
|
||||||
polyplets = { path = "../crates/air-lib/polyplets" }
|
polyplets = { path = "../crates/air-lib/polyplets" }
|
||||||
marine-rs-sdk = { version = "0.6.11", features = ["logger"] }
|
marine-rs-sdk = { version = "0.6.15", features = ["logger"] }
|
||||||
|
|
||||||
serde = { version = "1.0.118", features = [ "derive", "rc" ] }
|
serde = { version = "1.0.118", features = [ "derive", "rc" ] }
|
||||||
serde_json = "1.0.61"
|
serde_json = "1.0.61"
|
||||||
|
@ -63,7 +63,7 @@ fn set_last_error<'i>(
|
|||||||
// use tetraplet if they set, because an error could be propagated from data
|
// use tetraplet if they set, because an error could be propagated from data
|
||||||
// (from CallServiceFailed state) and exec_ctx.current_peer_id won't mean
|
// (from CallServiceFailed state) and exec_ctx.current_peer_id won't mean
|
||||||
// a peer where the error was occurred
|
// a peer where the error was occurred
|
||||||
Some(tetraplet) => tetraplet.borrow().triplet.peer_pk.clone(),
|
Some(tetraplet) => tetraplet.borrow().peer_pk.clone(),
|
||||||
None => exec_ctx.current_peer_id.to_string(),
|
None => exec_ctx.current_peer_id.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ pub(super) fn handle_prev_state<'i>(
|
|||||||
}
|
}
|
||||||
RequestSentBy(..) => {
|
RequestSentBy(..) => {
|
||||||
// check whether current node can execute this call
|
// check whether current node can execute this call
|
||||||
let is_current_peer = tetraplet.borrow().triplet.peer_pk.as_str() == exec_ctx.current_peer_id.as_str();
|
let is_current_peer = tetraplet.borrow().peer_pk.as_str() == exec_ctx.current_peer_id.as_str();
|
||||||
if is_current_peer {
|
if is_current_peer {
|
||||||
// if this peer could execute this call early return and
|
// if this peer could execute this call early return and
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
|
@ -31,7 +31,6 @@ use air_interpreter_interface::CallRequestParams;
|
|||||||
use air_parser::ast::{AstVariable, CallInstrArgValue, CallOutputValue};
|
use air_parser::ast::{AstVariable, CallInstrArgValue, CallOutputValue};
|
||||||
use air_trace_handler::MergerCallResult;
|
use air_trace_handler::MergerCallResult;
|
||||||
use air_trace_handler::TraceHandler;
|
use air_trace_handler::TraceHandler;
|
||||||
use polyplets::ResolvedTriplet;
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -75,7 +74,7 @@ impl<'i> ResolvedCall<'i> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// call can be executed only on peers with such peer_id
|
// call can be executed only on peers with such peer_id
|
||||||
let tetraplet = &self.tetraplet.borrow().triplet;
|
let tetraplet = &self.tetraplet.borrow();
|
||||||
if tetraplet.peer_pk.as_str() != exec_ctx.current_peer_id.as_str() {
|
if tetraplet.peer_pk.as_str() != exec_ctx.current_peer_id.as_str() {
|
||||||
set_remote_call_result(tetraplet.peer_pk.clone(), exec_ctx, trace_ctx);
|
set_remote_call_result(tetraplet.peer_pk.clone(), exec_ctx, trace_ctx);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -101,7 +100,7 @@ impl<'i> ResolvedCall<'i> {
|
|||||||
fn prepare_request_params(
|
fn prepare_request_params(
|
||||||
&self,
|
&self,
|
||||||
exec_ctx: &ExecutionCtx<'i>,
|
exec_ctx: &ExecutionCtx<'i>,
|
||||||
triplet: &ResolvedTriplet,
|
tetraplet: &SecurityTetraplet,
|
||||||
) -> ExecutionResult<CallRequestParams> {
|
) -> ExecutionResult<CallRequestParams> {
|
||||||
let ResolvedArguments {
|
let ResolvedArguments {
|
||||||
call_arguments,
|
call_arguments,
|
||||||
@ -111,8 +110,8 @@ impl<'i> ResolvedCall<'i> {
|
|||||||
let serialized_tetraplets = serde_json::to_string(&tetraplets).expect("default serializer shouldn't fail");
|
let serialized_tetraplets = serde_json::to_string(&tetraplets).expect("default serializer shouldn't fail");
|
||||||
|
|
||||||
let request_params = CallRequestParams::new(
|
let request_params = CallRequestParams::new(
|
||||||
triplet.service_id.to_string(),
|
tetraplet.service_id.to_string(),
|
||||||
triplet.function_name.to_string(),
|
tetraplet.function_name.to_string(),
|
||||||
call_arguments,
|
call_arguments,
|
||||||
serialized_tetraplets,
|
serialized_tetraplets,
|
||||||
);
|
);
|
||||||
|
@ -76,10 +76,10 @@ fn last_error_tetraplets() {
|
|||||||
r#"Local service error, ret_code is 1, error message is '"error"'"#
|
r#"Local service error, ret_code is 1, error message is '"error"'"#
|
||||||
);
|
);
|
||||||
|
|
||||||
let triplet = (*tetraplets.borrow()).as_ref().unwrap()[0][0].triplet.clone();
|
let tetraplet = (*tetraplets.borrow()).as_ref().unwrap()[0][0].clone();
|
||||||
assert_eq!(triplet.peer_pk, fallible_peer_id);
|
assert_eq!(tetraplet.peer_pk, fallible_peer_id);
|
||||||
assert_eq!(triplet.service_id, "fallible_call_service");
|
assert_eq!(tetraplet.service_id, "fallible_call_service");
|
||||||
assert_eq!(triplet.function_name, "");
|
assert_eq!(tetraplet.function_name, "");
|
||||||
assert_eq!(&(*tetraplets.borrow()).as_ref().unwrap()[0][0].json_path, "");
|
assert_eq!(&(*tetraplets.borrow()).as_ref().unwrap()[0][0].json_path, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use air::ResolvedTriplet;
|
|
||||||
use air::SecurityTetraplet;
|
use air::SecurityTetraplet;
|
||||||
use air_test_utils::prelude::*;
|
use air_test_utils::prelude::*;
|
||||||
|
|
||||||
@ -74,23 +73,17 @@ fn simple_fold() {
|
|||||||
let result = checked_call_vm!(set_variable_vm, init_peer_id.clone(), script.clone(), "", "");
|
let result = checked_call_vm!(set_variable_vm, init_peer_id.clone(), script.clone(), "", "");
|
||||||
let mut data = result.data;
|
let mut data = result.data;
|
||||||
|
|
||||||
let first_arg_triplet = ResolvedTriplet {
|
let first_arg_tetraplet = SecurityTetraplet {
|
||||||
peer_pk: set_variable_vm_peer_id,
|
peer_pk: set_variable_vm_peer_id,
|
||||||
service_id,
|
service_id,
|
||||||
function_name,
|
function_name,
|
||||||
};
|
|
||||||
let first_arg_tetraplet = SecurityTetraplet {
|
|
||||||
triplet: first_arg_triplet,
|
|
||||||
json_path: String::new(),
|
json_path: String::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let second_arg_triplet = ResolvedTriplet {
|
let second_arg_tetraplet = SecurityTetraplet {
|
||||||
peer_pk: init_peer_id.clone(),
|
peer_pk: init_peer_id.clone(),
|
||||||
service_id: String::new(),
|
service_id: String::new(),
|
||||||
function_name: String::new(),
|
function_name: String::new(),
|
||||||
};
|
|
||||||
let second_arg_tetraplet = SecurityTetraplet {
|
|
||||||
triplet: second_arg_triplet,
|
|
||||||
json_path: String::new(),
|
json_path: String::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,23 +130,17 @@ fn fold_json_path() {
|
|||||||
let init_peer_id = String::from("some_init_peer_id");
|
let init_peer_id = String::from("some_init_peer_id");
|
||||||
let result = checked_call_vm!(set_variable_vm, init_peer_id.clone(), script.clone(), "", "");
|
let result = checked_call_vm!(set_variable_vm, init_peer_id.clone(), script.clone(), "", "");
|
||||||
|
|
||||||
let first_arg_triplet = ResolvedTriplet {
|
let first_arg_tetraplet = SecurityTetraplet {
|
||||||
peer_pk: set_variable_vm_peer_id,
|
peer_pk: set_variable_vm_peer_id,
|
||||||
service_id,
|
service_id,
|
||||||
function_name,
|
function_name,
|
||||||
};
|
|
||||||
let first_arg_tetraplet = SecurityTetraplet {
|
|
||||||
triplet: first_arg_triplet,
|
|
||||||
json_path: String::from(".args"),
|
json_path: String::from(".args"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let second_arg_triplet = ResolvedTriplet {
|
let second_arg_tetraplet = SecurityTetraplet {
|
||||||
peer_pk: init_peer_id.clone(),
|
peer_pk: init_peer_id.clone(),
|
||||||
service_id: String::new(),
|
service_id: String::new(),
|
||||||
function_name: String::new(),
|
function_name: String::new(),
|
||||||
};
|
|
||||||
let second_arg_tetraplet = SecurityTetraplet {
|
|
||||||
triplet: second_arg_triplet,
|
|
||||||
json_path: String::new(),
|
json_path: String::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,6 +10,6 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
air = { path = "../../../../../../air" }
|
air = { path = "../../../../../../air" }
|
||||||
marine-rs-sdk = "0.6.11"
|
marine-rs-sdk = "0.6.15"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
@ -10,6 +10,6 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
air = { path = "../../../../../../air" }
|
air = { path = "../../../../../../air" }
|
||||||
marine-rs-sdk = "0.6.11"
|
marine-rs-sdk = "0.6.15"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
@ -19,7 +19,7 @@ path = "src/lib.rs"
|
|||||||
air-interpreter-interface = { version = "0.7.0", path = "../../crates/air-lib/interpreter-interface" }
|
air-interpreter-interface = { version = "0.7.0", path = "../../crates/air-lib/interpreter-interface" }
|
||||||
avm-data-store = { version = "0.1.0", path = "../../crates/data-store" }
|
avm-data-store = { version = "0.1.0", path = "../../crates/data-store" }
|
||||||
fluence-faas = "0.9.2"
|
fluence-faas = "0.9.2"
|
||||||
polyplets = { version = "0.1.2", path = "../../crates/air-lib/polyplets" }
|
polyplets = { version = "0.2.0", path = "../../crates/air-lib/polyplets" }
|
||||||
|
|
||||||
eyre = "0.6.5"
|
eyre = "0.6.5"
|
||||||
thiserror = "1.0.29"
|
thiserror = "1.0.29"
|
||||||
|
@ -16,7 +16,7 @@ name = "air_interpreter_interface"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
marine-rs-sdk = "0.6.11"
|
marine-rs-sdk = "0.6.15"
|
||||||
fluence-it-types = "0.3.0"
|
fluence-it-types = "0.3.0"
|
||||||
|
|
||||||
serde = "1.0.118"
|
serde = "1.0.118"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "polyplets"
|
name = "polyplets"
|
||||||
version = "0.1.2"
|
version = "0.2.0"
|
||||||
description = "Security primitives to verify origin of service calls in Fluence network"
|
description = "Security primitives to verify origin of service calls in Fluence network"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@ -16,6 +16,7 @@ name = "polyplets"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
marine-rs-sdk = { version = "0.6.11", features = ["logger"] }
|
marine-macro = "0.6.15"
|
||||||
serde = { version = "1.0.118", features = ["rc", "derive"] }
|
marine-rs-sdk-main = "0.6.15"
|
||||||
|
|
||||||
|
serde = { version = "1.0.118", features = ["rc", "derive"] }
|
||||||
|
@ -30,3 +30,17 @@ mod triplet;
|
|||||||
|
|
||||||
pub use tetraplet::SecurityTetraplet;
|
pub use tetraplet::SecurityTetraplet;
|
||||||
pub use triplet::ResolvedTriplet;
|
pub use triplet::ResolvedTriplet;
|
||||||
|
|
||||||
|
// This is a temporary solution that allow using the marine macro by importing
|
||||||
|
// just marine-macro crate instead of marine-rs-sdk.
|
||||||
|
#[allow(unused_extern_crates)]
|
||||||
|
extern crate self as marine_rs_sdk;
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
mod internal {
|
||||||
|
pub(crate) use marine_rs_sdk_main::add_object_to_release;
|
||||||
|
pub(crate) use marine_rs_sdk_main::get_result_ptr;
|
||||||
|
pub(crate) use marine_rs_sdk_main::get_result_size;
|
||||||
|
pub(crate) use marine_rs_sdk_main::set_result_ptr;
|
||||||
|
pub(crate) use marine_rs_sdk_main::set_result_size;
|
||||||
|
}
|
||||||
|
@ -16,15 +16,22 @@
|
|||||||
|
|
||||||
use crate::ResolvedTriplet;
|
use crate::ResolvedTriplet;
|
||||||
|
|
||||||
|
use marine_macro::marine;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
/// Describes an origin returned corresponding value.
|
/// Describes an origin that set corresponding value.
|
||||||
|
#[marine]
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
/// Describes origin of the value in the network.
|
/// Id of a peer where corresponding value was set.
|
||||||
#[serde(flatten)]
|
pub peer_pk: String,
|
||||||
pub triplet: ResolvedTriplet,
|
|
||||||
|
/// Id of a service that set corresponding value.
|
||||||
|
pub service_id: String,
|
||||||
|
|
||||||
|
/// Name of a function that returned corresponding value.
|
||||||
|
pub function_name: String,
|
||||||
|
|
||||||
/// Value was produced by applying this `json_path` to the output from `call_service`.
|
/// Value was produced by applying this `json_path` to the output from `call_service`.
|
||||||
// TODO: since it's not a json path anymore, it's needed to rename it to lambda
|
// TODO: since it's not a json path anymore, it's needed to rename it to lambda
|
||||||
@ -35,15 +42,11 @@ impl SecurityTetraplet {
|
|||||||
/// Create a tetraplet for string literals defined in the script
|
/// Create a tetraplet for string literals defined in the script
|
||||||
/// such as variable here `(call ("" "") "" ["variable_1"])`.
|
/// such as variable here `(call ("" "") "" ["variable_1"])`.
|
||||||
pub fn literal_tetraplet(init_peer_id: String) -> Self {
|
pub fn literal_tetraplet(init_peer_id: String) -> Self {
|
||||||
let triplet = ResolvedTriplet {
|
Self {
|
||||||
// these variables represent the initiator peer
|
// these variables represent the initiator peer
|
||||||
peer_pk: init_peer_id,
|
peer_pk: init_peer_id,
|
||||||
service_id: String::new(),
|
service_id: String::new(),
|
||||||
function_name: String::new(),
|
function_name: String::new(),
|
||||||
};
|
|
||||||
|
|
||||||
Self {
|
|
||||||
triplet,
|
|
||||||
// json path can't be applied to the string literals
|
// json path can't be applied to the string literals
|
||||||
json_path: String::new(),
|
json_path: String::new(),
|
||||||
}
|
}
|
||||||
@ -51,7 +54,9 @@ impl SecurityTetraplet {
|
|||||||
|
|
||||||
pub fn from_triplet(triplet: ResolvedTriplet) -> Self {
|
pub fn from_triplet(triplet: ResolvedTriplet) -> Self {
|
||||||
Self {
|
Self {
|
||||||
triplet,
|
peer_pk: triplet.peer_pk,
|
||||||
|
service_id: triplet.service_id,
|
||||||
|
function_name: triplet.function_name,
|
||||||
json_path: String::new(),
|
json_path: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ use serde::Serialize;
|
|||||||
|
|
||||||
/// ResolvedTriplet represents peer network location with all
|
/// ResolvedTriplet represents peer network location with all
|
||||||
/// variables, literals and etc resolved into final string.
|
/// variables, literals and etc resolved into final string.
|
||||||
|
/// This structure contains a subset of values that
|
||||||
|
/// SecurityTetraplet consists of.
|
||||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||||
pub struct ResolvedTriplet {
|
pub struct ResolvedTriplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
|
@ -17,6 +17,6 @@ path = "src/lib.rs"
|
|||||||
air = { path = "../../../air" }
|
air = { path = "../../../air" }
|
||||||
air-interpreter-interface = { path = "../interpreter-interface" }
|
air-interpreter-interface = { path = "../interpreter-interface" }
|
||||||
avm-server = { path = "../../../avm/server" }
|
avm-server = { path = "../../../avm/server" }
|
||||||
marine-rs-sdk = "0.6.13"
|
marine-rs-sdk = "0.6.15"
|
||||||
|
|
||||||
serde_json = "1.0.61"
|
serde_json = "1.0.61"
|
||||||
|
Loading…
Reference in New Issue
Block a user