Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

warnings as errors #583

Merged
merged 14 commits into from
Feb 15, 2019
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mac things
.DS_Store

# Build.
n# Build.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you added this by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, let me fix it

tests/build
target/
**/*.rs.bk
Expand Down Expand Up @@ -52,3 +52,7 @@ tests/rpc-tests/

# Coverage report from Tarpaulin
cobertura.xml

# in case credentials are put in the repo for using
# inside the docker container
.git-credentials
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline.

1 change: 1 addition & 0 deletions api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(warnings)]
extern crate protobuf;
extern crate serde;

Expand Down
1 change: 1 addition & 0 deletions common/src/confidential/confidential_ctx.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(warnings)]
use super::key_manager::KeyManagerClient;
use ekiden_core::mrae::{
nonce::{Nonce, NONCE_SIZE},
Expand Down
54 changes: 1 addition & 53 deletions common/src/confidential/key_manager.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#[cfg(feature = "test")]
use ekiden_core::random;
use ekiden_keymanager_client::KeyManager as EkidenKeyManager;
use ekiden_keymanager_common::{ContractId, ContractKey};
use ekiden_keymanager_common::ContractKey;
#[cfg(feature = "test")]
use ekiden_keymanager_common::{
PublicKeyType, EMPTY_PRIVATE_KEY, EMPTY_PUBLIC_KEY, EMPTY_STATE_KEY,
};
use ethereum_types::Address;
use keccak_hash::keccak;
#[cfg(feature = "test")]
use std::collections::HashMap;
#[cfg(feature = "test")]
Expand Down Expand Up @@ -41,56 +39,6 @@ impl KeyManagerClient {
}
}

/// Wrapper around the Ekiden key manager client to provide a more convenient
/// Ethereum address based interface along with runtime-specific utility methods.
struct KeyManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What made you delete this? We still need it. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was just not being used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely used. See KeyManagerClient. We do some conditional compilation for testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The e2e tests will fail if this is deleted.

impl KeyManager {
/// Returns the contract id for the given contract address. The contract_id
/// is used to fetch keys for a contract.
fn contract_id(contract: Address) -> ContractId {
ContractId::from(&keccak(contract.to_vec())[..])
}

/// Creates and returns the long term public key for the given contract.
/// If the key already exists, returns the existing key.
/// Returns the tuple (public_key, signature_{KeyManager}(public_key)).
fn create_long_term_public_key(contract: Address) -> Result<(Vec<u8>, Vec<u8>), String> {
let contract_id = Self::contract_id(contract);
let mut km = EkidenKeyManager::instance().expect("Should always have a key manager client");

// first create the keys
km.get_or_create_secret_keys(contract_id)
.map_err(|err| err.description().to_string())?;
// then extract the long term key
km.long_term_public_key(contract_id)
.map_err(|err| err.description().to_string())
.map(|pk_payload| {
(
pk_payload.public_key.to_vec(),
pk_payload.signature.to_vec(),
)
})
}

fn contract_key(address: Address) -> Result<ContractKey, String> {
let contract_id = Self::contract_id(address);
let mut km = EkidenKeyManager::instance().expect("Should always have a key manager client");

let (secret_key, state_key) = km
.get_or_create_secret_keys(contract_id)
.map_err(|err| err.description().to_string())?;
let public_key_payload = km
.get_public_key(contract_id)
.map_err(|err| err.description().to_string())?;

Ok(ContractKey::new(
public_key_payload.public_key,
secret_key,
state_key,
))
}
}

#[cfg(feature = "test")]
lazy_static! {
static ref TEST_KEY_MANAGER: Mutex<TestKeyManager> = Mutex::new(TestKeyManager::new());
Expand Down
1 change: 1 addition & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Common data structures shared by runtime and gateway.

#![deny(warnings)]
extern crate ekiden_core;
extern crate ekiden_keymanager_client;
extern crate ekiden_keymanager_common;
Expand Down
1 change: 1 addition & 0 deletions gateway/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! web3 gateway for Oasis Ethereum runtime.

#![deny(warnings)]
extern crate ctrlc;
extern crate fdlimit;
extern crate log;
Expand Down
9 changes: 3 additions & 6 deletions gateway/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ use hash::keccak;
use parity_rpc::v1::types::Bytes as RpcBytes;
use runtime_ethereum;
use runtime_ethereum_common::{confidential::has_confidential_prefix, State as EthState};
use std::time::{SystemTime, UNIX_EPOCH};
use traits::confidential::PublicKeyResult;
use transaction::{Action, LocalizedTransaction, SignedTransaction};

use client_utils::{self, db::Snapshot};
use ekiden_common::{bytes::B512, environment::Environment};
use ekiden_common::environment::Environment;
use ekiden_core::{error::Error, futures::prelude::*};
use ekiden_db_trusted::Database;
use ekiden_keymanager_client::KeyManager as EkidenKeyManager;
Expand Down Expand Up @@ -817,9 +816,9 @@ impl Client {
.is_confidential(transaction)
.map_err(|_| CallError::StateCorrupt)?
{
self.confidential_estimate_gas(transaction, id)
self.confidential_estimate_gas(transaction)
} else {
self._estimate_gas(transaction, id, db, state)
self._estimate_gas(transaction, db, state)
}
}

Expand All @@ -828,7 +827,6 @@ impl Client {
fn _estimate_gas<T: 'static + Database + Send + Sync>(
&self,
transaction: &SignedTransaction,
id: BlockId,
db: StateDb<T>,
mut state: EthState,
) -> Result<U256, CallError> {
Expand All @@ -849,7 +847,6 @@ impl Client {
fn confidential_estimate_gas(
&self,
transaction: &SignedTransaction,
id: BlockId,
) -> Result<U256, CallError> {
info!("estimating gas for a confidential contract");

Expand Down
15 changes: 3 additions & 12 deletions gateway/src/impls/confidential.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
use client::Client;
use ekiden_common::bytes::B512;
use ekiden_core::futures::FutureExt;
use ekiden_keymanager_common::confidential;
use ethereum_api::TransactionRequest;
use ethereum_types::Address;
use impls::eth::EthClient;
use jsonrpc_core::{
futures::{future, Future},
BoxFuture, Error, ErrorCode, Result,
};
use jsonrpc_core::{futures::Future, BoxFuture, Error, ErrorCode, Result};
use jsonrpc_macros::Trailing;
use parity_rpc::v1::{
helpers::errors,
metadata::Metadata,
traits::Eth,
types::{BlockNumber, Bytes, CallRequest, H256},
types::{BlockNumber, Bytes, CallRequest},
};
use std::sync::Arc;
use traits::confidential::{Confidential, PublicKeyResult};

pub struct ConfidentialClient {
client: Arc<Client>,
eth_client: EthClient,
}

impl ConfidentialClient {
pub fn new(client: Arc<Client>) -> Self {
ConfidentialClient {
client: client.clone(),
eth_client: EthClient::new(&client),
}
}
}
Expand All @@ -45,7 +36,7 @@ impl Confidential for ConfidentialClient {

fn call_enc(
&self,
meta: Self::Metadata,
_meta: Self::Metadata,
request: CallRequest,
tag: Trailing<BlockNumber>,
) -> BoxFuture<Bytes> {
Expand Down
7 changes: 3 additions & 4 deletions gateway/src/impls/oasis.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::{str::FromStr, sync::Arc};
use std::sync::Arc;

use ekiden_common::bytes::H256;
use ekiden_core::futures::Future;

use ethereum_types::Address;
use jsonrpc_core::{futures::future, BoxFuture, Error, ErrorCode, Result};
use jsonrpc_core::{BoxFuture, Error, ErrorCode};
use jsonrpc_macros::Trailing;
use parity_rpc::v1::types::{BlockNumber, H160 as RpcH160, H256 as RpcH256};
use parity_rpc::v1::types::{BlockNumber, H160 as RpcH160};

use client::Client;
use impls::eth::EthClient;
Expand Down
14 changes: 0 additions & 14 deletions gateway/src/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ impl RpcStats {
.map(|calc| calc.write().tick())
.unwrap_or(0)
}

/// Returns number of open sessions
pub fn sessions(&self) -> usize {
self.sessions.read().len()
}

/// Returns requests rate
pub fn requests_rate(&self, id: &H256) -> usize {
self.sessions
.read()
.get(id)
.map(|calc| calc.read().rate())
.unwrap_or(0)
}
}

#[cfg(test)]
Expand Down
5 changes: 2 additions & 3 deletions gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

//! Ethcore client application.
#![deny(warnings)]

#[macro_use]
extern crate clap;
extern crate env_logger;
#[macro_use]
extern crate futures;
#[macro_use]
extern crate lazy_static;
Expand All @@ -45,7 +45,6 @@ extern crate jsonrpc_pubsub;
extern crate jsonrpc_ws_server;

extern crate common_types;
#[macro_use]
extern crate ethcore;
extern crate ethcore_bytes as bytes;
extern crate ethcore_transaction as transaction;
Expand Down Expand Up @@ -119,7 +118,7 @@ use ethereum_types::U256;

use ekiden_core::{environment::Environment, x509};
use ekiden_runtime_client::create_runtime_client;
use ekiden_storage_base::{BackendIdentityMapper, StorageBackend};
use ekiden_storage_base::BackendIdentityMapper;
use ethereum_api::with_api;

pub use self::run::RunningClient;
Expand Down
6 changes: 0 additions & 6 deletions gateway/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ pub struct HttpConfiguration {
pub max_batch_size: usize,
}

impl HttpConfiguration {
pub fn address(&self) -> Option<rpc::Host> {
address(self.enabled, &self.interface, self.port, &self.hosts)
}
}

impl Default for HttpConfiguration {
fn default() -> Self {
HttpConfiguration {
Expand Down
3 changes: 0 additions & 3 deletions gateway/src/rpc_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ impl FromStr for Api {

#[derive(Debug, Clone)]
pub enum ApiSet {
// Safe context (like token-protected WS interface)
SafeContext,
// Unsafe context (like jsonrpc over http)
UnsafeContext,
// All possible APIs
Expand Down Expand Up @@ -239,7 +237,6 @@ impl ApiSet {
match *self {
ApiSet::List(ref apis) => apis.clone(),
ApiSet::UnsafeContext => public_list,
ApiSet::SafeContext => public_list,
ApiSet::All => public_list,
}
}
Expand Down
3 changes: 1 addition & 2 deletions gateway/src/traits/confidential.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use ekiden_common::bytes::B512;
use ethereum_types::Address;
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_macros::Trailing;
use parity_rpc::v1::types::{BlockNumber, Bytes, CallRequest, H256};
use parity_rpc::v1::types::{BlockNumber, Bytes, CallRequest};

build_rpc_trait! {
pub trait Confidential {
Expand Down
4 changes: 2 additions & 2 deletions gateway/src/traits/oasis.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Oasis rpc interface.

use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_core::BoxFuture;
use jsonrpc_macros::Trailing;

use parity_rpc::v1::types::{BlockNumber, H160, H256};
use parity_rpc::v1::types::{BlockNumber, H160};

build_rpc_trait! {
pub trait Oasis {
Expand Down
1 change: 1 addition & 0 deletions genesis/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(warnings)]
extern crate clap;
extern crate ethcore;
extern crate ethereum_types;
Expand Down
1 change: 1 addition & 0 deletions inspector/parity_patricia_trie/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Trie interface and implementation.
// extern crate rand;
#![deny(warnings)]
extern crate elastic_array;
extern crate ethcore_bytes as bytes;
extern crate ethereum_types;
Expand Down
1 change: 1 addition & 0 deletions inspector/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(warnings)]
extern crate clap;
extern crate ethcore;
extern crate ethereum_types;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(warnings)]
extern crate common_types as ethcore_types;
extern crate ekiden_common;
extern crate ekiden_core;
Expand Down