@@ -216,10 +216,10 @@ We define two productions named `#return_foundry` and `#call_foundry`, which wil
216
216
The rule ` foundry.return ` will rewrite the ` #return_foundry ` production into other productions that will place the output of the execution into the local memory, refund the gas value of the call and push the value ` 1 ` on the call stack.
217
217
218
218
``` {.k .bytes}
219
- syntax KItem ::= "#error_foundry" [klabel(foundry_error)]
220
- | "#return_foundry" Int Int [klabel(foundry_return)]
219
+ syntax KItem ::= "#return_foundry" Int Int [klabel(foundry_return)]
221
220
| "#call_foundry" Int ByteArray [klabel(foundry_call)]
222
- // ---------------------------------------------------------------------
221
+ | "#error_foundry" Int ByteArray [klabel(foundry_error)]
222
+ // -----------------------------------------------------------------------
223
223
rule [foundry.return]:
224
224
<k> #return_foundry RETSTART RETWIDTH
225
225
=> #setLocalMem RETSTART RETWIDTH OUT
@@ -230,6 +230,13 @@ The rule `foundry.return` will rewrite the `#return_foundry` production into oth
230
230
<callGas> GCALL </callGas>
231
231
```
232
232
233
+ We define a new status code named ` FOUNDRY_UNIMPLEMENTED ` , which signals that the execution ran into an unimplemented cheat code.
234
+
235
+ ``` {.k .bytes}
236
+ syntax ExceptionalStatusCode ::= "FOUNDRY_UNIMPLEMENTED"
237
+ // --------------------------------------------------------
238
+ ```
239
+
233
240
Below, we define rules for the ` #call_foundry ` production, handling the cheat codes.
234
241
235
242
#### ` assume ` - Insert a condition
@@ -541,7 +548,9 @@ Otherwise, throw an error for any other call to the Foundry contract.
541
548
542
549
``` {.k .bytes}
543
550
rule [foundry.call.owise]:
544
- <k> #call_foundry _ _ => #error_foundry ... </k> [owise]
551
+ <k> #call_foundry SELECTOR ARGS => #error_foundry SELECTOR ARGS ... </k>
552
+ <statusCode> _ => FOUNDRY_UNIMPLEMENTED </statusCode>
553
+ [owise]
545
554
```
546
555
547
556
Utils
@@ -724,6 +733,79 @@ If the production is matched when no prank is active, it will be ignored.
724
733
rule ( selector ( "startPrank(address,address)" ) => 1169514616 )
725
734
rule ( selector ( "stopPrank()" ) => 2428830011 )
726
735
```
736
+
737
+ - selectors for unimplemented cheat code functions.
738
+
739
+ ``` k
740
+ rule selector ( "sign(uint256,bytes32)" ) => 3812747940
741
+ rule selector ( "ffi(string[])" ) => 2299921511
742
+ rule selector ( "setEnv(string,string)" ) => 1029252078
743
+ rule selector ( "envBool(string)" ) => 2127686781
744
+ rule selector ( "envUint(string)" ) => 3247934751
745
+ rule selector ( "envInt(string)" ) => 2301234273
746
+ rule selector ( "envAddress(string)" ) => 890066623
747
+ rule selector ( "envBytes32(string)" ) => 2543095874
748
+ rule selector ( "envString(string)" ) => 4168600345
749
+ rule selector ( "envBytes(string)" ) => 1299951366
750
+ rule selector ( "envBool(string,string)" ) => 2863521455
751
+ rule selector ( "envUint(string,string)" ) => 4091461785
752
+ rule selector ( "envInt(string,string)" ) => 1108873552
753
+ rule selector ( "envAddress(string,string)" ) => 2905717242
754
+ rule selector ( "envBytes32(string,string)" ) => 1525821889
755
+ rule selector ( "envString(string,string)" ) => 347089865
756
+ rule selector ( "envBytes(string,string)" ) => 3720504603
757
+ rule selector ( "prank(address)" ) => 3395723175
758
+ rule selector ( "startPrank(address)" ) => 105151830
759
+ rule selector ( "prank(address,address)" ) => 1206193358
760
+ rule selector ( "startPrank(address,address)" ) => 1169514616
761
+ rule selector ( "stopPrank()" ) => 2428830011
762
+ rule selector ( "expectRevert(bytes)" ) => 4069379763
763
+ rule selector ( "expectRevert(bytes4)" ) => 3273568480
764
+ rule selector ( "expectRevert()" ) => 4102309908
765
+ rule selector ( "record()" ) => 644673801
766
+ rule selector ( "accesses(address)" ) => 1706857601
767
+ rule selector ( "expectEmit(bool,bool,bool,bool)" ) => 1226622914
768
+ rule selector ( "expectEmit(bool,bool,bool,bool,address)" ) => 2176505587
769
+ rule selector ( "mockCall(address,bytes calldata,bytes)" ) => 378193464
770
+ rule selector ( "mockCall(address,uint256,bytes,bytes)" ) => 2168494993
771
+ rule selector ( "clearMockedCalls()" ) => 1071599125
772
+ rule selector ( "expectCall(address,bytes)" ) => 3177903156
773
+ rule selector ( "expectCall(address,uint256,bytes)" ) => 4077681571
774
+ rule selector ( "getCode(string)" ) => 2367473957
775
+ rule selector ( "broadcast()" ) => 2949218368
776
+ rule selector ( "broadcast(address)" ) => 3868601563
777
+ rule selector ( "startBroadcast()" ) => 2142579071
778
+ rule selector ( "startBroadcast(address)" ) => 2146183821
779
+ rule selector ( "stopBroadcast()" ) => 1995103542
780
+ rule selector ( "readFile(string)" ) => 1626979089
781
+ rule selector ( "readLine(string)" ) => 1895126824
782
+ rule selector ( "writeFile(string,string)" ) => 2306738839
783
+ rule selector ( "writeLine(string,string)" ) => 1637714303
784
+ rule selector ( "closeFile(string)" ) => 1220748319
785
+ rule selector ( "removeFile(string)" ) => 4054835277
786
+ rule selector ( "toString(address)" ) => 1456103998
787
+ rule selector ( "toString(bytes)" ) => 1907020045
788
+ rule selector ( "toString(bytes32)" ) => 2971277800
789
+ rule selector ( "toString(bool)" ) => 1910302682
790
+ rule selector ( "toString(uint256)" ) => 1761649582
791
+ rule selector ( "toString(int256)" ) => 2736964622
792
+ rule selector ( "recordLogs()" ) => 1101999954
793
+ rule selector ( "getRecordedLogs()" ) => 420828068
794
+ rule selector ( "snapshot()" ) => 2534502746
795
+ rule selector ( "revertTo(uint256)" ) => 1155002532
796
+ rule selector ( "createFork(string,uint256)" ) => 1805892139
797
+ rule selector ( "createFork(string)" ) => 834286744
798
+ rule selector ( "createSelectFork(string,uint256)" ) => 1911440973
799
+ rule selector ( "createSelectFork(string)" ) => 2556952628
800
+ rule selector ( "selectFork(uint256)" ) => 2663344167
801
+ rule selector ( "activeFork()" ) => 789593890
802
+ rule selector ( "rollFork(uint256)" ) => 3652973473
803
+ rule selector ( "rollFork(uint256,uint256)" ) => 3612115876
804
+ rule selector ( "rpcUrl(string)" ) => 2539285737
805
+ rule selector ( "rpcUrls()" ) => 2824504344
806
+ rule selector ( "deriveKey(string,uint32)" ) => 1646872971
807
+ ```
808
+
727
809
``` k
728
810
endmodule
729
811
```
0 commit comments