|
| 1 | +requires "evm.k" |
| 2 | +requires "edsl.k" |
| 3 | + |
| 4 | +module VERIFICATION |
| 5 | + imports EVM |
| 6 | + imports EDSL |
| 7 | + |
| 8 | + syntax StepSort ::= MerkleTree | String |
| 9 | + syntax KItem ::= runMerkle ( StepSort ) |
| 10 | + | doneMerkle( StepSort ) |
| 11 | + // ------------------------------------------ |
| 12 | + rule runMerkle( T ) => doneMerkle( T ) |
| 13 | + |
| 14 | +endmodule |
| 15 | + |
| 16 | +module STORAGEROOT-SPEC |
| 17 | + imports VERIFICATION |
| 18 | + |
| 19 | + rule <k> runMerkle( #storageRoot( .Map ) ) |
| 20 | + => doneMerkle( .MerkleTree ) |
| 21 | + </k> |
| 22 | + |
| 23 | + // uint pos0; |
| 24 | + // |
| 25 | + // pos0 = 1234; |
| 26 | + rule <k> runMerkle( Keccak256( #rlpEncodeMerkleTree( #storageRoot( |
| 27 | + #hashedLocation( "Solidity", 0, .IntList ) |-> 1234 |
| 28 | + ) |
| 29 | + ) |
| 30 | + ) |
| 31 | + ) |
| 32 | + => doneMerkle( "6ff6cfba457bc662332201b53a8bda503e307197962f2c51e5e2dcc3809e19be" ) |
| 33 | + </k> |
| 34 | + |
| 35 | + // mapping (uint => uint) pos0; |
| 36 | + // |
| 37 | + // pos0[0] = 100; |
| 38 | + // pos0[1] = 200; |
| 39 | + rule <k> runMerkle( Keccak256( #rlpEncodeMerkleTree( #storageRoot( |
| 40 | + #hashedLocation( "Solidity", 0, 0 ) |-> 100 |
| 41 | + #hashedLocation( "Solidity", 0, 1 ) |-> 200 |
| 42 | + ) |
| 43 | + ) |
| 44 | + ) |
| 45 | + ) |
| 46 | + => doneMerkle( "27093708a19995cf73ddd4b27049a7e33fb49e242bde6c1bffbb6596b67b8b3e" ) |
| 47 | + </k> |
| 48 | + |
| 49 | + // uint pos0; |
| 50 | + // mapping (uint => uint) pos1; |
| 51 | + // |
| 52 | + // pos0 = 600; |
| 53 | + // pos1[0] = 200; |
| 54 | + // pos1[5] = 24; |
| 55 | + rule <k> runMerkle( Keccak256( #rlpEncodeMerkleTree( #storageRoot( |
| 56 | + #hashedLocation( "Solidity", 0, .IntList ) |-> 600 |
| 57 | + #hashedLocation( "Solidity", 1, 0 ) |-> 200 |
| 58 | + #hashedLocation( "Solidity", 1, 5 ) |-> 24 |
| 59 | + ) |
| 60 | + ) |
| 61 | + ) |
| 62 | + ) |
| 63 | + => doneMerkle( "7df5d7b198240b49434b4e1dbff02fcb0649dd91650ae0fae191b2881cbb009e" ) |
| 64 | + </k> |
| 65 | + |
| 66 | + // mapping (uint => uint) pos0; |
| 67 | + // mapping (uint => uint) pos1; |
| 68 | + // |
| 69 | + // pos0[0] = 123; |
| 70 | + // pos0[1] = 456; |
| 71 | + // pos1[6] = 56; |
| 72 | + // pos1[9] = 333; |
| 73 | + rule <k> runMerkle( Keccak256( #rlpEncodeMerkleTree( #storageRoot( |
| 74 | + #hashedLocation( "Solidity", 0, 0 ) |-> 123 |
| 75 | + #hashedLocation( "Solidity", 0, 1 ) |-> 456 |
| 76 | + #hashedLocation( "Solidity", 1, 6 ) |-> 56 |
| 77 | + #hashedLocation( "Solidity", 1, 9 ) |-> 333 |
| 78 | + ) |
| 79 | + ) |
| 80 | + ) |
| 81 | + ) |
| 82 | + => doneMerkle( "e3d130ca69a8d33ad2058d86ba26ec414f6e5639930041d6a266ee88b25ea835" ) |
| 83 | + </k> |
| 84 | + |
| 85 | + // uint pos0; |
| 86 | + // mapping (uint => uint) pos1; |
| 87 | + // uint pos2; |
| 88 | + // mapping (uint => mapping (uint => uint)) pos3; |
| 89 | + // |
| 90 | + // pos0 = 1234; |
| 91 | + // pos1[0] = 0; |
| 92 | + // pos1[1] = 1; |
| 93 | + // pos2 = 100; |
| 94 | + // pos3[0][0] = 42; |
| 95 | + // pos3[2][1] = 2019; |
| 96 | + rule <k> runMerkle( Keccak256( #rlpEncodeMerkleTree( #storageRoot( |
| 97 | + #hashedLocation( "Solidity", 0, .IntList ) |-> 1234 |
| 98 | + #hashedLocation( "Solidity", 1, 0 ) |-> 0 |
| 99 | + #hashedLocation( "Solidity", 1, 1 ) |-> 1 |
| 100 | + #hashedLocation( "Solidity", 2, .IntList ) |-> 100 |
| 101 | + #hashedLocation( "Solidity", 3, 0 0 ) |-> 42 |
| 102 | + #hashedLocation( "Solidity", 3, 2 1 ) |-> 2019 |
| 103 | + ) |
| 104 | + ) |
| 105 | + ) |
| 106 | + ) |
| 107 | + => doneMerkle( "6786e17b1f185ba3b51ec15f28526a1d47d74052ca98c1b8edf7cdc6243eebba" ) |
| 108 | + </k> |
| 109 | +endmodule |
0 commit comments