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
19 changes: 19 additions & 0 deletions .buildkite/rust/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ export INTEL_SGX_SDK="/opt/sgxsdk"
export EKIDEN_UNSAFE_SKIP_AVR_VERIFY="1"
export RUST_BACKTRACE="1"

##################################
# Set up RUSTFLAGS for the build #
##################################
if [ -z ${RUSTLINT+x} ]; then
RUSTLINT=""
for opt in $(cat .buildkite/rust/lint.txt | grep -v '#'); do
RUSTLINT=$RUSTLINT" -D "$opt
done

export RUSTLINT
if [ -z ${RUSTFLAGS+x} ]; then
export RUSTFLAGS=$RUSTLINT
else
export RUSTFLAGS=$RUSTFLAGS" "$RUSTLINT
fi

echo "Using RUSTFLAGS="$RUSTFLAGS
fi

####################################################
# By default, .bashrc will quit if the shell
# is not interactive. It checks whether $PS1 is
Expand Down
32 changes: 32 additions & 0 deletions .buildkite/rust/lint.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity is this an exhaustive list? I assume not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got the list from here https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md. It's not exhaustive since rust still adds/deprecates lints with quite some frequency. Based on that post, it looks like this is a reasonable set. Let me know if there's any other lint that you think should be added

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 this is great to start. We can add/subtract as necessary in the future.

# list of lints that will be used to compile the code
# elements after a '#' will be ignored
#
bad-style
const-err
dead-code
improper-ctypes
legacy-directory-ownership
non-shorthand-field-patterns
no-mangle-generic-items
overflowing-literals
path-statements
patterns-in-fns-without-body
plugin-as-library
private-in-public
safe-extern-statics
unconditional-recursion
unions-with-drop-fields
# unused
unused-allocation
unused-comparisons
unused-parens
while-true
# missing-debug-implementations
# missing-docs
# trivial-casts
# trivial-numeric-casts
# unused-extern-crates
# unused-import-braces
# unused-qualifications
# unused-results
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions api/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Build crate for the ekiden api.

extern crate ekiden_tools;

fn main() {
Expand Down
1 change: 0 additions & 1 deletion api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate protobuf;
extern crate serde;

#[macro_use]
extern crate serde_derive;
Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! build crate for the ekiden runtime based enclave
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//! build crate for the ekiden runtime based enclave
//! Build crate for the ekiden runtime based enclave.


extern crate ekiden_edl;
extern crate ekiden_tools;

Expand Down
3 changes: 0 additions & 3 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ keccak-hash = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
lazy_static = { version = "1.1.0", features = ["spin_no_std"] }
sodalite = "0.3.0"

[target.'cfg(not(target_env = "sgx"))'.dependencies]
rand = "0.4.2"

[dev-dependencies]
ekiden-storage-dummy = { git = "https://github.com/oasislabs/ekiden", branch = "master" }

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
4 changes: 4 additions & 0 deletions common/src/confidential/key_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ impl KeyManagerClient {
}
}

#[cfg(not(feature = "test"))]
#[derive(Debug)]
/// Wrapper around the Ekiden key manager client to provide a more convenient
/// Ethereum address based interface along with runtime-specific utility methods.
struct KeyManager;

#[cfg(not(feature = "test"))]
impl KeyManager {
/// Returns the contract id for the given contract address. The contract_id
/// is used to fetch keys for a contract.
Expand Down
7 changes: 1 addition & 6 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ extern crate keccak_hash;
#[macro_use]
extern crate lazy_static;

#[cfg(not(target_env = "sgx"))]
extern crate rand;

#[cfg(target_env = "sgx")]
extern crate sgx_rand;

pub mod confidential;

use std::{
Expand Down Expand Up @@ -318,6 +312,7 @@ where
}
}

#[derive(Debug)]
/// Blockchain state database.
pub struct BlockchainStateDb<T: Database + Send + Sync> {
db: Mutex<T>,
Expand Down
12 changes: 0 additions & 12 deletions gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ authors = ["Oasis Labs Inc. <[email protected]>", "Parity Technologies <admin@p

[dependencies]
log = "0.4"
env_logger = "0.4"
rustc-hex = "1.0"
parking_lot = "0.5"
rayon = "1.0"
regex = "0.2"
toml = "0.4"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
Expand All @@ -21,7 +17,6 @@ ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
jsonrpc-ipc-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
lazy_static = "1.0.1"
Expand All @@ -32,18 +27,12 @@ ethcore-transaction = { git = "https://github.com/oasislabs/parity", branch = "e
ethereum-types = { git = "https://github.com/oasislabs/primitives", branch = "ekiden" }
rlp = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
rlp_compress = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
parity-machine = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
parity-reactor = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
parity-rpc = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
path = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
keccak-hash = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
kvdb = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
journaldb = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
mem = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
evm = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
common-types = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
vm = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }
util-error = { git = "https://github.com/oasislabs/parity", branch = "ekiden" }

## Common functionality between runtime and gateway
runtime-ethereum-common = { path = "../common" }
Expand All @@ -56,7 +45,6 @@ ekiden-runtime-client = { git = "https://github.com/oasislabs/ekiden", branch =
ekiden-core = { git = "https://github.com/oasislabs/ekiden", branch = "master" }
ekiden-db-trusted = { git = "https://github.com/oasislabs/ekiden", branch = "master" }
ekiden-instrumentation = { git = "https://github.com/oasislabs/ekiden", branch = "master" }
ekiden-rpc-client = { git = "https://github.com/oasislabs/ekiden", branch = "master" }
ekiden-storage-base = { git = "https://github.com/oasislabs/ekiden", branch = "master" }
ekiden-tracing = { git = "https://github.com/oasislabs/ekiden", branch = "master" }
ekiden-keymanager-client = { git = "https://github.com/oasislabs/ekiden", branch = "master" }
Expand Down
2 changes: 1 addition & 1 deletion gateway/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

//! web3 gateway for Oasis Ethereum runtime.

#![deny(warnings)]
extern crate ctrlc;
extern crate fdlimit;
extern crate log;
extern crate parking_lot;
#[macro_use]
extern crate clap;
extern crate rand;

#[macro_use]
extern crate client_utils;
Expand Down
15 changes: 7 additions & 8 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 @@ -86,9 +85,11 @@ pub trait ChainNotify: Send + Sync {
pub struct Client {
client: runtime_ethereum::Client,
engine: Arc<EthEngine>,
#[cfg(not(test))]
snapshot_manager: Option<client_utils::db::Manager>,
eip86_transition: u64,
environment: Arc<Environment>,
#[cfg(not(test))]
storage_backend: Arc<StorageBackend>,
/// The most recent block for which we have sent notifications.
notified_block_number: Mutex<BlockNumber>,
Expand Down Expand Up @@ -118,9 +119,11 @@ impl Client {
Self {
client: client,
engine: spec.engine.clone(),
#[cfg(not(test))]
snapshot_manager: snapshot_manager,
eip86_transition: spec.params().eip86_transition,
environment,
#[cfg(not(test))]
storage_backend: backend,
// start at current block
notified_block_number: Mutex::new(current_block_number),
Expand All @@ -140,10 +143,8 @@ impl Client {
Self {
client: test_helpers::get_test_runtime_client(),
engine: spec.engine.clone(),
snapshot_manager: None,
eip86_transition: spec.params().eip86_transition,
environment: environment,
storage_backend: Arc::new(DummyStorageBackend::new()),
notified_block_number: Mutex::new(0),
listeners: RwLock::new(vec![]),
gas_price: U256::from(1_000_000_000),
Expand Down Expand Up @@ -817,9 +818,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 +829,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 +849,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
2 changes: 2 additions & 0 deletions gateway/src/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ impl RpcStats {
.unwrap_or(0)
}

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

#[cfg(test)]
/// Returns requests rate
pub fn requests_rate(&self, id: &H256) -> usize {
self.sessions
Expand Down
Loading