Skip to content
Snippets Groups Projects
Commit 54f40f37 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Better handling of behaviour when accounts are defined.

parent d83714da
Branches master
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env
source "${BFAHOME}/bin/libbfa.sh" || exit 1
declare -A commands help
TOMLCONFIGFILE="${BFANETWORKDIR}/config.full+archive+nohttp"
function register_subcommand
{
......@@ -73,7 +74,7 @@ function psprocs
if [ -z "$pids" ]
then
echo "There are no processes of interest." >&2
exit 1
return 1
fi
# shellcheck disable=SC2086
ps -p ${pids// /,}
......@@ -86,7 +87,7 @@ function topprocs
if [ -z "$pids" ]
then
echo "There are no processes of interest." >&2
exit 1
return 1
fi
# shellcheck disable=SC2086
local args pid
......@@ -117,7 +118,7 @@ function sendsig
kill "$signal" $pids || true
}
register_subcommand 'kill' 'killbfastuff' 'Kill BFA background processes (no questions asked).'
register_subcommand 'kill' 'killbfastuff' 'Hard kill BFA background processes (BAD IDEA! Use stop instead).'
function killbfastuff
{
local pids
......@@ -125,7 +126,7 @@ function killbfastuff
if [ -z "$pids" ]
then
echo "Nothing to send signals to." >&2
exit 2
return 2
fi
sendsig -KILL "$pids"
}
......@@ -139,7 +140,7 @@ function graceful
if [ -z "$pids" ]
then
echo "Nothing to send signals to." >&2
return
return 1
fi
sendsig -TERM "$pids"
sleep 1
......@@ -162,7 +163,7 @@ function graceful
register_subcommand 'initdb' 'initdb' 'Stop geth and reset the node to block zero (genesis).'
function initdb
{
killbfastuff
killbfastuff || true
yes | geth --cache 0 --datadir "${BFANODEDIR}" removedb
geth --networkid "${BFANETWORKID}" --cache 0 --datadir "${BFANODEDIR}" init "${BFANETWORKDIR}/genesis.json"
}
......@@ -172,7 +173,7 @@ function exportdb
{
local million maxblocks blockstart toblock filename
million=1000000
graceful
graceful || true
maxblocks=$(bfageth --exec 'eth.blockNumber' console 2> /dev/null)
# 0 is genesis.. shouldn't dump that
blockstart=1
......@@ -197,30 +198,27 @@ function importdb
local dumpurl million blockstart continue_at haveblocks theirsize oursize
dumpurl="https://s3.wasabisys.com/bfa/blockdumps"
million=1000000
graceful
graceful || true
haveblocks=$(bfageth --exec 'eth.blockNumber' console 2> /dev/null)
blockstart=$((haveblocks/million*million+1))
while :
do
printf -v filename 'bfa2018.blocks.%09d-%09d.export.gz' "$blockstart" "$((blockstart + million - 1))"
blockstart=$((blockstart + million))
read -r theirsize < <( curl --head "${dumpurl}/${filename}" 2>/dev/null | grep -i '^Content-Length: ' | head -1 )
theirsize=$(curl --head "${dumpurl}/${filename}" 2>/dev/null | grep -i '^Content-Length: ' | head -1)
if [ -z "$theirsize" ]
then
break
else
theirsize="${theirsize//*: }"
# remove trailing newline
theirsize="${theirsize%$'\r'}"
fi
theirsize="${theirsize//*: }"
# remove trailing newline
theirsize="${theirsize%$'\r'}"
#
unset oursize continue_at
if [ -r "$filename" ]
then
oursize=$(stat -c %s "$filename")
continue_at="--continue-at $oursize"
else
oursize=0
continue_at=
fi
if [ "${oursize:-0}" -lt "$theirsize" ]
then
......@@ -233,77 +231,6 @@ function importdb
done
}
register_subcommand 'syncmode' 'admin_syncmode' 'Set initial synchronization mode.'
function admin_syncmode
{
echo "Synchronization modes can only be set for the initial "
echo "synchronization. Later follow-up block synchronization "
echo "operations will always be \"full\" and can not be changed."
echo "Available synchronization modes:"
echo " full : verify all blocks and all transactions (most secure)"
echo " fast : verify all blocks but not all transactions (faster than full, but less certain)"
echo " light: Makes this node into a light node which downloads almost"
echo " nothing, but relies on fast and full nodes in the network"
echo " to answer it's requests. This is the fastest and uses least"
echo " local resources, but outsources all trust to another node."
echo " Possibly still an untested-by-BFA feature."
echo "Default mode is fast, because for many, it is a healthy compromise"
echo "between speed and paranoia. You can change the setting, according to"
echo "your needs."
mode=$(cat "${BFANODEDIR}/syncmode" 2>/dev/null || true)
mode=${mode:-fast}
echo "Your current mode is set to ${mode}"
killed=0
orgmode=$mode
mode=
echo
while [ -z "${mode}" ]
do
read -rp "Which mode do you wish? : " mode
modefilter "$mode"
if [[ "$mode" =~ ^full$|^fast$|^light$ ]]
then
:
else
echo "Unsupported synchronization mode." >&2
exit 1
fi
done
echo "Remembering your choice."
echo "$mode" > "${BFANODEDIR}/syncmode"
if [ "$orgmode" = "fast" ] && [ "$mode" = "full" ]
then
echo "You increased your paranoia level. The proper thing to do now,"
echo "would be to delete your version of what you synchronized with"
echo "fast mode, and revalidate everything in the entire blockchain."
echo "This probably takes quite a long time and also requires downloading"
echo "all blocks from the entire blockchain again."
yesno n "Do you wish to delete all downloaded blocks and resynchronize?"
if [ "$REPLY" = "y" ]
then
if [ -r "${BFANODEDIR}/geth.pid" ]
then
pid=$(< "${BFANODEDIR}/geth.pid")
kill -0 "$pid" 2>/dev/null &&
echo "Killing running geth." &&
killed=1
while ! kill "$pid" 2>/dev/null
do
sleep 1
done
fi
initdb
test "$killed" -eq 1 &&
echo &&
echo "The startup.sh should restart your geth shortly."
fi
else
echo "No further action taken."
fi
}
register_subcommand 'bootnode' 'admin_bootnode' 'Enable/disable the local bootnode.'
function admin_bootnode
{
......@@ -396,7 +323,10 @@ function bfageth
echo "You should not run this command without any arguments. Start the background processes with start.sh instead." >&2
exit 1
fi
geth --config "${BFANETWORKDIR}/config.localhost+full+archive" "$@"
local DATACFG
# Strange how it seems to ignore this variable from the config file
DATACFG=$(sed --regexp-extended -ne '/^\[Node\]$/,/^$/{/^DataDir *=/{s/^.*= *"(..*)"$/--datadir \1/;p}}' "${TOMLCONFIGFILE}")
geth --config "${TOMLCONFIGFILE}" $DATACFG "$@"
}
function bfaadmin
......@@ -405,14 +335,11 @@ function bfaadmin
'bootnode')
admin_bootnode
;;
'syncmode')
admin_syncmode
;;
'account')
create_account
;;
*)
echo "Usage: $(basename "$0") {bootnode|syncmode|account}"
echo "Usage: $(basename "$0") {bootnode|account}"
trap '' ERR
exit 1
esac
......
......@@ -2,55 +2,11 @@
NetworkId = 47525974938
SyncMode = "full"
NoPruning = true
NoPrefetch = false
LightPeers = 100
UltraLightFraction = 75
DatabaseCache = 2048
DatabaseFreezer = ""
TrieCleanCache = 1024
TrieDirtyCache = 1024
TrieTimeout = 3600000000000
EnablePreimageRecording = false
EWASMInterpreter = ""
EVMInterpreter = ""
DatabaseCache = 4096
[Eth.Miner]
GasFloor = 8000000
GasCeil = 8000000
GasPrice = 1000000000
Recommit = 3000000000
Noverify = false
[Eth.Ethash]
CacheDir = "ethash"
CachesInMem = 2
CachesOnDisk = 3
DatasetDir = "/home/bfa/.ethash"
DatasetsInMem = 1
DatasetsOnDisk = 2
PowMode = 0
[Eth.TxPool]
Locals = []
NoLocals = true
Journal = "transactions.rlp"
Rejournal = 3600000000000
PriceLimit = 1
PriceBump = 10
AccountSlots = 16
GlobalSlots = 4096
AccountQueue = 64
GlobalQueue = 1024
Lifetime = 10800000000000
[Eth.GPO]
Blocks = 20
Percentile = 60
[Shh]
MaxMessageSize = 1048576
MinimumAcceptedPOW = 2e-01
RestrictConnectionBetweenLightClients = true
[Node.P2P]
BootstrapNodes = ["enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@[2800:110:44:6300::aad2:2db3]:30301", "enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@170.210.45.179:30301", "enode://82b66b13d7addcf9ffe1e4e972a105f6ccf50557161c4a0978a5d9ce595ababde609ea8a49897ae89b1d41e90551cb2e9241363238593e950ca68bd5af7c24d6@200.16.28.28:30301", "enode://ddbf37799e8d33b0c42dddbda713037b17d14696b29ecf424ca3d57bb47db78a467505e22c5f2b709a98c3d55ac8ecbf4610765385317dd51049438f498881c6@200.108.146.100:30301"]
BootstrapNodesV5 = ["enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@[2800:110:44:6300::aad2:2db3]:30301", "enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@170.210.45.179:30301", "enode://82b66b13d7addcf9ffe1e4e972a105f6ccf50557161c4a0978a5d9ce595ababde609ea8a49897ae89b1d41e90551cb2e9241363238593e950ca68bd5af7c24d6@200.16.28.28:30301", "enode://ddbf37799e8d33b0c42dddbda713037b17d14696b29ecf424ca3d57bb47db78a467505e22c5f2b709a98c3d55ac8ecbf4610765385317dd51049438f498881c6@200.108.146.100:30301"]
[Node]
DataDir = "/home/bfa/bfa/network/node"
......@@ -63,26 +19,4 @@ HTTPVirtualHosts = ["*"]
HTTPModules = ["net", "web3", "eth", "clique"]
WSHost = "0.0.0.0"
WSPort = 8546
WSModules = ["net", "web3", "eth", "clique"]
GraphQLPort = 8547
GraphQLVirtualHosts = ["localhost"]
[Node.P2P]
MaxPeers = 50
NoDiscovery = false
BootstrapNodes = ["enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@[2800:110:44:6300::aad2:2db3]:30301", "enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@170.210.45.179:30301", "enode://82b66b13d7addcf9ffe1e4e972a105f6ccf50557161c4a0978a5d9ce595ababde609ea8a49897ae89b1d41e90551cb2e9241363238593e950ca68bd5af7c24d6@200.16.28.28:30301", "enode://ddbf37799e8d33b0c42dddbda713037b17d14696b29ecf424ca3d57bb47db78a467505e22c5f2b709a98c3d55ac8ecbf4610765385317dd51049438f498881c6@200.108.146.100:30301"]
BootstrapNodesV5 = ["enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@[2800:110:44:6300::aad2:2db3]:30301", "enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@170.210.45.179:30301", "enode://82b66b13d7addcf9ffe1e4e972a105f6ccf50557161c4a0978a5d9ce595ababde609ea8a49897ae89b1d41e90551cb2e9241363238593e950ca68bd5af7c24d6@200.16.28.28:30301", "enode://ddbf37799e8d33b0c42dddbda713037b17d14696b29ecf424ca3d57bb47db78a467505e22c5f2b709a98c3d55ac8ecbf4610765385317dd51049438f498881c6@200.108.146.100:30301"]
StaticNodes = []
TrustedNodes = []
ListenAddr = ":30303"
EnableMsgEvents = false
[Node.HTTPTimeouts]
ReadTimeout = 30000000000
WriteTimeout = 30000000000
IdleTimeout = 120000000000
[Dashboard]
Host = "localhost"
Port = 8080
Refresh = 5000000000
WSModules = ["eth", "net", "web3", "clique"]
......@@ -4,13 +4,9 @@ SyncMode = "full"
NoPruning = true
DatabaseCache = 4096
[Node]
DataDir = "/home/bfa/bfa/network/node"
HTTPHost = "127.0.0.1"
HTTPCors = ["*"]
HTTPVirtualHosts = ["localhost"]
HTTPModules = ["eth", "net", "web3", "clique", "admin", "miner", "personal"]
[Node.P2P]
BootstrapNodes = ["enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@[2800:110:44:6300::aad2:2db3]:30301", "enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@170.210.45.179:30301", "enode://82b66b13d7addcf9ffe1e4e972a105f6ccf50557161c4a0978a5d9ce595ababde609ea8a49897ae89b1d41e90551cb2e9241363238593e950ca68bd5af7c24d6@200.16.28.28:30301", "enode://ddbf37799e8d33b0c42dddbda713037b17d14696b29ecf424ca3d57bb47db78a467505e22c5f2b709a98c3d55ac8ecbf4610765385317dd51049438f498881c6@200.108.146.100:30301"]
BootstrapNodesV5 = ["enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@[2800:110:44:6300::aad2:2db3]:30301", "enode://7ec4dd9d5e1a2b29d6b60aa9f95677c0c3a5f9306e73d65dd3bcbfda3737a8c509b02d1eab763ce39f18cfe96423df7ee544d6c36191ec17f59ade75bc99d358@170.210.45.179:30301", "enode://82b66b13d7addcf9ffe1e4e972a105f6ccf50557161c4a0978a5d9ce595ababde609ea8a49897ae89b1d41e90551cb2e9241363238593e950ca68bd5af7c24d6@200.16.28.28:30301", "enode://ddbf37799e8d33b0c42dddbda713037b17d14696b29ecf424ca3d57bb47db78a467505e22c5f2b709a98c3d55ac8ecbf4610765385317dd51049438f498881c6@200.108.146.100:30301"]
[Node]
DataDir = "/home/bfa/bfa/network/node"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment