EIPs 155, 160, 161 (#2976)

* The front-end for each hard-fork, also EIP-160.

* Address EIP161 a/c

* Include EIP-161b

* EIP-161 part d.

* Fix test build.

* Fix one test, add another.

* Fix use of bloom & renaming.

* Initial groundwork for EIP-155

* Fix minor bug.

* Fix all tests finally.

* Rest of EIP-155.

* Add tests for EIP-155 algorithm.

Update transaction tests validation.

* Minor reformat.

* Address grumbles.

* Remove unused code.

* Fix SUICIDE gas mechanism and add consensus tests.

* Remove commented code.

* Set Frontier hardfork block number

* Fix warning.

* Transaction tests,
This commit is contained in:
Gav Wood
2016-11-03 22:22:25 +01:00
committed by GitHub
parent 7e592e5389
commit d3de475205
65 changed files with 652 additions and 232 deletions

View File

@@ -63,15 +63,16 @@ pub fn decrypt(accounts: &AccountProvider, address: Address, password: Option<St
pub fn sign_and_dispatch<C, M>(client: &C, miner: &M, accounts: &AccountProvider, request: TransactionRequest, password: Option<String>) -> Result<RpcH256, Error>
where C: MiningBlockChainClient, M: MinerService {
let network_id = client.signing_network_id();
let address = request.from;
let signed_transaction = {
let t = prepare_transaction(client, miner, request);
let hash = t.hash();
let hash = t.hash(network_id);
let signature = try!(signature(accounts, address, password, hash));
t.with_signature(signature)
t.with_signature(signature, network_id)
};
trace!(target: "miner", "send_transaction: dispatching tx: {}", ::rlp::encode(&signed_transaction).to_vec().pretty());
trace!(target: "miner", "send_transaction: dispatching tx: {} for network ID {:?}", ::rlp::encode(&signed_transaction).to_vec().pretty(), network_id);
dispatch_transaction(&*client, &*miner, signed_transaction)
}

View File

@@ -255,6 +255,7 @@ pub fn from_transaction_error(error: EthcoreError) -> Error {
SenderBanned => "Sender is banned in local queue.".into(),
RecipientBanned => "Recipient is banned in local queue.".into(),
CodeBanned => "Code is banned in local queue.".into(),
e => format!("{}", e).into(),
};
Error {
code: ErrorCode::ServerError(codes::TRANSACTION_ERROR),

View File

@@ -45,7 +45,7 @@ fn account_provider() -> Arc<AccountProvider> {
fn sync_provider() -> Arc<TestSyncProvider> {
Arc::new(TestSyncProvider::new(Config {
network_id: U256::from(3),
network_id: 3,
num_peers: 120,
}))
}

View File

@@ -16,13 +16,13 @@
//! Test implementation of SyncProvider.
use util::{RwLock, U256};
use util::{RwLock};
use ethsync::{SyncProvider, SyncStatus, SyncState, PeerInfo};
/// TestSyncProvider config.
pub struct Config {
/// Protocol version.
pub network_id: U256,
pub network_id: usize,
/// Number of peers.
pub num_peers: usize,
}

View File

@@ -43,7 +43,7 @@ fn accounts_provider() -> Arc<AccountProvider> {
fn sync_provider() -> Arc<TestSyncProvider> {
Arc::new(TestSyncProvider::new(Config {
network_id: U256::from(3),
network_id: 3,
num_peers: 120,
}))
}
@@ -737,8 +737,8 @@ fn rpc_eth_send_transaction() {
value: U256::from(0x9184e72au64),
data: vec![]
};
let signature = tester.accounts_provider.sign(address, None, t.hash()).unwrap();
let t = t.with_signature(signature);
let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#;
@@ -754,8 +754,8 @@ fn rpc_eth_send_transaction() {
value: U256::from(0x9184e72au64),
data: vec![]
};
let signature = tester.accounts_provider.sign(address, None, t.hash()).unwrap();
let t = t.with_signature(signature);
let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#;
@@ -819,8 +819,8 @@ fn rpc_eth_send_raw_transaction() {
value: U256::from(0x9184e72au64),
data: vec![]
};
let signature = tester.accounts_provider.sign(address, None, t.hash()).unwrap();
let t = t.with_signature(signature);
let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
let rlp = ::rlp::encode(&t).to_vec().to_hex();

View File

@@ -246,8 +246,8 @@ fn should_dispatch_transaction_if_account_is_unlock() {
value: U256::from(0x9184e72au64),
data: vec![]
};
let signature = tester.accounts.sign(acc, None, t.hash()).unwrap();
let t = t.with_signature(signature);
let signature = tester.accounts.sign(acc, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
// when
let request = r#"{

View File

@@ -16,7 +16,7 @@
use std::sync::Arc;
use util::log::RotatingLogger;
use util::{U256, Address};
use util::{Address};
use ethsync::ManageNetwork;
use ethcore::client::{TestBlockChainClient};
use ethstore::ethkey::{Generator, Random};
@@ -46,7 +46,7 @@ impl Dependencies {
miner: Arc::new(TestMinerService::default()),
client: Arc::new(TestBlockChainClient::default()),
sync: Arc::new(TestSyncProvider::new(Config {
network_id: U256::from(3),
network_id: 3,
num_peers: 120,
})),
logger: Arc::new(RotatingLogger::new("rpc=trace".to_owned())),

View File

@@ -21,7 +21,7 @@ use v1::tests::helpers::{Config, TestSyncProvider};
fn sync_provider() -> Arc<TestSyncProvider> {
Arc::new(TestSyncProvider::new(Config {
network_id: 3.into(),
network_id: 3,
num_peers: 120,
}))
}

View File

@@ -201,8 +201,8 @@ fn sign_and_send_transaction() {
data: vec![]
};
tester.accounts.unlock_account_temporarily(address, "password123".into()).unwrap();
let signature = tester.accounts.sign(address, None, t.hash()).unwrap();
let t = t.with_signature(signature);
let signature = tester.accounts.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#;
@@ -219,8 +219,8 @@ fn sign_and_send_transaction() {
data: vec![]
};
tester.accounts.unlock_account_temporarily(address, "password123".into()).unwrap();
let signature = tester.accounts.sign(address, None, t.hash()).unwrap();
let t = t.with_signature(signature);
let signature = tester.accounts.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#;

View File

@@ -186,8 +186,8 @@ fn should_confirm_transaction_and_dispatch() {
data: vec![]
};
tester.accounts.unlock_account_temporarily(address, "test".into()).unwrap();
let signature = tester.accounts.sign(address, None, t.hash()).unwrap();
let t = t.with_signature(signature);
let signature = tester.accounts.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
assert_eq!(tester.signer.requests().len(), 1);