Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr Maxim Orlovsky committed Nov 15, 2024
1 parent 9413a3e commit 62b5d30
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Ultraviolet revives P2P with client-side validation, enabling a mind-blowing TPS rate, supporting
IoT and AI dApps, and providing trustless multichain gateways & DEX.

This repository hosts command-line executables for connecting and using ultraviolet network. It also
This repository hosts command-line executables for connecting and using Ultraviolet network. It also
includes a set of libraries which can be used by wallet, exchange and other developers to integrate
Ultraviolet into their products. However, for developers, we recommend to use [Ultraviolet SDK]
(which internally uses crates from this repository, but provides language-specific bindings and
Expand Down
41 changes: 41 additions & 0 deletions doc/worflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Fulfilling invoice:

| Action | Prime | BP | Input | Output | Method | Components |
|-------------------------------------|---------------|------------------|----------------|-------------|----------------|------------|
| 1. Draft operation | mine PoW | | Invoice | OpPrefab | prefab_op | Stockpile |
| 2. Create witness for the operation | not needed | blanks, mine PoW | OpPrefab | PSBT | construct_psbt | Possessor |
| | | | OpPerfab, PSBT | PSBT | color_psbt | Stockpile |
| 4. Add operation to the stockpile | | ops | OpPrefab | | import_prefab | Stockpile |
| 5. Prepare consignment | removing sigs | | OpPrefab | Consignment | consign | Stockpile |
| 6. Send consignment to receiver | | | Consignment | OpConfirm | - | - |
| 7a. Sign operation | | not needed | OpPrefab | Operation | | Signer |
| 7b. Sign witness | not needed | | PSBT | Tx | | Signer |
| 8. Send to miners | | | Request | Witness | - | - |
| 9. Store witness | | | Witness | | import_witness | Pile |
| 10. Store & send op to receiver | | not needed | Operation | | import_op | Stock |

Multiparty procedures (like multisigs of payjoins) happen in step 3 (for BP) and step 5 (Prime, only
multisigs).

Consignment: must have a header defining type of seal. Should include witness information, and
a dedicated section on terminals.

Everything is in the stockpile:

- `stock`: partially-replicable state machine (PRISM) data, including:
- `stash`: ledger of the contract operations (calls to contract state transitioning methods);
- `state`: most recent contract state;
- `trace`: incremental updates to the contract states from contract calls;
- `repo`: repository of contract declarations and interfaces;
- `pile`: proof-of-publication data, store of witnesses and their links to operations, consisting of:
- `hoard`: client-side witnesses (must be backed up, required for consensus);
- `cache`: cache of published witnesses;
- `index`: mapping of witnesses to operations (recoverable, but hard).

For read access, the only thing which is needed is contract state.
Wallet (possessor) acts as a prism (or a filter), allowing to see only the part of the state owned by the user.
Thus, the only form of a wallet we need for the read access is the seal filter.

On the sending side, we need wallet only when we prepare a witness for the operation, which is needed only in BP.

On the receiving side, we do not need wallet at all.
60 changes: 60 additions & 0 deletions src/wallet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Ultraviolet: post-blockchain P2P smart contracts
//
// SPDX-License-Identifier: Apache-2.0
//
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
// Written in 2024 by Dr Maxim Orlovsky <[email protected]>
//
// Copyright (C) 2024-2025 Ultraviolet Alliance. All rights 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 std::collections::BTreeSet;

/////
pub struct ContractId;

pub struct TxPrefab {
pub layer1: L1Prefab,
pub sonic: OpPrefab,
}
/////

pub trait ContractReader {}

pub trait ContractIface {}

pub trait Stockpile {
fn contracts_list(&self) -> impl Iterator<Item = ContractInfo>;
fn has_contract(&self, contract_id: ContractId) -> bool;
fn contract(&self, contract_id: ContractId) -> Option<impl ContractReader>;

fn import(&mut self, prefab: VerifiedKit);
fn consume(&mut self, consignment: Consignment);
}

pub trait Possessor {

}

pub struct Portfolio<S: Stockpile, P: Possessor> {
pub possessor: P,
pub stockpile: S,
}

impl<Stock: Stockpile, Owner: OwnerAccount> Portfolio<Stock, Owner> {
pub fn owned_assets(&self, iface: impl Into<IfaceName>) -> BTreeSet<ContractId, ContractAssets> {}
pub fn prepare(&mut self, invoice: Invoice) -> Result<TxPrefab, FullfilmentError> {}
pub fn consign(&mut self, op: Operation) -> Result<Consignment, ConsignError> {}

/// Stores information about operation in stockpile, once the operation is signed and the witness is mined.
pub fn store(&mut self, witness: Witness) -> Result<(), CompletionError> {}
}

0 comments on commit 62b5d30

Please sign in to comment.