Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement RGB Isa instructions #201

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/contract/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::cmp::Ordering;
use std::collections::{btree_map, btree_set, BTreeMap};
use std::iter;

use amplify::confinement::{Confined, SmallBlob, TinyOrdMap, TinyOrdSet};
use amplify::confinement::{Confined, SmallBlob, SmallOrdSet, TinyOrdMap, TinyOrdSet};
use amplify::Wrapper;
use commit_verify::{
CommitEncode, CommitEngine, CommitId, Conceal, MerkleHash, MerkleLeaves, StrictHash,
Expand Down Expand Up @@ -105,7 +105,7 @@ impl<'a> IntoIterator for &'a Redeemed {
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
pub struct Inputs(TinyOrdSet<Input>);
pub struct Inputs(SmallOrdSet<Input>);

impl<'a> IntoIterator for &'a Inputs {
type Item = Input;
Expand Down
2 changes: 1 addition & 1 deletion src/stl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::{

/// Strict types id for the library providing data types for RGB consensus.
pub const LIB_ID_RGB: &str =
"urn:ubideco:stl:2nWgjeSMhVE2mKgC7WyE5Dn8a6tZJDMoNugDWdc4vcZZ#spring-moral-almanac";
"urn:ubideco:stl:HqdNNAehK3yaQ1AC5pQmEuNNS1zgyo2Jw31fdUNKb9MU#annual-virus-garlic";

fn _rgb_core_stl() -> Result<TypeLib, CompileError> {
LibBuilder::new(libname!(LIB_NAME_RGB), tiny_bset! {
Expand Down
28 changes: 25 additions & 3 deletions src/vm/macroasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#[macro_export]
macro_rules! rgbasm {
($( $tt:tt )+) => {{ #[allow(unused_imports)] {
use amplify::num::u5;
crisdut marked this conversation as resolved.
Show resolved Hide resolved
use $crate::{AssignmentType, GlobalStateType};
use $crate::vm::{RgbIsa, ContractOp, TimechainOp};
use $crate::vm::aluasm_isa;
use $crate::isa_instr;
Expand All @@ -34,8 +36,28 @@ macro_rules! rgbasm {
macro_rules! isa_instr {
(pcvs $no:literal) => {{ RgbIsa::Contract(ContractOp::PcVs($no.into())) }};
(pccs $no1:literal, $no2:literal) => {{ RgbIsa::Contract(ContractOp::PcCs($no1.into(), $no2.into())) }};
(ldg $t:literal, $no:literal,s16[$s_idx:literal]) => {{ RgbIsa::Contract(ContractOp::LdG($t.into(), $no, RegS::from($s_idx))) }};
(lds $t:literal, $no:literal,s16[$s_idx:literal]) => {{ RgbIsa::Contract(ContractOp::LdS($t.into(), $no, RegS::from($s_idx))) }};
(ldp $t:literal, $no:literal,s16[$s_idx:literal]) => {{ RgbIsa::Contract(ContractOp::LdP($t.into(), $no, RegS::from($s_idx))) }};
(cng $t:literal,a8[$a_idx:literal]) => {{ RgbIsa::Contract(ContractOp::CnG($t.into(), Reg32::from(u5::with($a_idx)))) }};
(cnc $t:literal,a16[$a_idx:literal]) => {{ RgbIsa::Contract(ContractOp::CnC($t.into(), Reg32::from(u5::with($a_idx)))) }};
(ldg $t:literal,a8[$a_idx:literal],s16[$s_idx:literal]) => {{
RgbIsa::Contract(ContractOp::LdG(
GlobalStateType::from($t as u16),
Reg16::from(u4::with($a_idx)),
RegS::from($s_idx),
))
}};
(ldp $t:literal,a16[$a_idx:literal],s16[$s_idx:literal]) => {{
RgbIsa::Contract(ContractOp::LdP(
AssignmentType::from($t as u16),
Reg16::from(u4::with($a_idx)),
RegS::from($s_idx),
))
}};
(lds $t:literal,a16[$a_idx:literal],s16[$s_idx:literal]) => {{
RgbIsa::Contract(ContractOp::LdS(
AssignmentType::from($t as u16),
Reg16::from(u4::with($a_idx)),
RegS::from($s_idx),
))
}};
($op:ident $($tt:tt)+) => {{ compile_error!(concat!("unknown RGB assembly opcode `", stringify!($op), "`")) }};
}
Loading
Loading