Skip to content

Commit 4e9d064

Browse files
committed
request and API drafts
1 parent a898a93 commit 4e9d064

File tree

14 files changed

+431
-126
lines changed

14 files changed

+431
-126
lines changed

Cargo.lock

Lines changed: 53 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
2-
members = [".", "inmem"]
3-
default-members = [".", "inmem"]
2+
members = [".", "inmem", "request"]
3+
default-members = [".", "inmem", "request"]
44

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

1616
[workspace.dependencies]
1717
amplify = "~4.8.0"
18-
strict_encoding = "~2.8.0"
19-
strict_types = "~2.8.0"
18+
strict_encoding = "~2.8.1"
19+
strict_types = "~2.8.1"
2020
aluvm = "0.12.0-beta.2"
2121
ultrasonic = "0.12.0-beta.1"
2222
serde = { version = "1", features = ["derive"] }
@@ -41,7 +41,7 @@ name = "sonare"
4141

4242
[dependencies]
4343
amplify.workspace = true
44-
baid64 = "0.3.0"
44+
baid64 = "0.4.0"
4545
strict_encoding.workspace = true
4646
strict_types.workspace = true
4747
commit_verify = "0.12.0-alpha.3"
@@ -72,3 +72,6 @@ wasm-bindgen-test = "0.3"
7272

7373
[package.metadata.docs.rs]
7474
features = ["all"]
75+
76+
[patch.crates-io]
77+
ultrasonic = { git = "https://github.com/AluVM/ultrasonic" }

inmem/src/state.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131
//! persistence solution adapted for enterprise needs.
3232
3333
use amplify::confinement::{SmallOrdMap, SmallVec, TinyOrdMap};
34-
use sonare::{StateTy, StructData};
34+
use sonare::api::ApiId;
35+
use sonare::state::{StateTy, StructData};
3536
use ultrasonic::{CellAddr, StateCell, StateData};
3637

37-
// TODO: Remove temporary type
38-
pub type IfaceId = u128;
39-
4038
/// The state as it is defined in the contract. Accessed during the validation.
4139
pub struct RawState {
4240
pub append_only: SmallOrdMap<CellAddr, StateData>,
@@ -65,7 +63,7 @@ pub struct MemState {
6563
///
6664
/// When more API adaptors are added, these values are either lazy computed - or computed in a
6765
/// background task.
68-
pub converted: TinyOrdMap<IfaceId, ConvertedState>,
66+
pub converted: TinyOrdMap<ApiId, ConvertedState>,
6967

7068
/// Index for resolving state types into values.
7169
pub index: StateIndex,

request/Cargo.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "sonare-request"
3+
version.workspace = true
4+
authors.workspace = true
5+
description = "SONARE request builders and parsers"
6+
repository.workspace = true
7+
homepage.workspace = true
8+
keywords.workspace = true
9+
categories = ["algorithms", "cryptography", "science", "no-std"]
10+
readme.workspace = true
11+
license.workspace = true
12+
edition.workspace = true
13+
rust-version.workspace = true
14+
exclude = [".github"]
15+
16+
[dependencies]
17+
amplify.workspace = true
18+
strict_encoding.workspace = true
19+
strict_types.workspace = true
20+
ultrasonic.workspace = true
21+
sonare = { version = "0.12.0-alpha.1", path = ".." }
22+
serde = { workspace = true, optional = true }
23+
24+
[features]
25+
default = ["std"]
26+
all = ["std"]
27+
28+
std = []

request/src/data.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SONARE: Runtime environment for formally-verifiable distributed software
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
6+
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
7+
//
8+
// Copyright (C) 2019-2025 LNP/BP Standards Association, Switzerland.
9+
// Copyright (C) 2024-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
10+
// Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
11+
// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
12+
// All rights under the above copyrights are reserved.
13+
//
14+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
15+
// in compliance with the License. You may obtain a copy of the License at
16+
//
17+
// http://www.apache.org/licenses/LICENSE-2.0
18+
//
19+
// Unless required by applicable law or agreed to in writing, software distributed under the License
20+
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
21+
// or implied. See the License for the specific language governing permissions and limitations under
22+
// the License.
23+
24+
use amplify::confinement::{TinyString, TinyVec};
25+
use strict_types::StrictVal;
26+
use ultrasonic::{ContractId, ProofOfPubl};
27+
28+
pub trait SonareProtocol {
29+
const URL_SCHEME: &'static str;
30+
type PoP: ProofOfPubl;
31+
}
32+
33+
pub struct Request<S: SonareProtocol> {
34+
pub pop: S::PoP,
35+
pub contract_id: Option<ContractId>,
36+
pub interface: Option<TinyString>,
37+
pub method: Option<TinyString>,
38+
pub args: TinyVec<RequestArg>,
39+
}
40+
41+
pub struct RequestArg {
42+
pub name: TinyString,
43+
pub value: StrictVal,
44+
}

request/src/lib.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SONARE: Runtime environment for formally-verifiable distributed software
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
6+
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
7+
//
8+
// Copyright (C) 2019-2025 LNP/BP Standards Association, Switzerland.
9+
// Copyright (C) 2024-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
10+
// Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
11+
// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
12+
// All rights under the above copyrights are reserved.
13+
//
14+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
15+
// in compliance with the License. You may obtain a copy of the License at
16+
//
17+
// http://www.apache.org/licenses/LICENSE-2.0
18+
//
19+
// Unless required by applicable law or agreed to in writing, software distributed under the License
20+
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
21+
// or implied. See the License for the specific language governing permissions and limitations under
22+
// the License.
23+
24+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
25+
#![cfg_attr(not(feature = "std"), no_std)]
26+
27+
//! _Request_ (or _transaction request_) is a specification on constructing a transaction for a
28+
//! SONARE contract.
29+
30+
mod data;
31+
32+
extern crate alloc;

src/api/alu.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SONARE: Runtime environment for formally-verifiable distributed software
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
6+
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
7+
//
8+
// Copyright (C) 2019-2025 LNP/BP Standards Association, Switzerland.
9+
// Copyright (C) 2024-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
10+
// Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
11+
// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
12+
// All rights under the above copyrights are reserved.
13+
//
14+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
15+
// in compliance with the License. You may obtain a copy of the License at
16+
//
17+
// http://www.apache.org/licenses/LICENSE-2.0
18+
//
19+
// Unless required by applicable law or agreed to in writing, software distributed under the License
20+
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
21+
// or implied. See the License for the specific language governing permissions and limitations under
22+
// the License.
23+
24+
use aluvm::LibSite;
25+
26+
use super::{ApiVm, ApiVmType, StateArithm};
27+
use crate::state::StructData;
28+
29+
impl ApiVm for aluvm::Vm {
30+
const TYPE: ApiVmType = ApiVmType::AluVM;
31+
type Arithm = AluVMArithm;
32+
type ReaderSite = LibSite;
33+
type AdaptorSite = LibSite;
34+
}
35+
36+
pub struct AluVMArithm {
37+
pub vm: Option<aluvm::Vm>,
38+
pub accumulate: LibSite,
39+
pub lessen: LibSite,
40+
pub diff: LibSite,
41+
}
42+
43+
impl StateArithm for AluVMArithm {
44+
type Site = LibSite;
45+
46+
fn measure(&self, state: StructData) -> Option<u8> { todo!() }
47+
48+
fn accumulate(&mut self, state: StructData) -> Option<()> { todo!() }
49+
50+
fn lessen(&mut self, state: StructData) -> Option<()> { todo!() }
51+
52+
fn diff(&self) -> Option<StructData> { todo!() }
53+
}

0 commit comments

Comments
 (0)