Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Revert "Transaction permissioning (#6441)"
Browse files Browse the repository at this point in the history
This reverts commit eed0e8b.
  • Loading branch information
tomusdrw committed Sep 5, 2017
1 parent 7e3c081 commit 8f96415
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 308 deletions.
2 changes: 0 additions & 2 deletions ethcore/native_contracts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const SECRETSTORE_ACL_STORAGE_ABI: &'static str = include_str!("res/secretstore_
const VALIDATOR_SET_ABI: &'static str = include_str!("res/validator_set.json");
const VALIDATOR_REPORT_ABI: &'static str = include_str!("res/validator_report.json");
const PEER_SET_ABI: &'static str = include_str!("res/peer_set.json");
const TX_ACL_ABI: &'static str = include_str!("res/tx_acl.json");

const TEST_VALIDATOR_SET_ABI: &'static str = include_str!("res/test_validator_set.json");

Expand All @@ -56,7 +55,6 @@ fn main() {
build_file("ValidatorSet", VALIDATOR_SET_ABI, "validator_set.rs");
build_file("ValidatorReport", VALIDATOR_REPORT_ABI, "validator_report.rs");
build_file("PeerSet", PEER_SET_ABI, "peer_set.rs");
build_file("TransactAcl", TX_ACL_ABI, "tx_acl.rs");

build_test_contracts();
}
3 changes: 1 addition & 2 deletions ethcore/native_contracts/generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ fn detokenize(name: &str, output_type: ParamType) -> String {
}
ParamType::Uint(width) => {
let read_uint = match width {
8 => "u[31] as u8".into(),
16 | 32 | 64 => format!("BigEndian::read_u{}(&u[{}..])", width, 32 - (width / 8)),
8 | 16 | 32 | 64 => format!("bigint::prelude::U256(u).low_u64() as u{}", width),
_ => format!("bigint::prelude::U{}::from(&u[..])", width),
};

Expand Down
1 change: 0 additions & 1 deletion ethcore/native_contracts/res/tx_acl.json

This file was deleted.

2 changes: 0 additions & 2 deletions ethcore/native_contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ mod secretstore_acl_storage;
mod validator_set;
mod validator_report;
mod peer_set;
mod tx_acl;

pub mod test_contracts;

Expand All @@ -43,4 +42,3 @@ pub use self::secretstore_acl_storage::SecretStoreAclStorage;
pub use self::validator_set::ValidatorSet;
pub use self::validator_report::ValidatorReport;
pub use self::peer_set::PeerSet;
pub use self::tx_acl::TransactAcl;
21 changes: 0 additions & 21 deletions ethcore/native_contracts/src/tx_acl.rs

This file was deleted.

4 changes: 0 additions & 4 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,10 +1448,6 @@ impl BlockChainClient for Client {
self.state_at(id).and_then(|s| s.code(address).ok()).map(|c| c.map(|c| (&*c).clone()))
}

fn code_hash(&self, address: &Address, id: BlockId) -> Option<H256> {
self.state_at(id).and_then(|s| s.code_hash(address).ok())
}

fn balance(&self, address: &Address, id: BlockId) -> Option<U256> {
self.state_at(id).and_then(|s| s.balance(address).ok())
}
Expand Down
7 changes: 0 additions & 7 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,6 @@ impl BlockChainClient for TestBlockChainClient {
}
}

fn code_hash(&self, address: &Address, id: BlockId) -> Option<H256> {
match id {
BlockId::Latest | BlockId::Pending => self.code.read().get(address).map(|c| keccak(&c)),
_ => None,
}
}

fn balance(&self, address: &Address, id: BlockId) -> Option<U256> {
match id {
BlockId::Latest | BlockId::Pending => Some(self.balances.read().get(address).cloned().unwrap_or_else(U256::zero)),
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ pub trait BlockChainClient : Sync + Send {
.expect("code will return Some if given BlockId::Latest; qed")
}

/// Get address code hash at given block's state.
fn code_hash(&self, address: &Address, id: BlockId) -> Option<H256>;

/// Get address balance at the given block's state.
///
/// May not return None if given BlockId::Latest.
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ pub enum TransactionError {
CodeBanned,
/// Invalid chain ID given.
InvalidChainId,
/// Not enough permissions given by permission contract.
NotAllowed,
}

impl fmt::Display for TransactionError {
Expand All @@ -109,7 +107,6 @@ impl fmt::Display for TransactionError {
RecipientBanned => "Recipient is temporarily banned.".into(),
CodeBanned => "Contract code is temporarily banned.".into(),
InvalidChainId => "Transaction of this chain ID is not allowed on this chain.".into(),
NotAllowed => "Sender does not have permissions to execute this type of transction".into(),
};

f.write_fmt(format_args!("Transaction error ({})", msg))
Expand Down
23 changes: 2 additions & 21 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::path::Path;
use std::cmp;
use std::collections::{BTreeMap, HashMap};
use std::sync::{Arc, Weak};
use std::sync::Arc;
use hash::{KECCAK_EMPTY_LIST_RLP};
use ethash::{quick_get_difficulty, slow_get_seedhash, EthashManager};
use bigint::prelude::U256;
Expand All @@ -32,15 +32,13 @@ use trace::{Tracer, ExecutiveTracer, RewardType};
use header::{Header, BlockNumber};
use state::CleanupMode;
use spec::CommonParams;
use transaction::{UnverifiedTransaction, SignedTransaction};
use transaction::UnverifiedTransaction;
use engines::{self, Engine};
use evm::Schedule;
use ethjson;
use rlp::{self, UntrustedRlp};
use vm::LastHashes;
use semantic_version::SemanticVersion;
use tx_filter::{TransactionFilter};
use client::{Client, BlockChainClient};

/// Parity tries to round block.gas_limit to multiple of this constant
pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
Expand Down Expand Up @@ -146,7 +144,6 @@ pub struct Ethash {
ethash_params: EthashParams,
builtins: BTreeMap<Address, Builtin>,
pow: EthashManager,
tx_filter: Option<TransactionFilter>,
}

impl Ethash {
Expand All @@ -158,7 +155,6 @@ impl Ethash {
builtins: BTreeMap<Address, Builtin>,
) -> Arc<Self> {
Arc::new(Ethash {
tx_filter: TransactionFilter::from_params(&params),
params,
ethash_params,
builtins,
Expand Down Expand Up @@ -444,28 +440,13 @@ impl Engine for Arc<Ethash> {
Ok(())
}

fn verify_transaction(&self, t: UnverifiedTransaction, header: &Header) -> Result<SignedTransaction, Error> {
let signed = SignedTransaction::new(t)?;
if !self.tx_filter.as_ref().map_or(true, |filter| filter.transaction_allowed(header.parent_hash(), &signed)) {
return Err(From::from(TransactionError::NotAllowed));
}
Ok(signed)
}

fn epoch_verifier<'a>(&self, _header: &Header, _proof: &'a [u8]) -> engines::ConstructedVerifier<'a> {
engines::ConstructedVerifier::Trusted(Box::new(self.clone()))
}

fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> {
Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS)))
}

fn register_client(&self, client: Weak<Client>) {
if let Some(ref filter) = self.tx_filter {
filter.register_client(client as Weak<BlockChainClient>);
}
}

}

// Try to round gas_limit a bit so that:
Expand Down
1 change: 0 additions & 1 deletion ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ mod executive;
mod externalities;
mod blockchain;
mod factory;
mod tx_filter;

#[cfg(test)]
mod tests;
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ pub struct CommonParams {
pub registrar: Address,
/// Node permission managing contract address.
pub node_permission_contract: Option<Address>,
/// Transaction permission managing contract address.
pub transaction_permission_contract: Option<Address>,
}

impl CommonParams {
Expand Down Expand Up @@ -180,7 +178,6 @@ impl From<ethjson::spec::Params> for CommonParams {
block_reward: p.block_reward.map_or_else(U256::zero, Into::into),
registrar: p.registrar.map_or_else(Address::new, Into::into),
node_permission_contract: p.node_permission_contract.map(Into::into),
transaction_permission_contract: p.transaction_permission_contract.map(Into::into),
}
}
}
Expand Down
Loading

0 comments on commit 8f96415

Please sign in to comment.