Skip to content

Commit

Permalink
vm: use operation type in ordering
Browse files Browse the repository at this point in the history
If we have two different state transitions of different mined into the same block, which (by mistake) have the same nonce, we still can order them using type. This allows usage of type id value as a way of setting strong ordering overriding nonce values (for instance token issues can be always ordered before spendings)
  • Loading branch information
dr-orlovsky committed Aug 22, 2024
1 parent 14d07f5 commit 495f035
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
24 changes: 20 additions & 4 deletions src/vm/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ impl<'op> OrdOpRef<'op> {
OrdOpRef::Genesis(_) => OpOrd::Genesis,
OrdOpRef::Transition(op, _, witness_ord) => OpOrd::Transition {
witness: *witness_ord,
ty: op.transition_type,
nonce: op.nonce,
opid: op.id(),
},
OrdOpRef::Extension(op, _, witness_ord) => OpOrd::Extension {
witness: *witness_ord,
ty: op.extension_type,
nonce: op.nonce,
opid: op.id(),
},
Expand Down Expand Up @@ -415,14 +417,14 @@ pub enum OpOrd {
#[strict_type(tag = 0x01)]
Extension {
witness: WitnessOrd,
// TODO: Consider using extension type here
ty: ExtensionType,
nonce: u64,
opid: OpId,
},
#[strict_type(tag = 0xFF)]
Transition {
witness: WitnessOrd,
// TODO: Consider using transition type here
ty: TransitionType,
nonce: u64,
opid: OpId,
},
Expand Down Expand Up @@ -465,20 +467,34 @@ impl GlobalOrd {
idx,
}
}
pub fn transition(opid: OpId, idx: u16, nonce: u64, witness: WitnessOrd) -> Self {
pub fn transition(
opid: OpId,
idx: u16,
ty: TransitionType,
nonce: u64,
witness: WitnessOrd,
) -> Self {
Self {
op_ord: OpOrd::Transition {
witness,
ty,
nonce,
opid,
},
idx,
}
}
pub fn extension(opid: OpId, idx: u16, nonce: u64, witness: WitnessOrd) -> Self {
pub fn extension(
opid: OpId,
idx: u16,
ty: ExtensionType,
nonce: u64,
witness: WitnessOrd,
) -> Self {
Self {
op_ord: OpOrd::Extension {
witness,
ty,
nonce,
opid,
},
Expand Down
24 changes: 12 additions & 12 deletions stl/[email protected]
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-----BEGIN STRICT TYPE LIB-----
Id: stl:LpE2Q!Jf-pKsvjM$-ntKgUld-!zeRRa!-v7l6pzJ-qW2YceY#africa-choice-biology
Id: stl:w3K7P7FD-SQ36YW9-C4zqzxS-9RCkgd$-osrL6RV-gk11t!g#satire-vital-richard
Name: RGBLogic
Dependencies:
RGBCommit#tuna-safari-design,
BPCore#totem-holiday-helena,
BPCore#garbo-radius-peru,
RGBCommit#nova-lobby-dialog,
Bitcoin#signal-color-cipher
Check-SHA256: ec5fbe3beec7e0816d76eb90ea8fb35c931847f2b189f7befdde4e7e16d53e18
Check-SHA256: b385c363a383d9a2cce01e0c7b4e75acd48725312341a0dcfe23317f431e744b

2vSEvOmAmtV*_Nw)d@|xKsr716mTQmaB}ROZ@Dgs2ia_2=g^?i+KdTOM?ynyZEb0ErdhI3FM~0|p{<6(
sS&)~H{Xkb4j+}v9*QG}Q6KKm20~CnZ*pbzY!hN5_Bp3Y36tDMM#=e#tGI($UA5U3KNx<*C>ja}LTPkk
2vSEvOmAmtV*_s<midRhTh1hu7-!n@1Cr{swqbZoGSd8tmgp<3rE>;CP(yEWW!w3x9BR2~UxbGv2Fx@x
O&x#t!~fsyrIq3x!~?M?<q1+pLPKwDZE1A%Y!hN5_Bp3Y36tDMM#=e#tGI($UA5U3KNx<*C>ja}LTPkk
Z)t7=20~CnZ*pY?00DdlT>wB!7L}MA7sFvK#<=RP4S#T1Vv-hhTICs&5fM~jaB^jIPH$voP+@X(Ze?;0
wjY>38tto&d&=e<t?OC7vzr3sh4VL=aEO-K69^0oRAF#(Wpq$-Z*OK3#8XmcC%Z%?j5}xa%));D{NyLM
&t4DxfsZeKd)RyrRAF#(Wpq$sbZAg=Z*OKeKVmL%Q_{#Gkvz+H9iKg9-*)mSRaq_gMnjYqO>G4cRAF#(
Expand All @@ -18,14 +18,14 @@ DJ{*3f84s>#k$1lf7uIEVQ@}wW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rv
?4579E{O-(Y+vWlpwilmmB{9L9(7`0)Rt93YLV-HLXe?vTA1;^Q1`ZqBog<<3Rh`#Ze??GPjX}g0{{qN
LK#dEwxUFHJ){RjtgLvL_X>0rou@Knb#Vo5Z*F5{000OCZ*Xa30^9kj9BR2~UxbGv2Fx@xO&x#t!~fsy
rIq3x!~?M?<(0_hdLDIRU(}XWLTZugenOC;Z(5k~zEJnJiX;;E#s3O)a$#<BX>@6CZU6=Y2X|?7Ze??G
0rm?cniq>g8B7tjqC|5&qz6Q-tazCB3Um~mr!r)9aRqK~ZewKt00;zcaA{-$+xe;-YPo4&goh&r%rrDj
9e?-3|KIJUmEs-51F<OOmB{9L9(7`0)Rt93YLV-HLXe?vTA1;^Q1`ZqBog<<3Rh`#Ze??GPjX}g0{{qN
a${&|c4cG$00036ZE0?0WB>&L0S>>o?Kom?q=ULN^A!11b?H{wM>P}NCm0qyW47Umu>uKnWo~p~bZK^F
0000AS7~%^Wpi^-Z*v9$254nzXJ~W)00aqiX>Db5bYX39002k

Expand Down
7 changes: 5 additions & 2 deletions stl/[email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-
Id: stl:LpE2Q!Jf-pKsvjM$-ntKgUld-!zeRRa!-v7l6pzJ-qW2YceY#africa-choice-biology
Id: stl:w3K7P7FD-SQ36YW9-C4zqzxS-9RCkgd$-osrL6RV-gk11t!g#satire-vital-richard
Name: RGBLogic
Version: 0.1.0
Description: Consensus logic layer for RGB smart contracts
Expand All @@ -11,7 +11,7 @@
@context
typelib RGBLogic
import RGBCommit#tuna-safari-design
import RGBCommit#pretend-carpet-caesar
use OpId#picnic-single-gloria
import BPCore#totem-holiday-helena
Expand All @@ -21,6 +21,9 @@ import BPCore#totem-holiday-helena
use TapretRightBranch#miracle-patriot-touch
use OpretProof#good-village-flex
import RGBCommit#nova-lobby-dialog
use OpId#picnic-single-gloria
import Bitcoin#signal-color-cipher
use ScriptBytes#equator-cockpit-gong
use TapNodeHash#paprika-amanda-hunter
Expand Down

0 comments on commit 495f035

Please sign in to comment.