Merge branch 'master' into jsonrpc

This commit is contained in:
debris 2016-02-06 21:31:46 +01:00
commit 4116bdd8fd
10 changed files with 566 additions and 275 deletions

View File

@ -55,6 +55,7 @@ env:
global: global:
- secure: 3sUjNi9mhdL5h1GTm8LONnDN/SYvUHT+WSkMl93h3nYiLCQXk8eZaPS98AS7oOaTsfW4UvnwckVFCFl49ttInsv4cd/TkAxmrJHe6kPyS9/4NWUdmP8BjicbBvL/ioSdXMECMEYzPDLV+I3KhtC2LcB6ceDEl/XwMOJlzbGf7RbtcXGVQgMLqSYY1YKjQA4vbT5nFgIS/sZu3Z9yFgN0GafnihKcizqoHhdJjs/zxmX+qJepnC6o3V6KcFnS7QHhM1JOr85twE6S422UlvNaEb5ovwLPqmOl5+fA+6shbx4AxFTY6E9Iors+OVY/JliFhrqOdCt0i2P1FUHN4kbGZQkf0rphN/ZOI2uKNFTOyXiPvppfo/ZemKmcqkwkqP9+lf5QqYmtE6hsAYagxn49xJZILl8tAYbdqxF5gxa+TEVrfsBFtz/Sv3q8QhKQNPAmjEcKyMatyEreLUIFEpFTGIco8jN4eXeSoLRdJ+Z75ihttfQWhNfUDgNL30iQLy0AgFSsh/cyb5M8y9lxrGDzDTogvaiKGwr/V45sPkcXWCkmOgMdINqBB6ZtdL3bGHdyjmYj+y3btjf3aP11k++BL0fXIaKn25aS/p/9iyGb1FyGCM03o4ZRQ3YhTOvfMRfRGf6nWbaMx9upv8o5ShSdysewhrnh3082r7u896ny1Ho= - secure: 3sUjNi9mhdL5h1GTm8LONnDN/SYvUHT+WSkMl93h3nYiLCQXk8eZaPS98AS7oOaTsfW4UvnwckVFCFl49ttInsv4cd/TkAxmrJHe6kPyS9/4NWUdmP8BjicbBvL/ioSdXMECMEYzPDLV+I3KhtC2LcB6ceDEl/XwMOJlzbGf7RbtcXGVQgMLqSYY1YKjQA4vbT5nFgIS/sZu3Z9yFgN0GafnihKcizqoHhdJjs/zxmX+qJepnC6o3V6KcFnS7QHhM1JOr85twE6S422UlvNaE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J98EYIg3WPJuC93waTTXcS0xDyy09XHxWxZ/5PiXorRZjpHvnZfRF0X4Mus6jUJ7hqDuOUiF5BI1RHomHvJQQHUrLdmh7OHyrer3YUpKRs65tww6H+VM+lKNa3MnMkB5+or/co14svs7I4pni9S+aZg//bwuxGVXchK6bjLCP1X99Ar4fA5EGsTVdjp3PRqutM/P3RqNGkwTczat/PNZ8fFAD9y7pDs2L6YkqpflTC9d6vKTSl6gORGw6ltLUJs23ON6xRNIBMw1cXp67wN57vF46TPt1i3ZlIQsYn0pAVNKavbZE=
deploy: deploy:
provider: releases provider: releases
@ -64,3 +65,11 @@ deploy:
file: parity${ARCHIVE_SUFFIX}.tar.gz file: parity${ARCHIVE_SUFFIX}.tar.gz
on: on:
tags: true tags: true
notifications:
webhooks:
urls:
- https://hooks.slack.com/services/${SLACK_WEBHOOK}
on_success: always
on_failure: always
on_start: never

View File

@ -17,6 +17,7 @@ ethcore-util = { path = "util" }
ethcore = { path = "ethcore" } ethcore = { path = "ethcore" }
ethsync = { path = "sync" } ethsync = { path = "sync" }
ethcore-rpc = { path = "rpc", optional = true } ethcore-rpc = { path = "rpc", optional = true }
fdlimit = { path = "util/fdlimit" }
[features] [features]
default = ["rpc"] default = ["rpc"]

View File

@ -17,7 +17,7 @@
//! Blockchain database client. //! Blockchain database client.
use util::*; use util::*;
use rocksdb::{Options, DB}; use rocksdb::{Options, DB, DBCompactionStyle};
use blockchain::{BlockChain, BlockProvider, CacheSize}; use blockchain::{BlockChain, BlockProvider, CacheSize};
use views::BlockView; use views::BlockView;
use error::*; use error::*;
@ -163,16 +163,23 @@ pub struct Client {
} }
const HISTORY: u64 = 1000; const HISTORY: u64 = 1000;
const CLIENT_DB_VER_STR: &'static str = "1.0";
impl Client { impl Client {
/// Create a new client with given spec and DB path. /// Create a new client with given spec and DB path.
pub fn new(spec: Spec, path: &Path, message_channel: IoChannel<NetSyncMessage> ) -> Result<Arc<Client>, Error> { pub fn new(spec: Spec, path: &Path, message_channel: IoChannel<NetSyncMessage> ) -> Result<Arc<Client>, Error> {
let mut dir = path.to_path_buf();
dir.push(H64::from(spec.genesis_header().hash()).hex());
//TODO: sec/fat: pruned/full versioning
dir.push(format!("v{}-sec-pruned", CLIENT_DB_VER_STR));
let path = dir.as_path();
let gb = spec.genesis_block(); let gb = spec.genesis_block();
let chain = Arc::new(RwLock::new(BlockChain::new(&gb, path))); let chain = Arc::new(RwLock::new(BlockChain::new(&gb, path)));
let mut opts = Options::new(); let mut opts = Options::new();
opts.set_max_open_files(256); opts.set_max_open_files(256);
opts.create_if_missing(true); opts.create_if_missing(true);
opts.set_use_fsync(false); opts.set_use_fsync(false);
opts.set_compaction_style(DBCompactionStyle::DBUniversalCompaction);
/* /*
opts.set_bytes_per_sync(8388608); opts.set_bytes_per_sync(8388608);
opts.set_disable_data_sync(false); opts.set_disable_data_sync(false);

View File

@ -48,7 +48,6 @@ impl ClientService {
info!("Configured for {} using {} engine", spec.name, spec.engine_name); info!("Configured for {} using {} engine", spec.name, spec.engine_name);
let mut dir = env::home_dir().unwrap(); let mut dir = env::home_dir().unwrap();
dir.push(".parity"); dir.push(".parity");
dir.push(H64::from(spec.genesis_header().hash()).hex());
let client = try!(Client::new(spec, &dir, net_service.io().channel())); let client = try!(Client::new(spec, &dir, net_service.io().channel()));
let client_io = Arc::new(ClientIoHandler { let client_io = Arc::new(ClientIoHandler {
client: client.clone() client: client.clone()

View File

@ -46,6 +46,7 @@ function run_installer()
dim=`tput dim` dim=`tput dim`
reverse=`tput rev` reverse=`tput rev`
reset=`tput sgr0` reset=`tput sgr0`
n=$'\n'
function head() { function head() {
@ -93,13 +94,19 @@ function run_installer()
####### Setup methods ####### Setup methods
function wait_for_user() { function wait_for_user() {
if [[ $( ask_user "$1" ) == false ]]; then
abort_install "${red}==>${reset} Process stopped by user. To resume the install run the one-liner command again."
fi
}
function ask_user() {
while : while :
do do
read -p "${blue}==>${reset} $1 [Y/n] " imp read -p "${blue}==>${reset} $1 [Y/n] " imp
case $imp in case $imp in
[yY] ) echo; break ;; [yY] ) echo true; break ;;
'' ) echo; break ;; '' ) echo true; break ;;
[nN] ) abortInstall "${red}==>${reset} Process stopped by user. To resume the install run the one-liner command again." ;; [nN] ) echo false; break ;;
* ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'"; * ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'";
esac esac
done done
@ -118,7 +125,15 @@ function run_installer()
echo "\$ $@"; "$@" echo "\$ $@"; "$@"
} }
function detectOS() { function sudo() {
if $isSudo; then
`which sudo` "$@"
else
"$@"
fi
}
function detect_os() {
if [[ "$OSTYPE" == "linux-gnu" ]] if [[ "$OSTYPE" == "linux-gnu" ]]
then then
OS_TYPE="linux" OS_TYPE="linux"
@ -129,7 +144,7 @@ function run_installer()
get_osx_dependencies get_osx_dependencies
else else
OS_TYPE="win" OS_TYPE="win"
abortInstall "${red}==>${reset} ${b}OS not supported:${reset} parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}" abort_install "${red}==>${reset} ${b}OS not supported:${reset} Parity one-liner currently support OS X and Linux.${n}For instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}"
fi fi
echo echo
@ -144,11 +159,11 @@ function run_installer()
elif [[ $canContinue == false && $depFound == 0 ]] elif [[ $canContinue == false && $depFound == 0 ]]
then then
red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)" red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)"
abortInstall "$errorMessages"; abort_install "$errorMessages";
elif [[ $canContinue == false ]] elif [[ $canContinue == false ]]
then then
red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)" red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)"
abortInstall "$errorMessages"; abort_install "$errorMessages";
fi fi
fi fi
} }
@ -191,8 +206,8 @@ function run_installer()
fi fi
fi fi
errorMessages+="${red}==>${reset} ${b}Mac OS version too old:${reset} eth requires OS X version ${red}$OSX_REQUIERED_VERSION${reset} at least in order to run.\n" errorMessages+="${red}==>${reset} ${b}Mac OS version too old:${reset} eth requires OS X version ${red}$OSX_REQUIERED_VERSION${reset} at least in order to run.${n}"
errorMessages+=" Please update the OS and reload the install process.\n" errorMessages+=" Please update the OS and reload the install process.${n}"
} }
function find_eth() function find_eth()
@ -243,8 +258,8 @@ function run_installer()
uncheck "Ruby is missing 🔥" uncheck "Ruby is missing 🔥"
isRuby=false isRuby=false
canContinue=false canContinue=false
errorMessages+="${red}==>${reset} ${b}Couldn't find Ruby:${reset} Brew requires Ruby which could not be found.\n" errorMessages+="${red}==>${reset} ${b}Couldn't find Ruby:${reset} Brew requires Ruby which could not be found.${n}"
errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.\n" errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.${n}"
fi fi
} }
@ -261,10 +276,10 @@ function run_installer()
uncheck "Homebrew is missing" uncheck "Homebrew is missing"
isBrew=false isBrew=false
INSTALL_FILES+="${blue}${dim}==> Homebrew:${reset}\n" INSTALL_FILES+="${blue}${dim}==> Homebrew:${reset}${n}"
INSTALL_FILES+=" ${blue}${dim}${reset} $HOMEBREW_PREFIX/bin/brew\n" INSTALL_FILES+=" ${blue}${dim}${reset} $HOMEBREW_PREFIX/bin/brew${n}"
INSTALL_FILES+=" ${blue}${dim}${reset} $HOMEBREW_PREFIX/Library\n" INSTALL_FILES+=" ${blue}${dim}${reset} $HOMEBREW_PREFIX/Library${n}"
INSTALL_FILES+=" ${blue}${dim}${reset} $HOMEBREW_PREFIX/share/man/man1/brew.1\n" INSTALL_FILES+=" ${blue}${dim}${reset} $HOMEBREW_PREFIX/share/man/man1/brew.1${n}"
fi fi
depCount=$((depCount+1)) depCount=$((depCount+1))
@ -314,7 +329,7 @@ function run_installer()
if [[ $isBrew == false ]] if [[ $isBrew == false ]]
then then
abortInstall "Couldn't install brew" abort_install "Couldn't install brew"
fi fi
fi fi
} }
@ -359,16 +374,16 @@ function run_installer()
source /etc/lsb-release source /etc/lsb-release
if [[ $DISTRIB_ID == "Ubuntu" ]]; then if [[ $DISTRIB_ID == "Ubuntu" ]]; then
if [[ $DISTRIB_RELEASE == "14.04" ]]; then if [[ $DISTRIB_RELEASE == "14.04" || $DISTRIB_RELEASE == "15.04" || $DISTRIB_RELEASE == "15.10" ]]; then
check "Ubuntu-14.04" check "Ubuntu"
isUbuntu1404=true isUbuntu=true
else else
check "Ubuntu, but not 14.04" check "Ubuntu, but version not supported"
isUbuntu1404=false isUbuntu=false
fi fi
else else
check "Ubuntu not found" check "Ubuntu not found"
isUbuntu1404=false isUbuntu=false
fi fi
} }
@ -385,6 +400,7 @@ function run_installer()
find_gcc find_gcc
find_apt find_apt
find_sudo
} }
function find_rocksdb() function find_rocksdb()
@ -394,10 +410,11 @@ function run_installer()
depFound=$((depFound+1)) depFound=$((depFound+1))
check "apt-get" check "apt-get"
isRocksDB=true isRocksDB=true
INSTALL_FILES+="${blue}${dim}==> librocksdb:${reset}$n"
else else
uncheck "librocksdb is missing" uncheck "librocksdb is missing"
isRocksDB=false isRocksDB=false
INSTALL_FILES+="${blue}${dim}==> librocksdb:${reset}\n" INSTALL_FILES+="${blue}${dim}==> librocksdb:${reset}$n"
fi fi
} }
@ -416,14 +433,14 @@ function run_installer()
else else
uncheck "rust is not nightly" uncheck "rust is not nightly"
isMultirustNightly=false isMultirustNightly=false
INSTALL_FILES+="${blue}${dim}==> multirust -> rust nightly:${reset}\n" INSTALL_FILES+="${blue}${dim}==> multirust -> rust nightly:${reset}${n}"
fi fi
else else
uncheck "multirust is missing" uncheck "multirust is missing"
uncheck "rust nightly is missing" uncheck "rust nightly is missing"
isMultirust=false isMultirust=false
isMultirustNightly=false isMultirustNightly=false
INSTALL_FILES+="${blue}${dim}==> multirust:${reset}\n" INSTALL_FILES+="${blue}${dim}==> multirust:${reset}${n}"
fi fi
} }
@ -444,8 +461,8 @@ function run_installer()
if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then
canContinue=false canContinue=false
errorMessages+="${red}==>${reset} ${b}Couldn't find apt-get:${reset} We can only use apt-get in order to grab our dependencies.\n" errorMessages+="${red}==>${reset} ${b}Couldn't find apt-get:${reset} We can only use apt-get in order to grab our dependencies.${n}"
errorMessages+=" Please switch to a distribution such as Debian or Ubuntu or manually install the missing packages.\n" errorMessages+=" Please switch to a distribution such as Debian or Ubuntu or manually install the missing packages.${n}"
fi fi
fi fi
} }
@ -463,7 +480,35 @@ function run_installer()
else else
uncheck "g++ is missing" uncheck "g++ is missing"
isGCC=false isGCC=false
INSTALL_FILES+="${blue}${dim}==> g++:${reset}\n" INSTALL_FILES+="${blue}${dim}==> g++:${reset}${n}"
fi
}
function find_sudo()
{
depCount=$((depCount+1))
SUDO_PATH=`which sudo 2>/dev/null`
if [[ -f $SUDO_PATH ]]
then
depFound=$((depFound+1))
check "sudo"
isSudo=true
else
uncheck "sudo is missing"
if [[ `whoami` == "root" ]]; then
if [[ $isApt == false && $isMultirust == false ]]; then
canContinue=false
errorMessages+="${red}==>${reset} ${b}Couldn't find sudo:${reset} Sudo is needed for the installation of multirust.${n}"
errorMessages+=" Please ensure you have sudo installed or alternatively install multirust manually.${n}"
fi
isSudo=false
else
canContinue=false
errorMessages+="${red}==>${reset} ${b}Couldn't find sudo:${reset} Root access is needed for parts of this installation.${n}"
errorMessages+=" Please ensure you have sudo installed or alternatively run this script as root.${n}"
fi
fi fi
} }
@ -480,7 +525,7 @@ function run_installer()
else else
uncheck "git is missing" uncheck "git is missing"
isGit=false isGit=false
INSTALL_FILES+="${blue}${dim}==> git:${reset}\n" INSTALL_FILES+="${blue}${dim}==> git:${reset}${n}"
fi fi
} }
@ -497,7 +542,7 @@ function run_installer()
else else
uncheck "make is missing" uncheck "make is missing"
isMake=false isMake=false
INSTALL_FILES+="${blue}${dim}==> make:${reset}\n" INSTALL_FILES+="${blue}${dim}==> make:${reset}${n}"
fi fi
} }
@ -514,15 +559,15 @@ function run_installer()
else else
uncheck "curl is missing" uncheck "curl is missing"
isCurl=false isCurl=false
INSTALL_FILES+="${blue}${dim}==> curl:${reset}\n" INSTALL_FILES+="${blue}${dim}==> curl:${reset}${n}"
fi fi
} }
function ubuntu1404_rocksdb_installer() function ubuntu_rocksdb_installer()
{ {
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get install -qq -y software-properties-common sudo apt-get install -qq -y software-properties-common
sudo apt-add-repository -y ppa:giskou/librocksdb sudo apt-add-repository -y ppa:ethcore/ethcore
sudo apt-get -f -y install sudo apt-get -f -y install
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get install -qq -y librocksdb sudo apt-get install -qq -y librocksdb
@ -530,12 +575,12 @@ function run_installer()
function linux_rocksdb_installer() function linux_rocksdb_installer()
{ {
if [[ $isUbuntu1404 == true ]]; then if [[ $isUbuntu == true ]]; then
ubuntu1404_rocksdb_installer ubuntu_rocksdb_installer
else else
oldpwd=`pwd` oldpwd=`pwd`
cd /tmp cd /tmp
exe git clone --branch v4.1 --depth=1 https://github.com/facebook/rocksdb.git exe git clone --branch v4.2 --depth=1 https://github.com/facebook/rocksdb.git
cd rocksdb cd rocksdb
exe make shared_lib exe make shared_lib
sudo cp -a librocksdb.so* /usr/lib sudo cp -a librocksdb.so* /usr/lib
@ -574,6 +619,9 @@ function run_installer()
if [[ $isMultirust == false ]]; then if [[ $isMultirust == false ]]; then
info "Installing multirust..." info "Installing multirust..."
if [[ $isSudo == false ]]; then
apt-get install -q -y sudo
fi
curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes
echo echo
fi fi
@ -613,7 +661,7 @@ function run_installer()
find_multirust find_multirust
if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then
abortInstall abort_install
fi fi
fi fi
} }
@ -709,10 +757,10 @@ EOL
cd .. cd ..
} }
function abortInstall() function abort_install()
{ {
echo echo
error "Installation failed" error "Installation aborted"
echo -e "$1" echo -e "$1"
echo echo
exit 0 exit 0
@ -737,7 +785,7 @@ EOL
# Check dependencies # Check dependencies
head "Checking OS dependencies" head "Checking OS dependencies"
detectOS detect_os
if [[ $INSTALL_FILES != "" ]]; then if [[ $INSTALL_FILES != "" ]]; then
echo echo
@ -757,14 +805,14 @@ EOL
if [[ ! -e parity ]]; then if [[ ! -e parity ]]; then
# Maybe install parity # Maybe install parity
if wait_for_user "${b}Build dependencies installed B-)!${reset} Would you like to download and build parity?"; then if [[ $(ask_user "${b}Parity${reset} Would you like to download and build parity?") == true ]]; then
# Do get parity. # Do get parity.
build_parity build_parity
fi fi
fi fi
if [[ $OS_TYPE == "linux" && $DISTRIB_ID == "Ubuntu" ]]; then if [[ $OS_TYPE == "linux" && $DISTRIB_ID == "Ubuntu" ]]; then
if wait_for_user "${b}Netstats:${reset} Would you like to install and configure a netstats client?"; then if [[ $(ask_user "${b}Netstats${reset} Would you like to download, install and configure a Netstats client?${n}${b}${red}WARNING: ${reset}${red}This will need a secret and reconfigure any existing node/NPM installation you have.${reset} ") == true ]]; then
install_netstats install_netstats
fi fi
fi fi

View File

@ -1,9 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/parity_0.9.0-0_amd64.deb PARITY_DEB_URL=https://github.com/ethcore/parity/releases/download/beta-0.9/parity_0.9.0-0_amd64.deb
function run_installer() function run_installer()
{ {
####### Init vars ####### Init vars
@ -13,7 +12,6 @@ function run_installer()
HOMEBREW_REPO=https://github.com/Homebrew/homebrew HOMEBREW_REPO=https://github.com/Homebrew/homebrew
OSX_REQUIERED_VERSION="10.7.0" OSX_REQUIERED_VERSION="10.7.0"
declare OS_TYPE declare OS_TYPE
declare OSX_VERSION declare OSX_VERSION
declare GIT_PATH declare GIT_PATH
@ -26,13 +24,11 @@ function run_installer()
isGit=false isGit=false
isRuby=false isRuby=false
isBrew=false isBrew=false
isDocker=false
canContinue=true canContinue=true
depCount=0 depCount=0
depFound=0 depFound=0
####### Setup colors ####### Setup colors
red=`tput setaf 1` red=`tput setaf 1`
@ -119,6 +115,9 @@ function run_installer()
done done
} }
function exe() {
echo "\$ $@"; "$@"
}
function detectOS() { function detectOS() {
if [[ "$OSTYPE" == "linux-gnu" ]] if [[ "$OSTYPE" == "linux-gnu" ]]
@ -155,14 +154,6 @@ function run_installer()
fi fi
} }
function get_osx_dependencies()
{
macos_version
find_git
find_ruby
find_brew
}
function macos_version() function macos_version()
{ {
declare -a reqVersion declare -a reqVersion
@ -197,56 +188,45 @@ function run_installer()
errorMessages+=" Please update the OS and reload the install process.\n" errorMessages+=" Please update the OS and reload the install process.\n"
} }
function find_eth() function get_osx_dependencies()
{ {
ETH_PATH=`which parity 2>/dev/null` macos_version
find_git
find_ruby
find_brew
}
if [[ -f $ETH_PATH ]] function linux_version()
then {
check "Found parity: $ETH_PATH" source /etc/lsb-release
isEth=true
if [[ $DISTRIB_ID == "Ubuntu" ]]; then
if [[ $DISTRIB_RELEASE == "14.04" ]]; then
check "Ubuntu-14.04"
isUbuntu1404=true
else else
uncheck "parity is missing" check "Ubuntu, but not 14.04"
isEth=false isUbuntu1404=false
fi
else
check "Ubuntu not found"
isUbuntu1404=false
fi fi
} }
function find_git() function get_linux_dependencies()
{ {
depCount=$((depCount+1)) linux_version
GIT_PATH=`which git 2>/dev/null` find_multirust
find_rocksdb
if [[ -f $GIT_PATH ]] find_curl
then find_git
check "$($GIT_PATH --version)" find_make
isGit=true find_gcc
depFound=$((depFound+1))
else
uncheck "Git is missing"
isGit=false
fi
}
function find_ruby() find_apt
{
depCount=$((depCount+1))
RUBY_PATH=`which ruby 2>/dev/null`
if [[ -f $RUBY_PATH ]]
then
RUBY_VERSION=`ruby -e "print RUBY_VERSION"`
check "Ruby ${RUBY_VERSION}"
isRuby=true
depFound=$((depFound+1))
else
uncheck "Ruby is missing 🔥"
isRuby=false
canContinue=false
errorMessages+="${red}==>${reset} ${b}Couldn't find Ruby:${reset} Brew requires Ruby which could not be found.\n"
errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.\n"
fi
} }
function find_brew() function find_brew()
@ -271,59 +251,276 @@ function run_installer()
depCount=$((depCount+1)) depCount=$((depCount+1))
} }
function install_brew() function find_ruby()
{ {
if [[ $isBrew == false ]] depCount=$((depCount+1))
then
head "Installing Homebrew"
if [[ $isRuby == true ]] RUBY_PATH=`which ruby 2>/dev/null`
if [[ -f $RUBY_PATH ]]
then then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" RUBY_VERSION=`ruby -e "print RUBY_VERSION"`
check "Ruby ${RUBY_VERSION}"
isRuby=true
depFound=$((depFound+1))
else else
cd /usr uncheck "Ruby is missing 🔥"
isRuby=false
if [[ ! -d $HOMEBREW_PREFIX ]] canContinue=false
then errorMessages+="${red}==>${reset} ${b}Couldn't find Ruby:${reset} Brew requires Ruby which could not be found.\n"
sudo mkdir $HOMEBREW_PREFIX errorMessages+=" Please install Ruby using these instructions ${u}${blue}https://www.ruby-lang.org/en/documentation/installation/${reset}.\n"
sudo chmod g+rwx $HOMEBREW_PREFIX
fi fi
}
if [[ ! -d $HOMEBREW_CACHE ]] function find_rocksdb()
then {
sudo mkdir $HOMEBREW_CACHE depCount=$((depCount+1))
sudo chmod g+rwx $HOMEBREW_CACHE if [[ $(ldconfig -v 2>/dev/null | grep rocksdb | wc -l) == 1 ]]; then
depFound=$((depFound+1))
check "librocksdb"
isRocksDB=true
else
uncheck "librocksdb is missing"
isRocksDB=false
INSTALL_FILES+="${blue}${dim}==>${reset}\tlibrocksdb\n"
fi fi
}
DEVELOPER_DIR=`/usr/bin/xcode-select -print-path 2>/dev/null` function find_multirust()
{
if [[ ! $(ls -A $DEVELOPER_DIR) || ! -f $DEVELOPER_DIR/usr/bin/git ]] depCount=$((depCount+2))
then MULTIRUST_PATH=`which multirust 2>/dev/null`
info "Installing the Command Line Tools (expect a GUI popup):" if [[ -f $MULTIRUST_PATH ]]; then
sudo /usr/bin/xcode-select --install depFound=$((depFound+1))
check "multirust"
echo "Press any key when the installation has completed" isMultirust=true
if [[ $(multirust show-default 2>/dev/null | grep nightly | wc -l) == 4 ]]; then
depFound=$((depFound+1))
check "rust nightly"
isMultirustNightly=true
else
uncheck "rust is not nightly"
isMultirustNightly=false
INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust -> rust nightly\n"
fi fi
else
cd $HOMEBREW_PREFIX uncheck "multirust is missing"
uncheck "rust nightly is missing"
bash -o pipefail -c "curl -fsSL ${HOMEBREW_REPO}/tarball/master | tar xz -m --strip 1" isMultirust=false
isMultirustNightly=false
INSTALL_FILES+="${blue}${dim}==>${reset}\tmultirust\n"
fi fi
}
find_brew function find_apt()
echo {
depCount=$((depCount+1))
if [[ $isBrew == false ]] APT_PATH=`which apt-get 2>/dev/null`
if [[ -f $APT_PATH ]]
then then
abortInstall "Couldn't install brew" depFound=$((depFound+1))
check "apt-get"
isApt=true
else
uncheck "apt-get is missing"
isApt=false
if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then
canContinue=false
errorMessages+="${red}==>${reset} ${b}Couldn't find apt-get:${reset} We can only use apt-get in order to grab our dependencies.\n"
errorMessages+=" Please switch to a distribution such as Debian or Ubuntu or manually install the missing packages.\n"
fi fi
fi fi
} }
function find_gcc()
{
depCount=$((depCount+1))
GCC_PATH=`which g++ 2>/dev/null`
if [[ -f $GCC_PATH ]]
then
depFound=$((depFound+1))
check "g++"
isGCC=true
else
uncheck "g++ is missing"
isGCC=false
INSTALL_FILES+="${blue}${dim}==>${reset}\tg++\n"
fi
}
function find_git()
{
depCount=$((depCount+1))
GIT_PATH=`which git 2>/dev/null`
if [[ -f $GIT_PATH ]]
then
depFound=$((depFound+1))
check "git"
isGit=true
else
uncheck "git is missing"
isGit=false
INSTALL_FILES+="${blue}${dim}==>${reset}\tgit\n"
fi
}
function find_make()
{
depCount=$((depCount+1))
MAKE_PATH=`which make 2>/dev/null`
if [[ -f $MAKE_PATH ]]
then
depFound=$((depFound+1))
check "make"
isMake=true
else
uncheck "make is missing"
isMake=false
INSTALL_FILES+="${blue}${dim}==>${reset}\tmake\n"
fi
}
function find_curl()
{
depCount=$((depCount+1))
CURL_PATH=`which curl 2>/dev/null`
if [[ -f $CURL_PATH ]]
then
depFound=$((depFound+1))
check "curl"
isCurl=true
else
uncheck "curl is missing"
isCurl=false
INSTALL_FILES+="${blue}${dim}==>${reset}\tcurl\n"
fi
}
function ubuntu1404_rocksdb_installer()
{
sudo apt-get update -qq
sudo apt-get install -qq -y software-properties-common
sudo apt-add-repository -y ppa:giskou/librocksdb
sudo apt-get -f -y install
sudo apt-get update -qq
sudo apt-get install -qq -y librocksdb
}
function linux_rocksdb_installer()
{
if [[ $isUbuntu1404 == true ]]; then
ubuntu1404_rocksdb_installer
else
oldpwd=`pwd`
cd /tmp
exe git clone --branch v4.2 --depth=1 https://github.com/facebook/rocksdb.git
cd rocksdb
exe make shared_lib
sudo cp -a librocksdb.so* /usr/lib
sudo ldconfig
cd /tmp
rm -rf /tmp/rocksdb
cd $oldpwd
fi
}
function verify_installation()
{
ETH_PATH=`which parity 2>/dev/null`
if [[ -f $ETH_PATH ]]
then
success "Parity has been installed"
else
error "Parity is missing"
abortInstall
fi
}
function verify_dep_installation()
{
info "Verifying installation"
if [[ $OS_TYPE == "linux" ]]; then
find_curl
find_git
find_make
find_gcc
find_rocksdb
find_multirust
if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then
abortInstall
fi
fi
}
function linux_deps_installer()
{
if [[ $isGCC == false || $isGit == false || $isMake == false || $isCurl == false ]]; then
info "Installing build dependencies..."
sudo apt-get update -qq
if [[ $isGit == false ]]; then
sudo apt-get install -q -y git
fi
if [[ $isGCC == false ]]; then
sudo apt-get install -q -y g++ gcc
fi
if [[ $isMake == false ]]; then
sudo apt-get install -q -y make
fi
if [[ $isCurl == false ]]; then
sudo apt-get install -q -y curl
fi
echo
fi
if [[ $isRocksDB == false ]]; then
info "Installing rocksdb..."
linux_rocksdb_installer
echo
fi
if [[ $isMultirust == false ]]; then
info "Installing multirust..."
curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes
echo
fi
if [[ $isMultirustNightly == false ]]; then
info "Installing rust nightly..."
sudo multirust update nightly
sudo multirust default nightly
echo
fi
}
function linux_installer()
{
linux_deps_installer
verify_dep_installation
info "Installing parity"
file=/tmp/parity.deb
wget $PARITY_DEB_URL -qO $file
sudo dpkg -i $file
rm $file
}
function osx_installer() function osx_installer()
{ {
osx_dependency_installer
info "Adding ethcore repository" info "Adding ethcore repository"
brew tap ethcore/ethcore https://github.com/ethcore/homebrew-ethcore.git brew tap ethcore/ethcore https://github.com/ethcore/homebrew-ethcore.git
echo echo
@ -343,104 +540,65 @@ function run_installer()
echo echo
} }
function osx_dependency_installer() function install()
{ {
if [[ $isGit == false ]];
then
echo "Installing Git"
fi
if [[ $isRuby == false ]];
then
echo "Installing Ruby"
fi
if [[ $isBrew == false ]];
then
install_brew
fi
}
function get_linux_dependencies()
{
find_apt
find_docker
}
function find_apt()
{
APT_PATH=`which apt-get 2>/dev/null`
if [[ -f $APT_PATH ]]
then
check "apt-get"
echo "$($APT_PATH -v)"
isApt=true
else
uncheck "apt-get is missing"
isApt=false
fi
}
function find_docker()
{
DOCKER_PATH=`which docker 2>/dev/null`
if [[ -f $DOCKER_PATH ]]
then
check "docker"
echo "$($DOCKER_PATH -v)"
isDocker=true
else
isDocker=false
fi
}
function linux_rocksdb_installer()
{
sudo add-apt-repository -y ppa:giskou/librocksdb
sudo apt-get -f -y install
sudo apt-get update
sudo apt-get install -y librocksdb
}
function linux_installer()
{
info "Installing dependencies"
sudo apt-get update && sudo apt-get install -q -y git curl g++ wget
echo echo
head "Installing Parity build dependencies"
info "Installing rocksdb" if [[ $OS_TYPE == "osx" ]]
linux_rocksdb_installer then
echo osx_installer
elif [[ $OS_TYPE == "linux" ]]
then
linux_installer
fi
info "Installing parity" verify_installation
file=/tmp/parity.deb
wget $PARITY_DEB_URL -qO $file
sudo dpkg -i $file
rm $file
} }
function install_netstats() function install_netstats()
{ {
echo "install netstats" echo "Installing netstats"
if [[ $isDocker == false ]]
then
info "installing docker"
curl -sSL https://get.docker.com/ | sh
fi
dir=$HOME/.netstats
secret=$(prompt_for_input "Please enter the netstats secret:") secret=$(prompt_for_input "Please enter the netstats secret:")
instance_name=$(prompt_for_input "Please enter your instance name:") instance_name=$(prompt_for_input "Please enter your instance name:")
contact_details=$(prompt_for_input "Please enter your contact details (optional):") contact_details=$(prompt_for_input "Please enter your contact details (optional):")
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
sudo apt-get update
mkdir -p $dir # install ethereum & install dependencies
cat > $dir/app.json << EOL sudo apt-get install -y -qq build-essential git unzip wget nodejs ntp cloud-utils
sudo apt-get install -y -qq npm
# add node symlink if it doesn't exist
[[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node
# set up time update cronjob
sudo bash -c "cat > /etc/cron.hourly/ntpdate << EOF
#!/bin/sh
pm2 flush
sudo service ntp stop
sudo ntpdate -s ntp.ubuntu.com
sudo service ntp start
EOF"
sudo chmod 755 /etc/cron.hourly/ntpdate
cd $HOME
[ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api netstats
oldpwd= $(pwd)
cd netstats
git pull
git checkout 95d595258239a0fdf56b97dedcfb2be62f6170e6
sudo npm install
sudo npm install pm2 -g
cat > app.json << EOL
[ [
{ {
"name" : "node-app", "name" : "node-app",
@ -468,35 +626,10 @@ function run_installer()
] ]
EOL EOL
sudo docker rm --force netstats-client 2> /dev/null pm2 startOrRestart app.json
sudo docker pull ethcore/netstats-client cd $oldpwd
sudo docker run -d --net=host --name netstats-client -v $dir/app.json:/home/ethnetintel/eth-net-intelligence-api/app.json ethcore/netstats-client
} }
function install()
{
echo
head "Installing Parity build dependencies"
if [[ $OS_TYPE == "osx" ]]
then
osx_installer
elif [[ $OS_TYPE == "linux" ]]
then
linux_installer
fi
}
function verify_installation()
{
info "Verifying installation"
find_eth
if [[ $isEth == false ]]
then
abortInstall
fi
}
function abortInstall() function abortInstall()
{ {
@ -510,32 +643,37 @@ EOL
function finish() function finish()
{ {
echo echo
successHeading "Installation successful!" successHeading "All done"
# head "Next steps" # head "Next steps"
# info "Run ${cyan}\`\`${reset} to get started.${reset}" # info "Run ${cyan}\`\`${reset} to get started.${reset}"
echo echo
exit 0 exit 0
} }
# Check dependencies
head "Checking OS dependencies" head "Checking OS dependencies"
detectOS detectOS
if [[ $INSTALL_FILES != "" ]]; then
echo echo
head "In addition to the parity build dependencies, this script will install:" head "In addition to the Parity build dependencies, this script will install:"
echo "$INSTALL_FILES" printf "$INSTALL_FILES"
echo echo
# Prompt user to continue or abort
if wait_for_user "${b}OK,${reset} let's go!"
then
echo "Installing..."
else
abortInstall "${red}==>${reset} Process stopped by user. To resume the install run the one-liner command again."
fi fi
# Install dependencies and eth #DEBUG
head "${b}OK,${reset} let's install Parity now!"
if wait_for_user "${b}Last chance!${reset} Sure you want to install this software?"
then
install install
echo
echo
else
finish
fi
if [[ $OS_TYPE == "linux" ]] if [[ $OS_TYPE == "linux" ]]
then then
@ -547,10 +685,8 @@ EOL
fi fi
fi fi
# Check installation
verify_installation
# Display goodby message # Display goodbye message
finish finish
} }

View File

@ -28,6 +28,7 @@ extern crate ethsync;
extern crate log as rlog; extern crate log as rlog;
extern crate env_logger; extern crate env_logger;
extern crate ctrlc; extern crate ctrlc;
extern crate fdlimit;
#[cfg(feature = "rpc")] #[cfg(feature = "rpc")]
extern crate ethcore_rpc as rpc; extern crate ethcore_rpc as rpc;
@ -95,6 +96,7 @@ fn main() {
let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
setup_log(&args.flag_logging); setup_log(&args.flag_logging);
unsafe { ::fdlimit::raise_fd_limit(); }
let spec = ethereum::new_frontier(); let spec = ethereum::new_frontier();
let init_nodes = match args.arg_enode.len() { let init_nodes = match args.arg_enode.len() {

10
util/fdlimit/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
description = "Utility function to raise file descriptor limit on OS X"
homepage = "http://ethcore.io"
license = "GPL-3.0"
name = "fdlimit"
version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"]
[dependencies]
libc = "0.2"

18
util/fdlimit/src/lib.rs Normal file
View File

@ -0,0 +1,18 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
//
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.extern crate libc;
extern crate libc;
pub mod raise_fd_limit;
pub use raise_fd_limit::raise_fd_limit;

View File

@ -0,0 +1,61 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/// darwin_fd_limit exists to work around an issue where launchctl on Mac OS X
/// defaults the rlimit maxfiles to 256/unlimited. The default soft limit of 256
/// ends up being far too low for our multithreaded scheduler testing, depending
/// on the number of cores available.
///
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[allow(non_camel_case_types)]
pub unsafe fn raise_fd_limit() {
use libc;
use std::cmp;
use std::io;
use std::mem::size_of_val;
use std::ptr::null_mut;
static CTL_KERN: libc::c_int = 1;
static KERN_MAXFILESPERPROC: libc::c_int = 29;
// The strategy here is to fetch the current resource limits, read the
// kern.maxfilesperproc sysctl value, and bump the soft resource limit for
// maxfiles up to the sysctl value.
// Fetch the kern.maxfilesperproc value
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
let mut maxfiles: libc::c_int = 0;
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
if libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size,
null_mut(), 0) != 0 {
let err = io::Error::last_os_error();
panic!("raise_fd_limit: error calling sysctl: {}", err);
}
// Fetch the current resource limits
let mut rlim = libc::rlimit{rlim_cur: 0, rlim_max: 0};
if libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) != 0 {
let err = io::Error::last_os_error();
panic!("raise_fd_limit: error calling getrlimit: {}", err);
}
// Bump the soft limit to the smaller of kern.maxfilesperproc and the hard
// limit
rlim.rlim_cur = cmp::min(maxfiles as libc::rlim_t, rlim.rlim_max);
// Set our newly-increased resource limit
if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) != 0 {
let err = io::Error::last_os_error();
panic!("raise_fd_limit: error calling setrlimit: {}", err);
}
}
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
pub unsafe fn raise_fd_limit() {}