Skip to content

Commit

Permalink
request and API drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 17, 2024
1 parent a898a93 commit 29bff25
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 116 deletions.
69 changes: 53 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [".", "inmem"]
default-members = [".", "inmem"]
members = [".", "inmem", "request"]
default-members = [".", "inmem", "request"]

[workspace.package]
version = "0.12.0-alpha.1"
Expand All @@ -15,8 +15,8 @@ rust-version = "1.77.0" # Due to `rustfix`

[workspace.dependencies]
amplify = "~4.8.0"
strict_encoding = "~2.8.0"
strict_types = "~2.8.0"
strict_encoding = "~2.8.1"
strict_types = "~2.8.1"
aluvm = "0.12.0-beta.2"
ultrasonic = "0.12.0-beta.1"
serde = { version = "1", features = ["derive"] }
Expand All @@ -41,7 +41,7 @@ name = "sonare"

[dependencies]
amplify.workspace = true
baid64 = "0.3.0"
baid64 = "0.4.0"
strict_encoding.workspace = true
strict_types.workspace = true
commit_verify = "0.12.0-alpha.3"
Expand Down Expand Up @@ -72,3 +72,6 @@ wasm-bindgen-test = "0.3"

[package.metadata.docs.rs]
features = ["all"]

[patch.crates-io]
ultrasonic = { git = "https://github.com/AluVM/ultrasonic" }
28 changes: 28 additions & 0 deletions request/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "sonare-request"
version.workspace = true
authors.workspace = true
description = "SONARE request builders and parsers"
repository.workspace = true
homepage.workspace = true
keywords.workspace = true
categories = ["algorithms", "cryptography", "science", "no-std"]
readme.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
exclude = [".github"]

[dependencies]
amplify.workspace = true
strict_encoding.workspace = true
strict_types.workspace = true
ultrasonic.workspace = true
sonare = { version = "0.12.0-alpha.1", path = ".." }
serde = { workspace = true, optional = true }

[features]
default = ["std"]
all = ["std"]

std = []
44 changes: 44 additions & 0 deletions request/src/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SONARE: Runtime environment for formally-verifiable distributed software
//
// SPDX-License-Identifier: Apache-2.0
//
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
//
// Copyright (C) 2019-2025 LNP/BP Standards Association, Switzerland.
// Copyright (C) 2024-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
// Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
// All rights under the above copyrights are reserved.
//
// 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 amplify::confinement::{TinyString, TinyVec};
use strict_types::StrictVal;
use ultrasonic::{ContractId, ProofOfPubl};

pub trait SonareProtocol {
const URL_SCHEME: &'static str;
type PoP: ProofOfPubl;
}

pub struct Request<S: SonareProtocol> {
pub pop: S::PoP,
pub contract_id: Option<ContractId>,
pub interface: Option<TinyString>,
pub method: Option<TinyString>,
pub args: TinyVec<RequestArg>,
}

pub struct RequestArg {
pub name: TinyString,
pub value: StrictVal,
}
32 changes: 32 additions & 0 deletions request/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SONARE: Runtime environment for formally-verifiable distributed software
//
// SPDX-License-Identifier: Apache-2.0
//
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
//
// Copyright (C) 2019-2025 LNP/BP Standards Association, Switzerland.
// Copyright (C) 2024-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
// Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
// All rights under the above copyrights are reserved.
//
// 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.

#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]

//! _Request_ (or _transaction request_) is a specification on constructing a transaction for a
//! SONARE contract.
mod data;

extern crate alloc;
53 changes: 53 additions & 0 deletions src/api/alu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SONARE: Runtime environment for formally-verifiable distributed software
//
// SPDX-License-Identifier: Apache-2.0
//
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
//
// Copyright (C) 2019-2025 LNP/BP Standards Association, Switzerland.
// Copyright (C) 2024-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
// Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
// All rights under the above copyrights are reserved.
//
// 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 aluvm::LibSite;

use super::{ApiVm, ApiVmType, StateArithm};
use crate::StructData;

impl ApiVm for aluvm::Vm {
const TYPE: ApiVmType = ApiVmType::AluVM;
type Arithm = AluVMArithm;
type ReaderSite = LibSite;
type AdaptorSite = LibSite;
}

pub struct AluVMArithm {
pub vm: Option<aluvm::Vm>,
pub accumulate: LibSite,
pub lessen: LibSite,
pub diff: LibSite,
}

impl StateArithm for AluVMArithm {
type Site = LibSite;

fn measure(&self, state: StructData) -> Option<u8> { todo!() }

fn accumulate(&mut self, state: StructData) -> Option<()> { todo!() }

fn lessen(&mut self, state: StructData) -> Option<()> { todo!() }

fn diff(&self) -> Option<StructData> { todo!() }
}
Loading

0 comments on commit 29bff25

Please sign in to comment.