Skip to content

Commit

Permalink
Web3: Start KEVM Web3 Client with default accounts (#522)
Browse files Browse the repository at this point in the history
* kevm: implement kevm-client

* kevm: update help message

* kevm: change to web3-client to web3-ganache

* kevm: use notif instead of echo
  • Loading branch information
anvacaru authored and rv-jenkins committed Oct 19, 2019
1 parent 96d7b64 commit 5a67a5b
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions kevm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ run_web3_send() {
| netcat 127.0.0.1 "$web3_port" -q 0
}

run_web3_ganache() {
local web3_port
web3_port="$1" ; shift

notif 'Launching web3 client'
$0 web3 "$web3_port" "$@" &
while ! netcat -z 127.0.0.1 "$web3_port"; do sleep 0.1; done
notif 'Generating accounts'
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0xdc7e9a7c64933ab893160b79d099c254d274e1c40c6df6d5239e1a623e3d6de1", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0x6e2687f9732d970c6b1d5baa3dff26c4af36257552bc17df737afbc00ca70de2", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0xd34d8e873da77217abaef9424a7d87fce351b603920c7f5288d7701c5f148860", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0x976b5ec9253759d4a2746c37597841beba57527123dc3db2165b637adce58bcb", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0x23dff7ac7981167eb5386e51c3d6d2e3ca9dc219315749b2058d0a2d1e21625e", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0xe040e4bf96d8c9d3a8d1ffb22b30ed4b0a79a25342d656c5a8e2784b0fab752f", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0x13abddd7d94165fc46bed2cad6b0b14cd0267a85f70ad5c26cce82c609e0bf87", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0x0e29f7d6984bb47d60db479212ca56af516705b07d8753b474bd7f0db8bc1921", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0xea7fe1480e9ab71c261c5e1e727f36482f84dbdb07dbf8c8e9f767dcecf87568", "balance":"0x56BC75E2D63100000"'}
$0 web3-send "$web3_port" firefly_addAccount {'"key":"0x5f9addbbf41ae2e3d6cb7b07ffabf2c5ff6edc3a38c9dd64a9afd23df02ad7ee", "balance":"0x56BC75E2D63100000"'}
}

run_klab() {
local run_mode klab_log

Expand Down Expand Up @@ -167,16 +187,17 @@ run_command="$1" ; shift

if [[ "$run_command" == 'help' ]]; then
echo "
usage: $0 run [--backend (ocaml|java|llvm|haskell)] <pgm> <K arg>*
$0 interpret [--backend (ocaml|llvm)] [--debug] <pgm> <interpreter arg>*
$0 kast [--backend (ocaml|java|llvm|haskell|web3)] <pgm> <output format> <K arg>*
$0 prove [--backend (java|haskell)] <spec> <K arg>* -m <def_module>
$0 search [--backend (java|haskell)] <pgm> <pattern> <K arg>*
$0 web3 [--debug|--dump] <port>
$0 web3-send <port> <web3 method> <web3 params>
$0 klab-run <pgm> <K arg>*
$0 klab-prove <spec> <K arg>* -m <def_module>
$0 klab-view <spec>
usage: $0 run [--backend (ocaml|java|llvm|haskell)] <pgm> <K arg>*
$0 interpret [--backend (ocaml|llvm)] [--debug] <pgm> <interpreter arg>*
$0 kast [--backend (ocaml|java|llvm|haskell|web3)] <pgm> <output format> <K arg>*
$0 prove [--backend (java|haskell)] <spec> <K arg>* -m <def_module>
$0 search [--backend (java|haskell)] <pgm> <pattern> <K arg>*
$0 web3 [--debug|--dump] <port>
$0 web3-ganache [--debug|--dump] <port>
$0 web3-send <port> <web3 method> <web3 params>
$0 klab-run <pgm> <K arg>*
$0 klab-prove <spec> <K arg>* -m <def_module>
$0 klab-view <spec>
$0 run : Run a single EVM program
$0 interpret : Run JSON EVM programs without K Frontend (external parser)
Expand All @@ -185,6 +206,7 @@ if [[ "$run_command" == 'help' ]]; then
$0 search : Search for a K pattern in an EVM program execution
$0 web3 : Run version of semantics which understand Web3 RPC (**UNDER CONSTRUCTION**)
$0 web3-send : Send message to running Web3 instance of KEVM (**UNDER CONSTRUCTION**)
$0 web3-ganache : Run version of semantics which understand Web3 RPC and is able to communicate with Truffle Test Framework (**UNDER CONSTRUCTION**)
$0 klab-(run|prove) : Run program or prove spec and dump StateLogs which KLab can read
$0 klab-view : View the statelog associated with a given program or spec
Expand Down Expand Up @@ -257,6 +279,7 @@ case "$run_command-$backend" in
search-@(java|haskell) ) run_search "$@" ;;
web3-@(llvm) ) run_web3 "$@" ;;
web3-send-@(llvm) ) run_web3_send "$@" ;;
web3-ganache-@(llvm) ) run_web3_ganache "$@" ;;
klab-@(run|prove)-java ) run_klab "${run_command#klab-}" "$@" ;;
klab-view-java ) view_klab "$@" ;;
*) $0 help ; fatal "Unknown command on backend: $run_command $backend" ;;
Expand Down

0 comments on commit 5a67a5b

Please sign in to comment.