std:EVM/State/Layout/Description

lib/EVM/State/Layout/Description.omg

lib/EVM/State/Layout/Description.omg62 lines
1{- Unchecked, inspectable placement data of storage format version 2. These
2   values are candidates, not permissions to access storage.
3   EVM/State/Layout supplies checked selections.
4
5   Slots are relative to the owner's reservation start. The root object is
6   the relative slots from 0; every other object (list data, blob words, a
7   hashed mapping entry) starts at a hash of its preimage, placed by
8   `hashing`. Zero storage decodes to the default of every node.
9-}
10let Scalar : Type = < Unsigned : Natural | Boolean | String | NaturalNumber | IntegerNumber >
11let Member : Type = { name : Text, offset : Natural, child : Natural }
12let Alternative : Type = { name : Text, tag : Natural, child : Natural }
13-- How a mapping finds its entries. Direct carries the entry stride in bits.
14let Addressing : Type = < Hashed | Direct : Natural >
15let Form
16    : Type
17    = < Primitive : Scalar
18      | Blob : Scalar
19      | Fields : List Member
20      | Choice : { width : Natural, payload : Natural, alternatives : List Alternative }
21      | List : { element : Natural, stride : Natural }
22      | Dictionary : { key : Natural, value : Natural, addressing : Addressing }
23      | Unsupported : Text
24      >
25let Node : Type = { id : Natural, bits : Natural, form : Form }
26-- Where hashed objects live. Confined: the block [start, start + 2^bits) of
27-- relative slots, inside the reservation. Solidity: unconfined 256-bit
28-- hashes, one owner at 0. Absent: there is no hashed object.
29let Hashing : Type = < Absent | Confined : { start : Natural, bits : Natural } | Solidity >
30let Description
31    : Type
32    = { version : Natural
33      , root : Natural
34      , nodes : List Node
35      , space : std:Region.Region
36      , hashing : Hashing
37      }
38-- The format version these descriptions follow.
39let version : Natural = 2
40-- A list holds fewer than 2^lengthBits elements.
41let lengthBits : Natural = 64
42-- A blob holds fewer than 2^blobBytesBits bytes.
43let blobBytesBits : Natural = 63
44-- The least difference between a hashed block's bits and the bits of the
45-- largest hashed object. Overlapping two objects with chosen keys then takes
46-- about 2^(margin / 2) hash evaluations.
47let margin : Natural = 160
48let Of : Type -> Type = \(A : Type) -> Reflect {=} (\(_ : {}) -> A)
49in  { Scalar
50    , Member
51    , Alternative
52    , Addressing
53    , Form
54    , Node
55    , Hashing
56    , Description
57    , version
58    , lengthBits
59    , blobBytesBits
60    , margin
61    , Of
62    }
Your result
Complete file: lib/EVM/State/Layout/Description.omg · with imports