From 7113c1dcc841768eda1903f9ad7fead1218129fb Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 30 Jan 2025 09:23:41 +0100 Subject: [PATCH 1/5] differentiate seal definitions from resolved seals --- Cargo.lock | 12 ++--- Cargo.toml | 10 ++-- cli/src/dump.rs | 38 +++++++------ cli/src/exec.rs | 6 +-- src/mound.rs | 74 +++++++++++++------------ src/pile.rs | 86 +++++++++++++++++------------ src/popls/bp.rs | 42 +++++++++------ src/stockpile.rs | 137 +++++++++++++++++++++++++---------------------- 8 files changed, 228 insertions(+), 177 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 957fde50..e9168c00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -238,7 +238,7 @@ checksum = "3eeab4423108c5d7c744f4d234de88d18d636100093ae04caf4825134b9c3a32" [[package]] name = "bp-consensus" version = "0.12.0-beta.4" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.12#12ff9e64b21883ffd1124173426bd6531879a522" +source = "git+https://github.com/BP-WG/bp-core?branch=wtxoseal#1487568dba4ca18b15dc211583060a7fb01096e7" dependencies = [ "amplify", "chrono", @@ -252,7 +252,7 @@ dependencies = [ [[package]] name = "bp-core" version = "0.12.0-beta.4" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.12#12ff9e64b21883ffd1124173426bd6531879a522" +source = "git+https://github.com/BP-WG/bp-core?branch=wtxoseal#1487568dba4ca18b15dc211583060a7fb01096e7" dependencies = [ "amplify", "bp-consensus", @@ -270,7 +270,7 @@ dependencies = [ [[package]] name = "bp-dbc" version = "0.12.0-beta.4" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.12#12ff9e64b21883ffd1124173426bd6531879a522" +source = "git+https://github.com/BP-WG/bp-core?branch=wtxoseal#1487568dba4ca18b15dc211583060a7fb01096e7" dependencies = [ "amplify", "base85", @@ -284,7 +284,7 @@ dependencies = [ [[package]] name = "bp-invoice" version = "0.12.0-beta.4" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.12#d8e4d74c5f6e43a8d1bab8dc3e80cf62807ada58" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.12#91aaf51498126f6a514f0d9af80888465e5dbfee" dependencies = [ "amplify", "bech32", @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "bp-seals" version = "0.12.0-beta.4" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.12#12ff9e64b21883ffd1124173426bd6531879a522" +source = "git+https://github.com/BP-WG/bp-core?branch=wtxoseal#1487568dba4ca18b15dc211583060a7fb01096e7" dependencies = [ "amplify", "baid64", @@ -738,7 +738,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.12.0-beta.4" -source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.12#3f86c299cd46604edd8690ef4914ceb9c9ded0b1" +source = "git+https://github.com/RGB-WG/rgb-core?branch=wtxoseal#43d885ffee9d6bce56ea400e5dbf90878d25b443" dependencies = [ "amplify", "bp-core", diff --git a/Cargo.toml b/Cargo.toml index 7dcf6409..3ed4872a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,9 +107,9 @@ ultrasonic = { git = "https://github.com/AluVM/ultrasonic", branch = "master" } hypersonic = { git = "https://github.com/AluVM/sonic", branch = "master" } sonic-api = { git = "https://github.com/AluVM/sonic", branch = "master" } sonic-callreq = { git = "https://github.com/AluVM/sonic", branch = "master" } -bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "v0.12" } -bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "v0.12" } -bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "v0.12" } -bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "v0.12" } +bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "wtxoseal" } +bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "wtxoseal" } +bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "wtxoseal" } +bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "wtxoseal" } bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "v0.12" } -rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.12" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "wtxoseal" } diff --git a/cli/src/dump.rs b/cli/src/dump.rs index e502bebd..9ae85f4d 100644 --- a/cli/src/dump.rs +++ b/cli/src/dump.rs @@ -35,25 +35,26 @@ use commit_verify::ReservedBytes; use hypersonic::aora::Aora; use hypersonic::{Articles, ContractId, FileSupply, Operation}; use rgb::{ - FilePile, Index, MoundConsumeError, Pile, PublishedWitness, RgbSeal, SealWitness, Stockpile, - MAGIC_BYTES_CONSIGNMENT, + FilePile, Index, MoundConsumeError, Pile, PublishedWitness, RgbSealDef, SealWitness, + SingleUseSeal, Stockpile, MAGIC_BYTES_CONSIGNMENT, }; use serde::{Deserialize, Serialize}; use strict_encoding::{DecodeError, StreamReader, StrictDecode, StrictEncode, StrictReader}; -pub fn dump_stockpile(src: &Path, dst: impl AsRef) -> anyhow::Result<()> +pub fn dump_stockpile(src: &Path, dst: impl AsRef) -> anyhow::Result<()> where - Seal: RgbSeal + Serialize + for<'de> Deserialize<'de>, - Seal::CliWitness: Serialize + StrictEncode + StrictDecode, - Seal::PubWitness: Serialize + StrictEncode + StrictDecode, - >::PubId: + SealDef: RgbSealDef + Serialize + for<'de> Deserialize<'de>, + SealDef::Src: Serialize + for<'de> Deserialize<'de>, + ::CliWitness: Serialize + StrictEncode + StrictDecode, + ::PubWitness: Serialize + StrictEncode + StrictDecode, + <::PubWitness as PublishedWitness>::PubId: Ord + From<[u8; 32]> + Into<[u8; 32]> + Serialize, { let dst = dst.as_ref(); fs::create_dir_all(dst)?; print!("Reading contract stockpile from '{}' ... ", src.display()); - let mut stockpile = Stockpile::>::load(src); + let mut stockpile = Stockpile::>::load(src); println!("success reading {}", stockpile.contract_id()); print!("Processing contract articles ... "); @@ -129,12 +130,15 @@ where Ok(()) } -pub fn dump_consignment(src: &Path, dst: impl AsRef) -> anyhow::Result<()> +pub fn dump_consignment(src: &Path, dst: impl AsRef) -> anyhow::Result<()> where - Seal: RgbSeal + Serialize, - Seal::CliWitness: Serialize + for<'de> Deserialize<'de> + StrictEncode + StrictDecode, - Seal::PubWitness: Serialize + for<'de> Deserialize<'de> + StrictEncode + StrictDecode, - >::PubId: + SealDef: RgbSealDef + Serialize, + SealDef::Src: Serialize, + ::CliWitness: + Serialize + for<'de> Deserialize<'de> + StrictEncode + StrictDecode, + ::PubWitness: + Serialize + for<'de> Deserialize<'de> + StrictEncode + StrictDecode, + <::PubWitness as PublishedWitness>::PubId: Ord + From<[u8; 32]> + Into<[u8; 32]> + Serialize, { let dst = dst.as_ref(); @@ -146,7 +150,7 @@ where let magic_bytes = Bytes16::strict_decode(&mut stream)?; if magic_bytes.to_byte_array() != MAGIC_BYTES_CONSIGNMENT { return Err(anyhow!( - MoundConsumeError::::UnrecognizedMagic(magic_bytes.to_hex()).to_string() + MoundConsumeError::::UnrecognizedMagic(magic_bytes.to_hex()).to_string() )); } // Version @@ -173,7 +177,7 @@ where let out = File::create_new(dst.join("0000-seals.yml"))?; let defined_seals = - SmallVec::::strict_decode(&mut stream).expect("Failed to read consignment stream"); + SmallVec::::strict_decode(&mut stream).expect("Failed to read consignment stream"); serde_yaml::to_writer(&out, &defined_seals)?; seal_count += defined_seals.len(); @@ -196,7 +200,7 @@ where serde_yaml::to_writer(&out, &operation)?; let out = File::create_new(dst.join(format!("{op_count:04}-seals.yml")))?; - let defined_seals = SmallVec::::strict_decode(&mut stream) + let defined_seals = SmallVec::::strict_decode(&mut stream) .expect("Failed to read consignment stream"); serde_yaml::to_writer(&out, &defined_seals)?; seal_count += defined_seals.len(); @@ -206,7 +210,7 @@ where let out = File::create_new( dst.join(format!("{op_count:04}-witness-{:02}.yaml", no + 1)), )?; - let witness = SealWitness::::strict_decode(&mut stream)?; + let witness = SealWitness::::strict_decode(&mut stream)?; serde_yaml::to_writer(&out, &witness)?; } diff --git a/cli/src/exec.rs b/cli/src/exec.rs index c1ea6cbe..a543e63d 100644 --- a/cli/src/exec.rs +++ b/cli/src/exec.rs @@ -25,7 +25,7 @@ use std::fs; use std::io::stdout; -use bp::seals::TxoSeal; +use bp::seals::WTxoSeal; use rgb::popls::bp::PrefabBundle; use rgb::Schema; use strict_encoding::StrictDeserialize; @@ -95,7 +95,7 @@ impl Args { } })?; } - dump_consignment::(src, dst)?; + dump_consignment::(src, dst)?; } Some(ext) if ext == "contract" => { let dst = dst @@ -111,7 +111,7 @@ impl Args { } })?; } - dump_stockpile::(src, dst)?; + dump_stockpile::(src, dst)?; } Some(_) => { return Err(anyhow!( diff --git a/src/mound.rs b/src/mound.rs index af616e93..8d2af326 100644 --- a/src/mound.rs +++ b/src/mound.rs @@ -30,7 +30,7 @@ use amplify::hex::ToHex; use amplify::Bytes16; use commit_verify::ReservedBytes; use hypersonic::{AuthToken, CellAddr, CodexId, ContractId, ContractName, Opid, Schema, Supply}; -use rgb::RgbSeal; +use rgb::RgbSealDef; use single_use_seals::{PublishedWitness, SingleUseSeal}; use strict_encoding::{ DecodeError, ReadRaw, StrictDecode, StrictDumb, StrictEncode, StrictReader, StrictWriter, @@ -93,7 +93,7 @@ impl> Mound { pub fn issue( &mut self, - params: CreateParams, + params: CreateParams, supply: S, pile: P, ) -> Result { @@ -174,7 +174,7 @@ impl> Mound { pub fn select<'seal>( &self, - seal: &'seal P::Seal, + seal: &'seal P::SealDef, ) -> impl Iterator + use<'_, 'seal, S, P, X> { self.contracts .iter() @@ -185,8 +185,8 @@ impl> Mound { &mut self, contract_id: ContractId, opid: Opid, - pub_witness: &::PubWitness, - anchor: ::CliWitness, + pub_witness: &::PubWitness, + anchor: ::CliWitness, ) { self.contract_mut(contract_id) .include(opid, anchor, pub_witness) @@ -199,9 +199,10 @@ impl> Mound { mut writer: StrictWriter, ) -> io::Result<()> where - ::CliWitness: StrictDumb + StrictEncode, - ::PubWitness: StrictDumb + StrictEncode, - <::PubWitness as PublishedWitness>::PubId: StrictEncode, + ::CliWitness: StrictDumb + StrictEncode, + ::PubWitness: StrictDumb + StrictEncode, + <::PubWitness as PublishedWitness>::PubId: + StrictEncode, { writer = MAGIC_BYTES_CONSIGNMENT.strict_encode(writer)?; // Version @@ -213,12 +214,13 @@ impl> Mound { pub fn consume( &mut self, reader: &mut StrictReader, - seal_resolver: impl FnMut(&Operation) -> BTreeMap, - ) -> Result<(), MoundConsumeError> + seal_resolver: impl FnMut(&Operation) -> BTreeMap, + ) -> Result<(), MoundConsumeError> where - ::CliWitness: StrictDecode, - ::PubWitness: StrictDecode, - <::PubWitness as PublishedWitness>::PubId: StrictDecode, + ::CliWitness: StrictDecode, + ::PubWitness: StrictDecode, + <::PubWitness as PublishedWitness>::PubId: + StrictDecode, { let magic_bytes = Bytes16::strict_decode(reader)?; if magic_bytes.to_byte_array() != MAGIC_BYTES_CONSIGNMENT { @@ -253,7 +255,7 @@ pub enum IssueError { #[derive(Display, From)] #[display(doc_comments)] -pub enum MoundConsumeError { +pub enum MoundConsumeError { /// unrecognized magic bytes in consignment stream ({0}) UnrecognizedMagic(String), @@ -275,22 +277,22 @@ pub mod file { use hypersonic::expect::Expect; use hypersonic::FileSupply; - use rgb::RgbSeal; + use rgb::RgbSealDef; use single_use_seals::PublishedWitness; use strict_encoding::{StreamWriter, StrictDecode, StrictEncode}; use super::*; use crate::FilePile; - pub struct DirExcavator { + pub struct DirExcavator { dir: PathBuf, consensus: Consensus, testnet: bool, no_prefix: bool, - _phantom: PhantomData, + _phantom: PhantomData, } - impl DirExcavator { + impl DirExcavator { pub fn new(consensus: Consensus, testnet: bool, dir: PathBuf, no_prefix: bool) -> Self { Self { dir, consensus, testnet, no_prefix, _phantom: PhantomData } } @@ -318,11 +320,13 @@ pub mod file { } } - impl Excavate> for DirExcavator + impl Excavate> + for DirExcavator where - Seal::CliWitness: StrictEncode + StrictDecode, - Seal::PubWitness: StrictEncode + StrictDecode, - >::PubId: Ord + From<[u8; 32]> + Into<[u8; 32]>, + ::CliWitness: StrictEncode + StrictDecode, + ::PubWitness: StrictEncode + StrictDecode, + <::PubWitness as PublishedWitness>::PubId: + Ord + From<[u8; 32]> + Into<[u8; 32]>, { fn schemata(&mut self) -> impl Iterator { self.contents(true).filter_map(|(ty, path)| { @@ -338,7 +342,8 @@ pub mod file { fn contracts( &mut self, - ) -> impl Iterator>)> { + ) -> impl Iterator>)> + { self.contents(false).filter_map(|(ty, path)| { if ty.is_dir() && path.extension().and_then(OsStr::to_str) == Some("contract") { let contract = Stockpile::load(path); @@ -352,13 +357,15 @@ pub mod file { } } - pub type DirMound = Mound, DirExcavator>; + pub type DirMound = + Mound::Src>, DirExcavator>; - impl DirMound + impl DirMound where - Seal::CliWitness: StrictEncode + StrictDecode, - Seal::PubWitness: StrictEncode + StrictDecode, - >::PubId: Ord + From<[u8; 32]> + Into<[u8; 32]>, + ::CliWitness: StrictEncode + StrictDecode, + ::PubWitness: StrictEncode + StrictDecode, + <::PubWitness as PublishedWitness>::PubId: + Ord + From<[u8; 32]> + Into<[u8; 32]>, { pub fn load_testnet(consensus: Consensus, path: impl AsRef, no_prefix: bool) -> Self { let path = path.as_ref(); @@ -368,11 +375,11 @@ pub mod file { pub fn issue_to_file( &mut self, - params: CreateParams, + params: CreateParams, ) -> Result { let dir = self.persistence.consensus_dir(); let supply = FileSupply::new(params.name.as_str(), &dir); - let pile = FilePile::::new(params.name.as_str(), &dir); + let pile = FilePile::::new(params.name.as_str(), &dir); self.issue(params, supply, pile) } @@ -385,9 +392,10 @@ pub mod file { path: impl AsRef, ) -> io::Result<()> where - Seal::CliWitness: StrictDumb, - Seal::PubWitness: StrictDumb, - >::PubId: StrictEncode, + ::CliWitness: StrictDumb, + ::PubWitness: StrictDumb, + <::PubWitness as PublishedWitness>::PubId: + StrictEncode, { let file = File::create_new(path)?; let writer = StrictWriter::with(StreamWriter::new::<{ usize::MAX }>(file)); diff --git a/src/pile.rs b/src/pile.rs index 49f94994..fc85262b 100644 --- a/src/pile.rs +++ b/src/pile.rs @@ -25,7 +25,7 @@ use amplify::confinement::SmallOrdMap; use hypersonic::aora::Aora; use hypersonic::Opid; -use rgb::{ClientSideWitness, RgbSeal}; +use rgb::{ClientSideWitness, RgbSealDef, RgbSealSrc}; use single_use_seals::{PublishedWitness, SealWitness, SingleUseSeal}; pub trait Index { @@ -35,19 +35,20 @@ pub trait Index { } pub trait Pile { - type Seal: RgbSeal; + type SealSrc: RgbSealSrc; + type SealDef: RgbSealDef; type Hoard: Aora< - Id = <::PubWitness as PublishedWitness>::PubId, - Item = ::CliWitness, + Id = <::PubWitness as PublishedWitness>::PubId, + Item = ::CliWitness, >; type Cache: Aora< - Id = <::PubWitness as PublishedWitness>::PubId, - Item = ::PubWitness, + Id = <::PubWitness as PublishedWitness>::PubId, + Item = ::PubWitness, >; - type Keep: Aora>; + type Keep: Aora>; type Index: Index< Opid, - <::PubWitness as PublishedWitness>::PubId, + <::PubWitness as PublishedWitness>::PubId, >; fn hoard(&self) -> &Self::Hoard; @@ -60,13 +61,14 @@ pub trait Pile { fn keep_mut(&mut self) -> &mut Self::Keep; fn index_mut(&mut self) -> &mut Self::Index; - fn retrieve(&mut self, opid: Opid) -> impl ExactSizeIterator>; + fn retrieve(&mut self, opid: Opid) + -> impl ExactSizeIterator>; fn append( &mut self, opid: Opid, - anchor: ::CliWitness, - published: &::PubWitness, + anchor: ::CliWitness, + published: &::PubWitness, ) { let pubid = published.pub_id(); self.index_mut().add(opid, pubid); @@ -92,6 +94,7 @@ pub mod fs { use std::fs::File; use std::io; use std::io::{Read, Write}; + use std::marker::PhantomData; use std::path::{Path, PathBuf}; use hypersonic::aora::file::FileAora; @@ -172,18 +175,26 @@ pub mod fs { } } - pub struct FilePile - where >::PubId: + pub struct FilePile, SealSrc: RgbSealSrc> + where >::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]> { - hoard: FileAora<>::PubId, Seal::CliWitness>, - cache: FileAora<>::PubId, Seal::PubWitness>, - keep: FileAora>, - index: FileIndex<<::PubWitness as PublishedWitness>::PubId>, + hoard: FileAora< + >::PubId, + SealSrc::CliWitness, + >, + cache: FileAora< + >::PubId, + SealSrc::PubWitness, + >, + keep: FileAora>, + index: + FileIndex<<::PubWitness as PublishedWitness>::PubId>, + _phantom: PhantomData, } - impl FilePile - where >::PubId: + impl, SealSrc: RgbSealSrc> FilePile + where >::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]> { pub fn new(name: &str, path: impl AsRef) -> Self { @@ -197,12 +208,12 @@ pub mod fs { let index = FileIndex::create(path.join("index.dat")) .expect_or(format!("unable to create index file `{}`", path.display())); - Self { hoard, cache, keep, index } + Self { hoard, cache, keep, index, _phantom: PhantomData } } } - impl FilePile - where >::PubId: + impl, SealSrc: RgbSealSrc> FilePile + where >::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]> { pub fn open(path: impl AsRef) -> Self { @@ -215,25 +226,30 @@ pub mod fs { let index = FileIndex::new(index_name.clone()) .expect_or(format!("unable to open index file `{}`", index_name.display())); - Self { hoard, cache, keep, index } + Self { hoard, cache, keep, index, _phantom: PhantomData } } } - impl Pile for FilePile + impl, SealSrc: RgbSealSrc> Pile for FilePile where - Seal::CliWitness: StrictEncode + StrictDecode, - Seal::PubWitness: StrictEncode + StrictDecode, - >::PubId: + SealSrc::CliWitness: StrictEncode + StrictDecode, + SealSrc::PubWitness: StrictEncode + StrictDecode, + >::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]>, { - type Seal = Seal; - type Hoard = - FileAora<>::PubId, Seal::CliWitness>; - type Cache = - FileAora<>::PubId, Seal::PubWitness>; - type Keep = FileAora>; + type SealSrc = SealSrc; + type SealDef = SealDef; + type Hoard = FileAora< + >::PubId, + SealSrc::CliWitness, + >; + type Cache = FileAora< + >::PubId, + SealSrc::PubWitness, + >; + type Keep = FileAora>; type Index = - FileIndex<<::PubWitness as PublishedWitness>::PubId>; + FileIndex<<::PubWitness as PublishedWitness>::PubId>; fn hoard(&self) -> &Self::Hoard { &self.hoard } @@ -251,7 +267,7 @@ pub mod fs { fn index_mut(&mut self) -> &mut Self::Index { &mut self.index } - fn retrieve(&mut self, opid: Opid) -> impl ExactSizeIterator> { + fn retrieve(&mut self, opid: Opid) -> impl ExactSizeIterator> { self.index.get(opid).map(|pubid| { let client = self.hoard.read(pubid); let published = self.cache.read(pubid); diff --git a/src/popls/bp.rs b/src/popls/bp.rs index 6df668d8..110d7764 100644 --- a/src/popls/bp.rs +++ b/src/popls/bp.rs @@ -31,7 +31,7 @@ use alloc::vec; use amplify::confinement::{Collection, NonEmptyVec, SmallOrdMap, SmallOrdSet, U8 as U8MAX}; use amplify::{confinement, ByteArray, Bytes32, Wrapper}; use bp::dbc::tapret::TapretProof; -use bp::seals::{mmb, Anchor, TxoSeal, TxoSealExt}; +use bp::seals::{mmb, Anchor, TxoSeal, TxoSealExt, WTxoSeal}; use bp::{Outpoint, Sats, ScriptPubkey, Tx, Vout}; use commit_verify::mpc::ProtocolId; use commit_verify::{mpc, Digest, DigestExt, Sha256}; @@ -42,7 +42,7 @@ use hypersonic::{ }; use invoice::bp::{Address, WitnessOut}; use invoice::{RgbBeneficiary, RgbInvoice}; -use rgb::SealAuthToken; +use rgb::RgbSealDef; use strict_encoding::{ReadRaw, StrictDecode, StrictDeserialize, StrictReader, StrictSerialize}; use strict_types::StrictVal; @@ -56,11 +56,11 @@ pub trait WalletProvider { fn noise_seed(&self) -> Bytes32; fn has_utxo(&self, outpoint: Outpoint) -> bool; fn utxos(&self) -> impl Iterator; - fn register_seal(&mut self, seal: TxoSeal); + fn register_seal(&mut self, seal: WTxoSeal); fn resolve_seals( &self, seals: impl Iterator, - ) -> impl Iterator; + ) -> impl Iterator; fn next_address(&mut self) -> Address; fn next_nonce(&mut self) -> u64; } @@ -103,10 +103,10 @@ impl EitherSeal { } impl EitherSeal { - pub fn transform(self, noise_engine: Sha256, nonce: u64) -> EitherSeal { + pub fn transform(self, noise_engine: Sha256, nonce: u64) -> EitherSeal { match self { EitherSeal::Alt(seal) => { - EitherSeal::Alt(TxoSeal::no_fallback(seal, noise_engine, nonce)) + EitherSeal::Alt(WTxoSeal::no_fallback(seal, noise_engine, nonce)) } EitherSeal::Token(auth) => EitherSeal::Token(auth), } @@ -114,7 +114,7 @@ impl EitherSeal { } impl CreateParams { - pub fn transform(self, mut noise_engine: Sha256) -> CreateParams { + pub fn transform(self, mut noise_engine: Sha256) -> CreateParams { noise_engine.input_raw(self.codex_id.as_slice()); noise_engine.input_raw(&[self.consensus as u8]); noise_engine.input_raw(self.method.as_bytes()); @@ -382,12 +382,23 @@ impl PrefabBundle { /// Barrow contains a bunch of RGB contract stockpiles, which are held by a single owner; such that /// when a new operation under any of the contracts happen it may affect other contracts sharing the /// same UTXOs. -pub struct Barrow, X: Excavate> { +pub struct Barrow< + W: WalletProvider, + S: Supply, + P: Pile, + X: Excavate, +> { pub wallet: W, pub mound: Mound, } -impl, X: Excavate> Barrow { +impl< + W: WalletProvider, + S: Supply, + P: Pile, + X: Excavate, + > Barrow +{ pub fn with(wallet: W, mound: Mound) -> Self { Self { wallet, mound } } pub fn unbind(self) -> (W, Mound) { (self.wallet, self.mound) } @@ -405,7 +416,7 @@ impl, X: Excavate> B pub fn auth_token(&mut self, nonce: Option) -> Option { let outpoint = self.wallet.utxos().next()?; let nonce = nonce.unwrap_or_else(|| self.wallet.next_nonce()); - let seal = TxoSeal::no_fallback(outpoint, self.noise_engine(), nonce); + let seal = WTxoSeal::no_fallback(outpoint, self.noise_engine(), nonce); let auth = seal.auth_token(); self.wallet.register_seal(seal); Some(auth) @@ -576,7 +587,7 @@ impl, X: Excavate> B .push(vout) .map_err(|_| PrefabError::TooManyOutputs)?; let seal = - TxoSeal::vout_no_fallback(vout, noise_engine.clone(), opout_no as u64); + WTxoSeal::vout_no_fallback(vout, noise_engine.clone(), opout_no as u64); seals.insert(opout_no as u16, seal).expect("checked above"); seal.auth_token() } @@ -656,7 +667,7 @@ impl, X: Excavate> B .copied() .enumerate() .find(|(nonce, outpoint)| { - let seal = TxoSeal::no_fallback( + let seal = WTxoSeal::no_fallback( *outpoint, noise_engine.clone(), *nonce as u64, @@ -747,7 +758,7 @@ impl, X: Excavate> B pub fn consume( &mut self, reader: &mut StrictReader, - ) -> Result<(), MoundConsumeError> { + ) -> Result<(), MoundConsumeError> { self.mound.consume(reader, |op| { self.wallet .resolve_seals(op.destructible.iter().map(|cell| cell.auth)) @@ -856,7 +867,8 @@ pub mod file { use crate::mound::file::DirExcavator; use crate::FilePile; - pub type DirBarrow = Barrow, DirExcavator>; + pub type DirBarrow = + Barrow, DirExcavator>; impl DirBarrow { pub fn issue_to_file( @@ -877,5 +889,5 @@ pub mod file { } } - pub type BpDirMound = Mound, DirExcavator>; + pub type BpDirMound = Mound, DirExcavator>; } diff --git a/src/stockpile.rs b/src/stockpile.rs index 7fdaef58..ac8224db 100644 --- a/src/stockpile.rs +++ b/src/stockpile.rs @@ -40,8 +40,8 @@ use hypersonic::{ Schema, StateAtom, StateName, Stock, Supply, }; use rgb::{ - ContractApi, ContractVerify, OperationSeals, ReadOperation, ReadWitness, RgbSeal, - SealAuthToken, Step, VerificationError, + ContractApi, ContractVerify, OperationSeals, ReadOperation, ReadWitness, RgbSealDef, + RgbSealSrc, Step, VerificationError, }; use single_use_seals::{PublishedWitness, SealWitness, SingleUseSeal}; use strict_encoding::{ @@ -50,7 +50,7 @@ use strict_encoding::{ }; use strict_types::StrictVal; -use crate::{ContractMeta, Pile}; +use crate::{ContractMeta, Index, Pile}; #[derive(Copy, Clone, PartialEq, Eq, Debug, From)] #[cfg_attr( @@ -66,7 +66,7 @@ pub enum EitherSeal { impl EitherSeal { pub fn auth_token(&self) -> AuthToken - where Seal: RgbSeal { + where Seal: RgbSealDef { match self { EitherSeal::Alt(seal) => seal.auth_token(), EitherSeal::Token(auth) => *auth, @@ -186,7 +186,7 @@ pub struct Stockpile { } impl Stockpile { - pub fn issue(schema: Schema, params: CreateParams, supply: S, mut pile: P) -> Self { + pub fn issue(schema: Schema, params: CreateParams, supply: S, mut pile: P) -> Self { assert_eq!(params.codex_id, schema.codex.codex_id()); let seals = SmallOrdMap::try_from_iter(params.owned.iter().enumerate().filter_map( @@ -239,39 +239,35 @@ impl Stockpile { pub fn contract_id(&self) -> ContractId { self.stock.contract_id() } - pub fn seal(&self, seal: &P::Seal) -> Option { + pub fn seal(&self, seal: &P::SealDef) -> Option { let auth = seal.auth_token(); self.stock.state().raw.auth.get(&auth).copied() } - pub fn state(&mut self) -> ContractState { + pub fn state(&mut self) -> ContractState { let state = self.stock().state().main.clone(); - ContractState { - immutable: state.immutable, - owned: state - .owned - .into_iter() - .map(|(name, map)| { - let map = map - .into_iter() - .filter_map(|(addr, data)| { - let seals = self.pile_mut().keep_mut().read(addr.opid); - let seal = seals.get(&addr.pos)?.clone(); - Some((addr, Assignment { seal, data })) - }) - .collect(); - (name, map) - }) - .collect(), - computed: state.computed, + let mut owned = bmap! {}; + for (name, map) in state.owned { + let mut state = bmap! {}; + for (addr, data) in map { + let seals = self.pile_mut().keep_mut().read(addr.opid); + let Some(seal) = seals.get(&addr.pos) else { + continue; + }; + for wid in self.pile_mut().index_mut().get(addr.opid) { + state.insert(addr, Assignment { seal: seal.resolve(wid), data: data.clone() }); + } + } + owned.insert(name, state); } + ContractState { immutable: state.immutable, owned, computed: state.computed } } pub fn include( &mut self, opid: Opid, - anchor: ::CliWitness, - published: &::PubWitness, + anchor: ::CliWitness, + published: &::PubWitness, ) { self.pile.append(opid, anchor, published) } @@ -282,9 +278,10 @@ impl Stockpile { writer: StrictWriter, ) -> io::Result<()> where - ::CliWitness: StrictDumb + StrictEncode, - ::PubWitness: StrictDumb + StrictEncode, - <::PubWitness as PublishedWitness>::PubId: StrictEncode, + ::CliWitness: StrictDumb + StrictEncode, + ::PubWitness: StrictDumb + StrictEncode, + <::PubWitness as PublishedWitness>::PubId: + StrictEncode, { self.stock .export_aux(terminals, writer, |opid, mut writer| { @@ -307,12 +304,13 @@ impl Stockpile { pub fn consume( &mut self, stream: &mut StrictReader, - seal_resolver: impl FnMut(&Operation) -> BTreeMap, - ) -> Result<(), ConsumeError> + seal_resolver: impl FnMut(&Operation) -> BTreeMap, + ) -> Result<(), ConsumeError> where - ::CliWitness: StrictDecode, - ::PubWitness: StrictDecode, - <::PubWitness as PublishedWitness>::PubId: StrictDecode, + ::CliWitness: StrictDecode, + ::PubWitness: StrictDecode, + <::PubWitness as PublishedWitness>::PubId: + StrictDecode, { // We need to read articles field by field since we have to evaluate genesis separately let schema = Schema::strict_decode(stream)?; @@ -337,19 +335,24 @@ impl Stockpile { } } -pub struct OpReader<'r, Seal: RgbSeal, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> { +pub struct OpReader< + 'r, + SealDef: RgbSealDef, + R: ReadRaw, + F: FnMut(&Operation) -> BTreeMap, +> { stream: &'r mut StrictReader, seal_resolver: F, - _phantom: PhantomData, + _phantom: PhantomData, } -impl<'r, Seal: RgbSeal, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> ReadOperation - for OpReader<'r, Seal, R, F> +impl<'r, SealDef: RgbSealDef, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> + ReadOperation for OpReader<'r, SealDef, R, F> { - type Seal = Seal; - type WitnessReader = WitnessReader<'r, Seal, R, F>; + type SealDef = SealDef; + type WitnessReader = WitnessReader<'r, SealDef, R, F>; - fn read_operation(mut self) -> Option<(OperationSeals, Self::WitnessReader)> { + fn read_operation(mut self) -> Option<(OperationSeals, Self::WitnessReader)> { match Operation::strict_decode(self.stream) { Ok(operation) => { let mut defined_seals = SmallOrdMap::strict_decode(self.stream) @@ -371,19 +374,25 @@ impl<'r, Seal: RgbSeal, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> } } -pub struct WitnessReader<'r, Seal: RgbSeal, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> -{ +pub struct WitnessReader< + 'r, + SealDef: RgbSealDef, + R: ReadRaw, + F: FnMut(&Operation) -> BTreeMap, +> { left: u64, - parent: OpReader<'r, Seal, R, F>, + parent: OpReader<'r, SealDef, R, F>, } -impl<'r, Seal: RgbSeal, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> ReadWitness - for WitnessReader<'r, Seal, R, F> +impl<'r, SealDef: RgbSealDef, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> + ReadWitness for WitnessReader<'r, SealDef, R, F> { - type Seal = Seal; - type OpReader = OpReader<'r, Seal, R, F>; + type SealDef = SealDef; + type OperationReader = OpReader<'r, SealDef, R, F>; - fn read_witness(mut self) -> Step<(SealWitness, Self), Self::OpReader> { + fn read_witness( + mut self, + ) -> Step<(SealWitness<::Src>, Self), Self::OperationReader> { if self.left == 0 { return Step::Complete(self.parent); } @@ -398,7 +407,7 @@ impl<'r, Seal: RgbSeal, R: ReadRaw, F: FnMut(&Operation) -> BTreeMap> } } -impl ContractApi for Stockpile { +impl ContractApi for Stockpile { fn contract_id(&self) -> ContractId { self.stock.contract_id() } fn codex(&self) -> &Codex { &self.stock.articles().schema.codex } @@ -407,21 +416,21 @@ impl ContractApi for Stockpile { fn memory(&self) -> &impl Memory { &self.stock.state().raw } - fn apply_operation(&mut self, op: OperationSeals) { + fn apply_operation(&mut self, op: OperationSeals) { self.pile .keep_mut() .append(op.operation.opid(), &op.defined_seals); self.stock.apply(op.operation); } - fn apply_witness(&mut self, opid: Opid, witness: SealWitness) { + fn apply_witness(&mut self, opid: Opid, witness: SealWitness) { self.pile.append(opid, witness.client, &witness.published) } } #[derive(Display, From)] #[display(inner)] -pub enum ConsumeError { +pub enum ConsumeError { #[from] #[from(io::Error)] Io(IoError), @@ -433,7 +442,7 @@ pub enum ConsumeError { Merge(MergeError), #[from] - Verify(VerificationError), + Verify(VerificationError), } #[cfg(feature = "fs")] @@ -447,11 +456,13 @@ mod fs { use super::*; use crate::FilePile; - impl Stockpile> + impl, SealSrc: RgbSealSrc> + Stockpile> where - Seal::CliWitness: StrictEncode + StrictDecode, - Seal::PubWitness: StrictEncode + StrictDecode, - >::PubId: Ord + From<[u8; 32]> + Into<[u8; 32]>, + SealSrc::CliWitness: StrictEncode + StrictDecode, + SealSrc::PubWitness: StrictEncode + StrictDecode, + >::PubId: + Ord + From<[u8; 32]> + Into<[u8; 32]>, { pub fn load(path: impl AsRef) -> Self { let path = path.as_ref(); @@ -462,7 +473,7 @@ mod fs { pub fn issue_to_file( schema: Schema, - params: CreateParams, + params: CreateParams, path: impl AsRef, ) -> Self { let path = path.as_ref(); @@ -477,9 +488,9 @@ mod fs { path: impl AsRef, ) -> io::Result<()> where - Seal::CliWitness: StrictDumb, - Seal::PubWitness: StrictDumb, - >::PubId: StrictEncode, + SealSrc::CliWitness: StrictDumb, + SealSrc::PubWitness: StrictDumb, + >::PubId: StrictEncode, { let file = File::create_new(path)?; let writer = StrictWriter::with(StreamWriter::new::<{ usize::MAX }>(file)); From a3c827d4ab90ae69df1968520111c33825db8404 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 30 Jan 2025 11:10:48 +0100 Subject: [PATCH 2/5] bp: fix resolve_seal return type --- src/popls/bp.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/popls/bp.rs b/src/popls/bp.rs index 110d7764..b29cd77f 100644 --- a/src/popls/bp.rs +++ b/src/popls/bp.rs @@ -31,7 +31,7 @@ use alloc::vec; use amplify::confinement::{Collection, NonEmptyVec, SmallOrdMap, SmallOrdSet, U8 as U8MAX}; use amplify::{confinement, ByteArray, Bytes32, Wrapper}; use bp::dbc::tapret::TapretProof; -use bp::seals::{mmb, Anchor, TxoSeal, TxoSealExt, WTxoSeal}; +use bp::seals::{mmb, Anchor, TxoSeal, TxoSealExt, WOutpoint, WTxoSeal}; use bp::{Outpoint, Sats, ScriptPubkey, Tx, Vout}; use commit_verify::mpc::ProtocolId; use commit_verify::{mpc, Digest, DigestExt, Sha256}; @@ -48,7 +48,7 @@ use strict_types::StrictVal; use crate::stockpile::{ContractState, EitherSeal}; use crate::{ - Assignment, CreateParams, Excavate, IssueError, Mound, MoundConsumeError, Pile, Stockpile, Txid, + Assignment, CreateParams, Excavate, IssueError, Mound, MoundConsumeError, Pile, Stockpile, }; /// Trait abstracting specific implementation of a bitcoin wallet. @@ -261,14 +261,14 @@ impl OpRequest> { &self, wout: WitnessOut, resolver: impl Fn(&ScriptPubkey) -> Option, - ) -> Option { + ) -> Option { for assignment in &self.owned { if let EitherSeal::Alt(Some(assignment)) = &assignment.state.seal { if assignment.wout == wout { let spk = assignment.script_pubkey(); let vout = resolver(&spk)?; - let primary = Outpoint::new(Txid::from([0xFFu8; 32]), vout); - let seal = TxoSeal { primary, secondary: TxoSealExt::Noise(wout.noise()) }; + let primary = WOutpoint::Wout(vout); + let seal = WTxoSeal { primary, secondary: TxoSealExt::Noise(wout.noise()) }; return Some(seal); } } From a7dc992679323b64759e9d7cab5ae17c5b5fbccd Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 30 Jan 2025 11:20:55 +0100 Subject: [PATCH 3/5] fix accounting for non-witness-output based state --- Cargo.lock | 2 +- src/stockpile.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9168c00..fe9fce0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -738,7 +738,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.12.0-beta.4" -source = "git+https://github.com/RGB-WG/rgb-core?branch=wtxoseal#43d885ffee9d6bce56ea400e5dbf90878d25b443" +source = "git+https://github.com/RGB-WG/rgb-core?branch=wtxoseal#0aabcc42d53ee4202bcc0e559b9b74c6d0a0b89f" dependencies = [ "amplify", "bp-core", diff --git a/src/stockpile.rs b/src/stockpile.rs index ac8224db..a4973d51 100644 --- a/src/stockpile.rs +++ b/src/stockpile.rs @@ -254,8 +254,16 @@ impl Stockpile { let Some(seal) = seals.get(&addr.pos) else { continue; }; - for wid in self.pile_mut().index_mut().get(addr.opid) { - state.insert(addr, Assignment { seal: seal.resolve(wid), data: data.clone() }); + if let Some(seal) = seal.to_src() { + state.insert(addr, Assignment { seal, data }); + } else { + // We insert a copy of state for each of the witnesses created for the operation + for wid in self.pile_mut().index_mut().get(addr.opid) { + state.insert(addr, Assignment { + seal: seal.resolve(wid), + data: data.clone(), + }); + } } } owned.insert(name, state); From 85cefecb5f8f5068f22d43e13a3b6ed01c1a8eaf Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 30 Jan 2025 12:39:08 +0100 Subject: [PATCH 4/5] remove second generic argument for FileFile --- cli/src/dump.rs | 2 +- src/mound.rs | 11 ++++------ src/pile.rs | 53 ++++++++++++++++++++++++++---------------------- src/popls/bp.rs | 5 ++--- src/stockpile.rs | 20 +++++++++--------- 5 files changed, 46 insertions(+), 45 deletions(-) diff --git a/cli/src/dump.rs b/cli/src/dump.rs index 9ae85f4d..68e175a6 100644 --- a/cli/src/dump.rs +++ b/cli/src/dump.rs @@ -54,7 +54,7 @@ where fs::create_dir_all(dst)?; print!("Reading contract stockpile from '{}' ... ", src.display()); - let mut stockpile = Stockpile::>::load(src); + let mut stockpile = Stockpile::>::load(src); println!("success reading {}", stockpile.contract_id()); print!("Processing contract articles ... "); diff --git a/src/mound.rs b/src/mound.rs index 8d2af326..6bb70352 100644 --- a/src/mound.rs +++ b/src/mound.rs @@ -320,8 +320,7 @@ pub mod file { } } - impl Excavate> - for DirExcavator + impl Excavate> for DirExcavator where ::CliWitness: StrictEncode + StrictDecode, ::PubWitness: StrictEncode + StrictDecode, @@ -342,8 +341,7 @@ pub mod file { fn contracts( &mut self, - ) -> impl Iterator>)> - { + ) -> impl Iterator>)> { self.contents(false).filter_map(|(ty, path)| { if ty.is_dir() && path.extension().and_then(OsStr::to_str) == Some("contract") { let contract = Stockpile::load(path); @@ -357,8 +355,7 @@ pub mod file { } } - pub type DirMound = - Mound::Src>, DirExcavator>; + pub type DirMound = Mound, DirExcavator>; impl DirMound where @@ -379,7 +376,7 @@ pub mod file { ) -> Result { let dir = self.persistence.consensus_dir(); let supply = FileSupply::new(params.name.as_str(), &dir); - let pile = FilePile::::new(params.name.as_str(), &dir); + let pile = FilePile::::new(params.name.as_str(), &dir); self.issue(params, supply, pile) } diff --git a/src/pile.rs b/src/pile.rs index fc85262b..a507351e 100644 --- a/src/pile.rs +++ b/src/pile.rs @@ -175,26 +175,27 @@ pub mod fs { } } - pub struct FilePile, SealSrc: RgbSealSrc> - where >::PubId: + pub struct FilePile + where <::PubWitness as PublishedWitness>::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]> { hoard: FileAora< - >::PubId, - SealSrc::CliWitness, + <::PubWitness as PublishedWitness>::PubId, + ::CliWitness, >, cache: FileAora< - >::PubId, - SealSrc::PubWitness, + <::PubWitness as PublishedWitness>::PubId, + ::PubWitness, >, keep: FileAora>, - index: - FileIndex<<::PubWitness as PublishedWitness>::PubId>, + index: FileIndex< + <::PubWitness as PublishedWitness>::PubId, + >, _phantom: PhantomData, } - impl, SealSrc: RgbSealSrc> FilePile - where >::PubId: + impl FilePile + where <::PubWitness as PublishedWitness>::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]> { pub fn new(name: &str, path: impl AsRef) -> Self { @@ -212,8 +213,8 @@ pub mod fs { } } - impl, SealSrc: RgbSealSrc> FilePile - where >::PubId: + impl FilePile + where <::PubWitness as PublishedWitness>::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]> { pub fn open(path: impl AsRef) -> Self { @@ -230,26 +231,27 @@ pub mod fs { } } - impl, SealSrc: RgbSealSrc> Pile for FilePile + impl Pile for FilePile where - SealSrc::CliWitness: StrictEncode + StrictDecode, - SealSrc::PubWitness: StrictEncode + StrictDecode, - >::PubId: + ::CliWitness: StrictEncode + StrictDecode, + ::PubWitness: StrictEncode + StrictDecode, + <::PubWitness as PublishedWitness>::PubId: Copy + Ord + From<[u8; 32]> + Into<[u8; 32]>, { - type SealSrc = SealSrc; type SealDef = SealDef; + type SealSrc = SealDef::Src; type Hoard = FileAora< - >::PubId, - SealSrc::CliWitness, + <::PubWitness as PublishedWitness>::PubId, + ::CliWitness, >; type Cache = FileAora< - >::PubId, - SealSrc::PubWitness, + <::PubWitness as PublishedWitness>::PubId, + ::PubWitness, >; type Keep = FileAora>; - type Index = - FileIndex<<::PubWitness as PublishedWitness>::PubId>; + type Index = FileIndex< + <::PubWitness as PublishedWitness>::PubId, + >; fn hoard(&self) -> &Self::Hoard { &self.hoard } @@ -267,7 +269,10 @@ pub mod fs { fn index_mut(&mut self) -> &mut Self::Index { &mut self.index } - fn retrieve(&mut self, opid: Opid) -> impl ExactSizeIterator> { + fn retrieve( + &mut self, + opid: Opid, + ) -> impl ExactSizeIterator> { self.index.get(opid).map(|pubid| { let client = self.hoard.read(pubid); let published = self.cache.read(pubid); diff --git a/src/popls/bp.rs b/src/popls/bp.rs index b29cd77f..ae71f60e 100644 --- a/src/popls/bp.rs +++ b/src/popls/bp.rs @@ -867,8 +867,7 @@ pub mod file { use crate::mound::file::DirExcavator; use crate::FilePile; - pub type DirBarrow = - Barrow, DirExcavator>; + pub type DirBarrow = Barrow, DirExcavator>; impl DirBarrow { pub fn issue_to_file( @@ -889,5 +888,5 @@ pub mod file { } } - pub type BpDirMound = Mound, DirExcavator>; + pub type BpDirMound = Mound, DirExcavator>; } diff --git a/src/stockpile.rs b/src/stockpile.rs index a4973d51..b4faca10 100644 --- a/src/stockpile.rs +++ b/src/stockpile.rs @@ -40,8 +40,8 @@ use hypersonic::{ Schema, StateAtom, StateName, Stock, Supply, }; use rgb::{ - ContractApi, ContractVerify, OperationSeals, ReadOperation, ReadWitness, RgbSealDef, - RgbSealSrc, Step, VerificationError, + ContractApi, ContractVerify, OperationSeals, ReadOperation, ReadWitness, RgbSealDef, Step, + VerificationError, }; use single_use_seals::{PublishedWitness, SealWitness, SingleUseSeal}; use strict_encoding::{ @@ -464,12 +464,11 @@ mod fs { use super::*; use crate::FilePile; - impl, SealSrc: RgbSealSrc> - Stockpile> + impl Stockpile> where - SealSrc::CliWitness: StrictEncode + StrictDecode, - SealSrc::PubWitness: StrictEncode + StrictDecode, - >::PubId: + ::CliWitness: StrictEncode + StrictDecode, + ::PubWitness: StrictEncode + StrictDecode, + <::PubWitness as PublishedWitness>::PubId: Ord + From<[u8; 32]> + Into<[u8; 32]>, { pub fn load(path: impl AsRef) -> Self { @@ -496,9 +495,10 @@ mod fs { path: impl AsRef, ) -> io::Result<()> where - SealSrc::CliWitness: StrictDumb, - SealSrc::PubWitness: StrictDumb, - >::PubId: StrictEncode, + ::CliWitness: StrictDumb, + ::PubWitness: StrictDumb, + <::PubWitness as PublishedWitness>::PubId: + StrictEncode, { let file = File::create_new(path)?; let writer = StrictWriter::with(StreamWriter::new::<{ usize::MAX }>(file)); From 02ab71c5a530c30d8ff23759f741b698133e5667 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 30 Jan 2025 13:51:15 +0100 Subject: [PATCH 5/5] chore: fix clippy lints --- src/lib.rs | 1 + src/popls/bp.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 66b1d7dc..790eb1e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,7 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::type_complexity)] extern crate alloc; diff --git a/src/popls/bp.rs b/src/popls/bp.rs index ae71f60e..c7e11eec 100644 --- a/src/popls/bp.rs +++ b/src/popls/bp.rs @@ -505,7 +505,7 @@ impl< .collect::>(); // NB: we do state accumulation with `calc` inside coinselect let using = coinselect - .coinselect(&value, calc.as_mut(), src) + .coinselect(value, calc.as_mut(), src) .ok_or(FulfillError::StateInsufficient)?; let using = using .into_iter() @@ -530,7 +530,7 @@ impl< EitherSeal::Alt(Some(wout)) } }; - calc.lessen(&value)?; + calc.lessen(value)?; let assignment = Assignment { seal, data: value.clone() }; let state = NamedState { name: state_name.clone(), state: assignment }; let mut owned = vec![state];