diff --git a/bin/attach.sh b/bin/attach.sh index c9da22f8ba826a58768dea21848204203c6f84f5..6abfd77103d87ed553a2a2cbe089a882fe63cc29 100755 --- a/bin/attach.sh +++ b/bin/attach.sh @@ -4,5 +4,4 @@ if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi source ${BFAHOME}/bin/libbfa.sh || exit 1 -bfaconfig node -geth attach ipc:${BFANODEDIR}/geth.ipc +geth_attach diff --git a/bin/create.contract b/bin/create.contract index cc4ebb9ccceeb1709d4da4073e5f83b7355d25d2..d3721cfa5ff5db8c42c63bc151e16f088050cd45 100755 --- a/bin/create.contract +++ b/bin/create.contract @@ -6,31 +6,36 @@ source ${BFAHOME}/bin/libbfa.sh || exit 1 function create { - workdir=$( bfamktemp -p . -d ) - json=$( solc --optimize --combined-json abi,bin $filename ); test $? eq 0 - abi=$( echo "$json" | jq -rM ".contracts.${prefix}.abi" ); test $? eq 0 - bin=$( echo "$json" | jq -rM ".contracts.${prefix}.bin" ); test $? eq 0 + workdir=$( mktemp -p . -d ) + cleanup "$workdir" + json=$( solc --optimize --combined-json abi,bin $filename ); test $? = 0 + prefix=$( echo "$json" | jq -M '.contracts | keys | .[0]' ); + abi=$( echo "$json" | jq -rM ".contracts.${prefix}.abi" ); test $? = 0 + bin=$( echo "$json" | jq -rM ".contracts.${prefix}.bin" ); test $? = 0 # Save abi for future use echo $abi > ${workdir}/abi # We could save the bin, but we don't actually use it later, plus # it gets stored in the blockchain #echo $bin > ${workdir}/bin - js=$( bfamktemp ) + js=$( mktemp ) + cleanup "$js" cat > $js <<EOT -var mycontract = eth.contract(JSON.parse($abi)) +var mycontract = eth.contract($abi) var transaction = mycontract.new( { from: eth.accounts[0], data: "0x${bin}", gas: 1000000 } ) var rcpt while ( !rcpt ) { - admin.sleepBlocks( 1 ); - rcpt = eth.getTransactionReceipt( transaction.transactionHash ); + admin.sleepBlocks( 1 ) + rcpt = eth.getTransactionReceipt( transaction.transactionHash ) } -var address = rcpt.contractAddress; -var pubcontract = mycontract.at(address); -console.log( pubcontract.address ); +var address = rcpt.contractAddress +var pubcontract = mycontract.at(address) +console.log( pubcontract.address ) EOT echo '*** Creating contract. This will take at least 16 seconds.' - outfile=$( geth_exec_js $js ) + outfile=$( bfamktemp ) + cleanup "$outfile" + geth_exec_js $js > $outfile if [ ` wc -l < $outfile ` = 2 -a `tail -1 < $outfile` = "true" ] then addr=` head -1 < $outfile ` diff --git a/bin/libbfa.sh b/bin/libbfa.sh index e004e2dc1a863b1482e020c413f8ac170d463772..ebf15d428d98c241d45e6f6bfa13ac8590210fbc 100644 --- a/bin/libbfa.sh +++ b/bin/libbfa.sh @@ -32,25 +32,16 @@ function cleanup rm -rf $cleanup_files } -# calls mktemp and then cleanup - makes other scripts more compact -function bfamktemp -{ - local file=$( mktemp "$@" ) - cleanup $file - echo $file -} - function geth_attach { - geth "$@" attach ipc:node1/geth.ipc + bfaconfig node + geth --cache 256 "$@" attach ipc:${BFANODEDIR}/geth.ipc } function geth_exec_js { test -r "$1" - local out=$( bfamktemp ) - geth_attach --exec "loadScript(\"$1\")" > $out - echo $out + geth_attach --exec "loadScript(\"$1\")" } function getnetworkid @@ -126,6 +117,12 @@ function nodedir fatal "$BFANODEDIR is not a directory." test -d "${BFANODEDIR}/geth/chaindata" || fatal "Node is not initialised. Consider running: geth --datadir $BFANODEDIR init ${BFANETWORKDIR}/genesis.json" + # Support migrating from "former" setups + if [ -r "${BFANODEDIR}/port" -a ! -r "${BFANODEDIR}/netport" ] + then + mv "${BFANODEDIR}/port" "${BFANODEDIR}/netport" + fi + # test -r "${BFANODEDIR}/netport" || echo $(( $RANDOM / 2 + 12345 )) > ${BFANODEDIR}/netport netport=$( cat ${BFANODEDIR}/netport ) @@ -133,6 +130,10 @@ function nodedir test -r "${BFANODEDIR}/rpcport" || echo $(( $RANDOM / 2 + 12345 )) > ${BFANODEDIR}/rpcport rpcport=$( cat ${BFANODEDIR}/rpcport ) + # something uniqueish + local iphash=$( ip addr show scope global | awk '/^ *inet /{print $2}' | sed 's,/.*,,' | sha256sum ) + BFAEXTRADATA="${USER}@${HOSTNAME} ${iphash}" + BFAEXTRADATA="${BFAEXTRADATA:0:32}" } function account diff --git a/bin/start.sh b/bin/start.sh index 896f2c2ddff3e7069f4c58e9036b9f4d6a823967..a2ba1f17e70c31ef9776e4ed1bcf5bfc6031ea15 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -84,6 +84,12 @@ bfaconfig max --syncmode full \ --nousb \ --bootnodes "${bootnodes}" \ + --txpool.nolocals \ + --txpool.accountslots 128 \ + --txpool.globalslots 32768 \ + --txpool.accountqueue 512 \ + --txpool.globalqueue 8192 \ + --extradata "${BFAEXTRADATA}" \ --gcmode archive \ --cache 512 \ --verbosity 3