mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
feat(polyplets)!: move SecurityTetraplets to marine-rs-sdk (#674)
* wip
* remove patch.crates-io section
* switch from Into to From
* fmt + Cargo.lock update
* try use marine-rs-sdk 0.9.0
* Revert "try use marine-rs-sdk 0.9.0"
This reverts commit 603c18fb71
.
This commit is contained in:
parent
681ec35d07
commit
7a8a460572
24
Cargo.lock
generated
24
Cargo.lock
generated
@ -92,7 +92,7 @@ dependencies = [
|
|||||||
"newtype_derive",
|
"newtype_derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"polyplets",
|
"polyplets 0.4.1",
|
||||||
"semver 1.0.17",
|
"semver 1.0.17",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -195,7 +195,7 @@ dependencies = [
|
|||||||
"bimap",
|
"bimap",
|
||||||
"log",
|
"log",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"polyplets",
|
"polyplets 0.4.1",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tracing",
|
"tracing",
|
||||||
@ -324,7 +324,7 @@ dependencies = [
|
|||||||
"marine-rs-sdk",
|
"marine-rs-sdk",
|
||||||
"non-empty-vec",
|
"non-empty-vec",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"polyplets",
|
"polyplets 0.4.1",
|
||||||
"pretty_assertions 0.6.1",
|
"pretty_assertions 0.6.1",
|
||||||
"semver 1.0.17",
|
"semver 1.0.17",
|
||||||
"serde",
|
"serde",
|
||||||
@ -473,7 +473,7 @@ dependencies = [
|
|||||||
"air-utils",
|
"air-utils",
|
||||||
"log",
|
"log",
|
||||||
"maplit",
|
"maplit",
|
||||||
"polyplets",
|
"polyplets 0.4.1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
@ -494,7 +494,7 @@ dependencies = [
|
|||||||
"maplit",
|
"maplit",
|
||||||
"marine-runtime",
|
"marine-runtime",
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"polyplets",
|
"polyplets 0.4.1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
@ -2275,7 +2275,7 @@ dependencies = [
|
|||||||
"marine-macro",
|
"marine-macro",
|
||||||
"marine-rs-sdk-main",
|
"marine-rs-sdk-main",
|
||||||
"marine-timestamp-macro",
|
"marine-timestamp-macro",
|
||||||
"polyplets",
|
"polyplets 0.4.0",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2735,13 +2735,23 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polyplets"
|
name = "polyplets"
|
||||||
version = "0.4.1"
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b579a79a461ca50abb202eac61c76d8782fdf091a91775c9e181352e7cd30a8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"marine-macro",
|
"marine-macro",
|
||||||
"marine-rs-sdk-main",
|
"marine-rs-sdk-main",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "polyplets"
|
||||||
|
version = "0.4.1"
|
||||||
|
dependencies = [
|
||||||
|
"marine-rs-sdk",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
|
@ -38,6 +38,3 @@ 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" }
|
|
||||||
|
@ -73,7 +73,7 @@ impl<'i> ResolvedCall<'i> {
|
|||||||
#[tracing::instrument(level = "trace", skip_all)]
|
#[tracing::instrument(level = "trace", skip_all)]
|
||||||
pub(super) fn new(raw_call: &Call<'i>, exec_ctx: &ExecutionCtx<'i>) -> ExecutionResult<Self> {
|
pub(super) fn new(raw_call: &Call<'i>, exec_ctx: &ExecutionCtx<'i>) -> ExecutionResult<Self> {
|
||||||
let triplet = resolve(&raw_call.triplet, exec_ctx)?;
|
let triplet = resolve(&raw_call.triplet, exec_ctx)?;
|
||||||
let tetraplet = SecurityTetraplet::from_triplet(triplet);
|
let tetraplet = triplet.into();
|
||||||
let tetraplet = Rc::new(tetraplet);
|
let tetraplet = Rc::new(tetraplet);
|
||||||
|
|
||||||
check_output_name(&raw_call.output, exec_ctx)?;
|
check_output_name(&raw_call.output, exec_ctx)?;
|
||||||
|
@ -15,7 +15,6 @@ name = "polyplets"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
marine-macro = "0.8.1"
|
marine-rs-sdk = "0.8.1"
|
||||||
marine-rs-sdk-main = "0.8.1"
|
|
||||||
|
|
||||||
serde = { version = "1.0.164", features = ["rc", "derive"] }
|
serde = { version = "1.0.164", features = ["rc", "derive"] }
|
||||||
|
@ -26,22 +26,7 @@
|
|||||||
unreachable_patterns
|
unreachable_patterns
|
||||||
)]
|
)]
|
||||||
|
|
||||||
mod tetraplet;
|
|
||||||
mod triplet;
|
mod triplet;
|
||||||
|
|
||||||
pub use tetraplet::SecurityTetraplet;
|
pub use marine_rs_sdk::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;
|
|
||||||
}
|
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 Fluence Labs Limited
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use crate::ResolvedTriplet;
|
|
||||||
|
|
||||||
use marine_macro::marine;
|
|
||||||
use serde::Deserialize;
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
/// Describes an origin that set corresponding value.
|
|
||||||
#[marine]
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
|
||||||
pub struct SecurityTetraplet {
|
|
||||||
/// Id of a peer where corresponding value was set.
|
|
||||||
pub peer_pk: String,
|
|
||||||
|
|
||||||
/// 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`.
|
|
||||||
// TODO: since it's not a json path anymore, it's needed to rename it to lambda
|
|
||||||
pub json_path: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SecurityTetraplet {
|
|
||||||
pub fn new(
|
|
||||||
peer_pk: impl Into<String>,
|
|
||||||
service_id: impl Into<String>,
|
|
||||||
function_name: impl Into<String>,
|
|
||||||
json_path: impl Into<String>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
peer_pk: peer_pk.into(),
|
|
||||||
service_id: service_id.into(),
|
|
||||||
function_name: function_name.into(),
|
|
||||||
json_path: json_path.into(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a tetraplet for string literals defined in the script
|
|
||||||
/// such as variable here `(call ("" "") "" ["variable_1"])`.
|
|
||||||
pub fn literal_tetraplet(init_peer_id: impl Into<String>) -> Self {
|
|
||||||
Self {
|
|
||||||
// these variables represent the initiator peer
|
|
||||||
peer_pk: init_peer_id.into(),
|
|
||||||
service_id: String::new(),
|
|
||||||
function_name: String::new(),
|
|
||||||
// json path can't be applied to the string literals
|
|
||||||
json_path: String::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_triplet(triplet: ResolvedTriplet) -> Self {
|
|
||||||
Self {
|
|
||||||
peer_pk: triplet.peer_pk,
|
|
||||||
service_id: triplet.service_id,
|
|
||||||
function_name: triplet.function_name,
|
|
||||||
json_path: String::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_lambda(&mut self, json_path: &str) {
|
|
||||||
self.json_path.push_str(json_path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
impl fmt::Display for SecurityTetraplet {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(
|
|
||||||
f,
|
|
||||||
"peer_pk: {}, service_id: {}, function_name: {}, json_path: {}",
|
|
||||||
self.peer_pk, self.service_id, self.function_name, self.json_path
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use marine_rs_sdk::SecurityTetraplet;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
@ -27,3 +29,14 @@ pub struct ResolvedTriplet {
|
|||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ResolvedTriplet> for SecurityTetraplet {
|
||||||
|
fn from(triplet: ResolvedTriplet) -> Self {
|
||||||
|
Self {
|
||||||
|
peer_pk: triplet.peer_pk,
|
||||||
|
service_id: triplet.service_id,
|
||||||
|
function_name: triplet.function_name,
|
||||||
|
json_path: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user