diff --git a/README.md b/README.md index 3d0d4d35d4..d8733058f8 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,16 @@ Which will start mining blocks and transactions on a single CPU thread, creditin the account specified by `--etherbase`. You can further tune the mining by changing the default gas limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`). +## SHYFT NOTES + +#### CLI +Run `./shyft-geth.sh` with one of the following flags: + +- `--setup` - Setups postgres and the shyft chain db. +- `--start` - Starts geth. +- `--reset` - Drops postgress and chain db, and reinstantiates both. +- `--js [web3 filename]` - Executes web3 calls with a passed file name. If the file name is `sendTransactions.js`, `./shyft-geth.sh --js sendTransactions`. + ## Contribution Thank you for considering to help out with the source code! We welcome contributions from diff --git a/config.toml b/config.toml index 23515e0b2f..e48def5a74 100644 --- a/config.toml +++ b/config.toml @@ -45,7 +45,7 @@ HTTPHost = "127.0.0.1" HTTPPort = 8545 HTTPCors = ["*"] HTTPVirtualHosts = ["localhost"] -HTTPModules = ["net", "web3", "eth", "shh"] +HTTPModules = ["net", "web3", "eth", "shh", "admin", "debug"] WSPort = 8546 WSModules = ["net", "web3", "eth", "shh"] diff --git a/initShyftGeth.sh b/shyft-cli/initShyftGeth.sh similarity index 100% rename from initShyftGeth.sh rename to shyft-cli/initShyftGeth.sh diff --git a/shyftDb/postgres_setup/create_shyftdb.psql b/shyft-cli/postgres_setup/create_shyftdb.psql similarity index 100% rename from shyftDb/postgres_setup/create_shyftdb.psql rename to shyft-cli/postgres_setup/create_shyftdb.psql diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyft-cli/postgres_setup/create_tables.psql similarity index 90% rename from shyftDb/postgres_setup/create_tables.psql rename to shyft-cli/postgres_setup/create_tables.psql index e1fa00141a..a477f1e9af 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyft-cli/postgres_setup/create_tables.psql @@ -42,8 +42,3 @@ CREATE TABLE IF NOT EXISTS accounts ( CREATE TABLE IF NOT EXISTS contracts ( txHash text ); - -CREATE TABLE IF NOT EXISTS mined_blocks ( - blockNumber bigint, - addr text -); \ No newline at end of file diff --git a/shyftDb/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql similarity index 76% rename from shyftDb/postgres_setup/drop_tables.psql rename to shyft-cli/postgres_setup/drop_tables.psql index 2921358098..6316b8109c 100644 --- a/shyftDb/postgres_setup/drop_tables.psql +++ b/shyft-cli/postgres_setup/drop_tables.psql @@ -2,4 +2,3 @@ DROP TABLE txs; DROP TABLE blocks; DROP TABLE accounts; DROP TABLE contracts; -DROP TABLE mined_blocks; \ No newline at end of file diff --git a/shyftDb/postgres_setup/drop_tables.sh b/shyft-cli/postgres_setup/drop_tables.sh similarity index 52% rename from shyftDb/postgres_setup/drop_tables.sh rename to shyft-cli/postgres_setup/drop_tables.sh index 576637538a..b0d91aa52e 100644 --- a/shyftDb/postgres_setup/drop_tables.sh +++ b/shyft-cli/postgres_setup/drop_tables.sh @@ -1 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup psql -U postgres -d shyftdb -f drop_tables.psql \ No newline at end of file diff --git a/shyftDb/postgres_setup/init_tables.sh b/shyft-cli/postgres_setup/init_tables.sh similarity index 53% rename from shyftDb/postgres_setup/init_tables.sh rename to shyft-cli/postgres_setup/init_tables.sh index 988ad56700..50dfb4e695 100644 --- a/shyftDb/postgres_setup/init_tables.sh +++ b/shyft-cli/postgres_setup/init_tables.sh @@ -1 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup psql -U postgres -d shyftdb -f create_tables.psql diff --git a/shyft-cli/postgres_setup/initdb.sh b/shyft-cli/postgres_setup/initdb.sh new file mode 100644 index 0000000000..de2cf1c295 --- /dev/null +++ b/shyft-cli/postgres_setup/initdb.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup +psql -U postgres -f create_shyftdb.psql diff --git a/resetShyftGeth.sh b/shyft-cli/resetShyftGeth.sh similarity index 100% rename from resetShyftGeth.sh rename to shyft-cli/resetShyftGeth.sh diff --git a/run_js_in_geth.sh b/shyft-cli/runJs.sh similarity index 80% rename from run_js_in_geth.sh rename to shyft-cli/runJs.sh index b4a6649154..5c7f3e4fbd 100644 --- a/run_js_in_geth.sh +++ b/shyft-cli/runJs.sh @@ -1,4 +1,4 @@ file=$1 -echo $file +echo Executing "${file}"... runthing="./build/bin/geth --exec 'loadScript(\""$file"\")' attach http://127.0.0.1:8545" eval $runthing diff --git a/shyft-cli/setup.sh b/shyft-cli/setup.sh new file mode 100644 index 0000000000..dfb23704ee --- /dev/null +++ b/shyft-cli/setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then # Check if db is instantiated + echo Creating postgres db... + sh ./shyft-cli/postgres_setup/initdb.sh && # Init DB + echo Successfully created postgres db! && + sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables + sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data + sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth +else + echo Postgres DB found! + sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables + sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables + sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data + sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth +fi + diff --git a/shyft-cli/shyftFullReset.sh b/shyft-cli/shyftFullReset.sh new file mode 100644 index 0000000000..5dc4563468 --- /dev/null +++ b/shyft-cli/shyftFullReset.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then + echo Creating postgres db... + sh ./shyft-cli/postgres_setup/initdb.sh && + echo Successfully created postgres db! +fi + +sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables +sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables +sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data +sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth \ No newline at end of file diff --git a/startShyftGeth.sh b/shyft-cli/startShyftGeth.sh similarity index 100% rename from startShyftGeth.sh rename to shyft-cli/startShyftGeth.sh diff --git a/simulations/checkbalances.js b/shyft-cli/web3/checkbalances.js similarity index 100% rename from simulations/checkbalances.js rename to shyft-cli/web3/checkbalances.js diff --git a/simulations/deployContract.js b/shyft-cli/web3/deployContract.js similarity index 100% rename from simulations/deployContract.js rename to shyft-cli/web3/deployContract.js diff --git a/simulations/getGreeting.js b/shyft-cli/web3/getGreeting.js similarity index 100% rename from simulations/getGreeting.js rename to shyft-cli/web3/getGreeting.js diff --git a/simulations/sendTransactions.js b/shyft-cli/web3/sendTransactions.js similarity index 100% rename from simulations/sendTransactions.js rename to shyft-cli/web3/sendTransactions.js diff --git a/simulations/token_test/README.md b/shyft-cli/web3/token_test/README.md similarity index 100% rename from simulations/token_test/README.md rename to shyft-cli/web3/token_test/README.md diff --git a/simulations/token_test/callGreeterFnsTest.js b/shyft-cli/web3/token_test/callGreeterFnsTest.js similarity index 100% rename from simulations/token_test/callGreeterFnsTest.js rename to shyft-cli/web3/token_test/callGreeterFnsTest.js diff --git a/simulations/token_test/call_greeter_fns.js b/shyft-cli/web3/token_test/call_greeter_fns.js similarity index 100% rename from simulations/token_test/call_greeter_fns.js rename to shyft-cli/web3/token_test/call_greeter_fns.js diff --git a/simulations/token_test/calltx.js b/shyft-cli/web3/token_test/calltx.js similarity index 100% rename from simulations/token_test/calltx.js rename to shyft-cli/web3/token_test/calltx.js diff --git a/simulations/token_test/deploy.js b/shyft-cli/web3/token_test/deploy.js similarity index 100% rename from simulations/token_test/deploy.js rename to shyft-cli/web3/token_test/deploy.js diff --git a/simulations/token_test/deploy_greeter_contracts.js b/shyft-cli/web3/token_test/deploy_greeter_contracts.js similarity index 100% rename from simulations/token_test/deploy_greeter_contracts.js rename to shyft-cli/web3/token_test/deploy_greeter_contracts.js diff --git a/simulations/token_test/package.json b/shyft-cli/web3/token_test/package.json similarity index 100% rename from simulations/token_test/package.json rename to shyft-cli/web3/token_test/package.json diff --git a/simulations/token_test/token.sol b/shyft-cli/web3/token_test/token.sol similarity index 100% rename from simulations/token_test/token.sol rename to shyft-cli/web3/token_test/token.sol diff --git a/shyft-geth.sh b/shyft-geth.sh new file mode 100755 index 0000000000..b64fb5ec98 --- /dev/null +++ b/shyft-geth.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +if [[ $# -lt 1 ]]; then + echo + echo Shyft-Geth: No flags detected, see help: + echo + echo " --setup: Setups postgres and the shyft chain db." + echo " --start: Starts geth." + echo " --reset: Drops postgress and chain db, and reinstantiates both." + echo " --js [filename]: Executes web3 calls with a passed file name. If the file name is sendTransactions.js, $ ./shyft-geth.sh --js sendTransactions" + echo + exit 1 +fi + +illegalCommands=() +while [[ $# -gt 0 ]] +do +key="$1" +case $key in + --setup) + sh ./shyft-cli/setup.sh + shift # past argument + ;; + --start) + sh ./shyft-cli/startShyftGeth.sh + shift # past argument + ;; + --js) + sh ./shyft-cli/runJs.sh ./shyft-cli/web3/$2.js + shift # past argument + shift # past argument + ;; + --reset) + sh ./shyft-cli/shyftFullReset.sh + shift # past argument + ;; + *) # unknown option + illegalCommands+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done + +if [[ "${#illegalCommands[@]}" -gt "0" ]]; then + echo Shyft-Geth: The following commands are not supported: "${illegalCommands[*]}" +fi + diff --git a/shyftDb/postgres_setup/initdb.sh b/shyftDb/postgres_setup/initdb.sh deleted file mode 100644 index 1fb7d829c5..0000000000 --- a/shyftDb/postgres_setup/initdb.sh +++ /dev/null @@ -1 +0,0 @@ -psql -U postgres -f create_shyftdb.psql diff --git a/shyftFullReset.sh b/shyftFullReset.sh deleted file mode 100644 index 6fbcbc1683..0000000000 --- a/shyftFullReset.sh +++ /dev/null @@ -1,5 +0,0 @@ -cd ./shyftDb/postgres_setup -sh drop_tables.sh && sh init_tables.sh -cd .. -cd .. -sh resetShyftGeth.sh && sh initShyftGeth.sh \ No newline at end of file