diff --git a/evm_loader/lib/src/commands/get_contract.rs b/evm_loader/lib/src/commands/get_contract.rs index 7d6b8ccb1..b63df98fa 100644 --- a/evm_loader/lib/src/commands/get_contract.rs +++ b/evm_loader/lib/src/commands/get_contract.rs @@ -1,5 +1,6 @@ use evm_loader::{ account::{legacy::LegacyEtherData, ContractAccount}, + executor::precompile_extension::PrecompiledContracts, types::Address, }; use serde::{Deserialize, Serialize}; @@ -81,11 +82,10 @@ fn read_account( pub async fn execute( rpc: &(impl Rpc + BuildConfigSimulator), program_id: &Pubkey, - accounts: &[Address], + account_addresses: &[Address], ) -> NeonResult> { let legacy_chain_id = super::get_config::read_legacy_chain_id(rpc, *program_id).await?; - - let pubkeys: Vec<_> = accounts + let pubkeys: Vec<_> = account_addresses .iter() .map(|a| a.find_solana_address(program_id).0) .collect(); @@ -93,8 +93,13 @@ pub async fn execute( let accounts = rpc.get_multiple_accounts(&pubkeys).await?; let mut result = Vec::with_capacity(accounts.len()); - for (key, account) in pubkeys.into_iter().zip(accounts) { - let response = read_account(program_id, legacy_chain_id, key, account); + for ((key, account), account_address) in + pubkeys.into_iter().zip(accounts).zip(account_addresses) + { + let mut response = read_account(program_id, legacy_chain_id, key, account); + if PrecompiledContracts::is_precompile_extension(account_address) { + response.code = vec![0xfe]; + } result.push(response); } diff --git a/evm_loader/program/src/evm/mod.rs b/evm_loader/program/src/evm/mod.rs index 615332e5e..77d8e36c5 100644 --- a/evm_loader/program/src/evm/mod.rs +++ b/evm_loader/program/src/evm/mod.rs @@ -12,6 +12,7 @@ pub use buffer::Buffer; #[cfg(target_os = "solana")] use crate::evm::tracing::NoopEventListener; +use crate::executor::precompile_extension::PrecompiledContracts; use crate::{ debug::log_data, error::{build_revert_message, Error, Result}, @@ -372,8 +373,23 @@ impl Machine { let status = if is_precompile_address(&self.context.contract) { let value = Self::precompile(&self.context.contract, &self.call_data).unwrap(); + backend.commit_snapshot(); + end_vm!(self, backend, ExitStatus::Return(value.clone())); + ExitStatus::Return(value) + } else if PrecompiledContracts::is_precompile_extension(&self.context.contract) { + let value = PrecompiledContracts::call_precompile_extension( + backend, + &self.context, + &self.context.contract, + &self.call_data, + self.is_static, + ) + .await + .unwrap()?; + + backend.commit_snapshot(); end_vm!(self, backend, ExitStatus::Return(value.clone())); ExitStatus::Return(value) } else { diff --git a/evm_loader/program/src/executor/mod.rs b/evm_loader/program/src/executor/mod.rs index 756f871f5..3ff5803a7 100644 --- a/evm_loader/program/src/executor/mod.rs +++ b/evm_loader/program/src/executor/mod.rs @@ -1,10 +1,11 @@ mod action; mod block_params; mod cache; -mod precompile_extension; mod state; mod synced_state; +pub mod precompile_extension; + pub use action::Action; pub use cache::OwnedAccountInfo; pub use state::ExecutorState; diff --git a/evm_loader/program/src/lib.rs b/evm_loader/program/src/lib.rs index 561bb908f..b6508fcf2 100644 --- a/evm_loader/program/src/lib.rs +++ b/evm_loader/program/src/lib.rs @@ -15,7 +15,7 @@ solana_program::declare_id!(crate::config::PROGRAM_ID); mod allocator; #[macro_use] -mod debug; +pub mod debug; #[macro_use] pub mod error; pub mod account;