Skip to content

Commit a8a0d5d

Browse files
Booster improvements (#288)
* `startPrank` match: `getbuffer` => `#getBuffer` * `memLoad-zero-length` match * `appendToOutAccount` definedness of `_Map_` * add `preserves-definedness` * Set Version: 0.1.80 --------- Co-authored-by: devops <[email protected]>
1 parent 261cbeb commit a8a0d5d

File tree

7 files changed

+30
-24
lines changed

7 files changed

+30
-24
lines changed

kmultiversx/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "kmultiversx"
7-
version = "0.1.79"
7+
version = "0.1.80"
88
description = "Python tools for Elrond semantics"
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

kmultiversx/src/kmultiversx/kdist/mx-semantics/elrond-config.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ module ELROND-CONFIG
117117
requires #signed(i32 , LENGTH) <Int 0
118118
119119
rule [memLoad-zero-length]:
120-
<instrs> #memLoad(_, 0) => .K ... </instrs>
120+
<instrs> #memLoad(_, LENGTH) => .K ... </instrs>
121121
<bytesStack> STACK => .Bytes : STACK </bytesStack>
122+
requires LENGTH ==Int 0
122123
123124
rule [memLoad-bad-bounds]:
124125
<instrs> #memLoad(OFFSET, LENGTH) => #throwException(ExecutionFailed, "mem load: bad bounds") ... </instrs>

kmultiversx/src/kmultiversx/kdist/mx-semantics/elrond-node.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,23 +156,22 @@ Storage maps byte arrays to byte arrays.
156156
rule [appendToOutAccount]:
157157
<commands> appendToOutAccount(ACC, T) => .K ... </commands>
158158
<outputAccounts>
159-
...
160-
ACC |-> (OA => appendToOutTransfers(OA, T))
161-
...
159+
OAs => OAs [ ACC <- appendToOutTransfers(
160+
{ OAs [ ACC ] orDefault OutputAccount(ACC, .List) }:>OutputAccount,
161+
T
162+
) ]
162163
</outputAccounts>
163164
requires nonZeroOutputTransfer(T)
164-
[priority(60)]
165-
166-
rule [appendToOutAccount-new-item]:
167-
<commands> appendToOutAccount(ACC, T) => .K ... </commands>
168-
<outputAccounts> OAs => OAs [ ACC <- OutputAccount(ACC, ListItem(T))] </outputAccounts>
169-
requires nonZeroOutputTransfer(T)
170-
[priority(61)]
165+
andBool isOutputAccount( OAs [ ACC ] orDefault OutputAccount(ACC, .List) )
166+
[priority(60), preserves-definedness]
167+
// Preserving definedness
168+
// - Map[_<-_], Map[_]orDefault_ and appendToOutTransfers are total
169+
// - {_}:>OutputAccount is checked
171170
172171
rule [appendToOutAccount-zero]:
173172
<commands> appendToOutAccount(_, T) => .K ... </commands>
174173
requires notBool nonZeroOutputTransfer(T)
175-
[priority(61)]
174+
[priority(60)]
176175
177176
syntax TransferValue ::= Int // EGLD transfer
178177
| List

kmultiversx/src/kmultiversx/kdist/mx-semantics/kasmer.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -588,36 +588,33 @@ Only the `#kasmerRunner` account can execute these commands/host functions.
588588
```k
589589
rule [testapi-startPrank]:
590590
<instrs> hostCall ( "env" , "startPrank" , [ i32 .ValTypes ] -> [ .ValTypes ] )
591-
=> #startPrank(getBuffer(ADDR_HANDLE)) ...
591+
=> #getBuffer(ADDR_HANDLE)
592+
~> #startPrank ...
592593
</instrs>
593594
<locals>
594595
0 |-> <i32> ADDR_HANDLE
595596
</locals>
596597
<callee> #kasmerRunner </callee>
597598
598-
syntax InternalInstr ::= #startPrank(BytesResult)
599+
syntax InternalInstr ::= "#startPrank"
599600
// -------------------------------------------------
600601
rule [startPrank]:
601-
<instrs> #startPrank(ADDR:Bytes) => .K ... </instrs>
602+
<instrs> #startPrank => .K ... </instrs>
603+
<bytesStack> ADDR:Bytes : S => S </bytesStack>
602604
<callee> #kasmerRunner => ADDR </callee>
603605
<prank> false => true </prank>
604606
605607
rule [startPrank-not-allowed]:
606-
<instrs> #startPrank(_:Bytes)
608+
<instrs> #startPrank
607609
=> #throwException(ExecutionFailed, "Only the test contract can start a prank and the test contract can't start a prank while already pranking")
608610
...
609611
</instrs>
612+
<bytesStack> _:Bytes : S => S </bytesStack>
610613
<callee> ADDR </callee>
611614
<prank> PRANK </prank>
612615
requires ADDR =/=K #kasmerRunner
613616
orBool PRANK
614617
615-
rule [startPrank-err]:
616-
<instrs> #startPrank(Err(MSG))
617-
=> #throwException(ExecutionFailed, MSG)
618-
...
619-
</instrs>
620-
621618
rule [testapi-stopPrank]:
622619
<instrs> hostCall ( "env" , "stopPrank" , [ .ValTypes ] -> [ .ValTypes ] )
623620
=> .K ...

kmultiversx/src/kmultiversx/kdist/mx-semantics/vmhooks/manBufOps.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ module MANBUFOPS
169169
<locals> 0 |-> <i32> ARG_IDX 1 |-> <i32> DEST_IDX </locals>
170170
<callArgs> ARGS </callArgs>
171171
requires #validArgIdx(ARG_IDX, ARGS)
172+
[preserves-definedness]
173+
// Preserving definedness: #validArgIdx(_) ensures Map {{ }} is defined
172174
173175
// extern int32_t mBufferAppend(void* context, int32_t accumulatorHandle, int32_t dataHandle);
174176
rule <instrs> hostCall("env", "mBufferAppend", [ i32 i32 .ValTypes ] -> [ i32 .ValTypes ] )

kmultiversx/src/kmultiversx/kdist/mx-semantics/vmhooks/smallIntOps.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,20 @@ module SMALLINTOPS
5757
...
5858
</instrs>
5959
<locals> 0 |-> <i64> VALUE </locals>
60+
requires definedUnsigned(i64, VALUE)
61+
[preserves-definedness]
62+
// Preserving definedness: definedUnsigned(_) ensures #unsigned(_) is defined
6063
6164
// extern void smallIntFinishSigned(void* context, long long value);
6265
rule <instrs> hostCall("env", "smallIntFinishSigned", [ i64 .ValTypes ] -> [ .ValTypes ])
6366
=> #appendToOut(Int2Bytes(#signed(i64, VALUE), BE, Signed))
6467
...
6568
</instrs>
6669
<locals> 0 |-> <i64> VALUE </locals>
70+
requires definedSigned(i64, VALUE)
71+
[preserves-definedness]
72+
// Preserving definedness: definedSigned(_) ensures #signed(_) is defined
73+
6774
6875
// extern int32_t smallIntStorageStoreUnsigned(void *context, int32_t keyOffset, int32_t keyLength, long long value);
6976
rule <instrs> hostCall("env", "smallIntStorageStoreUnsigned", [ i32 i32 i64 .ValTypes ] -> [ i32 .ValTypes ])

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.79
1+
0.1.80

0 commit comments

Comments
 (0)