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

sla-136 precompiles are not recognised #580

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 10 additions & 5 deletions evm_loader/lib/src/commands/get_contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use evm_loader::{
account::{legacy::LegacyEtherData, ContractAccount},
executor::precompile_extension::PrecompiledContracts,
types::Address,
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -81,20 +82,24 @@ fn read_account(
pub async fn execute(
rpc: &(impl Rpc + BuildConfigSimulator),
program_id: &Pubkey,
accounts: &[Address],
account_addresses: &[Address],
) -> NeonResult<Vec<GetContractResponse>> {
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();

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);
}

Expand Down
16 changes: 16 additions & 0 deletions evm_loader/program/src/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -372,8 +373,23 @@ impl<B: Database, T: EventListener> Machine<B, T> {

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 {
Expand Down
3 changes: 2 additions & 1 deletion evm_loader/program/src/executor/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion evm_loader/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading