You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/developers/migration_notes.md
+95Lines changed: 95 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,101 @@ Aztec is in full-speed development. Literally every version breaks compatibility
9
9
10
10
## TBD
11
11
12
+
### `msg_sender` is now an `Option<AztecAddress>` type.
13
+
14
+
Because Aztec has native account abstraction, the very first function call of a tx has no `msg_sender`. (Recall, the first function call of an Aztec transaction is always a _private_ function call).
15
+
16
+
Previously (before this change) we'd been silently setting this first `msg_sender` to be `AztecAddress::from_field(-1);`, and enforcing this value in the protocol's kernel circuits. Now we're passing explicitness to smart contract developers by wrapping `msg_sender` in an `Option` type. We'll explain the syntax shortly.
17
+
18
+
We've also added a new protocol feature. Previously (before this change) whenever a public function call was enqueued by a private function (a so-called private->public call), the called public function (and hence the whole world) would be able to see `msg_sender`. For some use cases, visibility of `msg_sender` is important, to ensure the caller executed certain checks in private-land. For `#[internal]` public functions, visibility of `msg_sender` is unavoidable (the caller of an internal function must be the same contract address by definition). But for _some_ use cases, a visible `msg_sender` is an unnecessary privacy leakage.
19
+
We therefore have added a feature where `msg_sender` can be optionally set to `Option<AztecAddress>::none()` for enqueued public function calls (aka private->public calls). We've been colloquially referring to this as "setting msg_sender to null".
20
+
21
+
#### Aztec.nr diffs
22
+
23
+
> Note: we'll be doing another pass at this aztec.nr syntax in the near future.
24
+
25
+
Given the above, the syntax for accessing `msg_sender` in Aztec.nr is slightly different:
26
+
27
+
For most public and private functions, to adjust to this change, you can make this change to your code:
28
+
29
+
```diff
30
+
- let sender: AztecAddress = context.msg_sender();
31
+
+ let sender: AztecAddress = context.msg_sender().unwrap();
32
+
```
33
+
34
+
Recall that `Option::unwrap()` will throw if the Option is "none".
35
+
36
+
Indeed, most smart contract functions will require access to a proper contract address (instead of a "null" value), in order to do bookkeeping (allocation of state variables against user addresses), and so in such cases throwing is sensible behaviour.
37
+
38
+
If you want to output a useful error message when unwrapping fails, you can use `Option::expect`:
39
+
40
+
```diff
41
+
- let sender: AztecAddress = context.msg_sender();
42
+
+ let sender: AztecAddress = context.msg_sender().expect(f"Sender must not be none!");
43
+
```
44
+
45
+
For a minority of functions, a "null" msg_sender will be acceptable:
46
+
47
+
- A private entrypoint function.
48
+
- A public function which doesn't seek to do bookkeeping against `msg_sender`.
49
+
50
+
Some apps might even want to _assert_ that the `msg_sender` is "null" to force their users into strong privacy practices:
In keeping with this new feature of being able to enqueue public function calls with a hidden `msg_sender`, there are some new methods that can be chained instead of `.enqueue(...)`:
70
+
71
+
-`enqueue_incognito` -- akin to `enqueue`, but `msg_sender` is set "null".
72
+
-`enqueue_view_incognito` -- akin to `enqueue_view`, but `msg_sender` is "null".
73
+
-`set_as_teardown_incognito` -- akin to `set_as_teardown`, but `msg_sender` is "null".
74
+
75
+
> The name "incognito" has been chosen to imply "msg_sender will not be visible to observers".
76
+
77
+
These new functions enable the _calling_ contract to specify that it wants its address to not be visible to the called public function. This is worth re-iterating: it is the _caller's_ choice. A smart contract developer who uses these functions must be sure that the target public function will accept a "null" `msg_sender`. It would not be good (for example) if the called public function did `context.msg_sender().unwrap()`, because then a public function that is called via `enqueue_incognito` would _always fail_! Hopefully smart contract developers will write sufficient tests to catch such problems during development!
78
+
79
+
###### Making lower-level public function calls from the private context
80
+
81
+
This is discouraged vs using the auto-generated contract interfaces described directly above.
82
+
83
+
If you do use any of these low-level methods of the `PrivateContext` in your contract:
-`!is_public & !hide_msg_sender` -- will make a private call with a visible `msg_sender` (noting that since it's a private function call, the `msg_sender` will only be visible to the called private function, but not to the rest of the world).
105
+
106
+
12
107
## [cli-wallet]
13
108
14
109
The `deploy-account` command now requires the address (or alias) of the account to deploy as an argument, not a parameter
Copy file name to clipboardExpand all lines: docs/versioned_docs/version-v2.0.2/developers/migration_notes.md
-90Lines changed: 0 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,96 +9,6 @@ Aztec is in full-speed development. Literally every version breaks compatibility
9
9
10
10
## 2.0.2
11
11
12
-
### `msg_sender` is now an `Option<AztecAddress>` type.
13
-
14
-
Because Aztec has native account abstraction, the very first function call of a tx has no `msg_sender`. (Recall, the first function call of an Aztec transaction is always a _private_ function call).
15
-
16
-
Previously (before this change) we'd been silently setting this first `msg_sender` to be `AztecAddress::from_field(-1);`, and enforcing this value in the protocol's kernel circuits. Now we're passing explicitness to smart contract developers by wrapping `msg_sender` in an `Option` type. We'll explain the syntax shortly.
17
-
18
-
We've also added a new protocol feature. Previously (before this change) whenever a public function call was enqueued by a private function (a so-called private->public call), the called public function (and hence the whole world) would be able to see `msg_sender`. For some use cases, visibility of `msg_sender` is important, to ensure the caller executed certain checks in private-land. For `#[internal]` public functions, visibility of `msg_sender` is unavoidable (the caller of an internal function must be the same contract address by definition). But for _some_ use cases, a visible `msg_sender` is an unnecessary privacy leakage.
19
-
We therefore have added a feature where `msg_sender` can be optionally set to `Option<AztecAddress>::none()` for enqueued public function calls (aka private->public calls). We've been colloquially referring to this as "setting msg_sender to null".
20
-
21
-
#### Aztec.nr diffs
22
-
23
-
Given the above, the syntax for accessing `msg_sender` in Aztec.nr is slightly different:
24
-
25
-
For most public and private functions, to adjust to this change, you can make this change to your code:
26
-
27
-
```diff
28
-
- let sender: AztecAddress = context.msg_sender();
29
-
+ let sender: AztecAddress = context.msg_sender().unwrap();
30
-
```
31
-
32
-
Recall that `Option::unwrap()` will throw if the Option is "none".
33
-
34
-
Indeed, most smart contract functions will require access to a proper contract address (instead of a "null" value), in order to do bookkeeping (allocation of state variables against user addresses), and so in such cases throwing is sensible behaviour.
35
-
36
-
If you want to output a useful error message when unwrapping fails, you can use `Option::expect`:
37
-
38
-
```diff
39
-
- let sender: AztecAddress = context.msg_sender();
40
-
+ let sender: AztecAddress = context.msg_sender().expect(f"Sender must not be none!");
41
-
```
42
-
43
-
For a minority of functions, a "null" msg_sender will be acceptable:
44
-
45
-
- A private entrypoint function.
46
-
- A public function which doesn't seek to do bookkeeping against `msg_sender`.
47
-
48
-
Some apps might even want to _assert_ that the `msg_sender` is "null" to force their users into strong privacy practices:
In keeping with this new feature of being able to enqueue public function calls with a hidden `msg_sender`, there are some new methods that can be chained instead of `.enqueue(...)`:
68
-
69
-
-`enqueue_incognito` -- akin to `enqueue`, but `msg_sender` is set "null".
70
-
-`enqueue_view_incognito` -- akin to `enqueue_view`, but `msg_sender` is "null".
71
-
-`set_as_teardown_incognito` -- akin to `set_as_teardown`, but `msg_sender` is "null".
72
-
73
-
> The name "incognito" has been chosen to imply "msg_sender will not be visible to observers".
74
-
75
-
These new functions enable the _calling_ contract to specify that it wants its address to not be visible to the called public function. This is worth re-iterating: it is the _caller's_ choice. A smart contract developer who uses these functions must be sure that the target public function will accept a "null" `msg_sender`. It would not be good (for example) if the called public function did `context.msg_sender().unwrap()`, because then a public function that is called via `enqueue_incognito` would _always fail_! Hopefully smart contract developers will write sufficient tests to catch such problems during development!
76
-
77
-
###### Making lower-level public function calls from the private context
78
-
79
-
This is discouraged vs using the auto-generated contract interfaces described directly above.
80
-
81
-
If you do use any of these low-level methods of the `PrivateContext` in your contract:
-`!is_public & !hide_msg_sender` -- will make a private call with a visible `msg_sender` (noting that since it's a private function call, the `msg_sender` will only be visible to the called private function, but not to the rest of the world).
0 commit comments