Migration notes
Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them.
TBD
[Aztec Tools]
Contract compilation now requires two steps
The aztec-nargo
command is now a direct pass-through to vanilla nargo, without any special compilation flags or postprocessing. Contract compilation for Aztec now requires two explicit steps:
- Compile your contracts with
aztec-nargo compile
- Run postprocessing with the new
aztec-postprocess-contract
command
The postprocessing step includes:
- Transpiling functions for the Aztec VM
- Generating verification keys for private functions
- Caching verification keys for faster subsequent compilations
Update your build scripts accordingly:
- aztec-nargo compile
+ aztec-nargo compile
+ aztec-postprocess-contract
If you're using the aztec-up
installer, the aztec-postprocess-contract
command will be automatically installed alongside aztec-nargo
.
[Aztec.js] Mandatory from
As we prepare for a bigger Wallet
interface refactor and the upcoming WalletSDK
, a new parameter has been added to contract interactions, which now should indicate explicitly the address of the entrypoint (usually the account contract) that will be used to authenticate the request. This will be checked in runtime against the current this.wallet.getAddress()
value, to ensure consistent behavior while the rest of the API is reworked.
- await contract.methods.my_func(arg).send().wait();
+ await contract.methods.my_func(arg).send({ from: account1Address }).wait();
[Aztec.nr]
Private event emission API changes
The private event emission API has been significantly reworked to provide clearer semantics around message delivery guarantees. The key changes are:
emit_event_in_private_log
has been renamed toemit_event_in_private
and now takes adelivery_mode
parameter instead ofconstraints
emit_event_as_offchain_message
has been removed in favor of usingemit_event_in_private
withMessageDelivery.UNCONSTRAINED_OFFCHAIN
PrivateLogContent
enum has been replaced withMessageDelivery
enum with the following values:CONSTRAINED_ONCHAIN
: For on-chain delivery with cryptographic guarantees (replacesCONSTRAINED_ENCRYPTION
)UNCONSTRAINED_OFFCHAIN
: For off-chain delivery without constraintsUNCONSTRAINED_ONCHAIN
: For on-chain delivery without constraints (replacesNO_CONSTRAINTS
)
Contract functions can no longer be pub
or pub(crate)
With the latest changes to TestEnvironment
, making contract functions have public visibility is no longer required given the new call_public
and simulate_utility
functions. To avoid accidental direct invocation, and to reduce confusion with the autogenerated interfaces, we're forbidding them being public.
- pub(crate) fn balance_of_private(account: AztecAddress) -> 128 {
+ fn balance_of_private(account: AztecAddress) -> 128 {
Notes require you to manually implement or derive Packable
We have decided to drop auto-derivation of Packable
from the #[note]
macro because we want to make the macros less magical.
With this change you will be forced to either apply #[derive(Packable)
on your notes:
+use aztec::protocol_types::traits::Packable;
+#[derive(Packable)]
#[note]
pub struct UintNote {
owner: AztecAddress,
randomness: Field,
value: u128,
}
or to implement it manually yourself:
impl Packable for UintNote {
let N: u32 = 3;
fn pack(self) -> [Field; Self::N] {
[self.owner.to_field(), randomness, value as Field]
}
fn unpack(fields: [Field; Self::N]) -> Self {
let owner = AztecAddress::from_field(fields[0]);
let randomness = fields[1];
let value = fields[2] as u128;
UintNote { owner, randomness, value }
}
}
Tagging sender now managed via oracle functions
Now, instead of manually needing to pass a tagging sender as an argument to log emission functions (e.g. encode_and_encrypt_note
, encode_and_encrypt_note_unconstrained
, emit_event_in_private_log
, ...) we automatically load the sender via the get_sender_for_tags()
oracle.
This value is expected to be populated by account contracts that should call set_sender_for_tags()
in their entry point functions.
The changes you need to do in your contracts are quite straightforward.
You simply need to drop the sender
arg from the callsites of the log emission functions.
E.g. note emission:
storage.balances.at(from).sub(from, amount).emit(encode_and_encrypt_note(
&mut context,
from,
- tagging_sender,
));
E.g. private event emission:
emit_event_in_private_log(
Transfer { from, to, amount },
&mut context,
- tagging_sender,
to,
PrivateLogContent.NO_CONSTRAINTS,
);
This change affected arguments prepare_private_balance_increase
and mint_to_private
functions on the Token
contract.
Drop the from
argument when calling these.
Example n TypeScript test:
- await token.methods.mint_to_private(fundedWallet.getAddress(), alice, mintAmount).send().wait();
+ await token.methods.mint_to_private(alice, mintAmount).send().wait();
Example when
let token_out_partial_note = Token::at(token_out).prepare_private_balance_increase(
sender,
- tagging_sender
).call(&mut context);