-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: TXE 2: Electric boogaloo (#7154)
Adds new capabilities to TXE, and a proper `TokenContract` suite to showcase them: - Private -> Public calls - Public -> Public calls - Actual account contract deployment for complex interactions - Auhtwits, both public and private - Note cache storage - Speed improvements ![Screenshot 2024-06-21 at 18 16 23](https://github.com/AztecProtocol/aztec-packages/assets/5404052/16e583bb-e05e-497a-b278-1a39ee177b23) The full test suite is comparable to the e2e one (with some caveats, some things just cannot be tested yet using TXE), but runs significantly faster. Interestingly, runs faster on an M3 macbook than on mainframe (120s vs. 240s). e2e tests take more than 600s (without stored snapshots), but the gap increases as we reduce the amount of tests launched simultaneously. An unconstrained private transfer runs in less than 10s using TXE! If launching many tests in parallel, it is recommended to increase the nargo timeout for foreign calls to avoid timeout errors: `NARGO_FOREIGN_CALL_TIMEOUT=300000` Closes #7086 --------- Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
- Loading branch information
Showing
35 changed files
with
2,047 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use dep::aztec::{ | ||
protocol_types::address::AztecAddress, | ||
context::{public_context::PublicContext, call_interfaces::CallInterface}, test::helpers::cheatcodes, | ||
hash::hash_args | ||
}; | ||
|
||
use crate::auth::{compute_inner_authwit_hash, compute_outer_authwit_hash, set_authorized}; | ||
|
||
pub fn add_private_authwit_from_call_interface<C, M, T, P, Env>( | ||
on_behalf_of: AztecAddress, | ||
caller: AztecAddress, | ||
call_interface: C | ||
) where C: CallInterface<M, T, P, Env> { | ||
let target = call_interface.get_contract_address(); | ||
let inputs = cheatcodes::get_private_context_inputs(cheatcodes::get_block_number()); | ||
let chain_id = inputs.tx_context.chain_id; | ||
let version = inputs.tx_context.version; | ||
let args_hash = hash_args(call_interface.get_args()); | ||
let selector = call_interface.get_selector(); | ||
let inner_hash = compute_inner_authwit_hash([caller.to_field(), selector.to_field(), args_hash]); | ||
let message_hash = compute_outer_authwit_hash(target, chain_id, version, inner_hash); | ||
cheatcodes::add_authwit(on_behalf_of, message_hash); | ||
} | ||
|
||
pub fn add_public_authwit_from_call_interface<C, M, T, P, Env>( | ||
on_behalf_of: AztecAddress, | ||
caller: AztecAddress, | ||
call_interface: C | ||
) where C: CallInterface<M, T, P, Env> { | ||
let current_contract = cheatcodes::get_contract_address(); | ||
cheatcodes::set_contract_address(on_behalf_of); | ||
let target = call_interface.get_contract_address(); | ||
let inputs = cheatcodes::get_private_context_inputs(cheatcodes::get_block_number()); | ||
let chain_id = inputs.tx_context.chain_id; | ||
let version = inputs.tx_context.version; | ||
let args_hash = hash_args(call_interface.get_args()); | ||
let selector = call_interface.get_selector(); | ||
let inner_hash = compute_inner_authwit_hash([caller.to_field(), selector.to_field(), args_hash]); | ||
let message_hash = compute_outer_authwit_hash(target, chain_id, version, inner_hash); | ||
let mut inputs = cheatcodes::get_public_context_inputs(); | ||
let mut context = PublicContext::new(inputs); | ||
set_authorized(&mut context, message_hash, true); | ||
cheatcodes::set_contract_address(current_contract); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ mod account; | |
mod auth_witness; | ||
mod auth; | ||
mod entrypoint; | ||
mod cheatcodes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mod test_environment; | ||
mod cheatcodes; | ||
mod types; | ||
mod utils; | ||
mod keys; |
Oops, something went wrong.