Limiting result of the execution to execution-specific errors (#1071)
* execution error/result limiting * missing trailing comma * fix executive tests * adding original error as string to the generic transaction error * 'mallformed'-s all around
This commit is contained in:
@@ -63,7 +63,7 @@ pub use external::{ExternalMiner, ExternalMinerService};
|
||||
use util::{H256, U256, Address, Bytes};
|
||||
use ethcore::client::{BlockChainClient, Executed};
|
||||
use ethcore::block::{ClosedBlock};
|
||||
use ethcore::error::{Error};
|
||||
use ethcore::error::{Error, ExecutionError};
|
||||
use ethcore::transaction::SignedTransaction;
|
||||
|
||||
/// Miner client API
|
||||
@@ -150,7 +150,7 @@ pub trait MinerService : Send + Sync {
|
||||
fn balance(&self, chain: &BlockChainClient, address: &Address) -> U256;
|
||||
|
||||
/// Call into contract code using pending state.
|
||||
fn call(&self, chain: &BlockChainClient, t: &SignedTransaction) -> Result<Executed, Error>;
|
||||
fn call(&self, chain: &BlockChainClient, t: &SignedTransaction) -> Result<Executed, ExecutionError>;
|
||||
|
||||
/// Get storage value in pending state.
|
||||
fn storage_at(&self, chain: &BlockChainClient, address: &Address, position: &H256) -> H256;
|
||||
|
||||
@@ -240,7 +240,7 @@ impl MinerService for Miner {
|
||||
}
|
||||
}
|
||||
|
||||
fn call(&self, chain: &BlockChainClient, t: &SignedTransaction) -> Result<Executed, Error> {
|
||||
fn call(&self, chain: &BlockChainClient, t: &SignedTransaction) -> Result<Executed, ExecutionError> {
|
||||
let sealing_work = self.sealing_work.lock().unwrap();
|
||||
match sealing_work.peek_last_ref() {
|
||||
Some(work) => {
|
||||
@@ -258,7 +258,10 @@ impl MinerService for Miner {
|
||||
};
|
||||
// that's just a copy of the state.
|
||||
let mut state = block.state().clone();
|
||||
let sender = try!(t.sender());
|
||||
let sender = try!(t.sender().map_err(|e| {
|
||||
let message = format!("Transaction malformed: {:?}", e);
|
||||
ExecutionError::TransactionMalformed(message)
|
||||
}));
|
||||
let balance = state.balance(&sender);
|
||||
// give the sender max balance
|
||||
state.sub_balance(&sender, &balance);
|
||||
|
||||
Reference in New Issue
Block a user