Skip to content

Commit

Permalink
update schemata scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 18, 2024
1 parent c9b133e commit 49213f2
Show file tree
Hide file tree
Showing 13 changed files with 376 additions and 219 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "develop" }
bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "develop" }
bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "develop" }
bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "develop" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "feat/fungible-nonconf" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "feat/asm" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "feat/fungible-nonconf" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "feat/fungible-nonconf" }
rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces", branch = "feat/fungible-nonconf" }
Binary file modified schemata/CollectibleFungibleAsset.rgb
Binary file not shown.
23 changes: 12 additions & 11 deletions schemata/CollectibleFungibleAsset.rgba
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
-----BEGIN RGB KIT-----
Id: rgb:kit:9MjsRLx8-ZsEU0o5-EmeSB3F-JjShSzg-MYxsXUy-lYD!O6E
Id: rgb:kit:xW0USI!D-IGKC74C-32$yhDw-eB$pRBD-L9dNB4E-2z4W3cY
Version: 2
Schema: CollectibleFungibleAsset;
id=so!3RW45M!uWA6pEYoKHn21cYqsINcbBEub7OjtUy3I#biology-temple-garbo;
id=XGLkK4Ouc3ry5Oz$Zt6PstuH43KdgUnXaA$VIyAzsCo#nobel-style-rodent;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Interface: RGB25Base;
id=xCgpButl-IG39Nk!-aynmAEm-Od5vc99-5WGtRbI-ej5!FiY#edison-secret-elvis;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Implementation: 0VoxuFqG-QOkPe43-qm5Eh3g-f4XVqEw-R3T8fQA-YOls71I#concert-juice-hilton;
Implementation: Zx!9tKwx-vrCKETz-nokbCqk-x4CHedR-jeqrl7F-$08jnwY#scale-diet-scroll;
interface=xCgpButl-IG39Nk!-aynmAEm-Od5vc99-5WGtRbI-ej5!FiY#edison-secret-elvis;
schema=so!3RW45M!uWA6pEYoKHn21cYqsINcbBEub7OjtUy3I#biology-temple-garbo;
schema=XGLkK4Ouc3ry5Oz$Zt6PstuH43KdgUnXaA$VIyAzsCo#nobel-style-rodent;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Type-System: sts:!sszu938-NL3ZW9T-DBsfmGE-cQLyhXS-53N8TEP-Ju$dT8o#marvin-silence-school
Alu-Lib: alu:$6jROmtH-krFeZwW-N$PMhJc-GX9BtLo-7VTiTjq-8tfFew4#morning-shrink-igloo
Check-SHA256: b1e06d874b9f5c6327427d00c937707a53ac8576034d8fdd0bc019739f97e2f3
Alu-Lib: alu:VWggsFAX-IHhDsgn-orDlH6$-0eFHj5n-86x!gxY-ySVe0gU#bless-prime-zero
Check-SHA256: 624fec2a49b9db2ead9c7f11d15666a014cd6150faacc3225c6b53ac5e7966b2

0s#RDQb$5EH9}!?WdefyeA22rmXX)ZV_yI}MH~YN>;K=mRmV)&;+=Xmp=5=Yl+T7onDsqJ)(GyQzUOj0
_|udNLf4!^9@NX6Lz#s60cHRI0000617UJ>0e1iJJu1QEX=%Xy>vn1>teUKtq)w3djjO=VIO}{ZUjP6H
Expand All @@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#>2x#JO!0is)`buE3*f$s=72pp@w!`LRkztQP;3W%Qi%!_9htpQ3t>=3qD6)+-@LI3~&000000RR60
000000QIdGAw<m5-D2$LPw@K`WF3=gfWe^2KEIc8afFF{ya-6XBNr;@ghiU?gEXK9KMDE{F?;HZBRuDV
qlk6qmbd@_00000001Wd00000008+H2n5}(1bO(?uXL+B(gNn{L2}utxi<$D8ry%w450%W0byYQVqyVf
V*zAj0cB+YW@Z6rX8~wv0cmLgYH9&%YXNL*0c~voZf*f@Zvk*{0da8wa&iH4a{+X80d;i&c6I@GcL8{K
0eN`=dV2e*SaKRYGgJn%Xv1$>f_VvG%;GuzyszPjx|liD+IRs000RR-OjQU%P((>bMN?D*Qb$4?01E&B
009RJ0096C2mk;J0RjNX+6MtSFaQAu1ONa500000
0eN`=dV2e*SaKRYGgJn%Xv1$>f_VvG%;GuzyszPjx|liD+IRs000RR-OjQU%P((>bMN?D*Qb$5H01E*C
0Kp9e3sC|9IWw;T3xNax1poj53jhWH8F_I52Md7&00jU500kic01E&D02zUC0S5;F+6Mptpbr57KdW~?
GO^3};mOgvH7UGe8wQe4n%)7JK7QsxT5dF(00

-----END RGB KIT-----
Binary file modified schemata/NonInflatableAssets.rgb
Binary file not shown.
25 changes: 14 additions & 11 deletions schemata/NonInflatableAssets.rgba
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
-----BEGIN RGB KIT-----
Id: rgb:kit:sstMiKFc-sQtkR41-rlNSnXt-TlnJjhh-kk8iZjS-3LjfVis
Id: rgb:kit:DwsdhjXJ-5dkQHm7-ESuqDHr-i5tWzS4-hQ6UzWS-hHJkhUE
Version: 2
Schema: NonInflatableAsset;
id=3UhXmwkss!wkBXlmYktxLMooF!B8Exbo8zYCg31RAjk#moses-monica-cello;
id=iIr5Jb83RvcOLO2JhzFB2bjJ2PTyTsKWvRluwYOTLaE#numeric-omega-ground;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Interface: RGB20Fixed;
id=Oq2rlfVG-m!!reli-q10Jxut-FBhzKXQ-mxtfYzg-Td1qVfQ#club-factor-montana;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Implementation: KsGa69z0-d7gBO!k-dYlkhBd-DKZu8Sv-fx1m!a8-JJP8IWM#radius-private-elastic;
Implementation: LeLkKJ3x-6Ch9GOz-x4ur5!6-b7MK5rS-MaLkrRe-X8H6YKI#next-coral-battery;
interface=Oq2rlfVG-m!!reli-q10Jxut-FBhzKXQ-mxtfYzg-Td1qVfQ#club-factor-montana;
schema=3UhXmwkss!wkBXlmYktxLMooF!B8Exbo8zYCg31RAjk#moses-monica-cello;
schema=iIr5Jb83RvcOLO2JhzFB2bjJ2PTyTsKWvRluwYOTLaE#numeric-omega-ground;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Type-System: sts:!sszu938-NL3ZW9T-DBsfmGE-cQLyhXS-53N8TEP-Ju$dT8o#marvin-silence-school
Alu-Lib: alu:$6jROmtH-krFeZwW-N$PMhJc-GX9BtLo-7VTiTjq-8tfFew4#morning-shrink-igloo
Check-SHA256: 3a9eca0b66a5acaded1efb659bc1dace623ec718ec4fba50ee2c1457e868ef1a
Alu-Lib: alu:P6t3PzKx-y$jhydG-7NSm8Yh-sGklCa3-gGYPn7m-QlpuNJs#service-user-flash
Alu-Lib: alu:VWggsFAX-IHhDsgn-orDlH6$-0eFHj5n-86x!gxY-ySVe0gU#bless-prime-zero
Check-SHA256: 3fad329df8695b4678aa814a123017338bbff4701cc1082f34f43756d83aa217

0s#REQb$5EFh*&3Wn=_aPh8{kau)pw>ewj^T{#F%_1b`zh4BqG=$aXZ#JgXGmXyziN0{|JN7e}Lp}yyG
JowX;3qseNLLSu1oI{zd+?yZx(V;8SnC`hL-TfxJSk!DhyM4=xS*w!UK;ApTd|%<8%-b!M&HBwn)KKUr
Expand All @@ -30,9 +31,9 @@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3LkM(eX>xRBWo|?WW^Z+JbY*33MF(bSW^`p`ZbtIDB!Cv4eL6_}05B~d-+;N}5sv|)Tc&j_eb0gK
`xImylWKs$pvgYJmvV80iF~{WNWLQ%D(Hkon&*Qwpawq)`VKLB>Wd>h=Ype%b?2720000000000CjbBd
00000`4<QT-L3?A_|>m;t2@#H=ITLm*{QiV2NfFIf5Z%-0~!HgVF6-d0b^qUWMlzlWdUYp0cU3cXlMax
X#r|#0c&dkY-|B-Z2@j>0dH>saBu-}aRG920dsQ!baVlAbpdvE0e5!+cz6MMc>#KQ`>9xR8a*>q2D50x
Z(4$R31H0PIsUw_;fcDKIn~;D0RaF513^qx2trUqNk>IfR0C2+LK^@J000012MYiJ01F5J01E*E0La=0
0XZ-L0S5#C00961000
Z(4$R31H0PIsUw_;fcDKIn~;D0RjL613^qx2trUqNk>IfR0C2+LP7uwQ2+o7g8~4+7l0%I|G@$TIW(XF
Ab?;2Bmw^e0018c3sC?73yS~%z#o7l0sp}R1UWRI0U(HA0VDzc0{{RY2MPcH000000000000096K}=N$
LQq6WM@3Uq15!sqH2@0%006-a1Pf6D068<S0Skcy00jU501E&H02z640S60#1ONp9000Fc000XB0st9-
aRCPh0NMut0H6;60Y9sEKQgh)_~FUXyEQ4iVjBjMP@3KWm_B~yLRxM#n*a

-----END RGB KIT-----
Binary file modified schemata/UniqueDigitalAsset.rgb
Binary file not shown.
24 changes: 12 additions & 12 deletions schemata/UniqueDigitalAsset.rgba
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
-----BEGIN RGB KIT-----
Id: rgb:kit:Teg5X4ru-4k1slWX-ev3ME3G-CSmuNEe-Oswr7MJ-aH8oTyc
Id: rgb:kit:teE3x7vZ-v$9YKUp-HaF0BTC-g3lzVY1-9FVaT5e-4YYlCg4
Version: 2
Schema: UniqueDigitalAsset;
id=PeD2xU6fhqcc5v3vZ$$yLEuL3zeiZ116ygOwDDIOKzA#margo-flex-fiber;
id=08$NoeyUKRv0srRplmISVv3J7SjAA5oSEdt0Tod6reU#arcade-hobby-igloo;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Interface: RGB21Unique;
id=kymCOGIa-NmKvwpn-1d6tvAZ-e4vilfE-vnlugPf-s0w2P$c#speed-color-cipher;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Implementation: FrdOYWg1-z8e$dWH-vW7jyts-gzoENCb-kTAHkwI-vynzh3U#broken-bicycle-ladder;
Implementation: yCk$9blq-neYaWQA-PPzZqJk-2V6p70r-3UW6rmi-I8Ez978#pencil-java-patrol;
interface=kymCOGIa-NmKvwpn-1d6tvAZ-e4vilfE-vnlugPf-s0w2P$c#speed-color-cipher;
schema=PeD2xU6fhqcc5v3vZ$$yLEuL3zeiZ116ygOwDDIOKzA#margo-flex-fiber;
schema=08$NoeyUKRv0srRplmISVv3J7SjAA5oSEdt0Tod6reU#arcade-hobby-igloo;
dev=ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w
Type-System: sts:kpZfoOkQ-QBnpq7x-EJj84tu-U$4kkhC-rBTh4YL-iXu5rnw#atomic-enigma-image
Alu-Lib: alu:NhZxdclE-0421s28-MHR$kz$-SadRGjv-iUElfKp-6DiE1KU#metal-coral-charter
Check-SHA256: df9b4111649e843ae7dd123d32703457b082fa2c6a0ae33f39d008854996ba0f
Alu-Lib: alu:sEUjL73M-75sHyss-EEUjrYd-PS6Csi4-AJj5gxb-JDfT9nw#kevin-century-granite
Check-SHA256: 4f09257f2e62698994517b1a1cb755b08a5ad6970c24608bf73ab91f1fea69ec

0s#RFQb$5EF;#A9adl+`R!>~x^Kusb3F_D>3|%=0P4(J<mWA;RHt3oehQzyHV%jp;&2=G}UMKp!;*oOE
<`7J_f%|6IrHK%KPM;|~9DH^hiD%?FRr>XvjR(~i7`}+dRIMW)E%}WETGtn8n`Mj)aOlxt9k`1fWGHk&
Exp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ue$g9R_r1V{2t{E8n<KJxdz(fwc)SY1`R=bsQP${hcDMp~L&2I*~!W1a4t%Wue-9Yt#1Jp*e72xXvv~
_Ej0eK<_)d?1f|rB(T3THwR>8bYW?1b49m+C58dTCbBzQNMS|_kWk@2HT%AU1*iZKSL6XWhzD?TWp-(0
clRD;j;BmNHBOwq)*#;<L?Bf&wD(odi6_qI74u|O1O;tnWNBgGhp04`Gl!Y4#EOy;XgWfDE7LwMr|Y<=
xPa<PwCjNjVRUq1V`yz<Zgg|ZkLS5x^+<}LcGEaI7ODd}u5+h&HA24Gvz{DuJelnXa%FR6a&~2NZgk9_
9SqA<&i^g*B+1lO!K~_XGCIw-T+RZwy_cg^0RRI7K}=N$LQq6WM@3Uq15!sqKmZE?006|G4*&ue01E*C
01F5J0LV570Sf>C068E43kd)K#h?!nIUxZV0YL!^00ICD5d#1@F(3;I1ppZVVF3*Q000UE0096100000
0000
9SqA<&i^g*B+1lO!K~_XGCIw-T+RZwy_cg^0RRI7K}=N$LQq6WM@3Uq15!sqK>!N@000Yt0sz4R1OgWT
3jqKC3wZ<p!NCJLAOH)20sz5B068H63jhEB839273jhWH3lRqZIWZs$3kd)j0bv0V0001>4>kx21ONd5
0000000000

-----END RGB KIT-----
115 changes: 80 additions & 35 deletions src/nia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
//! Non-Inflatable Assets (NIA) schema implementing RGB20 fungible assets
//! interface.

use aluvm::isa::Instr;
use aluvm::isa::opcodes::{INSTR_PUTA, INSTR_TEST};
use aluvm::library::{Lib, LibSite};
use amplify::confinement::Confined;
use bp::dbc::Method;
Expand All @@ -38,7 +36,6 @@ use rgbstd::schema::{
GenesisSchema, GlobalStateSchema, Occurrences, OwnedStateSchema, Schema, TransitionSchema,
};
use rgbstd::validation::Scripts;
use rgbstd::vm::RgbIsa;
use rgbstd::{Identity, rgbasm};
use strict_encoding::InvalidRString;
use strict_types::TypeSystem;
Expand All @@ -48,33 +45,78 @@ use crate::{
OS_ASSET, TS_TRANSFER,
};

pub(crate) fn nia_lib() -> Lib {
let code = rgbasm! {
// SUBROUTINE Transfer validation
// Set errno
put a8[0],ERRNO_NON_EQUAL_IN_OUT;
// Checking that the sum of pedersen commitments in inputs is equal to the sum in outputs.
// ..................
test;
ret;
pub(crate) fn util_lib() -> Lib {
rgbasm! {
// SUBROUTINE Compute sum of inputs
// Input: a16[16] - state to compute
// Output: a64[16] - sum
// Uses: a16[0] - counter, a16[10] - zero constant, a64[0] - extracted amounts
// Fails: on sum overflow or invalid state (should not happen)
// St0: unmodified if not fails
put a16[10],0; // zero constant
put a64[16],0; // init sum with 0
cn.i a16[0],a16[16]; // count state
dec a16[0]; // counter = len - 1
/**/ld.i s16[0],a16[16],a16[0]; // load state
extr s16[4],a64[0],a16[10]; // extract 64 bits
test; // fail if state is absent or invalid
add.uc a64[16],a64[0]; // add amount to the sum
test; // fail on sum overflow
dec a16[0]; // dec counter
jif 0/**/; // repeat for all assignments
inv st0; // reset status flag
ret; // finish

// SUBROUTINE Compute sum of outputs
// Input: a16[16] - state to compute
// Output: a64[17] - sum
// Uses: a16[0] - counter, a16[10] - zero constant, a64[0] - extracted amounts
// Fails: on sum overflow or invalid state (should not happen)
// St0: unmodified if not fails
put a16[10],0; // zero constant
put a64[17],0; // init sum with 0
cn.o a16[0],a16[16]; // count state
dec a16[0]; // counter = len - 1
/**/ld.o s16[0],a16[16],a16[0]; // load state
extr s16[4],a64[0],a16[10]; // extract 64 bits
test; // fail if state is absent or invalid
add.uc a64[17],a64[0]; // add amount to the sum
test; // fail on sum overflow
dec a16[0]; // dec counter
jif 0/**/; // repeat for all assignments
inv st0; // reset status flag
ret; // finish
}
}

pub(crate) fn nia_lib() -> Lib {
let util = util_lib().id();
const ISSUED: u16 = GS_ISSUED_SUPPLY.to_u16();
const DISTRIBUTED: u16 = OS_ASSET.to_u16();
rgbasm! {
// SUBROUTINE Genesis validation
// Checking pedersen commitments against reported amount of issued assets present in the
// global state.
put a8[0],ERRNO_ISSUED_MISMATCH;
put a8[1],0;
put a16[0],0;
// Read global state into s16[0]
ldg GS_ISSUED_SUPPLY,a8[1],s16[0];
// Extract 64 bits from the beginning of s16[0] into a64[1]
// NB: if the global state is invalid, we will fail here and fail the validation
extr s16[0],a64[0],a16[0];
// verify sum of pedersen commitments for assignments against a64[0] value
// ..................
test;
ret;
};
Lib::assemble::<Instr<RgbIsa<MemContract>>>(&code).expect("wrong non-inflatable asset script")
put a16[0],ISSUED; // global state to load
ld.g s16[3],a16[16],a16[0]; // load reported issued amount
put a16[10],0; // zero offset
extr s16[3],a64[15],a16[10]; // a64[15] <- GS_ISSUED_SUPPLY
test; // fail if state is absent or invalid

put a16[16],DISTRIBUTED; // owned state to load
call 0x00 @ util; // a64[17] <- sum of OS_ASSET allocations
put a8[0],ERRNO_ISSUED_MISMATCH; // set errno to return if we fail
eq.n a64[15],a64[17]; // check if ISSUED =? sum(DISTRIBUTED)
test; // fail if not
ret; // complete

// SUBROUTINE Transfer validation
put a16[16],DISTRIBUTED; // owned state to load
call 0x00 @ util; // a64[16] <- sum of inputs
call 0x21 @ util; // a64[17] <- sum of outputs
put a8[0],ERRNO_NON_EQUAL_IN_OUT; // set errno to return if we fail
eq.n a64[16],a64[17]; // check if sum(inputs) =? sum(outputs)
test; // fail if not
ret; // complete
}
}
pub(crate) const FN_NIA_GENESIS_OFFSET: u16 = 4 + 3 + 2 - 3;
pub(crate) const FN_NIA_TRANSFER_OFFSET: u16 = 0;
Expand All @@ -84,10 +126,6 @@ fn nia_schema() -> Schema {

let alu_lib = nia_lib();
let alu_id = alu_lib.id();
assert_eq!(alu_lib.code.as_ref()[FN_NIA_TRANSFER_OFFSET as usize + 4], INSTR_TEST);
assert_eq!(alu_lib.code.as_ref()[FN_NIA_GENESIS_OFFSET as usize], INSTR_PUTA);
assert_eq!(alu_lib.code.as_ref()[FN_NIA_GENESIS_OFFSET as usize + 4], INSTR_PUTA);
assert_eq!(alu_lib.code.as_ref()[FN_NIA_GENESIS_OFFSET as usize + 8], INSTR_PUTA);

Schema {
ffv: zero!(),
Expand Down Expand Up @@ -187,8 +225,9 @@ impl IssuerWrapper for NonInflatableAsset {
fn types() -> TypeSystem { StandardTypes::with(Self::FEATURES.stl()).type_system() }

fn scripts() -> Scripts {
let util = util_lib();
let lib = nia_lib();
Confined::from_checked(bmap! { lib.id() => lib })
Confined::from_checked(bmap! { lib.id() => lib, util.id() => util })
}
}

Expand Down Expand Up @@ -221,10 +260,16 @@ mod test {
use ifaces::stl::*;
use rgbstd::containers::{BuilderSeal, ConsignmentExt};
use rgbstd::interface::*;
use rgbstd::*;
use rgbstd::{disassemble, *};

use super::*;

#[test]
fn lib_check() {
let util = util_lib();
println!("{}", disassemble(&util));
}

#[test]
fn iimpl_check() {
let iface = NonInflatableAsset::FEATURES.iface();
Expand Down Expand Up @@ -282,7 +327,7 @@ mod test {

assert_eq!(
contract.contract_id().to_string(),
s!("rgb:pOIzGFyQ-mA!yQq2-QH8vB5!-5fAplY!-x2lW!vz-JHDbYPg")
s!("rgb:vGAyeGF9-bPAAV8T-w1V46jM-Iz7TW7K-QzZBzcf-RMuzznw")
);
}
}
Loading

0 comments on commit 49213f2

Please sign in to comment.