Skip to content

Commit 69a6352

Browse files
committed
draft section2.1
1 parent c008918 commit 69a6352

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

doc/src/installation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Installation

doc/src/store_type.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,25 @@ creates
2929
The Act storage corresponds directly to the EVM state variables, but with two important differences:
3030
1. All storage is immutable by default.
3131
Storage can only change through explicit updates inside transitions.
32-
2. Types are explicit and checked. Storage in Act can have the following types:
33-
- **base types** e.g. line 2 in the snippet above: `uint256 totalSupply`
34-
- unsigned integers of various sizes: `uint8`, `uint16`, `uint32`, `uint64`, `uint128`, `uint256`,
35-
- signed integers of various sizes: `int8`, `int16`, `int32`, `int64`, `int128`, `int256`,
36-
- booleans: `bool`
37-
- addresses:`address`
38-
- **mapping types**
39-
- mappings from one base type to another, e.g. from `address` to `uint256` in line 3 `mapping(address => uint256) balanceOf`
40-
- nested mappings: from a base type to another mapping, e.g. from `address` to `mapping(address => uint256)` in line 4 `mapping(address => mapping(address => uint256)) allowance`
41-
- **contract types** referencing the storage of other contracts (details later in <span style="color:red">
42-
"Advanced Topics: Aliasing and Unique Ownership" (?)
43-
</span>).
44-
- Artificial example: Another contract `OtherContract` uses in its storage a reference to an ERC20 `Token` contract: In `OtherContract`'s storage we would have a field of type `Token`, which can be initialized with an address of a specific deployed ERC20 contract.
32+
2. Types are explicit and checked. Which types storage can have is detailed next.
33+
34+
### Storage Types
35+
Storage in Act can have the following types:
36+
37+
- **base types** e.g. line 2 in the snippet above: `uint256 totalSupply`
38+
- unsigned integers of various sizes: `uint8`, `uint16`, `uint32`, `uint64`, `uint128`, `uint256`,
39+
- signed integers of various sizes: `int8`, `int16`, `int32`, `int64`, `int128`, `int256`,
40+
- booleans: `bool`
41+
- addresses:`address`
42+
- **mapping types**
43+
- mappings from one base type to another, e.g. from `address` to `uint256` in line 3 `mapping(address => uint256) balanceOf`
44+
- nested mappings: from a base type to another mapping, e.g. from `address` to `mapping(address => uint256)` in line 4 `mapping(address => mapping(address => uint256)) allowance`
45+
- **contract types** referencing the storage of other contracts (details later in
46+
<span style="color:red">
47+
"Advanced Topics: Aliasing and Unique Ownership" (?)
48+
</span>).
49+
50+
- Artificial example: Another contract `OtherContract` uses in its storage a reference to an ERC20 `Token` contract: In `OtherContract`'s storage we would have a field of type `Token`, which can be initialized with an address of a specific deployed ERC20 contract.~
4551

4652

4753
## Mapping Types and Defaults
@@ -70,17 +76,12 @@ The **defaults** for the different mapping types are:
7076

7177
This matches Solidity’s behavior but is **made explicit** in Act, which is essential for reasoning about invariants.
7278

73-
## ABI Types vs Storage Types
74-
Not all types in Act are allowed everywhere. There is a distinction between:
75-
1. **ABI types**: used for function parameters and return values.
76-
2. **Storage types**: used for persistent state (e.g. mappings, contract references
77-
78-
### ABI types
79+
## ABI Types
7980

80-
The following types are used for function parameters and return values.
81+
The following types are used for function parameters and return values, mirroring the Ethereum ABI specification:
8182

8283
- All **base types** (`uint*`, `int*`, `bool`, `address`) are allowed here.
83-
- Additionally, there is another ABI type: specially **annotated address types**. These are addresses which point to contracts.
84+
- Additionally, there is another ABI type: specially **annotated address types**. These are addresses which point to contracts. Intuitively, an annotated address type `address<ContractType>` can be thought of as a regular address, for which we know that it points to the storage of a contract of type `ContractType`.
8485

8586
Consider the following act snippet that declares a transition `foo` which takes an address of an ERC20 contract as parameter:
8687

@@ -90,14 +91,15 @@ The following types are used for function parameters and return values.
9091
storage
9192
erc_token := token_addr as Token
9293
```
93-
The parameter `token_addr` has type `address<Token>`, which indicates that the address points to a deployed contract of type `Token` (e.g. in our example an ERC20). This allows Act to reason about calls to this contract now called `erc_token`, which *lives* at address `token_addr` inside the transition body.
94-
95-
Intuitively, an annotated address type `address<ContractType>` can be thought of as a regular address, for which we know that it points to the storage of a contract of type `ContractType`.
96-
97-
CONTINUE HERE: talk about how this allows reasoning about calls to other contracts, and how act can verify that the called contract conforms to its spec (if provided). Refer to the correctness section (paragraph on Input space equivalence)
94+
The parameter `token_addr` has type `address<Token>`, which indicates that the address points to a deployed contract of type `Token` (e.g. in our example an ERC20 token).
95+
96+
This special type exists to allow Act to reason about calls to this contract now called `erc_token`, which *lives* at address `token_addr` inside the transition body. Ensuring that the spec which includes this annotated address types is equivalent to the implementation which only uses regular addresses is still possible and discussed in the <span style="color:red">
97+
correctness section (paragraph on Input space equivalence).</span>)
9898
99-
### Storage types
100-
Used for persistent state
101-
(e.g. mappings, contract references)
10299
103-
For ERC20, all parameters and storage fields are ABI-compatible, which simplifies the specification. More complex contracts may involve non-ABI storage types.
100+
*Note:* Not all types in Act are allowed everywhere. There is a distinction between **ABI types** and **Storage types**:
101+
1. **ABI types** include **base types** and **annotated address types**. They are used for function parameters and return values.
102+
2. **Storage types** include **base types**, **mapping types**, and **contract types**. They are
103+
used for storage.
104+
105+
That means in function parameters and return values, mapping types and contract types are not allowed. Whereas in storage, annotated address types are not allowed.

0 commit comments

Comments
 (0)