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

188 remove call from solana user #191

Merged
merged 3 commits into from
Aug 27, 2021
Merged
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
16 changes: 11 additions & 5 deletions evm_loader/program/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
account_data::AccountData,
solana_backend::{AccountStorage, SolanaBackend},
solidity_account::SolidityAccount,
utils::keccak256_h256,
// utils::keccak256_h256,
token::{get_token_account_balance, check_token_account, transfer_token},
};
use evm::backend::Apply;
Expand Down Expand Up @@ -138,11 +138,17 @@ impl<'a> ProgramAccountStorage<'a> {
push_account(caller_acc, caller_info, caller_token_info, None);
Sender::Ethereum(caller_address)
} else {
if !caller_info.is_signer {
return Err!(ProgramError::InvalidArgument; "Caller must be signer. Caller pubkey: {} ", &caller_info.key.to_string());
}
// TODO: EvmInstruction::Call
// https://github.com/neonlabsorg/neon-evm/issues/188
// Does not fit in current vision.
// It is needed to update behavior for all system in whole.
return Err!(ProgramError::InvalidArgument; "Caller could not be Solana user. It must be neon-evm owned account");

// if !caller_info.is_signer {
// return Err!(ProgramError::InvalidArgument; "Caller must be signer. Caller pubkey: {} ", &caller_info.key.to_string());
// }

Sender::Solana(keccak256_h256(&caller_info.key.to_bytes()).into())
// Sender::Solana(keccak256_h256(&caller_info.key.to_bytes()).into())
}
};

Expand Down
49 changes: 26 additions & 23 deletions evm_loader/program/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use solana_program::{
use crate::{
// bump_allocator::BumpAllocator,
account_data::{Account, AccountData, Contract},
account_storage::{ProgramAccountStorage, Sender},
account_storage::{ProgramAccountStorage, /* Sender */ },
solana_backend::{SolanaBackend, AccountStorage},
solidity_account::SolidityAccount,
transaction::{UnsignedTransaction, verify_tx_signature, check_secp256k1_instruction, find_rent_info},
Expand Down Expand Up @@ -248,28 +248,31 @@ fn process_instruction<'a>(
EvmInstruction::Finalize => {
do_finalize(program_id, accounts)
},
EvmInstruction::Call {bytes} => {
StorageAccount::check_for_blocked_accounts(program_id, accounts)?;
let mut account_storage = ProgramAccountStorage::new(program_id, accounts)?;
if let Sender::Solana(_addr) = account_storage.get_sender() {
// Success execution
} else {
return Err!(ProgramError::InvalidArgument; "This method should used with Solana sender");
}

let call_return = do_call(&mut account_storage, accounts, bytes.to_vec(), U256::zero(), u64::MAX)?;

if let Some(call_results) = call_return {
applies_and_invokes(
program_id,
&mut account_storage,
accounts,
None,
call_results)?;
}

Ok(())
},
// TODO: EvmInstruction::Call
// https://github.com/neonlabsorg/neon-evm/issues/188
// Does not fit in current vision.
// It is needed to update behavior for all system in whole.
// EvmInstruction::Call {bytes} => {
// let mut account_storage = ProgramAccountStorage::new(program_id, accounts)?;
// if let Sender::Solana(_addr) = account_storage.get_sender() {
// // Success execution
// } else {
// return Err!(ProgramError::InvalidArgument; "This method should used with Solana sender");
// }

// let call_return = do_call(&mut account_storage, accounts, bytes.to_vec(), U256::zero(), u64::MAX)?;

// if let Some(call_results) = call_return {
// applies_and_invokes(
// program_id,
// &mut account_storage,
// accounts,
// None,
// call_results)?;
// }

// Ok(())
// },
EvmInstruction::ExecuteTrxFromAccountDataIterative{collateral_pool_index, step_count} => {
debug_print!("Execute iterative transaction from account data");
let holder_info = next_account_info(account_info_iter)?;
Expand Down
38 changes: 23 additions & 15 deletions evm_loader/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,22 @@ pub enum EvmInstruction<'a> {
nonce: u8,
},

/// Call Ethereum-contract action
/// ### Account references
/// 0. \[WRITE\] Contract account for execution (Ether account)
/// 1. \[WRITE\] Contract code account (Code account)
/// 2. \[WRITE\] Caller (Ether account)
/// 3. \[SIGNER\] Signer for caller
/// 4. \[\] Clock sysvar
/// ... other Ether accounts
Call {
/// Call data
bytes: &'a [u8],
},
// TODO: EvmInstruction::Call
// https://github.com/neonlabsorg/neon-evm/issues/188
// Does not fit in current vision.
// It is needed to update behavior for all system in whole.
// /// Call Ethereum-contract action
// /// ### Account references
// /// 0. \[WRITE\] Contract account for execution (Ether account)
// /// 1. \[WRITE\] Contract code account (Code account)
// /// 2. \[WRITE\] Caller (Ether account)
// /// 3. \[SIGNER\] Signer for caller
// /// 4. \[\] Clock sysvar
// /// ... other Ether accounts
// Call {
// /// Call data
// bytes: &'a [u8],
// },

///
/// Create ethereum account with seed
Expand Down Expand Up @@ -211,9 +215,13 @@ impl<'a> EvmInstruction<'a> {
let (nonce, _rest) = rest.split_first().ok_or(InvalidInstructionData)?;
EvmInstruction::CreateAccount {lamports, space, ether, nonce: *nonce}
},
3 => {
EvmInstruction::Call {bytes: rest}
},
// TODO: EvmInstruction::Call
// https://github.com/neonlabsorg/neon-evm/issues/188
// Does not fit in current vision.
// It is needed to update behavior for all system in whole.
// 3 => {
// EvmInstruction::Call {bytes: rest}
// },
4 => {
let (_, rest) = rest.split_at(3);
let (base, rest) = rest.split_at(32);
Expand Down
1 change: 1 addition & 0 deletions evm_loader/test_remove_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
client = Client(solana_url)


@unittest.skip("Depends on 03 instruction that is disabled now")
class EvmLoaderTestsNewAccount(unittest.TestCase):
@classmethod
def setUpClass(cls):
Expand Down