Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
904a2e8
just one error to fix
digitsu Mar 28, 2021
64da0dd
Fixed all the error handling issues (very poorly, need to revisit)
digitsu Mar 28, 2021
25191f5
Fixed all the error handling issues (very poorly, need to revisit)
digitsu Mar 28, 2021
350e8f8
added bitcoind
joeldejesus1 Mar 28, 2021
09d084b
Merge pull request #1 from joeldejesus1/t-1-bitcoind
digitsu Mar 29, 2021
7d652c8
First clean build!
digitsu Mar 29, 2021
2418e07
Migrated to rust 1.51 nightly toolchain working through build errors …
digitsu Apr 3, 2021
9393a1a
builds with no errors. Fixed all deprecated rust 1.25.0-nightly usage…
digitsu Apr 3, 2021
b25d262
Remaining warnings nixed, deprecated try! and missing 'dyn'
digitsu Apr 3, 2021
202a7a6
docker image now builds clean, only thing missing is the libbitcoinco…
digitsu Apr 4, 2021
d10cb8b
removed monitor
digitsu Apr 4, 2021
41a69e6
Fixed incorrect atomic failure ordering flags after the deprecation o…
digitsu Apr 4, 2021
cd5a6f8
ignore data-bench2 and tmp directories, which are created during test…
digitsu Apr 5, 2021
71ca617
First clean build!
digitsu Mar 29, 2021
e062515
Migrated to rust 1.51 nightly toolchain working through build errors …
digitsu Apr 3, 2021
c4c1839
builds with no errors. Fixed all deprecated rust 1.25.0-nightly usage…
digitsu Apr 3, 2021
b154a79
Remaining warnings nixed, deprecated try! and missing 'dyn'
digitsu Apr 3, 2021
fbc3561
docker image now builds clean, only thing missing is the libbitcoinco…
digitsu Apr 4, 2021
51e8995
removed monitor
digitsu Apr 4, 2021
f4fbb8a
Fixed incorrect atomic failure ordering flags after the deprecation o…
digitsu Apr 4, 2021
e904bdd
ignore data-bench2 and tmp directories, which are created during test…
digitsu Apr 5, 2021
ed0db64
Added back in all the other modules
digitsu Mar 28, 2021
001d9b5
Merge branch 'master' of github.com:digitsu/bitcrust
digitsu Oct 5, 2021
1c32654
Added back in all the other modules
digitsu Oct 5, 2021
a0606bb
Cleaned up some messy code, put back closest I can tell to where we f…
digitsu Oct 5, 2021
8f79d1a
Small bug fix. (note: currently the script interpreter isn't working …
digitsu Oct 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ target
/test-lmdb/
core-blocks
data-bench
data-bench2
tmp

Cargo.lock
launch.json
Expand All @@ -16,3 +18,4 @@ data/
bitcrust.iml

store/tst-*

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ itertools = "0.5.1"
memmap = "0.4"
libc = "0.2.30"
rand = "0.3"
ring = "0.12"

serde = "1"
serde_derive = "1"
ring = "0.16"
serde = { version = "1.0", features = ["derive"] }
toml = "0.4"

slog = { version = "1.3.2", features = ["max_level_trace", "release_max_level_info"] }
Expand All @@ -45,3 +43,5 @@ default = []
[workspace]
members = [ "bitcrustd", "monitor", "net", "encode-derive", "store", "hashstore"]



10 changes: 6 additions & 4 deletions bitcrustd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ bitcrust-net = {path = "../net"}
store = {path = "../store"}
clap = "~2.25"
simple_logger = "*"
log = "0.3"
log = "0.4"
multiqueue = "~0.3.2"
ring = "0.12"
ring = "0.16"
serde_derive = "1.0"
serde = "1.0"
toml = "0.4"
rusqlite = "~0.11"
# rusqlite = "~0.11"
rusqlite = "0.24.2"

serde_json = {path = "../serde_json"}
# serde_json = {path = "../serde_json"}
serde_json = "1.0.64"

[dev-dependencies]
tempfile = "2.2"
20 changes: 10 additions & 10 deletions bitcrustd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::{Read, Write};
use std::path::PathBuf;

use clap::{App, Arg, ArgMatches, SubCommand};
use log::LogLevel;
use log::Level;
use ring::{digest, rand, hmac};
use ring::rand::SecureRandom;
use toml;
Expand Down Expand Up @@ -53,19 +53,19 @@ pub struct ConfigFile {
}

pub struct Config {
pub log_level: LogLevel,
pub log_level: Level,
pub data_dir: PathBuf,
raw_key: [u8; 32],
signing_key: hmac::SigningKey,
signing_key: hmac::Key,
}

impl<'a, 'b> Config {
pub fn from_args(matches: &ArgMatches) -> Config {
let log_level = match matches.occurrences_of("debug") {
0 => LogLevel::Warn,
1 => LogLevel::Info,
2 => LogLevel::Debug,
3 | _ => LogLevel::Trace,
0 => Level::Warn,
1 => Level::Info,
2 => Level::Debug,
3 | _ => Level::Trace,
};
let config_file_path: PathBuf = matches.value_of("config").map(|p| PathBuf::from(&p)).unwrap_or_else(|| {
let mut path = home_dir().expect("Can't figure out where your $HOME is");
Expand All @@ -81,7 +81,7 @@ impl<'a, 'b> Config {
Config::create_default(config_file_path)
};

let key = hmac::SigningKey::new(&digest::SHA256, &config_from_file.key);
let key = hmac::Key::new(hmac::HMAC_SHA256, &config_from_file.key);
let data_dir = PathBuf::from(&config_from_file.data_dir);

let mut a: [u8; 32] = [0; 32];
Expand Down Expand Up @@ -160,7 +160,7 @@ impl<'a, 'b> Config {
c
}

pub fn key(&self) -> &hmac::SigningKey {
pub fn key(&self) -> &hmac::Key {
&self.signing_key
}
}
Expand All @@ -170,7 +170,7 @@ impl Clone for Config {
Config {
log_level: self.log_level,
raw_key: self.raw_key,
signing_key: hmac::SigningKey::new(&digest::SHA256, &self.raw_key),
signing_key: hmac::Key::new(hmac::HMAC_SHA256, &self.raw_key),
data_dir: self.data_dir.clone()
}
}
Expand Down
18 changes: 9 additions & 9 deletions bitcrustd/src/peer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::str::FromStr;
use std::thread;

use multiqueue::{BroadcastReceiver, BroadcastSender, broadcast_queue};
use rusqlite::{Error, Connection};
use rusqlite::{Error, Connection, NO_PARAMS};

use bitcrust_net::{NetAddr, Services};
use client_message::ClientMessage;
Expand Down Expand Up @@ -45,7 +45,7 @@ impl PeerManager {
\
port INTEGER
);",
&[])
NO_PARAMS)
.unwrap();

let addrs: HashSet<NetAddr> = {
Expand All @@ -54,14 +54,14 @@ impl PeerManager {
limit 1000")
.unwrap();

let addrs: HashSet<NetAddr> = stmt.query_map(&[], |row| {
NetAddr {
time: Some(row.get(0)),
services: Services::from(row.get::<_, i64>(1) as u64),
ip: Ipv6Addr::from_str(&row.get::<_, String>(2))
let addrs: HashSet<NetAddr> = stmt.query_map(NO_PARAMS, |row| {
Ok( NetAddr {
time: Some(row.get(0).unwrap_or(0u32)),
services: Services::from(row.get::<_, i64>(1).unwrap_or(0i64) as u64),
ip: Ipv6Addr::from_str(&row.get::<_, String>(2).unwrap_or("".to_string()))
.unwrap_or(Ipv6Addr::from_str("::").unwrap()),
port: row.get(3),
}
port: row.get(3).unwrap_or(0u16),
})
})
.unwrap()
.filter_map(|l| l.ok())
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
println!("cargo:rustc-link-search=/usr/local/Cellar/bitcoin/0.21.0/lib\n\
cargo:rustc-link-lib=dylib=bitcoinconsensus");
}
19 changes: 19 additions & 0 deletions contrib/bitcoind.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

COPY contrib/bitcoind /usr/src/bitcoind

WORKDIR /usr/src/bitcoind

RUN /bin/bash /usr/src/bitcoind/install.sh dep
RUN /bin/bash /usr/src/bitcoind/install.sh bitcoind
RUN /bin/bash /usr/src/bitcoind/install.sh run
RUN /bin/bash /usr/src/bitcoind/install.sh user
RUN /bin/bash /usr/src/bitcoind/install.sh conf

WORKDIR /home/bitcoinduser

USER bitcoinduser

CMD ["/usr/local/bin/run.sh"]
97 changes: 97 additions & 0 deletions contrib/bitcoind/bitcoind.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#start in background
daemon=1

#select network -- comment out both for mainnet
#testnet=1
#stn=1
regtest=1

#Required Consensus Rules for Genesis
excessiveblocksize=10000000000 #10GB
maxstackmemoryusageconsensus=100000000 #100MB

#Mining
#biggest block size you want to mine
blockmaxsize=4000000000
blockassembler=journaling #journaling is default as of 1.0.5

#preload mempool
preload=1

#mempool usage allowance
maxmempool=8000 #8G
dbcache=8192 #8G

#Pruning -- Uncomment to trim the chain in an effort to keep disk usage below the figure set
#prune=100000 #100GB

#orphan transaction storage
#blockreconstructionextratxn=200000
#maxorphantxsize=10000

#transaction options
#maxsigcachesize=260
#maxscriptcachesize=260
#minrelaytxfee=0.00000001
#mintxfee=0.00000001
#dustrelayfee=0.00000001
#blockmintxfee=0.00000001
#relaypriority=0
#feefilter=0
#limitfreerelay=1000
#maxscriptsizepolicy=500000

#OP Return max size
#datacarriersize=100000 #Genesis default is UINT32_MAX

#Max number and size of related Child and Parent transactions per block template
limitancestorcount=100
limitdescendantcount=100
#limitancestorsize=25000000
#limitdescendantsize=25000000

#connection options
maxconnections=80

#ZMQ
zmqpubhashtx=tcp://127.0.0.1:28332
zmqpubhashblock=tcp://127.0.0.1:28332

#Ports - Leave commented for defaults
#port=9333
#rpcport=9332

#rpc settings
rpcworkqueue=600
rpcthreads=16
rpcallowip=0.0.0.0/0
rpcuser=appuser
rpcpassword=abc123

#debug options
#can be: net, tor,
# mempool, http, bench, zmq, db, rpc, addrman, selectcoins,
# reindex, cmpctblock, rand, prune, proxy, mempoolrej, libevent,
# coindb, leveldb, txnprop, txnsrc, journal, txnval.
# 1 = all options enabled.
# 0 = off which is default
debug=1

#debugexclude to ignore set log items, can be used to keep log file a bit cleaner
debugexclude=libevent
debugexclude=leveldb
debugexclude=zmq
debugexclude=txnsrc
debugexclude=net

#shrinkdebugfile=0 # Setting to 1 prevents bitcoind from clearning the log file on restart. 0/off is default

#multi-threaded options
#threadsperblock=32
#maxparallelblocks
#scriptvalidatormaxbatchsize
#maxparallelblocksperpeer
maxstdtxvalidationduration=15
maxcollectedoutpoints=1000000
maxstdtxnsperthreadratio=10000
#maxnonstdtxvalidationduration
59 changes: 59 additions & 0 deletions contrib/bitcoind/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e


decho(){
1>&2 echo $@
}

install_dep(){
apt-get update
apt-get install -y wget
}

install_bitcoind(){
TMPDIR=$(mktemp --dir)
cd $TMPDIR
wget https://download.bitcoinsv.io/bitcoinsv/1.0.5/bitcoin-sv-1.0.5-x86_64-linux-gnu.tar.gz
sha256sum bitcoin-sv-1.0.5-x86_64-linux-gnu.tar.gz | grep 96f7c56c7ebd4ecb2dcd664297fcf0511169ac33eaf216407ebc49dae2535578
tar xvf bitcoin-sv-1.0.5-x86_64-linux-gnu.tar.gz
ln -s bitcoin-sv-1.0.5 bitcoin
install -m 0755 bitcoin/bin/* /usr/local/bin
chmod +x /usr/local/bin/*
rm -rf $TMPDIR
}

install_conf(){
mkdir -p /etc/bitcoind/
cp bitcoind.conf /etc/bitcoind/bitcoind.conf
}

install_run(){
install -m 0755 run.sh /usr/local/bin
}

user_create(){
useradd -ms /bin/bash bitcoinduser
mkdir /home/bitcoinduser/data
chown -R bitcoinduser:bitcoinduser /home/bitcoinduser/data
}


case $1 in
dep)
( install_dep )
;;
bitcoind)
( install_bitcoind )
;;
run)
( install_run )
;;
user)
( user_create )
;;
conf)
( install_conf )
;;
esac
12 changes: 12 additions & 0 deletions contrib/bitcoind/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash


decho(){
1>&2 echo $@
}

run_daemon(){
exec /usr/local/bin/bitcoind -conf=/etc/bitcoind/bitcoind.conf -datadir=/home/bitcoinduser/data -daemon
}

run_daemon
8 changes: 8 additions & 0 deletions contrib/bitcrust.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM rustlang/rust:nightly as builder
WORKDIR /usr/src/app
COPY . .
# RUN cargo install cargo-travis
RUN export PATH=$HOME/.cargo/bin:$PATH
# RUN cargo rustc -- -Awarnings
RUN cargo build --all --verbose --color always
# RUN cargo coveralls --exclude-pattern tests/,script/,bitcoin/src/,encode-derive/ --all
Loading