Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LindaGuiga committed Nov 4, 2024
1 parent f3fbbe9 commit 00c6292
Show file tree
Hide file tree
Showing 42 changed files with 25 additions and 553 deletions.
2 changes: 1 addition & 1 deletion evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ serde = { workspace = true, features = ["derive"] }
serde-big-array.workspace = true
serde_json.workspace = true
sha2.workspace = true
smt_trie = { workspace = true }
smt_trie.workspace = true
starky = { workspace = true, features = ["parallel"] }
static_assertions.workspace = true
stackstack = "0.3.0"
Expand Down
82 changes: 0 additions & 82 deletions evm_arithmetization/benches/fibonacci_25m_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ use evm_arithmetization::testing_utils::{
beacon_roots_account_nibbles, beacon_roots_contract_from_storage,
preinitialized_state_and_storage_tries, update_beacon_roots_account_storage,
};
// #[cfg(feature = "cdk_erigon")]
// use evm_arithmetization::util::h2u;
use evm_arithmetization::world::world::StateWorld;
use evm_arithmetization::{Node, EMPTY_CONSOLIDATED_BLOCKHASH};
use hex_literal::hex;
Expand Down Expand Up @@ -93,27 +91,9 @@ fn prepare_setup() -> anyhow::Result<GenerationInputs<F>> {
} else {
CodeHashType::Hash(keccak(code))
};
// let code_hash = keccak(code);
// #[cfg(feature = "cdk_erigon")]
// let code_hash = CodeHashType::Uint(hash_bytecode_u256(code.to_vec()));

let empty_trie_root = HashedPartialTrie::from(Node::Empty).hash();

// #[cfg(feature = "eth_mainnet")]
// let sender_account_before = Box::new(MptAccountRlp {
// nonce: 169.into(),
// balance: U256::from_dec_str("999999999998417410153631615")?,
// storage_root: empty_trie_root,
// code_hash: keccak(vec![]),
// });
// #[cfg(feature = "eth_mainnet")]
// let to_account_before = Box::new(MptAccountRlp {
// nonce: 1.into(),
// balance: 0.into(),
// storage_root: empty_trie_root,
// code_hash,
// });

let sender_account_before = if cfg!(feature = "cdk_erigon") {
Either::Right(SmtAccountRlp {
nonce: 169.into(),
Expand Down Expand Up @@ -152,41 +132,6 @@ fn prepare_setup() -> anyhow::Result<GenerationInputs<F>> {
}
};

// #[cfg(feature = "cdk_erigon")]
// let sender_account_before: Box<dyn AccountRlp> = if cfg!(feature =
// "cdk_erigon") { Box::new(SmtAccountRlp {
// nonce: 169.into(),
// balance: U256::from_dec_str("999999999998417410153631615")?,
// code_hash: hash_bytecode_u256(vec![]),
// code_length: 0.into(),
// })
// } else {
// Box::new(MptAccountRlp {
// nonce: 169.into(),
// balance: U256::from_dec_str("999999999998417410153631615")?,
// storage_root: empty_trie_root,
// code_hash: keccak(vec![]),
// })
// };
// #[cfg(feature = "cdk_erigon")]
// let to_account_before: Box<dyn AccountRlp> = if cfg!(feature = "cdk_erigon")
// { Box::new(SmtAccountRlp {
// nonce: 1.into(),
// balance: 0.into(),
// code_hash: get_u256_from_code_hash(code_hash.clone())
// .expect("In cdk_erigon, the code_hash is a U256"),
// code_length: code.len().into(),
// })
// } else {
// Box::new(MptAccountRlp {
// nonce: 1.into(),
// balance: 0.into(),
// storage_root: empty_trie_root,
// code_hash: get_h256_from_code_hash(code_hash.clone())
// .expect("In eth_mainnet, the code_hash is a H256"),
// })
// };

let mut state_trie_before = StateWorld::default();
#[cfg(feature = "eth_mainnet")]
let (mut state_trie_before_hashed, mut storage_tries) =
Expand Down Expand Up @@ -229,14 +174,9 @@ fn prepare_setup() -> anyhow::Result<GenerationInputs<F>> {
}

let tries_before = TrieInputs {
// #[cfg(feature = "eth_mainnet")]
// state_trie: state_trie_before,
// #[cfg(feature = "cdk_erigon")]
state_trie: state_trie_before,
transactions_trie: Node::Empty.into(),
receipts_trie: Node::Empty.into(),
// #[cfg(feature = "eth_mainnet")]
// storage_tries,
};

let gas_used = U256::from(0x17d7840_u32);
Expand Down Expand Up @@ -270,19 +210,6 @@ fn prepare_setup() -> anyhow::Result<GenerationInputs<F>> {
contract_code.insert(empty_code_hash, vec![]);
contract_code.insert(code_hash, code.to_vec());
}
// #[cfg(feature = "eth_mainnet")]
// {
// contract_code.insert(keccak(vec![]), vec![]);
// contract_code.insert(code_hash, code.to_vec());
// }
// #[cfg(feature = "cdk_erigon")]
// {
// contract_code.insert(hash_bytecode_u256(vec![]), vec![]);
// contract_code.insert(
// get_u256_from_code_hash(code_hash).expect("In cdk_erigon, the
// code_hash is a U256"), code.to_vec(),
// );
// }

let sender_account_after = if cfg!(feature = "cdk_erigon") {
let sender_account_before_smt =
Expand Down Expand Up @@ -387,10 +314,6 @@ fn prepare_setup() -> anyhow::Result<GenerationInputs<F>> {
))
};
let trie_roots_after = TrieRoots {
// #[cfg(feature = "eth_mainnet")]
// state_root: expected_state_trie_after.hash(),
// #[cfg(feature = "cdk_erigon")]
// state_root: H256::from_uint(&hashout2u(expected_smt_after.root)),
state_root,
transactions_root: transactions_trie.hash(),
receipts_root: receipts_trie.hash(),
Expand Down Expand Up @@ -450,11 +373,6 @@ fn set_account(world: &mut StateWorld, addr: Address, account: &SmtAccountRlp, c
U256(std::array::from_fn(|i| key.0[i].to_canonical_u64()))
);
}

// smt.set(key_code_length(addr), account.code_length);
// for (&k, &v) in storage {
// smt.set(key_storage(addr, k), v);
// }
}
#[cfg(feature = "eth_mainnet")]
use std::collections::BTreeMap;
Expand Down
3 changes: 0 additions & 3 deletions evm_arithmetization/src/cpu/kernel/asm/account_code.asm
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ load_code_ctd:
// stack: codehash, ctx, retdest
DUP1 ISZERO %jumpi(load_code_non_existent_account)
// Load the code non-deterministically in memory and return the length.
global debug_account_code:
PROVER_INPUT(account_code)
#[cfg(feature = eth_mainnet)]
{
Expand Down Expand Up @@ -220,8 +219,6 @@ load_code_padded_ctd:
DUP1 %jumpi(non_zero_padding)
%jump(padd)
non_zero_padding:
global debug_len_mod_56:

// curr_len mod 56, padding_addr, addr, len, retdest
PUSH 56 SUB
padd:
Expand Down
6 changes: 0 additions & 6 deletions evm_arithmetization/src/cpu/kernel/asm/cdk_pre_execution.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@ global pre_block_execution:
global update_scalable_block_number:
// stack: retdest
%blocknumber
global debug_blocknumber:
PUSH @LAST_BLOCK_STORAGE_POS
// stack: last_block_slot, block_number, retdest
%write_scalable_storage
// stack: retdest
global debug_wtf_is_happening_with_retdest:
// Check timestamp
PUSH @TIMESTAMP_STORAGE_POS
PUSH @ADDRESS_SCALABLE_L2
%read_slot_from_addr_key
// stack: old_timestamp, retdest
%timestamp
global debug_el_timestamp:
GT
global debug_before_jumpi:
%jumpi(update_scalable_timestamp)

global update_scalable_prev_block_root_hash:
Expand Down Expand Up @@ -91,7 +87,6 @@ skip_and_exit:
global update_scalable_timestamp:
// stack: retdest
%timestamp
global debug_le_timestamp:
PUSH @TIMESTAMP_STORAGE_POS
// stack: timestamp_slot, timestamp, retdest
%write_scalable_storage
Expand All @@ -107,7 +102,6 @@ global create_scalable_l2_account:
// stack: retdest
PUSH @EMPTY_STRING_POSEIDON_HASH
PUSH @ADDRESS_SCALABLE_L2
global debug_setting_scalable_code:
%set_code // code hash

// stack: retdest
Expand Down
1 change: 0 additions & 1 deletion evm_arithmetization/src/cpu/kernel/asm/core/call.asm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ global sys_call:
DUP1 %insert_accessed_addresses

%call_charge_gas(1, 1)
global debug_after_charge_gas:
%check_depth

%checkpoint // Checkpoint
Expand Down
1 change: 0 additions & 1 deletion evm_arithmetization/src/cpu/kernel/asm/core/call_gas.asm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ after_new_cost:
%charge_gas

// Compute C_callgas
global debug_por_aca:
%stack (kexit_info, Cgascap, address, gas, value) ->
(Cgascap, address, gas, kexit_info, value)
DUP5 ISZERO %not_bit
Expand Down
11 changes: 0 additions & 11 deletions evm_arithmetization/src/cpu/kernel/asm/core/create.asm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ global create_common:

%create_context
// stack: new_ctx, address, value, code_offset, code_len, kexit_info
global debug_new_ctx:
GET_CONTEXT
// stack: src_ctx, new_ctx, address, value, code_offset, code_len, kexit_info

Expand All @@ -114,16 +113,13 @@ global debug_new_ctx:

run_constructor:
// stack: new_ctx, value, address, kexit_info
global debug_run_constructor:
SWAP1 %set_new_ctx_value
global debug_1:
// stack: new_ctx, address, kexit_info

// Each line in the block below does not change the stack.
DUP2 %set_new_ctx_addr
%address %set_new_ctx_caller
%set_new_ctx_parent_pc(after_constructor)
global debug_2:
// stack: new_ctx, address, kexit_info

// All but 1/64 of the sender's remaining gas goes to the constructor.
Expand All @@ -136,9 +132,7 @@ global debug_2:

// Create the new contract account in the state trie.
DUP2
global debug_before_create_contract_account:
%create_contract_account
global debug_after_create_contract_account:
// stack: status, new_ctx, address, kexit_info
%jumpi(create_collision)

Expand Down Expand Up @@ -185,7 +179,6 @@ after_constructor:
#[cfg(feature = cdk_erigon)]
{
%poseidon_hash_code_unpadded
global debug_poseidon_output:
}
// stack: codehash, leftover_gas, success, address, kexit_info
%observe_new_contract
Expand Down Expand Up @@ -284,17 +277,14 @@ global set_codehash:
// stack: addr, codehash, retdest
DUP1 %insert_touched_addresses
DUP1
global debug_reading_code:
%read_code
// stack: prev_codehash, addr, codehash, retdest
DUP2
global debug_reading_code_length:
%read_code_length
%stack (prev_code_length, prev_codehash, addr) -> (addr, prev_codehash, prev_code_length, prev_code_length, addr)
%journal_add_code_change // Add the code change to the journal.
// stack: prev_code_length, addr, codehash, retdest
DUP3 DUP3
global debug_setting_code:
%set_code
// stack: prev_code_length, addr, codehash, retdest
%returndatasize
Expand All @@ -304,7 +294,6 @@ global set_codehash:
%pop3 JUMP
code_length_changed:
DUP2
global debug_setting_code_lenght:
%set_code_length
// stack: addr, codehash, retdest
%pop2 JUMP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
// (This should be impossible with contract creation transactions or CREATE, but possible with CREATE2.)
// So we return 1 to indicate an error.
%%error_collision:
%stack (address) -> (1)
%stack (address) -> (1)
%%end:
// stack: status
// stack: status
%endmacro

%macro append_created_contracts
Expand Down
11 changes: 0 additions & 11 deletions evm_arithmetization/src/cpu/kernel/asm/core/process_txn.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ global process_normalized_txn:

// Assert gas_limit >= intrinsic_gas.
%mload_txn_field(@TXN_FIELD_GAS_LIMIT)
global debug_invalid_txn:
%assert_ge(invalid_txn)

// Assert block gas limit >= txn gas limit.
Expand All @@ -33,18 +32,15 @@ global debug_invalid_txn:
// stack: sender_nonce, sender, retdest
%mload_txn_field(@TXN_FIELD_NONCE)
// stack: tx_nonce, sender_nonce, sender, retdest
global debug_eq_nonce:
%assert_eq(invalid_txn_1)
// stack: sender, retdest

// Assert sender has no code.
DUP1 %ext_code_empty
global debug_no_code:
%assert_nonzero(invalid_txn_1)
// stack: sender, retdest

// Assert sender balance >= gas_limit * gas_price + value.
global debug_balance:
%balance
// stack: sender_balance, retdest
%mload_txn_field(@TXN_FIELD_COMPUTED_FEE_PER_GAS)
Expand Down Expand Up @@ -237,7 +233,6 @@ process_contract_creation_txn_after_ef_check:
// stack: leftover_gas', new_ctx, address, retdest, success, leftover_gas
SWAP5 POP
%delete_all_touched_addresses
global debug_jump_to_delete_all_1:
%delete_all_selfdestructed_addresses
// stack: new_ctx, address, retdest, success, leftover_gas
POP
Expand Down Expand Up @@ -332,12 +327,10 @@ process_message_txn_after_call_contd:
%pay_coinbase_and_refund_sender
// stack: leftover_gas', new_ctx, retdest, success, leftover_gas
SWAP4 POP
global debug_delete_all_touched:
%delete_all_touched_addresses
%delete_all_selfdestructed_addresses
// stack: new_ctx, retdest, success, leftover_gas
POP
global debug_y_salta_salta_salta:
JUMP

process_message_txn_fail:
Expand Down Expand Up @@ -487,7 +480,6 @@ create_contract_account_fault:
%pay_coinbase_and_refund_sender
// stack: leftover_gas', retdest
%delete_all_touched_addresses
global debug_jump_to_delete_all_3:
%delete_all_selfdestructed_addresses
// stack: leftover_gas', retdest
SWAP1 PUSH 0 // success
Expand All @@ -501,7 +493,6 @@ contract_creation_fault_3:
%pay_coinbase_and_refund_sender
// stack: leftover_gas', retdest, success
%delete_all_touched_addresses
global debug_jump_to_delete_all_5:
%delete_all_selfdestructed_addresses
%stack (leftover_gas, retdest, success) -> (retdest, 0, leftover_gas)
JUMP
Expand All @@ -514,7 +505,6 @@ contract_creation_fault_3_zero_leftover:
// stack: leftover_gas, retdest, success
%pay_coinbase_and_refund_sender
%delete_all_touched_addresses
global debug_jump_to_delete_all_6:
%delete_all_selfdestructed_addresses
%stack (leftover_gas, retdest, success) -> (retdest, 0, leftover_gas)
JUMP
Expand All @@ -527,7 +517,6 @@ contract_creation_fault_4:
// stack: leftover_gas, retdest, success
%pay_coinbase_and_refund_sender
%delete_all_touched_addresses
global debug_jump_to_delete_all_7:
%delete_all_selfdestructed_addresses
%stack (leftover_gas, retdest, success) -> (retdest, 0, leftover_gas)
JUMP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ bingo:
delete_all_selfdestructed_addresses_done:
// stack: i, len, retdest
%pop2
global debug_jump_from_delete_all:
JUMP

%macro delete_all_selfdestructed_addresses
Expand Down
Loading

0 comments on commit 00c6292

Please sign in to comment.