Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vm2 account validation #2863

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
30a12bc
integrate stage1 (tracers don't handle hooks yet)
joonazan Oct 28, 2024
1983bd1
version of vm2 that inlines ExecutionStatus::merge
joonazan Oct 29, 2024
488c93a
improve naming: paymaster/account validation use the same end hook!
joonazan Sep 12, 2024
3837492
implement account validation gas limit
joonazan Sep 12, 2024
fcb559d
pass the validation gas limit test
joonazan Oct 8, 2024
603937b
clean up validation gas limit
joonazan Oct 10, 2024
1689cf2
add comment explaining why revert is ok
joonazan Oct 10, 2024
b4608ff
more general passing of hooks to tracers
joonazan Oct 10, 2024
dbc1742
stop validation run after validation
joonazan Oct 11, 2024
07a202e
make it clear that revert is not supposed to happen
joonazan Oct 11, 2024
31e05ae
improve error message
joonazan Oct 22, 2024
3c96ad3
first working test for account validation
joonazan Oct 22, 2024
79b3302
framework for testing every validation rule violation is done
joonazan Oct 23, 2024
0878b3b
long comment explaining validation rules' purpose
joonazan Oct 23, 2024
25a3757
prohibit gasleft
joonazan Oct 23, 2024
7b837aa
pass tests
joonazan Oct 25, 2024
fcd9185
properly use all ValidationParams
joonazan Oct 25, 2024
97911d5
pass validation params to tracer in oneshot executor
joonazan Oct 25, 2024
84f85ac
reminder
joonazan Oct 25, 2024
920b928
unused import
joonazan Oct 25, 2024
4430472
correctly set fast vm mode
joonazan Oct 28, 2024
2644a7f
special case the builtin tracers to eliminate TracerExt
joonazan Oct 29, 2024
85196b4
stop validation on error
joonazan Oct 29, 2024
50e2fad
hide some of the type complexity
joonazan Oct 30, 2024
96f1886
VmFactory no longer requires VmInterface
joonazan Oct 30, 2024
bf1f2e6
use DefaultTracers type alias
joonazan Oct 30, 2024
95f1bbf
do not expose ValidationTracer, CircuitsTracer
joonazan Oct 30, 2024
9ec83f2
try to make CI green
joonazan Oct 30, 2024
7525074
fix validation test
joonazan Oct 30, 2024
660cd9f
get up to date with latest main
joonazan Nov 1, 2024
eef1347
grant access to timestamp to timestampasserter
joonazan Nov 1, 2024
0f47e5d
properly compare shadow validation results
joonazan Nov 1, 2024
b9fcc3e
fix bug where proxies were not allowed
joonazan Nov 13, 2024
938f37a
remove gasleft test
joonazan Nov 13, 2024
2582006
Merge branch 'main' into jms-pla-908-account-validation-properly-hand…
joonazan Nov 13, 2024
f973d1c
Merge branch 'main' into jms-pla-908-account-validation-properly-hand…
joonazan Nov 13, 2024
f9c9f77
fix compilation
joonazan Nov 13, 2024
3136879
test upgradeable proxy
joonazan Nov 13, 2024
408d9b0
test catching out of gas
joonazan Nov 13, 2024
29cfabe
fix test solidity
joonazan Nov 13, 2024
85f33c3
make vm_latest validation fail on out of gas, even if caught
joonazan Nov 13, 2024
40484a7
Merge branch 'main' into jms-pla-908-account-validation-properly-hand…
joonazan Nov 14, 2024
9df63c2
reduce repetition
joonazan Nov 14, 2024
a33ec8e
implement bikeshedding-type review comments
joonazan Nov 14, 2024
4798cb5
crazy solution to .0.1.1 chains
joonazan Nov 14, 2024
0345875
proper hlist library to shut up clippy
joonazan Nov 15, 2024
727e2fe
Update from upstream
slowli Dec 3, 2024
1343f90
Simplify tracers in fast VM
slowli Dec 3, 2024
d293f8c
Structure fast VM tracers
slowli Dec 3, 2024
9f18a9c
Revert `VmInterface` as supertrait for `VmFactory`
slowli Dec 4, 2024
64c4b2b
Refactor validation in oneshot executor
slowli Dec 4, 2024
04a7a7f
Merge branch 'main' into jms-pla-908-account-validation-properly-hand…
slowli Dec 10, 2024
f9d334f
Merge branch 'main' into jms-pla-908-account-validation-properly-hand…
slowli Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reduce repetition
  • Loading branch information
joonazan committed Nov 14, 2024
commit 9df63c22d598f9103720ee105100b506cf990590
49 changes: 7 additions & 42 deletions core/lib/multivm/src/versions/testonly/account_validation_rules.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use assert_matches::assert_matches;
use zksync_types::{
fee::Fee, l2::L2Tx, transaction_request::TransactionRequest, u256_to_h256, AccountTreeId,
Address, Eip712Domain, L2ChainId, StorageKey, U256,
};
use zksync_types::{u256_to_h256, AccountTreeId, Address, StorageKey};
use zksync_vm_interface::tracer::ViolatedValidationRule;

use super::{
get_empty_storage, read_validation_test_contract, tester::VmTesterBuilder, ContractToDeploy,
TestedVm, TestedVmForValidation,
get_empty_storage, read_validation_test_contract, require_eip712::make_aa_transaction,
tester::VmTesterBuilder, ContractToDeploy, TestedVm, TestedVmForValidation,
};
use crate::interface::TxExecutionMode;

Expand Down Expand Up @@ -54,40 +51,8 @@ fn test_rule<VM: TestedVm + TestedVmForValidation>(rule: u32) -> Option<Violated

let private_account = vm.rich_accounts[0].clone();

// Use account abstraction
let chain_id: u32 = 270;

let tx_712 = L2Tx::new(
Some(beneficiary_address),
vec![],
private_account.nonce,
Fee {
gas_limit: U256::from(1000000000),
max_fee_per_gas: U256::from(1000000000),
max_priority_fee_per_gas: U256::from(1000000000),
gas_per_pubdata_limit: U256::from(1000000000),
},
aa_address,
U256::from(28374938),
vec![],
Default::default(),
);

let mut transaction_request: TransactionRequest = tx_712.into();
transaction_request.chain_id = Some(chain_id.into());

let domain = Eip712Domain::new(L2ChainId::from(chain_id));
let signature = private_account
.get_pk_signer()
.sign_typed_data(&domain, &transaction_request)
.unwrap();
let encoded_tx = transaction_request.get_signed_bytes(&signature).unwrap();

let (aa_txn_request, aa_hash) =
TransactionRequest::from_bytes(&encoded_tx, L2ChainId::from(chain_id)).unwrap();

let mut l2_tx = L2Tx::from_request(aa_txn_request, 100000, false).unwrap();
l2_tx.set_input(encoded_tx, aa_hash);

vm.vm.run_validation(l2_tx, 55)
vm.vm.run_validation(
make_aa_transaction(aa_address, beneficiary_address, &private_account),
55,
)
}
38 changes: 25 additions & 13 deletions core/lib/multivm/src/versions/testonly/require_eip712.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ethabi::Token;
use zksync_eth_signer::TransactionParameters;
use zksync_test_account::Account;
use zksync_types::{
fee::Fee, l2::L2Tx, transaction_request::TransactionRequest, Address, Eip712Domain, Execute,
L2ChainId, Nonce, Transaction, U256,
Expand Down Expand Up @@ -31,7 +32,6 @@ pub(crate) fn test_require_eip712<VM: TestedVm>() {
.with_rich_accounts(1)
.build::<VM>();
assert_eq!(vm.get_eth_balance(beneficiary_address), U256::from(0));
let chain_id: u32 = 270;
let mut private_account = vm.rich_accounts[0].clone();

// First, let's set the owners of the AA account to the `private_address`.
Expand Down Expand Up @@ -99,6 +99,29 @@ pub(crate) fn test_require_eip712<VM: TestedVm>() {
);

// // Now send the 'classic' EIP712 transaction

let transaction: Transaction =
make_aa_transaction(aa_address, beneficiary_address, &private_account).into();
vm.vm.push_transaction(transaction);
vm.vm.execute(InspectExecutionMode::OneTx);

assert_eq!(
vm.get_eth_balance(beneficiary_address),
U256::from(916375026)
);
assert_eq!(
private_account_balance,
vm.get_eth_balance(private_account.address)
);
}

pub(crate) fn make_aa_transaction(
aa_address: Address,
beneficiary_address: Address,
private_account: &Account,
) -> L2Tx {
let chain_id: u32 = 270;

let tx_712 = L2Tx::new(
Some(beneficiary_address),
vec![],
Expand Down Expand Up @@ -131,16 +154,5 @@ pub(crate) fn test_require_eip712<VM: TestedVm>() {
let mut l2_tx = L2Tx::from_request(aa_txn_request, 100000, false).unwrap();
l2_tx.set_input(encoded_tx, aa_hash);

let transaction: Transaction = l2_tx.into();
vm.vm.push_transaction(transaction);
vm.vm.execute(InspectExecutionMode::OneTx);

assert_eq!(
vm.get_eth_balance(beneficiary_address),
U256::from(916375026)
);
assert_eq!(
private_account_balance,
vm.get_eth_balance(private_account.address)
);
l2_tx
}
Loading