Skip to content

Commit 510c807

Browse files
feat: run transactions without checking the return value
Transactions were decoded into callTx(..., Void), which asserts the call returns Void, so any contract invocation returning a value got stuck in the semantics and was recorded as FAILED. Decode callTx steps into uncheckedCallTx instead, which performs the same call but drops the return value check.
1 parent 37c3ffb commit 510c807

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/komet_node/kdist/node.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,10 @@ SCVal arg encoding (key order also significant):
393393
=> deployContract(Account(HexBytes(FROM)), Contract(HexBytes(ADDR)), HexBytes(HASH))
394394
395395
rule #decodeStep({ "op" : "callTx" , "from" : FROM:String , "fromIsContract" : false , "func" : FUNC:String , "to" : TO:String , "args" : [ARGS:JSONs] })
396-
=> callTx(Account(HexBytes(FROM)), Contract(HexBytes(TO)), string2WasmToken("\"" +String FUNC +String "\""), #decodeArgList(ARGS), Void)
396+
=> uncheckedCallTx(Account(HexBytes(FROM)), Contract(HexBytes(TO)), string2WasmToken("\"" +String FUNC +String "\""), #decodeArgList(ARGS))
397397
398398
rule #decodeStep({ "op" : "callTx" , "from" : FROM:String , "fromIsContract" : true , "func" : FUNC:String , "to" : TO:String , "args" : [ARGS:JSONs] })
399-
=> callTx(Contract(HexBytes(FROM)), Contract(HexBytes(TO)), string2WasmToken("\"" +String FUNC +String "\""), #decodeArgList(ARGS), Void)
399+
=> uncheckedCallTx(Contract(HexBytes(FROM)), Contract(HexBytes(TO)), string2WasmToken("\"" +String FUNC +String "\""), #decodeArgList(ARGS))
400400
401401
syntax List ::= #decodeArgList(JSONs) [function]
402402
syntax ScVal ::= #decodeArg(JSON) [function]
@@ -415,6 +415,23 @@ SCVal arg encoding (key order also significant):
415415
rule #decodeArg({ "type" : "bytes" , "value" : V:String }) => ScBytes(HexBytes(V))
416416
rule #decodeArg({ "type" : "address" , "addrType" : "account" , "value" : V:String }) => ScAddress(Account(HexBytes(V)))
417417
rule #decodeArg({ "type" : "address" , "addrType" : "contract" , "value" : V:String }) => ScAddress(Contract(HexBytes(V)))
418+
```
419+
420+
`uncheckedCallTx` is like komet's `callTx` but it does not entail a return value check.
421+
422+
423+
```k
424+
syntax Step ::= uncheckedCallTx( from: Address, to: Address, func: WasmString, args: List) [symbol(uncheckedCallTx)]
425+
426+
rule [uncheckedCallTx]:
427+
<k> uncheckedCallTx(FROM, TO, FUNC, ARGS)
428+
=> allocObjects(ARGS)
429+
~> callContractFromStack(FROM, TO, FUNC)
430+
~> #resetHost
431+
...
432+
</k>
433+
// clear the host cell before contract calls
434+
(_:HostCell => <host> <hostStack> .HostStack </hostStack> ... </host>)
418435
419436
endmodule
420437
```

0 commit comments

Comments
 (0)