Skip to content

Commit

Permalink
Merge branch 'master' into _update-deps/runtimeverification/k
Browse files Browse the repository at this point in the history
  • Loading branch information
anvacaru authored Jun 4, 2024
2 parents bf2e01b + 80b6e07 commit 070c098
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/abi.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ For most types, this is a fixed 32 bytes, except for static tuples, for which th
- for `#bytes(BS)` and `#string(BS)`, the size is 32 bytes for the length prefix plus the size of the actual byte sequence, rounded up to the nearest multiple of 32.
- for `#tuple(ARGS)`, the size is 32 bytes for the length prefix plus the cumulative size of its elements.
- for `#array(T, N, _)` that has elements of a static `TypedArg` `T`, the size is `32 * (1 + N)`,which accounts for 32 bytes for the length prefix and 32 bytes for each element.
- for dynamic type arrays `#array(T, N, ELEMS)`, the size is `32 * (1 + N + #sizeOfDynamicTypeList(ELEMS))`.
- for dynamic type arrays `#array(T, N, ELEMS)`, the size is `32 * (1 + N) + #sizeOfDynamicTypeList(ELEMS)`.

```k
syntax Int ::= #sizeOfDynamicType ( TypedArg ) [klabel(#sizeOfDynamicType), function]
Expand All @@ -332,7 +332,7 @@ For most types, this is a fixed 32 bytes, except for static tuples, for which th
rule #sizeOfDynamicType(#array(T, N, _)) => 32 *Int (1 +Int N)
requires #isStaticType(T)
rule #sizeOfDynamicType(#array(T, N, ELEMS)) => 32 *Int (1 +Int N +Int #sizeOfDynamicTypeList(ELEMS))
rule #sizeOfDynamicType(#array(T, N, ELEMS)) => (32 *Int (1 +Int N)) +Int #sizeOfDynamicTypeList(ELEMS)
requires notBool #isStaticType(T)
syntax Int ::= #sizeOfDynamicTypeList ( TypedArgs ) [klabel(#sizeOfDynamicTypeList), function, total]
Expand Down
22 changes: 22 additions & 0 deletions tests/specs/functional/abi-spec.k
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,26 @@ module ABI-SPEC
...
</k>

claim [sizeOfDynamicType-2455]:
<k> runLemma(
#sizeOfDynamicType(
#array(
#bytes(b"\x00"),
3,
#bytes(b"\xaa"), #bytes(b"\xbb\xbb"), #bytes(b"\xcc\xcc\xcc")
)
)
==Int
lengthBytes(#enc(
#array(
#bytes(b"\x00"),
3,
#bytes(b"\xaa"), #bytes(b"\xbb\xbb"), #bytes(b"\xcc\xcc\xcc")
)
))
)
=> doneLemma(true)
...
</k>

endmodule

0 comments on commit 070c098

Please sign in to comment.