From 952648549f68980faac4458334768728c5532396 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 3 Jun 2018 10:06:25 -0400 Subject: [PATCH 1/7] remove miner table --- shyftDb/postgres_setup/create_tables.psql | 5 ----- shyftDb/postgres_setup/drop_tables.psql | 1 - 2 files changed, 6 deletions(-) diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyftDb/postgres_setup/create_tables.psql index b0bdb516d3..687931f83c 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyftDb/postgres_setup/create_tables.psql @@ -41,8 +41,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/shyftDb/postgres_setup/drop_tables.psql index 2921358098..6316b8109c 100644 --- a/shyftDb/postgres_setup/drop_tables.psql +++ b/shyftDb/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 From 1a5118de49440dd690320b9b43d00876d01bb7a5 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 3 Jun 2018 14:15:29 -0400 Subject: [PATCH 2/7] add debug and admin to http modules --- config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"] From 4617325367c75be70112e0bf5811e265cb1b9971 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 3 Jun 2018 17:19:33 -0400 Subject: [PATCH 3/7] Convert all scripts into a basic bash cli --- .../initShyftGeth.sh | 2 +- .../postgres_setup/create_shyftdb.psql | 0 .../postgres_setup/create_tables.psql | 0 .../postgres_setup/drop_tables.psql | 0 .../postgres_setup/drop_tables.sh | 3 ++ .../postgres_setup/init_tables.sh | 3 ++ shyft-cli/postgres_setup/initdb.sh | 4 +++ .../resetShyftGeth.sh | 0 run_js_in_geth.sh => shyft-cli/runJs.sh | 2 +- shyft-cli/setup.sh | 17 +++++++++ shyft-cli/shyftFullReset.sh | 12 +++++++ .../startShyftGeth.sh | 0 .../web3}/checkbalances.js | 0 .../web3}/deployContract.js | 0 .../web3}/getGreeting.js | 0 .../web3}/sendTransactions.js | 0 .../web3}/token_test/README.md | 0 .../web3}/token_test/callGreeterFnsTest.js | 0 .../web3}/token_test/call_greeter_fns.js | 0 .../web3}/token_test/calltx.js | 0 .../web3}/token_test/deploy.js | 0 .../token_test/deploy_greeter_contracts.js | 0 .../web3}/token_test/package.json | 0 .../web3}/token_test/token.sol | 0 shyft-geth.sh | 36 +++++++++++++++++++ shyftDb/postgres_setup/initdb.sh | 1 - shyftFullReset.sh | 5 --- 27 files changed, 77 insertions(+), 8 deletions(-) rename initShyftGeth.sh => shyft-cli/initShyftGeth.sh (62%) rename {shyftDb => shyft-cli}/postgres_setup/create_shyftdb.psql (100%) rename {shyftDb => shyft-cli}/postgres_setup/create_tables.psql (100%) rename {shyftDb => shyft-cli}/postgres_setup/drop_tables.psql (100%) rename {shyftDb => shyft-cli}/postgres_setup/drop_tables.sh (52%) rename {shyftDb => shyft-cli}/postgres_setup/init_tables.sh (53%) create mode 100644 shyft-cli/postgres_setup/initdb.sh rename resetShyftGeth.sh => shyft-cli/resetShyftGeth.sh (100%) rename run_js_in_geth.sh => shyft-cli/runJs.sh (80%) create mode 100644 shyft-cli/setup.sh create mode 100644 shyft-cli/shyftFullReset.sh rename startShyftGeth.sh => shyft-cli/startShyftGeth.sh (100%) rename {simulations => shyft-cli/web3}/checkbalances.js (100%) rename {simulations => shyft-cli/web3}/deployContract.js (100%) rename {simulations => shyft-cli/web3}/getGreeting.js (100%) rename {simulations => shyft-cli/web3}/sendTransactions.js (100%) rename {simulations => shyft-cli/web3}/token_test/README.md (100%) rename {simulations => shyft-cli/web3}/token_test/callGreeterFnsTest.js (100%) rename {simulations => shyft-cli/web3}/token_test/call_greeter_fns.js (100%) rename {simulations => shyft-cli/web3}/token_test/calltx.js (100%) rename {simulations => shyft-cli/web3}/token_test/deploy.js (100%) rename {simulations => shyft-cli/web3}/token_test/deploy_greeter_contracts.js (100%) rename {simulations => shyft-cli/web3}/token_test/package.json (100%) rename {simulations => shyft-cli/web3}/token_test/token.sol (100%) create mode 100755 shyft-geth.sh delete mode 100644 shyftDb/postgres_setup/initdb.sh delete mode 100644 shyftFullReset.sh diff --git a/initShyftGeth.sh b/shyft-cli/initShyftGeth.sh similarity index 62% rename from initShyftGeth.sh rename to shyft-cli/initShyftGeth.sh index c6a8d115e1..222a23e052 100755 --- a/initShyftGeth.sh +++ b/shyft-cli/initShyftGeth.sh @@ -1,2 +1,2 @@ #!/bin/sh -./build/bin/geth --identity "ShyftTestnetNode" --keystore ./ --datadir "./shyftData" init ShyftNetwork.json \ No newline at end of file +./build/bin/geth --identity "ShyftTestnetNode" --keystore ./ --datadir "./shyftData" init ShyftNetwork.json 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 100% rename from shyftDb/postgres_setup/create_tables.psql rename to shyft-cli/postgres_setup/create_tables.psql diff --git a/shyftDb/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql similarity index 100% rename from shyftDb/postgres_setup/drop_tables.psql rename to shyft-cli/postgres_setup/drop_tables.psql 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..5104f01844 --- /dev/null +++ b/shyft-geth.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +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 + 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 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 From 985ddce0d23b71f73630ef2a1e8a61b024fe911f Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 3 Jun 2018 17:27:01 -0400 Subject: [PATCH 4/7] remove newline --- shyft-cli/initShyftGeth.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shyft-cli/initShyftGeth.sh b/shyft-cli/initShyftGeth.sh index 222a23e052..c6a8d115e1 100755 --- a/shyft-cli/initShyftGeth.sh +++ b/shyft-cli/initShyftGeth.sh @@ -1,2 +1,2 @@ #!/bin/sh -./build/bin/geth --identity "ShyftTestnetNode" --keystore ./ --datadir "./shyftData" init ShyftNetwork.json +./build/bin/geth --identity "ShyftTestnetNode" --keystore ./ --datadir "./shyftData" init ShyftNetwork.json \ No newline at end of file From 88d516c9d0cdcbb1b89f97cb683a3dc47cb61fbd Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 3 Jun 2018 18:15:16 -0400 Subject: [PATCH 5/7] update readme --- README.md | 12 ++++++++++++ shyft-geth.sh | 11 ++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3d0d4d35d4..7476466d6d 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,18 @@ 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 example: filename = sendTransactions.js `--js sendTransactions` + +Note: An alias can be set for convenience `alias shyft-geth='/shyft_go-ethereum/shyft-geth.sh'` + ## Contribution Thank you for considering to help out with the source code! We welcome contributions from diff --git a/shyft-geth.sh b/shyft-geth.sh index 5104f01844..f80ee219f7 100755 --- a/shyft-geth.sh +++ b/shyft-geth.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [[ $# -lt 1 ]]; then + echo Shyft-Geth: No flags detected, refer to readme for available commands. + exit 1 +fi + illegalCommands=() while [[ $# -gt 0 ]] do @@ -15,7 +20,7 @@ case $key in shift # past argument ;; --js) - sh ./shyft-cli/runJs.sh ./shyft-cli/web3/$2 + sh ./shyft-cli/runJs.sh ./shyft-cli/web3/$2.js shift # past argument shift # past argument ;; @@ -30,7 +35,7 @@ case $key in esac done -if [[ "${#illegalCommands[@]}" -gt "0" ]] ; then - echo The following commands are not supported: "${illegalCommands[*]}" +if [[ "${#illegalCommands[@]}" -gt "0" ]]; then + echo Shyft-Geth: The following commands are not supported: "${illegalCommands[*]}" fi From 0719d414e6585f9e33e9d15487a8083a4eb0f4cc Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 3 Jun 2018 18:40:20 -0400 Subject: [PATCH 6/7] add help log for clie --- README.md | 6 +++--- shyft-geth.sh | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7476466d6d..d8f1f31831 100644 --- a/README.md +++ b/README.md @@ -282,10 +282,10 @@ limit blocks converge to (`--targetgaslimit`) and the price transactions are acc #### CLI Run `./shyft-geth.sh` with one of the following flags: -- `--setup` - Setups postgres and the shyft chain db -- `--start` - Starts geth +- `--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 example: filename = sendTransactions.js `--js sendTransactions` +- `--js [web3 filename]` - Executes web3 calls with a passed file name. If the file name is `sendTransactions.js`, `./shyft-geth.sh --js sendTransactions`. Note: An alias can be set for convenience `alias shyft-geth='/shyft_go-ethereum/shyft-geth.sh'` diff --git a/shyft-geth.sh b/shyft-geth.sh index f80ee219f7..f257e38a81 100755 --- a/shyft-geth.sh +++ b/shyft-geth.sh @@ -1,7 +1,14 @@ #!/bin/bash if [[ $# -lt 1 ]]; then - echo Shyft-Geth: No flags detected, refer to readme for available commands. + 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 From 285be847d7ade57cca0c15753ec82747d40f888e Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 3 Jun 2018 18:47:34 -0400 Subject: [PATCH 7/7] update readme --- README.md | 2 -- shyft-geth.sh | 1 - 2 files changed, 3 deletions(-) diff --git a/README.md b/README.md index d8f1f31831..d8733058f8 100644 --- a/README.md +++ b/README.md @@ -287,8 +287,6 @@ Run `./shyft-geth.sh` with one of the following flags: - `--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`. -Note: An alias can be set for convenience `alias shyft-geth='/shyft_go-ethereum/shyft-geth.sh'` - ## Contribution Thank you for considering to help out with the source code! We welcome contributions from diff --git a/shyft-geth.sh b/shyft-geth.sh index f257e38a81..b64fb5ec98 100755 --- a/shyft-geth.sh +++ b/shyft-geth.sh @@ -16,7 +16,6 @@ illegalCommands=() while [[ $# -gt 0 ]] do key="$1" - case $key in --setup) sh ./shyft-cli/setup.sh