From 571fc93723d91dda14a39981882b5f2d608ffafc Mon Sep 17 00:00:00 2001 From: Allen Chow Date: Sun, 30 Oct 2022 18:59:07 +0800 Subject: [PATCH 1/2] resolve #147 --- .../bytecode_modules/SignedInteger64.mv | Bin 514 -> 514 bytes .../StarcoinFramework/docs/SignedInteger64.md | 20 ++++++------ .../source_maps/SignedInteger64.mvsm | Bin 6063 -> 6063 bytes integration-tests/signed_integer/add.exp | 4 +-- integration-tests/signed_integer/add.move | 15 +++++++++ integration-tests/signed_integer/sub.exp | 4 +-- integration-tests/signed_integer/sub.move | 10 ++++++ sources/SignedInteger64.move | 29 +++++++++--------- 8 files changed, 53 insertions(+), 29 deletions(-) diff --git a/build/StarcoinFramework/bytecode_modules/SignedInteger64.mv b/build/StarcoinFramework/bytecode_modules/SignedInteger64.mv index d11b7f7ab288f54013bdda33c829046615de5bef..08873de97d5a8fae7ac4d1ddcb1ad264dfe80e4b 100644 GIT binary patch delta 18 YcmZo-X<}Kx$f!1%k?|CeJi}-P04-7k@c;k- delta 18 YcmZo-X<}Kx$fz=zk?|CeJi}-P04*{E?EnA( diff --git a/build/StarcoinFramework/docs/SignedInteger64.md b/build/StarcoinFramework/docs/SignedInteger64.md index 81d8dbda..41d31c5f 100644 --- a/build/StarcoinFramework/docs/SignedInteger64.md +++ b/build/StarcoinFramework/docs/SignedInteger64.md @@ -152,7 +152,7 @@ Sub: num - minus let result = num + minus.value; SignedInteger64 { value: (result as u64), is_negative: false } } else { - if (num > minus.value) { + if (num >= minus.value) { let result = num - minus.value; SignedInteger64 { value: (result as u64), is_negative: false } }else { @@ -197,16 +197,16 @@ Add: num + addend
public fun add_u64(num: u64, addend: SignedInteger64): SignedInteger64 {
     if (addend.is_negative) {
-       if (num > addend.value)  {
-           let result = num - addend.value;
-           SignedInteger64 { value: (result as u64), is_negative: false }
-       }else {
-           let result = addend.value - num;
-           SignedInteger64 { value: (result as u64), is_negative: true }
-       }
+        if (num >= addend.value) {
+            let result = num - addend.value;
+            SignedInteger64 { value: (result as u64), is_negative: false }
+        }else {
+            let result = addend.value - num;
+            SignedInteger64 { value: (result as u64), is_negative: true }
+        }
     } else {
-         let result = num + addend.value;
-         SignedInteger64 { value: (result as u64), is_negative: false }
+        let result = num + addend.value;
+        SignedInteger64 { value: (result as u64), is_negative: false }
     }
 }
 
diff --git a/build/StarcoinFramework/source_maps/SignedInteger64.mvsm b/build/StarcoinFramework/source_maps/SignedInteger64.mvsm index 61f625963ba20a0676aecb5bc518f36541f5e7fb..ccdb5a61239c2b5e76b5bf2c92a03f50ad373431 100644 GIT binary patch literal 6063 zcma)o}ZV>cB;bVm=%!UnoI_% zq|&QUt09_~sF|su(7ragrdq*B#X^v5^ z6thyAc8?}Ya}o7khAB?wGR!JzzJ}EdQ>D2as|lt_(>DHeX>Ow4Con^rA7E{P$EDei z^%Yc0Gr$^vnbNd-G)tQHKV-Hv&-3PsP%F(VSl8eQC-ZmAI%!_Qx(rWA)BY>Zk>(^m zCRH$3niW_z@U%4NW4!>+Nb?_N^CIT6(zJWz@bT!S;1GCzG}qdZ4b&%WAMSoA3VYV1 zg7(%-n3K;O!T-^`gHMzk`#r>mpuc;O0?#W3U)H=%y%J0Zb+7Mv2f*#7a}e_g#FAky z>`8a4)jN(m0+INJY&sJLDS0WmhwZa$d<*3?qj+)9OIL(70rb)tb25yRZ!f?q1bw-% zbJCZKM(QmAeYtoEYbnI#I9ssRfxd_g^mvU~4i1NFD_N?~1TLqj(vP_V z3Ofl1VOK{O$R6H>J`9mqS9dy@ZIdm075N6ZwD50ucT91)*~YvN`quvt%jfv$y?%iC zFX$GwbJ8t5n>Wt|-NFg1=Rmjc60GH*TiBRyf^Okrthc}+@(j@FdrY@G9kD^oA&7Q{ zscet>LVSmL*w_SInJ2f8^So10&VWN0zDCirxQ=1CjM9~0v#kunCy+-Tc|a!ll?&~0HCL?8AkOlvCW!#)FR7U;un%sS9VcpBDp&|%o_nLg~VQ*RaM z*t`O3E$G;s#>#+>%?(&ND3yP5c8_#y?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TULkR ztJM1rbQr#YH2|aKdK&X5&|&y{tm~k|ux)%DhGTSl3Ft5!#j1cBIiotPdKf3o2h64c zQ-@)@M>-6zrrvs}lTSBh06GjOvC^Q!@Hxfoxtn@NK*#2fv3fzr<}a`= WfR4>uvAzNwo9!OyFl^r;p7$SSr}onT diff --git a/integration-tests/signed_integer/add.exp b/integration-tests/signed_integer/add.exp index ab0e2edd..fdc51517 100644 --- a/integration-tests/signed_integer/add.exp +++ b/integration-tests/signed_integer/add.exp @@ -1,7 +1,7 @@ processed 3 tasks -task 2 'run'. lines 5-26: +task 2 'run'. lines 5-41: { - "gas_used": 54451, + "gas_used": 100737, "status": "Executed" } diff --git a/integration-tests/signed_integer/add.move b/integration-tests/signed_integer/add.move index efa879cd..12d9505f 100644 --- a/integration-tests/signed_integer/add.move +++ b/integration-tests/signed_integer/add.move @@ -22,5 +22,20 @@ fun main() { let i2 = SignedInteger64::create_from_raw_value(0, false); let z2 = SignedInteger64::add_u64(100, copy i2); assert!(SignedInteger64::get_value(z2) == 100, 6); + + let i3 = SignedInteger64::create_from_raw_value(1, true); + let z3 = SignedInteger64::add_u64(1, i3); + assert!(SignedInteger64::get_value(copy z3) == 0, 7); + assert!(SignedInteger64::is_negative(z3) == false, 8); + + let i4 = SignedInteger64::create_from_raw_value(0, true); + let z4 = SignedInteger64::add_u64(0, i4); + assert!(SignedInteger64::get_value(copy z4) == 0, 9); + assert!(SignedInteger64::is_negative(z4) == false, 10); + + let i5 = SignedInteger64::create_from_raw_value(0, false); + let z5 = SignedInteger64::add_u64(0, i5); + assert!(SignedInteger64::get_value(copy z5) == 0, 11); + assert!(SignedInteger64::is_negative(z5) == false, 12); } } \ No newline at end of file diff --git a/integration-tests/signed_integer/sub.exp b/integration-tests/signed_integer/sub.exp index ab0e2edd..008dcc06 100644 --- a/integration-tests/signed_integer/sub.exp +++ b/integration-tests/signed_integer/sub.exp @@ -1,7 +1,7 @@ processed 3 tasks -task 2 'run'. lines 5-26: +task 2 'run'. lines 5-36: { - "gas_used": 54451, + "gas_used": 84873, "status": "Executed" } diff --git a/integration-tests/signed_integer/sub.move b/integration-tests/signed_integer/sub.move index 1cc37569..c32676cd 100644 --- a/integration-tests/signed_integer/sub.move +++ b/integration-tests/signed_integer/sub.move @@ -22,5 +22,15 @@ fun main() { let i2 = SignedInteger64::create_from_raw_value(100, true); let z2 = SignedInteger64::sub_u64(100, copy i2); assert!(SignedInteger64::get_value(z2) == 200, 6); + + let i3 = SignedInteger64::create_from_raw_value(0, true); + let z3 = SignedInteger64::sub_u64(0, i3); + assert!(SignedInteger64::get_value(copy z3) == 0, 1); + assert!(SignedInteger64::is_negative(z3) == false, 2); + + let i4 = SignedInteger64::create_from_raw_value(0, false); + let z4 = SignedInteger64::sub_u64(0, i4); + assert!(SignedInteger64::get_value(copy z4) == 0, 1); + assert!(SignedInteger64::is_negative(z4) == false, 2); } } \ No newline at end of file diff --git a/sources/SignedInteger64.move b/sources/SignedInteger64.move index b61c83ba..172eceea 100644 --- a/sources/SignedInteger64.move +++ b/sources/SignedInteger64.move @@ -31,7 +31,7 @@ module SignedInteger64 { let result = num + minus.value; SignedInteger64 { value: (result as u64), is_negative: false } } else { - if (num > minus.value) { + if (num >= minus.value) { let result = num - minus.value; SignedInteger64 { value: (result as u64), is_negative: false } }else { @@ -40,19 +40,20 @@ module SignedInteger64 { } } } + /// Add: `num + addend` public fun add_u64(num: u64, addend: SignedInteger64): SignedInteger64 { if (addend.is_negative) { - if (num > addend.value) { - let result = num - addend.value; - SignedInteger64 { value: (result as u64), is_negative: false } - }else { - let result = addend.value - num; - SignedInteger64 { value: (result as u64), is_negative: true } - } + if (num >= addend.value) { + let result = num - addend.value; + SignedInteger64 { value: (result as u64), is_negative: false } + }else { + let result = addend.value - num; + SignedInteger64 { value: (result as u64), is_negative: true } + } } else { - let result = num + addend.value; - SignedInteger64 { value: (result as u64), is_negative: false } + let result = num + addend.value; + SignedInteger64 { value: (result as u64), is_negative: false } } } @@ -73,10 +74,8 @@ module SignedInteger64 { // **************** SPECIFICATIONS **************** - - spec multiply_u64 { - aborts_if multiplier.value * num > max_u64(); + aborts_if multiplier.value * num > max_u64(); } spec divide_u64 { @@ -88,7 +87,7 @@ module SignedInteger64 { } spec add_u64 { - aborts_if !addend.is_negative && num + addend.value > max_u64(); + aborts_if !addend.is_negative && num + addend.value > max_u64(); } spec create_from_raw_value { @@ -105,6 +104,6 @@ module SignedInteger64 { aborts_if false; ensures result == num.is_negative; } -} } +} From 3410cd1505d96b6eae061b4514d780d16be5c721 Mon Sep 17 00:00:00 2001 From: Allen Chow Date: Sun, 30 Oct 2022 19:10:24 +0800 Subject: [PATCH 2/2] remove unnecessary conversions --- .../bytecode_modules/SignedInteger64.mv | Bin 514 -> 506 bytes .../StarcoinFramework/docs/SignedInteger64.md | 16 ++++++++-------- .../source_maps/SignedInteger64.mvsm | Bin 6063 -> 5727 bytes integration-tests/signed_integer/add.exp | 2 +- .../signed_integer/add_overflow.exp | 2 +- integration-tests/signed_integer/divide.exp | 2 +- integration-tests/signed_integer/multiply.exp | 2 +- integration-tests/signed_integer/sub.exp | 2 +- sources/SignedInteger64.move | 16 ++++++++-------- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/StarcoinFramework/bytecode_modules/SignedInteger64.mv b/build/StarcoinFramework/bytecode_modules/SignedInteger64.mv index 08873de97d5a8fae7ac4d1ddcb1ad264dfe80e4b..366352d8adf83f798d64d8370c8e8ecd8a38e13a 100644 GIT binary patch delta 229 zcmYL@y$!-Z3`TwS`2>!GqA21}I{rd~5EC!~bFcs#(9(di6a^DeaS7JZS)c9iy_^5g zW9{!)zMs3-`8abGG{n3SNTX{yQjRu9_2Q>BDDrY#3Pfe$$q*H�R^aYmm^NTwAIo vt)gImaoelf>taYoTn!i;0B3lWYYg~r?kMsq`y}|!XPUj)uMf+!+Zz5(+@2>((9Jpublic fun multiply_u64(num: u64, multiplier: SignedInteger64): SignedInteger64 { let product = multiplier.value * num; - SignedInteger64 { value: (product as u64), is_negative: multiplier.is_negative } + SignedInteger64 { value: product, is_negative: multiplier.is_negative } } @@ -111,7 +111,7 @@ Divide a u64 integer by a signed integer number.
public fun divide_u64(num: u64, divisor: SignedInteger64): SignedInteger64 {
     let quotient = num / divisor.value;
-    SignedInteger64 { value: (quotient as u64), is_negative: divisor.is_negative }
+    SignedInteger64 { value: quotient, is_negative: divisor.is_negative }
 }
 
@@ -150,14 +150,14 @@ Sub: num - minus
public fun sub_u64(num: u64, minus: SignedInteger64): SignedInteger64 {
     if (minus.is_negative) {
         let result = num + minus.value;
-        SignedInteger64 { value: (result as u64), is_negative: false }
+        SignedInteger64 { value: result, is_negative: false }
     } else {
         if (num >= minus.value) {
             let result = num - minus.value;
-            SignedInteger64 { value: (result as u64), is_negative: false }
+            SignedInteger64 { value: result, is_negative: false }
         }else {
             let result = minus.value - num;
-            SignedInteger64 { value: (result as u64), is_negative: true }
+            SignedInteger64 { value: result, is_negative: true }
         }
     }
 }
@@ -199,14 +199,14 @@ Add: num + addend
     if (addend.is_negative) {
         if (num >= addend.value) {
             let result = num - addend.value;
-            SignedInteger64 { value: (result as u64), is_negative: false }
+            SignedInteger64 { value: result, is_negative: false }
         }else {
             let result = addend.value - num;
-            SignedInteger64 { value: (result as u64), is_negative: true }
+            SignedInteger64 { value: result, is_negative: true }
         }
     } else {
         let result = num + addend.value;
-        SignedInteger64 { value: (result as u64), is_negative: false }
+        SignedInteger64 { value: result, is_negative: false }
     }
 }
 
diff --git a/build/StarcoinFramework/source_maps/SignedInteger64.mvsm b/build/StarcoinFramework/source_maps/SignedInteger64.mvsm index ccdb5a61239c2b5e76b5bf2c92a03f50ad373431..1c9f9d8b237a2ad3f00f554c161e477a854caeb4 100644 GIT binary patch literal 5727 zcma)sWZG}^ zQ=iR3Xce`(D9~eygq1mf^baWSI?io~YV}sc^Zo-boR!QptHS?d-hrHkM8Z!dl>QL) zDMYf$N-LFIlf!5kG43qoPQ-nIo0Ia}GEHfve}mouvA25Z4D~>m+A+hs2WF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+)9OIL(70rb)tb25yRZ!f?q1bw-% zbJCZKM(QmAeYtoEYbnI#I9ssRfxd_g^mvU~4i1NFD_N?~1TLqj(vP_V z3Ofl1VOK{O$R6H>J`9mqS9dy@ZIdm075N6ZwD50ucT91)*~YvN`quvt%jfv$y?%iC zFX$GwbJ8t5n>Wt|-NFg1=Rmjc60GH*TiBRyf^Okrthc}+@(j@FdrY@G9kD^oA&7Q{ zscet>LVSmL*w_SInJ2f8^So10&VWN0zDCirxQ=1CjM9~0v#kunCy+-Tc|a!ll?&~0HCL?8AkOlvCW!#)FR7U;un%sS9VcpBDp&|%o_nLg~VQ*RaM z*t`O3E$G;s#>#+>%?(&ND3yP5c8_#y?xkKI=-9jiYbWT~Y|KH>VYnabOVDB1wyX}r zC#iQDbQm7PIt!1<^)%)M&|&x|tWnTm*fzcn!*RO31augVVO4?-!wIZ9sFrj8gW1f% z)M41}kq*PFsn-Sx`F3N5pu=znRvL5|eiv&!JSpF9|7&$@?xWto9!OyFl_%rJnuig&pcKD diff --git a/integration-tests/signed_integer/add.exp b/integration-tests/signed_integer/add.exp index fdc51517..f6b3dc0b 100644 --- a/integration-tests/signed_integer/add.exp +++ b/integration-tests/signed_integer/add.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-41: { - "gas_used": 100737, + "gas_used": 100723, "status": "Executed" } diff --git a/integration-tests/signed_integer/add_overflow.exp b/integration-tests/signed_integer/add_overflow.exp index c3cca6af..c0510b88 100644 --- a/integration-tests/signed_integer/add_overflow.exp +++ b/integration-tests/signed_integer/add_overflow.exp @@ -12,7 +12,7 @@ task 2 'run'. lines 5-16: } }, "function": 0, - "code_offset": 42 + "code_offset": 40 } } } diff --git a/integration-tests/signed_integer/divide.exp b/integration-tests/signed_integer/divide.exp index debe8124..663ea9ce 100644 --- a/integration-tests/signed_integer/divide.exp +++ b/integration-tests/signed_integer/divide.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-26: { - "gas_used": 53261, + "gas_used": 53253, "status": "Executed" } diff --git a/integration-tests/signed_integer/multiply.exp b/integration-tests/signed_integer/multiply.exp index 4dd911e9..4f28423f 100644 --- a/integration-tests/signed_integer/multiply.exp +++ b/integration-tests/signed_integer/multiply.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-23: { - "gas_used": 45726, + "gas_used": 45720, "status": "Executed" } diff --git a/integration-tests/signed_integer/sub.exp b/integration-tests/signed_integer/sub.exp index 008dcc06..927616f9 100644 --- a/integration-tests/signed_integer/sub.exp +++ b/integration-tests/signed_integer/sub.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-36: { - "gas_used": 84873, + "gas_used": 84861, "status": "Executed" } diff --git a/sources/SignedInteger64.move b/sources/SignedInteger64.move index 172eceea..5258cc78 100644 --- a/sources/SignedInteger64.move +++ b/sources/SignedInteger64.move @@ -16,27 +16,27 @@ module SignedInteger64 { /// Multiply a u64 integer by a signed integer number. public fun multiply_u64(num: u64, multiplier: SignedInteger64): SignedInteger64 { let product = multiplier.value * num; - SignedInteger64 { value: (product as u64), is_negative: multiplier.is_negative } + SignedInteger64 { value: product, is_negative: multiplier.is_negative } } /// Divide a u64 integer by a signed integer number. public fun divide_u64(num: u64, divisor: SignedInteger64): SignedInteger64 { let quotient = num / divisor.value; - SignedInteger64 { value: (quotient as u64), is_negative: divisor.is_negative } + SignedInteger64 { value: quotient, is_negative: divisor.is_negative } } /// Sub: `num - minus` public fun sub_u64(num: u64, minus: SignedInteger64): SignedInteger64 { if (minus.is_negative) { let result = num + minus.value; - SignedInteger64 { value: (result as u64), is_negative: false } + SignedInteger64 { value: result, is_negative: false } } else { if (num >= minus.value) { let result = num - minus.value; - SignedInteger64 { value: (result as u64), is_negative: false } + SignedInteger64 { value: result, is_negative: false } }else { let result = minus.value - num; - SignedInteger64 { value: (result as u64), is_negative: true } + SignedInteger64 { value: result, is_negative: true } } } } @@ -46,14 +46,14 @@ module SignedInteger64 { if (addend.is_negative) { if (num >= addend.value) { let result = num - addend.value; - SignedInteger64 { value: (result as u64), is_negative: false } + SignedInteger64 { value: result, is_negative: false } }else { let result = addend.value - num; - SignedInteger64 { value: (result as u64), is_negative: true } + SignedInteger64 { value: result, is_negative: true } } } else { let result = num + addend.value; - SignedInteger64 { value: (result as u64), is_negative: false } + SignedInteger64 { value: result, is_negative: false } } }