From 0ddc0f33fe468207222ec3d77b5255b73855f3f6 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Tue, 29 Aug 2023 18:49:39 +0300 Subject: [PATCH 01/15] added tests for dynamic_gas transactions (cherry picked from commit 9580e29312f4c8beba15c99735e3157d649d135e) --- .../test_execute_trx_from_instruction.py | 15 ++++++++ .../test_transaction_step_from_account.py | 37 ++++++++++++++++++ .../test_transaction_step_from_instruction.py | 38 +++++++++++++++++++ evm_loader/tests/utils/contract.py | 15 +++++--- evm_loader/tests/utils/ethereum.py | 8 +++- 5 files changed, 107 insertions(+), 6 deletions(-) diff --git a/evm_loader/tests/test_execute_trx_from_instruction.py b/evm_loader/tests/test_execute_trx_from_instruction.py index 9af502aeb..fe552bbeb 100644 --- a/evm_loader/tests/test_execute_trx_from_instruction.py +++ b/evm_loader/tests/test_execute_trx_from_instruction.py @@ -321,3 +321,18 @@ def test_old_trx_type_with_leading_zeros(self, sender_with_tokens, operator_keyp calculator_contract.solana_address], operator_keypair) check_transaction_logs_have_text(resp.value, "exit_status=0x12") + + @pytest.mark.parametrize("value", [0, 10]) + def test_transaction_with_dynamic_gas(self, operator_keypair, treasury_pool, sender_with_tokens, + evm_loader, holder_acc, + calculator_contract, calculator_caller_contract, value): + signed_tx = make_contract_call_trx(sender_with_tokens, calculator_caller_contract, "callCalculator()", [], + trx_type=2, max_fee_per_gas=20000, + max_priority_fee_per_gas=20000, value=value) + resp = execute_trx_from_instruction(operator_keypair, evm_loader, treasury_pool.account, treasury_pool.buffer, + signed_tx, + [sender_with_tokens.solana_account_address, + calculator_caller_contract.solana_address, + calculator_contract.solana_address], + operator_keypair) + check_transaction_logs_have_text(resp.value, "exit_status=0x12") diff --git a/evm_loader/tests/test_transaction_step_from_account.py b/evm_loader/tests/test_transaction_step_from_account.py index 09ccf8322..2ad0ca83c 100644 --- a/evm_loader/tests/test_transaction_step_from_account.py +++ b/evm_loader/tests/test_transaction_step_from_account.py @@ -361,6 +361,43 @@ def test_access_list_structure(self, operator_keypair, holder_acc, treasury_pool neon_cli().call_contract_get_function(evm_loader, sender_with_tokens, string_setter_contract, "get()")) + def test_transaction_with_dynamic_gas(self, operator_keypair, treasury_pool, sender_with_tokens, + evm_loader, holder_acc, + string_setter_contract): + signed_tx = make_contract_call_trx(sender_with_tokens, string_setter_contract, "set(string)", ["text"], + trx_type=2, max_fee_per_gas=9999, + max_priority_fee_per_gas=99, + value=10) + write_transaction_to_holder_account(signed_tx, holder_acc, operator_keypair) + resp = execute_transaction_steps_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc, + [string_setter_contract.solana_address, + sender_with_tokens.solana_account_address]) + + check_transaction_logs_have_text(resp.value, "exit_status=0x11") + assert "text" in to_text( + neon_cli().call_contract_get_function(evm_loader, sender_with_tokens, string_setter_contract, + "get()")) + + def test_deploy_contract_with_dynamic_gas(self, operator_keypair, holder_acc, treasury_pool, evm_loader, + sender_with_tokens): + contract_filename = "small.binary" + contract = create_contract_address(sender_with_tokens, evm_loader) + + signed_tx = make_deployment_transaction(sender_with_tokens, contract_filename, + max_fee_per_gas=20000, + max_priority_fee_per_gas=20000) + contract_path = pytest.CONTRACTS_PATH / contract_filename + with open(contract_path, 'rb') as f: + contract_code = f.read() + + steps_count = neon_cli().get_steps_count(evm_loader, sender_with_tokens, "deploy", contract_code.hex()) + resp = execute_transaction_steps_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc, + signed_tx, [contract.solana_address, + sender_with_tokens.solana_account_address], + steps_count) + check_holder_account_tag(holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_transaction_logs_have_text(resp.value.transaction.transaction.signatures[0], "exit_status=0x12") + class TestAccountStepContractCallContractInteractions: def test_contract_call_unchange_storage_function(self, rw_lock_contract, rw_lock_caller, session_user, evm_loader, diff --git a/evm_loader/tests/test_transaction_step_from_instruction.py b/evm_loader/tests/test_transaction_step_from_instruction.py index 76e808bf6..b24dfef87 100644 --- a/evm_loader/tests/test_transaction_step_from_instruction.py +++ b/evm_loader/tests/test_transaction_step_from_instruction.py @@ -354,6 +354,44 @@ def test_deploy_contract_with_access_list(self, operator_keypair, holder_acc, tr steps_count) check_transaction_logs_have_text(resp.value, "exit_status=0x12") + @pytest.mark.parametrize("value", [0, 10]) + def test_transaction_with_dynamic_gas(self, operator_keypair, treasury_pool, sender_with_tokens, + evm_loader, holder_acc, + string_setter_contract, value): + signed_tx = make_contract_call_trx(sender_with_tokens, string_setter_contract, "set(string)", ["text"], + value=value, trx_type=2, max_fee_per_gas=20000, + max_priority_fee_per_gas=20000) + resp = execute_transaction_steps_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc, + signed_tx, [string_setter_contract.solana_address, + sender_with_tokens.solana_account_address] + ) + + check_holder_account_tag(holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_transaction_logs_have_text(resp.value, "exit_status=0x11") + + + def test_transaction_with_dynamic_gas_and_access_list(self, operator_keypair, treasury_pool, sender_with_tokens, + evm_loader, holder_acc, + string_setter_contract): + access_list = ( + { + "address": string_setter_contract.eth_address.hex(), + "storageKeys": ( + "0x0000000000000000000000000000000000000000000000000000000000000000", + ) + }, + ) + signed_tx = make_contract_call_trx(sender_with_tokens, string_setter_contract, "set(string)", ["text"], + trx_type=2, max_fee_per_gas=20000, + max_priority_fee_per_gas=20000, access_list=access_list) + resp = execute_transaction_steps_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc, + signed_tx, [string_setter_contract.solana_address, + sender_with_tokens.solana_account_address] + ) + + check_holder_account_tag(holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_transaction_logs_have_text(resp.value, "exit_status=0x11") + class TestInstructionStepContractCallContractInteractions: def test_contract_call_unchange_storage_function(self, rw_lock_contract, session_user, evm_loader, operator_keypair, diff --git a/evm_loader/tests/utils/contract.py b/evm_loader/tests/utils/contract.py index 21bc071c4..17b17a023 100644 --- a/evm_loader/tests/utils/contract.py +++ b/evm_loader/tests/utils/contract.py @@ -21,7 +21,8 @@ def make_deployment_transaction( user: Caller, contract_path: tp.Union[pathlib.Path, str], encoded_args=None, - gas: int = 999999999, chain_id=111, access_list=None + gas: int = 999999999, chain_id=111, access_list=None, max_fee_per_gas=None, + max_priority_fee_per_gas=None ) -> SignedTransaction: if isinstance(contract_path, str): contract_path = pathlib.Path(contract_path) @@ -46,14 +47,17 @@ def make_deployment_transaction( if access_list: tx['accessList'] = access_list tx['type'] = 1 - print(tx) + if max_fee_per_gas: + tx["maxFeePerGas"] = max_fee_per_gas + tx["maxPriorityFeePerGas"] = max_priority_fee_per_gas + tx['type'] = 2 + tx.pop("gasPrice") return w3.eth.account.sign_transaction(tx, user.solana_account.secret_key[:32]) def make_contract_call_trx(user, contract, function_signature, params=None, value=0, chain_id=111, access_list=None, - trx_type=None): + trx_type=None, max_fee_per_gas=None, max_priority_fee_per_gas=None): data = abi.function_signature_to_4byte_selector(function_signature) - if params is not None: for param in params: if isinstance(param, int): @@ -62,7 +66,8 @@ def make_contract_call_trx(user, contract, function_signature, params=None, valu data += eth_abi.encode(['string'], [param]) signed_tx = make_eth_transaction(contract.eth_address, data, user.solana_account, user.solana_account_address, - value=value, chain_id=chain_id, access_list=access_list, type=trx_type) + value, chain_id, access_list=access_list, type=trx_type, + max_fee_per_gas=max_fee_per_gas, max_priority_fee_per_gas=max_priority_fee_per_gas) return signed_tx diff --git a/evm_loader/tests/utils/ethereum.py b/evm_loader/tests/utils/ethereum.py index 0c8cb4a0f..567132acc 100644 --- a/evm_loader/tests/utils/ethereum.py +++ b/evm_loader/tests/utils/ethereum.py @@ -28,7 +28,8 @@ def create_contract_address(user: Caller, evm_loader: EvmLoader) -> Contract: def make_eth_transaction(to_addr: bytes, data: Union[bytes, None], signer: Keypair, from_solana_user: PublicKey, - value: int = 0, chain_id=111, gas=9999999999, access_list=None, type=None): + value: int = 0, chain_id=111, gas=9999999999, access_list=None, type=None, + max_fee_per_gas=None, max_priority_fee_per_gas=None): nonce = get_transaction_count(solana_client, from_solana_user) tx = {'to': to_addr, 'value': value, 'gas': gas, 'gasPrice': 0, 'nonce': nonce} @@ -43,4 +44,9 @@ def make_eth_transaction(to_addr: bytes, data: Union[bytes, None], signer: Keypa tx['accessList'] = access_list if type is not None: tx['type'] = type + if max_fee_per_gas is not None: + tx["maxFeePerGas"] = max_fee_per_gas + tx.pop("gasPrice") + if max_priority_fee_per_gas is not None: + tx["maxPriorityFeePerGas"] = max_priority_fee_per_gas return w3.eth.account.sign_transaction(tx, signer.secret_key[:32]) From 91c4b93fb0d58079a1b74386e4cfdbfec0fadda1 Mon Sep 17 00:00:00 2001 From: Julian Pokrovsky Date: Tue, 29 Aug 2023 16:35:59 +0800 Subject: [PATCH 02/15] EIP-1559: RLP parser implementation (cherry picked from commit c41c3c983beddaaa0ad669a3e0fe05053e7e5d28) --- evm_loader/program/src/types/transaction.rs | 150 ++++++++++++++++++-- 1 file changed, 137 insertions(+), 13 deletions(-) diff --git a/evm_loader/program/src/types/transaction.rs b/evm_loader/program/src/types/transaction.rs index 7d4d5a664..2a2b2be3f 100644 --- a/evm_loader/program/src/types/transaction.rs +++ b/evm_loader/program/src/types/transaction.rs @@ -236,13 +236,112 @@ impl rlp::Decodable for AccessListTx { } } -// TODO: Will be added as a part of EIP-1559 -// struct DynamicFeeTx {} +// EIP-1559 transaction structure +#[derive(Debug, Clone)] +pub struct DynamicFeeTx { + nonce: u64, + // Tip to the validator: higher priority - faster processing + max_priority_fee_per_gas: U256, + // The maximum amount user wants to spend on transaction + #[allow(dead_code)] + max_fee_per_gas: U256, + gas_limit: U256, + target: Option
, + value: U256, + call_data: crate::evm::Buffer, + r: U256, + s: U256, + chain_id: U256, + recovery_id: u8, + access_list: Vec<(Address, Vec)>, +} + +impl rlp::Decodable for DynamicFeeTx { + fn decode(rlp: &rlp::Rlp) -> Result { + let rlp_len = { + let info = rlp.payload_info()?; + info.header_len + info.value_len + }; + + if rlp.as_raw().len() != rlp_len { + return Err(rlp::DecoderError::RlpInconsistentLengthAndData); + } + + let chain_id: U256 = u256(&rlp.at(0)?)?; + let nonce: u64 = rlp.val_at(1)?; + let max_priority_fee_per_gas: U256 = u256(&rlp.at(2)?)?; + let max_fee_per_gas: U256 = u256(&rlp.at(3)?)?; + let gas_limit: U256 = u256(&rlp.at(4)?)?; + let target: Option
= { + let target = rlp.at(5)?; + if target.is_empty() { + if target.is_data() { + None + } else { + return Err(rlp::DecoderError::RlpExpectedToBeData); + } + } else { + Some(target.as_val()?) + } + }; + + let value: U256 = u256(&rlp.at(6)?)?; + let call_data = crate::evm::Buffer::from_slice(rlp.at(7)?.data()?); + + let rlp_access_list = rlp.at(8)?; + let mut access_list = vec![]; + + for entry in rlp_access_list.iter() { + // Check if entry is a list + if entry.is_list() { + // Parse address from first element + let address: Address = entry.at(0)?.as_val()?; + + // Get storage keys from second element + let mut storage_keys: Vec = vec![]; + + for key in entry.at(1)?.iter() { + storage_keys.push(key.as_val()?); + } + + access_list.push((address, storage_keys)); + } else { + return Err(rlp::DecoderError::RlpExpectedToBeList); + } + } + + let y_parity: u8 = rlp.at(9)?.as_val()?; + let r: U256 = u256(&rlp.at(10)?)?; + let s: U256 = u256(&rlp.at(11)?)?; + + if rlp.at(12).is_ok() { + return Err(rlp::DecoderError::RlpIncorrectListLen); + } + + let tx = DynamicFeeTx { + nonce, + max_priority_fee_per_gas, + max_fee_per_gas, + gas_limit, + target, + value, + call_data, + r, + s, + chain_id, + recovery_id: y_parity, + access_list, + }; + + Ok(tx) + } +} #[derive(Debug, Clone)] pub enum TransactionPayload { Legacy(LegacyTx), AccessList(AccessListTx), + DynamicFee(DynamicFeeTx), } #[derive(Debug, Clone)] @@ -277,6 +376,14 @@ impl Transaction { (hash, signed_hash) } + // Dynamic Fee transaction + Some(TransactionEnvelope::DynamicFee) => { + let hash = + solana_program::keccak::hashv(&[&[0x02], transaction_rlp.as_raw()]).to_bytes(); + let signed_hash = Self::eip2718_signed_hash(&[0x02], transaction_rlp, 9)?; + + (hash, signed_hash) + } // Legacy trasaction None => { let hash = solana_program::keccak::hash(transaction_rlp.as_raw()).to_bytes(); @@ -284,7 +391,6 @@ impl Transaction { (hash, signed_hash) } - _ => unimplemented!(), }; let info = transaction_rlp.payload_info()?; @@ -465,7 +571,8 @@ impl Transaction { pub fn nonce(&self) -> u64 { match self.transaction { TransactionPayload::Legacy(LegacyTx { nonce, .. }) - | TransactionPayload::AccessList(AccessListTx { nonce, .. }) => nonce, + | TransactionPayload::AccessList(AccessListTx { nonce, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { nonce, .. }) => nonce, } } @@ -474,6 +581,11 @@ impl Transaction { match self.transaction { TransactionPayload::Legacy(LegacyTx { gas_price, .. }) | TransactionPayload::AccessList(AccessListTx { gas_price, .. }) => gas_price, + // TODO: Temporarily solution before new gas computation logic is implemeted for EIP-1559 + TransactionPayload::DynamicFee(DynamicFeeTx { + max_priority_fee_per_gas, + .. + }) => max_priority_fee_per_gas, } } @@ -481,7 +593,8 @@ impl Transaction { pub fn gas_limit(&self) -> U256 { match self.transaction { TransactionPayload::Legacy(LegacyTx { gas_limit, .. }) - | TransactionPayload::AccessList(AccessListTx { gas_limit, .. }) => gas_limit, + | TransactionPayload::AccessList(AccessListTx { gas_limit, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { gas_limit, .. }) => gas_limit, } } @@ -489,7 +602,8 @@ impl Transaction { pub fn target(&self) -> Option
{ match self.transaction { TransactionPayload::Legacy(LegacyTx { target, .. }) - | TransactionPayload::AccessList(AccessListTx { target, .. }) => target, + | TransactionPayload::AccessList(AccessListTx { target, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { target, .. }) => target, } } @@ -497,7 +611,8 @@ impl Transaction { pub fn value(&self) -> U256 { match self.transaction { TransactionPayload::Legacy(LegacyTx { value, .. }) - | TransactionPayload::AccessList(AccessListTx { value, .. }) => value, + | TransactionPayload::AccessList(AccessListTx { value, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { value, .. }) => value, } } @@ -505,7 +620,8 @@ impl Transaction { pub fn call_data(&self) -> &crate::evm::Buffer { match &self.transaction { TransactionPayload::Legacy(LegacyTx { call_data, .. }) - | TransactionPayload::AccessList(AccessListTx { call_data, .. }) => call_data, + | TransactionPayload::AccessList(AccessListTx { call_data, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { call_data, .. }) => call_data, } } @@ -518,6 +634,9 @@ impl Transaction { }) | TransactionPayload::AccessList(AccessListTx { ref mut call_data, .. + }) + | TransactionPayload::DynamicFee(DynamicFeeTx { + ref mut call_data, .. }) => std::mem::take(call_data), } } @@ -526,7 +645,8 @@ impl Transaction { pub fn r(&self) -> U256 { match self.transaction { TransactionPayload::Legacy(LegacyTx { r, .. }) - | TransactionPayload::AccessList(AccessListTx { r, .. }) => r, + | TransactionPayload::AccessList(AccessListTx { r, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { r, .. }) => r, } } @@ -534,7 +654,8 @@ impl Transaction { pub fn s(&self) -> U256 { match self.transaction { TransactionPayload::Legacy(LegacyTx { s, .. }) - | TransactionPayload::AccessList(AccessListTx { s, .. }) => s, + | TransactionPayload::AccessList(AccessListTx { s, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { s, .. }) => s, } } @@ -542,7 +663,8 @@ impl Transaction { pub fn chain_id(&self) -> Option { match self.transaction { TransactionPayload::Legacy(LegacyTx { chain_id, .. }) => chain_id, - TransactionPayload::AccessList(AccessListTx { chain_id, .. }) => Some(chain_id), + TransactionPayload::AccessList(AccessListTx { chain_id, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { chain_id, .. }) => Some(chain_id), } } @@ -550,7 +672,8 @@ impl Transaction { pub fn recovery_id(&self) -> u8 { match self.transaction { TransactionPayload::Legacy(LegacyTx { recovery_id, .. }) - | TransactionPayload::AccessList(AccessListTx { recovery_id, .. }) => recovery_id, + | TransactionPayload::AccessList(AccessListTx { recovery_id, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { recovery_id, .. }) => recovery_id, } } @@ -572,8 +695,9 @@ impl Transaction { #[must_use] pub fn access_list(&self) -> Option<&Vec<(Address, Vec)>> { match &self.transaction { - TransactionPayload::AccessList(AccessListTx { access_list, .. }) => Some(access_list), TransactionPayload::Legacy(_) => None, + TransactionPayload::AccessList(AccessListTx { access_list, .. }) + | TransactionPayload::DynamicFee(DynamicFeeTx { access_list, .. }) => Some(access_list), } } } From 1252c17013af609bf9d63e2fce42516ae3cf0cab Mon Sep 17 00:00:00 2001 From: Julian Pokrovsky Date: Tue, 29 Aug 2023 22:57:56 +0800 Subject: [PATCH 03/15] add skipped dynamicfee match (cherry picked from commit 6717a9261a2b2e32241489a76900582739b159c4) --- evm_loader/program/src/types/transaction.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/evm_loader/program/src/types/transaction.rs b/evm_loader/program/src/types/transaction.rs index 2a2b2be3f..ad4163e7c 100644 --- a/evm_loader/program/src/types/transaction.rs +++ b/evm_loader/program/src/types/transaction.rs @@ -542,13 +542,24 @@ impl Transaction { tx, )? } + Some(TransactionEnvelope::DynamicFee) => { + let dynamic_fee_tx = + rlp::decode::(transaction).map_err(Error::from)?; + let chain_id = dynamic_fee_tx.chain_id; + let tx = TransactionPayload::DynamicFee(dynamic_fee_tx); + Transaction::from_payload( + &Some(TransactionEnvelope::DynamicFee), + Some(chain_id), + &rlp::Rlp::new(transaction), + tx, + )? + } None => { let legacy_tx = rlp::decode::(transaction).map_err(Error::from)?; let chain_id = legacy_tx.chain_id; let tx = TransactionPayload::Legacy(legacy_tx); Transaction::from_payload(&None, chain_id, &rlp::Rlp::new(transaction), tx)? } - Some(TransactionEnvelope::DynamicFee) => unimplemented!(), }; Ok(tx) From 9e8f6a4b9ace28b188a7fec208e02f384fa6362e Mon Sep 17 00:00:00 2001 From: Julian Pokrovsky Date: Mon, 4 Sep 2023 15:18:16 +0800 Subject: [PATCH 04/15] abort dynamic_fee execution --- evm_loader/program/src/types/transaction.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/evm_loader/program/src/types/transaction.rs b/evm_loader/program/src/types/transaction.rs index ad4163e7c..916812235 100644 --- a/evm_loader/program/src/types/transaction.rs +++ b/evm_loader/program/src/types/transaction.rs @@ -240,7 +240,7 @@ impl rlp::Decodable for AccessListTx { #[derive(Debug, Clone)] pub struct DynamicFeeTx { nonce: u64, - // Tip to the validator: higher priority - faster processing + // Tip to the miner: higher priority - faster processing max_priority_fee_per_gas: U256, // The maximum amount user wants to spend on transaction #[allow(dead_code)] @@ -360,7 +360,7 @@ impl Transaction { transaction: TransactionPayload, ) -> Result { let (hash, signed_hash) = match *transaction_type { - // Legacy transaction wrapped in envelop + // Legacy transaction in EIP-2718 envelop Some(TransactionEnvelope::Legacy) => { let hash = solana_program::keccak::hashv(&[&[0x00], transaction_rlp.as_raw()]).to_bytes(); @@ -378,13 +378,14 @@ impl Transaction { } // Dynamic Fee transaction Some(TransactionEnvelope::DynamicFee) => { - let hash = - solana_program::keccak::hashv(&[&[0x02], transaction_rlp.as_raw()]).to_bytes(); - let signed_hash = Self::eip2718_signed_hash(&[0x02], transaction_rlp, 9)?; + panic!("Abort execution of dynamic_fee"); + // let hash = + // solana_program::keccak::hashv(&[&[0x02], transaction_rlp.as_raw()]).to_bytes(); + // let signed_hash = Self::eip2718_signed_hash(&[0x02], transaction_rlp, 9)?; - (hash, signed_hash) + // (hash, signed_hash) } - // Legacy trasaction + // Legacy trasaction without EIP-2718 envelop None => { let hash = solana_program::keccak::hash(transaction_rlp.as_raw()).to_bytes(); let signed_hash = Self::calculate_legacy_signature(transaction_rlp, chain_id)?; @@ -398,7 +399,7 @@ impl Transaction { // Legacy transaction info.header_len + info.value_len } else { - // Transaction in the type envelope + // Transaction in the EIP-2718 envelope info.header_len + info.value_len + 1 // + 1 byte for type }; From 649f27c07ed8c7e5718ac39095f753661ff3975d Mon Sep 17 00:00:00 2001 From: Julian Pokrovsky Date: Mon, 4 Sep 2023 16:03:04 +0800 Subject: [PATCH 05/15] reconnect dynamic_fee parser --- evm_loader/program/src/types/transaction.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/evm_loader/program/src/types/transaction.rs b/evm_loader/program/src/types/transaction.rs index 916812235..1ac846b4a 100644 --- a/evm_loader/program/src/types/transaction.rs +++ b/evm_loader/program/src/types/transaction.rs @@ -378,12 +378,11 @@ impl Transaction { } // Dynamic Fee transaction Some(TransactionEnvelope::DynamicFee) => { - panic!("Abort execution of dynamic_fee"); - // let hash = - // solana_program::keccak::hashv(&[&[0x02], transaction_rlp.as_raw()]).to_bytes(); - // let signed_hash = Self::eip2718_signed_hash(&[0x02], transaction_rlp, 9)?; + let hash = + solana_program::keccak::hashv(&[&[0x02], transaction_rlp.as_raw()]).to_bytes(); + let signed_hash = Self::eip2718_signed_hash(&[0x02], transaction_rlp, 9)?; - // (hash, signed_hash) + (hash, signed_hash) } // Legacy trasaction without EIP-2718 envelop None => { From 234ec462fc7c4a3aff0a667028ac07587d879841 Mon Sep 17 00:00:00 2001 From: Julian Pokrovsky Date: Mon, 4 Sep 2023 16:49:22 +0800 Subject: [PATCH 06/15] output decoder type --- evm_loader/program/src/types/transaction.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/evm_loader/program/src/types/transaction.rs b/evm_loader/program/src/types/transaction.rs index 1ac846b4a..db942af33 100644 --- a/evm_loader/program/src/types/transaction.rs +++ b/evm_loader/program/src/types/transaction.rs @@ -78,6 +78,8 @@ pub struct LegacyTx { impl rlp::Decodable for LegacyTx { fn decode(rlp: &rlp::Rlp) -> Result { + solana_program::msg!("LegacyTx decoder"); + let rlp_len = { let info = rlp.payload_info()?; info.header_len + info.value_len @@ -159,6 +161,8 @@ pub struct AccessListTx { impl rlp::Decodable for AccessListTx { fn decode(rlp: &rlp::Rlp) -> Result { + solana_program::msg!("AccessListTx decoder"); + let rlp_len = { let info = rlp.payload_info()?; info.header_len + info.value_len @@ -258,6 +262,8 @@ pub struct DynamicFeeTx { impl rlp::Decodable for DynamicFeeTx { fn decode(rlp: &rlp::Rlp) -> Result { + solana_program::msg!("DynamicFeeTx decoder"); + let rlp_len = { let info = rlp.payload_info()?; info.header_len + info.value_len From 9ea848c517e0ebf97d9dfc3bcc6f9ba702f2c37f Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 4 Sep 2023 12:52:34 +0300 Subject: [PATCH 07/15] Update conftest.py --- evm_loader/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm_loader/tests/conftest.py b/evm_loader/tests/conftest.py index ef25a219a..cc9c40e82 100644 --- a/evm_loader/tests/conftest.py +++ b/evm_loader/tests/conftest.py @@ -116,7 +116,7 @@ def sender_with_tokens(evm_loader, operator_keypair) -> Caller: return user -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def holder_acc(operator_keypair) -> PublicKey: return create_holder(operator_keypair) From d261bffd4145d12024aa170cd7b307eaa1e91014 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 4 Sep 2023 12:55:00 +0300 Subject: [PATCH 08/15] Update conftest.py --- evm_loader/tests/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evm_loader/tests/conftest.py b/evm_loader/tests/conftest.py index cc9c40e82..57f522e36 100644 --- a/evm_loader/tests/conftest.py +++ b/evm_loader/tests/conftest.py @@ -109,7 +109,7 @@ def second_session_user(evm_loader) -> Caller: return make_new_user(evm_loader) -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def sender_with_tokens(evm_loader, operator_keypair) -> Caller: user = make_new_user(evm_loader) deposit_neon(evm_loader, operator_keypair, user.eth_address, 100000) @@ -146,13 +146,13 @@ def string_setter_contract(evm_loader: EvmLoader, operator_keypair: Keypair, ses return deploy_contract(operator_keypair, session_user, "string_setter.binary", evm_loader, treasury_pool) -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def calculator_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, treasury_pool) -> Contract: return deploy_contract(operator_keypair, session_user, "Calculator.binary", evm_loader, treasury_pool) -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def calculator_caller_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, treasury_pool, calculator_contract) -> Contract: constructor_args = eth_abi.encode(['address'], [calculator_contract.eth_address.hex()]) From 958eaa52e251244ac9a79c18661fb7d170ceac4c Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 4 Sep 2023 13:59:08 +0300 Subject: [PATCH 09/15] Update test_execute_trx_from_instruction.py --- .../tests/test_execute_trx_from_instruction.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/evm_loader/tests/test_execute_trx_from_instruction.py b/evm_loader/tests/test_execute_trx_from_instruction.py index fe552bbeb..2ee8a9bf9 100644 --- a/evm_loader/tests/test_execute_trx_from_instruction.py +++ b/evm_loader/tests/test_execute_trx_from_instruction.py @@ -305,6 +305,7 @@ def test_old_trx_type_with_leading_zeros(self, sender_with_tokens, operator_keyp calculator_caller_contract, calculator_contract, treasury_pool, holder_acc): signed_tx = make_contract_call_trx(sender_with_tokens, calculator_caller_contract, "callCalculator()", []) + new_raw_trx = HexBytes('0x' + (b'\x00' + bytes.fromhex(signed_tx.rawTransaction.hex()[2:])).hex()) signed_tx_new = SignedTransaction( rawTransaction=new_raw_trx, @@ -313,7 +314,6 @@ def test_old_trx_type_with_leading_zeros(self, sender_with_tokens, operator_keyp s=signed_tx.s, v=signed_tx.v, ) - resp = execute_trx_from_instruction(operator_keypair, evm_loader, treasury_pool.account, treasury_pool.buffer, signed_tx_new, [sender_with_tokens.solana_account_address, @@ -325,14 +325,13 @@ def test_old_trx_type_with_leading_zeros(self, sender_with_tokens, operator_keyp @pytest.mark.parametrize("value", [0, 10]) def test_transaction_with_dynamic_gas(self, operator_keypair, treasury_pool, sender_with_tokens, evm_loader, holder_acc, - calculator_contract, calculator_caller_contract, value): - signed_tx = make_contract_call_trx(sender_with_tokens, calculator_caller_contract, "callCalculator()", [], - trx_type=2, max_fee_per_gas=20000, - max_priority_fee_per_gas=20000, value=value) + string_setter_contract, value): + signed_tx = make_contract_call_trx(sender_with_tokens, string_setter_contract, "set(string)", ["text"], + value=value, trx_type=2, max_fee_per_gas=20000, + max_priority_fee_per_gas=20000) resp = execute_trx_from_instruction(operator_keypair, evm_loader, treasury_pool.account, treasury_pool.buffer, signed_tx, [sender_with_tokens.solana_account_address, - calculator_caller_contract.solana_address, - calculator_contract.solana_address], + string_setter_contract.solana_address], operator_keypair) - check_transaction_logs_have_text(resp.value, "exit_status=0x12") + check_transaction_logs_have_text(resp.value, "exit_status=0x11") From 6d0bfe467f215a7bf637a5bb11deaa8389a57cff Mon Sep 17 00:00:00 2001 From: Julian Pokrovsky Date: Mon, 4 Sep 2023 21:29:25 +0800 Subject: [PATCH 10/15] add logs --- evm_loader/program/src/instruction/transaction_step.rs | 5 +++++ evm_loader/program/src/types/transaction.rs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/evm_loader/program/src/instruction/transaction_step.rs b/evm_loader/program/src/instruction/transaction_step.rs index 3396ec5d0..27a3652db 100644 --- a/evm_loader/program/src/instruction/transaction_step.rs +++ b/evm_loader/program/src/instruction/transaction_step.rs @@ -60,7 +60,12 @@ pub fn do_continue<'a>( ) -> Result<()> { debug_print!("do_continue"); + solana_program::msg!("step_count {}", step_count); + solana_program::msg!("storage.gas_price {}", storage.gas_price); + if (step_count < EVM_STEPS_MIN) && (storage.gas_price > 0) { + solana_program::msg!("Entering critical section!!!"); + return Err(Error::Custom(format!( "Step limit {step_count} below minimum {EVM_STEPS_MIN}" ))); diff --git a/evm_loader/program/src/types/transaction.rs b/evm_loader/program/src/types/transaction.rs index db942af33..baa36ebcb 100644 --- a/evm_loader/program/src/types/transaction.rs +++ b/evm_loader/program/src/types/transaction.rs @@ -76,6 +76,8 @@ pub struct LegacyTx { pub recovery_id: u8, } +// 0x02f8cc6f806382270f8502540be3ff941835f5f2a66f949e1b5cb934966df0ea58ec84470ab8644ed3885e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465787400000000000000000000000000000000000000000000000000000000c080a0e3d59fd90cc29fd747fd49e4309b5ecd8aad2d541655bf922f74bb3353855631a027accfd283e611a26ac2209942bdd679da865f394f1a97153f5d22299bd0061f + impl rlp::Decodable for LegacyTx { fn decode(rlp: &rlp::Rlp) -> Result { solana_program::msg!("LegacyTx decoder"); From 805c6aa673e84c2cfd90000bf8ed46d6db8aefd0 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 4 Sep 2023 18:26:12 +0300 Subject: [PATCH 11/15] fixed tests --- evm_loader/tests/solana_utils.py | 4 ++-- evm_loader/tests/test_transaction_step_from_account.py | 7 +++++-- evm_loader/tests/utils/contract.py | 7 ++++--- evm_loader/tests/utils/ethereum.py | 4 +++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/evm_loader/tests/solana_utils.py b/evm_loader/tests/solana_utils.py index 385e721c3..1db7b9c3d 100644 --- a/evm_loader/tests/solana_utils.py +++ b/evm_loader/tests/solana_utils.py @@ -615,14 +615,14 @@ def execute_transaction_steps_from_account(operator: Keypair, evm_loader, treasu signer: Keypair = None) -> GetTransactionResp: signer = operator if signer is None else signer - send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, 1, signer) + send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, signer) if steps_count > 0: steps_left = steps_count while steps_left > 0: send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, signer) steps_left = steps_left - EVM_STEPS - return send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, 1, + return send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, signer) diff --git a/evm_loader/tests/test_transaction_step_from_account.py b/evm_loader/tests/test_transaction_step_from_account.py index 2ad0ca83c..545bb3574 100644 --- a/evm_loader/tests/test_transaction_step_from_account.py +++ b/evm_loader/tests/test_transaction_step_from_account.py @@ -79,10 +79,13 @@ def test_deploy_contract(self, operator_keypair, holder_acc, treasury_pool, evm_ check_holder_account_tag(holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) check_transaction_logs_have_text(resp.value.transaction.transaction.signatures[0], "exit_status=0x12") + @pytest.mark.parametrize("gas_price", [None, 10]) def test_call_contract_function_without_neon_transfer(self, operator_keypair, holder_acc, treasury_pool, - sender_with_tokens, evm_loader, string_setter_contract): + sender_with_tokens, evm_loader, string_setter_contract, + gas_price): text = ''.join(random.choice(string.ascii_letters) for _ in range(10)) - signed_tx = make_contract_call_trx(sender_with_tokens, string_setter_contract, "set(string)", [text]) + signed_tx = make_contract_call_trx(sender_with_tokens, string_setter_contract, "set(string)", [text], + gas_price=gas_price) write_transaction_to_holder_account(signed_tx, holder_acc, operator_keypair) resp = execute_transaction_steps_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc, diff --git a/evm_loader/tests/utils/contract.py b/evm_loader/tests/utils/contract.py index 17b17a023..b31f653eb 100644 --- a/evm_loader/tests/utils/contract.py +++ b/evm_loader/tests/utils/contract.py @@ -22,7 +22,7 @@ def make_deployment_transaction( contract_path: tp.Union[pathlib.Path, str], encoded_args=None, gas: int = 999999999, chain_id=111, access_list=None, max_fee_per_gas=None, - max_priority_fee_per_gas=None + max_priority_fee_per_gas=None ) -> SignedTransaction: if isinstance(contract_path, str): contract_path = pathlib.Path(contract_path) @@ -56,7 +56,7 @@ def make_deployment_transaction( def make_contract_call_trx(user, contract, function_signature, params=None, value=0, chain_id=111, access_list=None, - trx_type=None, max_fee_per_gas=None, max_priority_fee_per_gas=None): + trx_type=None, max_fee_per_gas=None, max_priority_fee_per_gas=None, gas_price=None): data = abi.function_signature_to_4byte_selector(function_signature) if params is not None: for param in params: @@ -67,7 +67,8 @@ def make_contract_call_trx(user, contract, function_signature, params=None, valu signed_tx = make_eth_transaction(contract.eth_address, data, user.solana_account, user.solana_account_address, value, chain_id, access_list=access_list, type=trx_type, - max_fee_per_gas=max_fee_per_gas, max_priority_fee_per_gas=max_priority_fee_per_gas) + max_fee_per_gas=max_fee_per_gas, max_priority_fee_per_gas=max_priority_fee_per_gas, + gas_price=gas_price) return signed_tx diff --git a/evm_loader/tests/utils/ethereum.py b/evm_loader/tests/utils/ethereum.py index 567132acc..3bc698706 100644 --- a/evm_loader/tests/utils/ethereum.py +++ b/evm_loader/tests/utils/ethereum.py @@ -29,10 +29,12 @@ def create_contract_address(user: Caller, evm_loader: EvmLoader) -> Contract: def make_eth_transaction(to_addr: bytes, data: Union[bytes, None], signer: Keypair, from_solana_user: PublicKey, value: int = 0, chain_id=111, gas=9999999999, access_list=None, type=None, - max_fee_per_gas=None, max_priority_fee_per_gas=None): + max_fee_per_gas=None, max_priority_fee_per_gas=None, gas_price=None): nonce = get_transaction_count(solana_client, from_solana_user) tx = {'to': to_addr, 'value': value, 'gas': gas, 'gasPrice': 0, 'nonce': nonce} + if gas_price is not None: + tx['gasPrice'] = gas_price if chain_id is not None: tx['chainId'] = chain_id From f962b60ccc7ac4d28f1b4a549ca3448e0eefa3ea Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 4 Sep 2023 18:32:38 +0300 Subject: [PATCH 12/15] Update solana_utils.py --- evm_loader/tests/solana_utils.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/evm_loader/tests/solana_utils.py b/evm_loader/tests/solana_utils.py index 1db7b9c3d..93e554aff 100644 --- a/evm_loader/tests/solana_utils.py +++ b/evm_loader/tests/solana_utils.py @@ -162,8 +162,8 @@ def create_holder_account(account, operator, seed): AccountMeta(pubkey=operator, is_signer=True, is_writable=False), ], program_id=PublicKey(EVM_LOADER), - data=bytes.fromhex("24") + - len(seed).to_bytes(8, 'little') + seed + data=bytes.fromhex("24") + + len(seed).to_bytes(8, 'little') + seed ) @@ -585,7 +585,7 @@ def execute_transaction_steps_from_instruction(operator: Keypair, evm_loader, tr signer = operator if signer is None else signer send_transaction_step_from_instruction(operator, evm_loader, treasury, storage_account, instruction, - additional_accounts, 1, signer) + additional_accounts, EVM_STEPS, signer) if steps_count > 0: steps_left = steps_count while steps_left > 0: @@ -593,7 +593,7 @@ def execute_transaction_steps_from_instruction(operator: Keypair, evm_loader, tr additional_accounts, EVM_STEPS, signer) steps_left = steps_left - EVM_STEPS return send_transaction_step_from_instruction(operator, evm_loader, treasury, storage_account, instruction, - additional_accounts, 1, signer) + additional_accounts, EVM_STEPS, signer) def send_transaction_step_from_account(operator: Keypair, evm_loader, treasury, storage_account, @@ -615,14 +615,16 @@ def execute_transaction_steps_from_account(operator: Keypair, evm_loader, treasu signer: Keypair = None) -> GetTransactionResp: signer = operator if signer is None else signer - send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, signer) + send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, + signer) if steps_count > 0: steps_left = steps_count while steps_left > 0: send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, signer) steps_left = steps_left - EVM_STEPS - return send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, + return send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, + EVM_STEPS, signer) @@ -631,7 +633,8 @@ def execute_transaction_steps_from_account_no_chain_id(operator: Keypair, evm_lo signer: Keypair = None) -> GetTransactionResp: signer = operator if signer is None else signer - send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, 1, signer, + send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, + signer, tag=34) if steps_count > 0: steps_left = steps_count @@ -639,5 +642,6 @@ def execute_transaction_steps_from_account_no_chain_id(operator: Keypair, evm_lo send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, EVM_STEPS, signer, tag=34) steps_left = steps_left - EVM_STEPS - return send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, 1, + return send_transaction_step_from_account(operator, evm_loader, treasury, storage_account, additional_accounts, + EVM_STEPS, signer, tag=34) From 2bfa658eee064ea4be2411efed17f7aefc18af84 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 4 Sep 2023 18:45:18 +0300 Subject: [PATCH 13/15] fixed test_deploy_contract_with_dynamic_gas test --- evm_loader/tests/test_transaction_step_from_account.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/evm_loader/tests/test_transaction_step_from_account.py b/evm_loader/tests/test_transaction_step_from_account.py index 545bb3574..80058ed97 100644 --- a/evm_loader/tests/test_transaction_step_from_account.py +++ b/evm_loader/tests/test_transaction_step_from_account.py @@ -393,10 +393,12 @@ def test_deploy_contract_with_dynamic_gas(self, operator_keypair, holder_acc, tr with open(contract_path, 'rb') as f: contract_code = f.read() + write_transaction_to_holder_account(signed_tx, holder_acc, operator_keypair) + steps_count = neon_cli().get_steps_count(evm_loader, sender_with_tokens, "deploy", contract_code.hex()) resp = execute_transaction_steps_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc, - signed_tx, [contract.solana_address, - sender_with_tokens.solana_account_address], + [contract.solana_address, + sender_with_tokens.solana_account_address], steps_count) check_holder_account_tag(holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) check_transaction_logs_have_text(resp.value.transaction.transaction.signatures[0], "exit_status=0x12") From ff5a1a3531cc08d516fc0ec2a97933f78b4806bc Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 4 Sep 2023 19:30:57 +0300 Subject: [PATCH 14/15] fix tests --- evm_loader/tests/conftest.py | 8 ++++---- evm_loader/tests/test_transaction_step_from_account.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/evm_loader/tests/conftest.py b/evm_loader/tests/conftest.py index 57f522e36..ef25a219a 100644 --- a/evm_loader/tests/conftest.py +++ b/evm_loader/tests/conftest.py @@ -109,14 +109,14 @@ def second_session_user(evm_loader) -> Caller: return make_new_user(evm_loader) -@pytest.fixture(scope="function") +@pytest.fixture(scope="session") def sender_with_tokens(evm_loader, operator_keypair) -> Caller: user = make_new_user(evm_loader) deposit_neon(evm_loader, operator_keypair, user.eth_address, 100000) return user -@pytest.fixture(scope="function") +@pytest.fixture(scope="session") def holder_acc(operator_keypair) -> PublicKey: return create_holder(operator_keypair) @@ -146,13 +146,13 @@ def string_setter_contract(evm_loader: EvmLoader, operator_keypair: Keypair, ses return deploy_contract(operator_keypair, session_user, "string_setter.binary", evm_loader, treasury_pool) -@pytest.fixture(scope="function") +@pytest.fixture(scope="session") def calculator_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, treasury_pool) -> Contract: return deploy_contract(operator_keypair, session_user, "Calculator.binary", evm_loader, treasury_pool) -@pytest.fixture(scope="function") +@pytest.fixture(scope="session") def calculator_caller_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, treasury_pool, calculator_contract) -> Contract: constructor_args = eth_abi.encode(['address'], [calculator_contract.eth_address.hex()]) diff --git a/evm_loader/tests/test_transaction_step_from_account.py b/evm_loader/tests/test_transaction_step_from_account.py index 80058ed97..c4868ed51 100644 --- a/evm_loader/tests/test_transaction_step_from_account.py +++ b/evm_loader/tests/test_transaction_step_from_account.py @@ -376,7 +376,7 @@ def test_transaction_with_dynamic_gas(self, operator_keypair, treasury_pool, sen [string_setter_contract.solana_address, sender_with_tokens.solana_account_address]) - check_transaction_logs_have_text(resp.value, "exit_status=0x11") + check_transaction_logs_have_text(resp.value.transaction.transaction.signatures[0], "exit_status=0x11") assert "text" in to_text( neon_cli().call_contract_get_function(evm_loader, sender_with_tokens, string_setter_contract, "get()")) From b67d7547fe34b4d02bcdf8cddcf479fe1f6eb277 Mon Sep 17 00:00:00 2001 From: Julian Pokrovsky Date: Tue, 5 Sep 2023 15:01:26 +0800 Subject: [PATCH 15/15] clean up the code --- .../program/src/instruction/transaction_step.rs | 5 ----- evm_loader/program/src/types/transaction.rs | 13 +++---------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/evm_loader/program/src/instruction/transaction_step.rs b/evm_loader/program/src/instruction/transaction_step.rs index 27a3652db..3396ec5d0 100644 --- a/evm_loader/program/src/instruction/transaction_step.rs +++ b/evm_loader/program/src/instruction/transaction_step.rs @@ -60,12 +60,7 @@ pub fn do_continue<'a>( ) -> Result<()> { debug_print!("do_continue"); - solana_program::msg!("step_count {}", step_count); - solana_program::msg!("storage.gas_price {}", storage.gas_price); - if (step_count < EVM_STEPS_MIN) && (storage.gas_price > 0) { - solana_program::msg!("Entering critical section!!!"); - return Err(Error::Custom(format!( "Step limit {step_count} below minimum {EVM_STEPS_MIN}" ))); diff --git a/evm_loader/program/src/types/transaction.rs b/evm_loader/program/src/types/transaction.rs index baa36ebcb..bfa2a14a0 100644 --- a/evm_loader/program/src/types/transaction.rs +++ b/evm_loader/program/src/types/transaction.rs @@ -76,12 +76,8 @@ pub struct LegacyTx { pub recovery_id: u8, } -// 0x02f8cc6f806382270f8502540be3ff941835f5f2a66f949e1b5cb934966df0ea58ec84470ab8644ed3885e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465787400000000000000000000000000000000000000000000000000000000c080a0e3d59fd90cc29fd747fd49e4309b5ecd8aad2d541655bf922f74bb3353855631a027accfd283e611a26ac2209942bdd679da865f394f1a97153f5d22299bd0061f - impl rlp::Decodable for LegacyTx { fn decode(rlp: &rlp::Rlp) -> Result { - solana_program::msg!("LegacyTx decoder"); - let rlp_len = { let info = rlp.payload_info()?; info.header_len + info.value_len @@ -163,8 +159,6 @@ pub struct AccessListTx { impl rlp::Decodable for AccessListTx { fn decode(rlp: &rlp::Rlp) -> Result { - solana_program::msg!("AccessListTx decoder"); - let rlp_len = { let info = rlp.payload_info()?; info.header_len + info.value_len @@ -242,13 +236,14 @@ impl rlp::Decodable for AccessListTx { } } -// EIP-1559 transaction structure +// EIP-1559 Dynamic Fee transaction structure #[derive(Debug, Clone)] pub struct DynamicFeeTx { nonce: u64, - // Tip to the miner: higher priority - faster processing + // Tip to the miner max_priority_fee_per_gas: U256, // The maximum amount user wants to spend on transaction + // Unused before EIP-1559 gas price calculation is implemented #[allow(dead_code)] max_fee_per_gas: U256, gas_limit: U256, @@ -264,8 +259,6 @@ pub struct DynamicFeeTx { impl rlp::Decodable for DynamicFeeTx { fn decode(rlp: &rlp::Rlp) -> Result { - solana_program::msg!("DynamicFeeTx decoder"); - let rlp_len = { let info = rlp.payload_info()?; info.header_len + info.value_len