From 5bb208a22bbb36abbaa2e888b8b6698cdeb32f65 Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Tue, 13 Jun 2017 14:52:39 -0400 Subject: [PATCH 01/10] Fixed the Info to return Hash and Height, and rearranged the Set/Saves for atomicity --- app/app.go | 26 +++++++++++++++++++------- app/state.go | 16 +++++++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/app.go b/app/app.go index 7083f8e32..8fec1c0d8 100644 --- a/app/app.go +++ b/app/app.go @@ -1,6 +1,7 @@ package app import ( + "bytes" "fmt" "path" @@ -17,6 +18,7 @@ type MerkleEyesApp struct { state State db dbm.DB + hash []byte height uint64 } @@ -41,7 +43,7 @@ const ( func NewMerkleEyesApp(dbName string, cacheSize int) *MerkleEyesApp { // start at 1 so the height returned by query is for the // next block, ie. the one that includes the AppHash for our current state - initialHeight := uint64(1) + initialHeight := uint64(0) // Non-persistent case if dbName == "" { @@ -68,7 +70,7 @@ func NewMerkleEyesApp(dbName string, cacheSize int) *MerkleEyesApp { if empty { fmt.Println("no existing db, creating new db") db.Set(eyesStateKey, wire.BinaryBytes(MerkleEyesState{ - Hash: tree.Save(), + Hash: nil, Height: initialHeight, })) } else { @@ -99,7 +101,11 @@ func (app *MerkleEyesApp) CloseDB() { } func (app *MerkleEyesApp) Info() abci.ResponseInfo { - return abci.ResponseInfo{Data: cmn.Fmt("size:%v", app.state.Committed().Size())} + return abci.ResponseInfo{ + Data: cmn.Fmt("size:%v", app.state.Committed().Size()), + LastBlockHeight: app.height, + LastBlockAppHash: app.hash, + } } func (app *MerkleEyesApp) SetOption(key string, value string) (log string) { @@ -158,20 +164,26 @@ func (app *MerkleEyesApp) doTx(tree merkle.Tree, tx []byte) abci.Result { func (app *MerkleEyesApp) Commit() abci.Result { - hash := app.state.Commit() - + app.hash = app.state.Hash() app.height++ + if app.db != nil { + // Must in the same batch update as the tree app.db.Set(eyesStateKey, wire.BinaryBytes(MerkleEyesState{ - Hash: hash, + Hash: app.hash, Height: app.height, })) } + hash := app.state.Commit() + if !bytes.Equal(hash, app.hash) { + panic("App hash is incorrect") + } + if app.state.Committed().Size() == 0 { return abci.NewResultOK(nil, "Empty hash for empty tree") } - return abci.NewResultOK(hash, "") + return abci.NewResultOK(app.hash, "") } func (app *MerkleEyesApp) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQuery) { diff --git a/app/state.go b/app/state.go index 031271768..5d19ce71f 100644 --- a/app/state.go +++ b/app/state.go @@ -32,17 +32,27 @@ func (s State) Check() merkle.Tree { return s.checkTx } -// Commit stores the current Append() state as committed +// PreCommit stores the current Append() state as committed // starts new Append/Check state, and // returns the hash for the commit -func (s *State) Commit() []byte { +func (s *State) Hash() []byte { var hash []byte if s.persistent { - hash = s.deliverTx.Save() + // Don't save it right now, just calc the hash + hash = s.deliverTx.Hash() } else { hash = s.deliverTx.Hash() } + return hash +} +func (s *State) Commit() []byte { + var hash []byte + if s.persistent { + hash = s.committed.Save() + } else { + hash = s.committed.Hash() + } s.committed = s.deliverTx s.deliverTx = s.committed.Copy() s.checkTx = s.committed.Copy() From 52d22a9da2571be4c5f20765d83ff5b60d6f9b94 Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Tue, 13 Jun 2017 16:59:33 -0400 Subject: [PATCH 02/10] Added in basic commands to check the height --- tests/tendermint/height.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/tendermint/height.sh diff --git a/tests/tendermint/height.sh b/tests/tendermint/height.sh new file mode 100644 index 000000000..b42104878 --- /dev/null +++ b/tests/tendermint/height.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +curl http://localhost:46657/status 2>/dev/null | jq .result.latest_block_height; + +curl curl http://localhost:46657/abci_query\?data\=0x1234\&path\=\"/key\" 2>/dev/null | jq .result.response + From 49642ec5b55c09903458de46a5b11f201d357c3d Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Tue, 13 Jun 2017 17:18:13 -0400 Subject: [PATCH 03/10] Simple test to show that tendermint and merkleeyes heights are in sync --- tests/tendermint/height.sh | 0 tests/tendermint/height_test.sh | 12 ++++++++++++ tests/tendermint/kill-tendermerk.sh | 12 ++++++++++++ tests/tendermint/restart-tendermerk.sh | 7 +++++++ tests/tendermint/start-tendermerk.sh | 10 ++++++++++ 5 files changed, 41 insertions(+) mode change 100644 => 100755 tests/tendermint/height.sh create mode 100755 tests/tendermint/height_test.sh create mode 100755 tests/tendermint/kill-tendermerk.sh create mode 100755 tests/tendermint/restart-tendermerk.sh create mode 100755 tests/tendermint/start-tendermerk.sh diff --git a/tests/tendermint/height.sh b/tests/tendermint/height.sh old mode 100644 new mode 100755 diff --git a/tests/tendermint/height_test.sh b/tests/tendermint/height_test.sh new file mode 100755 index 000000000..a6f2b6820 --- /dev/null +++ b/tests/tendermint/height_test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +./start-tendermerk.sh +sleep 5 +./height.sh +./kill-tendermerk.sh +sleep 5 + +./restart-tendermerk.sh +sleep 5 +./height.sh +./kill-tendermerk.sh diff --git a/tests/tendermint/kill-tendermerk.sh b/tests/tendermint/kill-tendermerk.sh new file mode 100755 index 000000000..dbed44b69 --- /dev/null +++ b/tests/tendermint/kill-tendermerk.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +TPID=`pidof tendermint` +MPID=`pidof merkleeyes` + +if [ -n "$TPID" ]; then + kill $TPID +fi + +if [ -n "$MPID" ]; then + kill $MPID +fi diff --git a/tests/tendermint/restart-tendermerk.sh b/tests/tendermint/restart-tendermerk.sh new file mode 100755 index 000000000..d7d49c7c6 --- /dev/null +++ b/tests/tendermint/restart-tendermerk.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +merkleeyes start -d orphan-test-db --address=tcp://127.0.0.1:46658 >> merkleeyes.log & + +tendermint node >> tendermint.log & + +sleep 4 diff --git a/tests/tendermint/start-tendermerk.sh b/tests/tendermint/start-tendermerk.sh new file mode 100755 index 000000000..b66768276 --- /dev/null +++ b/tests/tendermint/start-tendermerk.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +rm -rf orphan-test-db +merkleeyes start -d orphan-test-db --address=tcp://127.0.0.1:46658 >> merkleeyes.log & + +rm -rf ~/.tendermint +tendermint init +tendermint node >> tendermint.log & + +sleep 4 From 4d69b3ece42062e17f63cc207125ec416d9ad54a Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Tue, 13 Jun 2017 19:25:22 -0400 Subject: [PATCH 04/10] Inserted the StateKey into the db batch with the Saved nodes --- app/app.go | 9 +++++---- app/state.go | 5 +++-- iavl/iavl_tree.go | 5 +++++ tests/tendermint/kill-tendermerk.sh | 2 ++ tests/tendermint/restart-tendermerk.sh | 2 ++ tests/tendermint/start-tendermerk.sh | 2 ++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index 8fec1c0d8..f242d32d4 100644 --- a/app/app.go +++ b/app/app.go @@ -70,7 +70,7 @@ func NewMerkleEyesApp(dbName string, cacheSize int) *MerkleEyesApp { if empty { fmt.Println("no existing db, creating new db") db.Set(eyesStateKey, wire.BinaryBytes(MerkleEyesState{ - Hash: nil, + Hash: tree.Save(), Height: initialHeight, })) } else { @@ -168,8 +168,9 @@ func (app *MerkleEyesApp) Commit() abci.Result { app.height++ if app.db != nil { - // Must in the same batch update as the tree - app.db.Set(eyesStateKey, wire.BinaryBytes(MerkleEyesState{ + // This is in the batch with the Save, but not in the tree + tree := app.state.Append().(*iavl.IAVLTree) + tree.BatchSet(eyesStateKey, wire.BinaryBytes(MerkleEyesState{ Hash: app.hash, Height: app.height, })) @@ -177,7 +178,7 @@ func (app *MerkleEyesApp) Commit() abci.Result { hash := app.state.Commit() if !bytes.Equal(hash, app.hash) { - panic("App hash is incorrect") + panic("AppHash is incorrect") } if app.state.Committed().Size() == 0 { diff --git a/app/state.go b/app/state.go index 5d19ce71f..38df07b0c 100644 --- a/app/state.go +++ b/app/state.go @@ -49,10 +49,11 @@ func (s *State) Hash() []byte { func (s *State) Commit() []byte { var hash []byte if s.persistent { - hash = s.committed.Save() + hash = s.deliverTx.Save() } else { - hash = s.committed.Hash() + hash = s.deliverTx.Hash() } + s.committed = s.deliverTx s.deliverTx = s.committed.Copy() s.checkTx = s.committed.Copy() diff --git a/iavl/iavl_tree.go b/iavl/iavl_tree.go index 82aee8600..b644612d0 100644 --- a/iavl/iavl_tree.go +++ b/iavl/iavl_tree.go @@ -103,6 +103,11 @@ func (t *IAVLTree) Set(key []byte, value []byte) (updated bool) { return updated } +// BatchSet adds a Set to the current batch, will get handled atomically +func (t *IAVLTree) BatchSet(key []byte, value []byte) { + t.ndb.batch.Set(key, value) +} + func (t *IAVLTree) Hash() []byte { if t.root == nil { return nil diff --git a/tests/tendermint/kill-tendermerk.sh b/tests/tendermint/kill-tendermerk.sh index dbed44b69..cb95959fa 100755 --- a/tests/tendermint/kill-tendermerk.sh +++ b/tests/tendermint/kill-tendermerk.sh @@ -3,6 +3,8 @@ TPID=`pidof tendermint` MPID=`pidof merkleeyes` +echo "Stopping Merkleeyes and Tendermint" + if [ -n "$TPID" ]; then kill $TPID fi diff --git a/tests/tendermint/restart-tendermerk.sh b/tests/tendermint/restart-tendermerk.sh index d7d49c7c6..d1ef3bfa2 100755 --- a/tests/tendermint/restart-tendermerk.sh +++ b/tests/tendermint/restart-tendermerk.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "Restarting Merkleeyes and Tendermint" + merkleeyes start -d orphan-test-db --address=tcp://127.0.0.1:46658 >> merkleeyes.log & tendermint node >> tendermint.log & diff --git a/tests/tendermint/start-tendermerk.sh b/tests/tendermint/start-tendermerk.sh index b66768276..348a14934 100755 --- a/tests/tendermint/start-tendermerk.sh +++ b/tests/tendermint/start-tendermerk.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "Starting Merkleeyes and Tendermint" + rm -rf orphan-test-db merkleeyes start -d orphan-test-db --address=tcp://127.0.0.1:46658 >> merkleeyes.log & From e6078411c4d81a57d3cc9a13217c3e9bfc3c5fcd Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Tue, 13 Jun 2017 19:29:59 -0400 Subject: [PATCH 05/10] Fixed the comments for Hash and Commit --- app/state.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/state.go b/app/state.go index 38df07b0c..f1fd19718 100644 --- a/app/state.go +++ b/app/state.go @@ -32,9 +32,7 @@ func (s State) Check() merkle.Tree { return s.checkTx } -// PreCommit stores the current Append() state as committed -// starts new Append/Check state, and -// returns the hash for the commit +// Hash updates the tree func (s *State) Hash() []byte { var hash []byte if s.persistent { @@ -46,6 +44,7 @@ func (s *State) Hash() []byte { return hash } +// Commit save persistent nodes to the database and re-copies the trees func (s *State) Commit() []byte { var hash []byte if s.persistent { From 9869d0bbbbafbefe61d41556784482364a5dedf5 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 14 Jun 2017 18:59:33 +0200 Subject: [PATCH 06/10] kill-tendermerk works on osx, added cleanup script --- tests/tendermint/cleanup.sh | 7 +++++++ tests/tendermint/kill-tendermerk.sh | 13 ++----------- 2 files changed, 9 insertions(+), 11 deletions(-) create mode 100755 tests/tendermint/cleanup.sh diff --git a/tests/tendermint/cleanup.sh b/tests/tendermint/cleanup.sh new file mode 100755 index 000000000..7ed474cac --- /dev/null +++ b/tests/tendermint/cleanup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "Cleaning up old test results" + +rm -rf orphan-test-db +rm merkleeyes.log +rm tendermint.log diff --git a/tests/tendermint/kill-tendermerk.sh b/tests/tendermint/kill-tendermerk.sh index cb95959fa..97a679501 100755 --- a/tests/tendermint/kill-tendermerk.sh +++ b/tests/tendermint/kill-tendermerk.sh @@ -1,14 +1,5 @@ #!/bin/bash -TPID=`pidof tendermint` -MPID=`pidof merkleeyes` - echo "Stopping Merkleeyes and Tendermint" - -if [ -n "$TPID" ]; then - kill $TPID -fi - -if [ -n "$MPID" ]; then - kill $MPID -fi +killall tendermint +killall merkleeyes From e3cbe63d4e16030def93ebb8e59dbabdff0acc2c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 14 Jun 2017 19:35:32 +0200 Subject: [PATCH 07/10] Added some tests with an actual tx before replay --- tests/tendermint/cleanup.sh | 1 + tests/tendermint/height.sh | 10 ++++++++-- tests/tendermint/start-tendermerk.sh | 9 +++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/tendermint/cleanup.sh b/tests/tendermint/cleanup.sh index 7ed474cac..7636c58fb 100755 --- a/tests/tendermint/cleanup.sh +++ b/tests/tendermint/cleanup.sh @@ -5,3 +5,4 @@ echo "Cleaning up old test results" rm -rf orphan-test-db rm merkleeyes.log rm tendermint.log +rm query.txt diff --git a/tests/tendermint/height.sh b/tests/tendermint/height.sh index b42104878..1e980d583 100755 --- a/tests/tendermint/height.sh +++ b/tests/tendermint/height.sh @@ -1,6 +1,12 @@ #!/bin/sh -curl http://localhost:46657/status 2>/dev/null | jq .result.latest_block_height; +curl http://localhost:46657/status 2>/dev/null | jq '.result | .latest_block_height, .latest_block_hash, .latest_app_hash' -curl curl http://localhost:46657/abci_query\?data\=0x1234\&path\=\"/key\" 2>/dev/null | jq .result.response +# store query for consistent parsing +curl http://localhost:46657/abci_query\?data\=0x1234\&path\=\"/key\"\&prove=true 2>/dev/null > query.txt +# get the apphash from the proof +cat query.txt | jq '.result.response.proof' | cut -c8-47 + +# get the height +cat query.txt | jq '.result.response' diff --git a/tests/tendermint/start-tendermerk.sh b/tests/tendermint/start-tendermerk.sh index 348a14934..8f0c72631 100755 --- a/tests/tendermint/start-tendermerk.sh +++ b/tests/tendermint/start-tendermerk.sh @@ -1,12 +1,17 @@ #!/bin/bash +./cleanup.sh + echo "Starting Merkleeyes and Tendermint" -rm -rf orphan-test-db merkleeyes start -d orphan-test-db --address=tcp://127.0.0.1:46658 >> merkleeyes.log & rm -rf ~/.tendermint tendermint init tendermint node >> tendermint.log & -sleep 4 +sleep 5 + +curl http://localhost:46657/broadcast_tx_commit\?tx\=0x0101021234010177 + +sleep 5 From ce2a4fb6954d9f6293572a30f93c951cb1c0a897 Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Thu, 15 Jun 2017 23:10:33 -0400 Subject: [PATCH 08/10] Set the initial height to 1 and fixed info height --- app/app.go | 12 ++++-- tests/tendermint/cleanup.sh | 8 ++-- tests/tendermint/eightbytekey.go | 12 ++++++ tests/tendermint/gen_merk_trans.sh | 13 ++++++ tests/tendermint/height.sh | 58 ++++++++++++++++++++++---- tests/tendermint/height_test.sh | 11 +++-- tests/tendermint/restart-tendermerk.sh | 6 +++ tests/tendermint/start-tendermerk.sh | 4 -- tests/tendermint/transaction.sh | 17 ++++++++ 9 files changed, 120 insertions(+), 21 deletions(-) create mode 100644 tests/tendermint/eightbytekey.go create mode 100755 tests/tendermint/gen_merk_trans.sh create mode 100755 tests/tendermint/transaction.sh diff --git a/app/app.go b/app/app.go index f242d32d4..75f7e31bb 100644 --- a/app/app.go +++ b/app/app.go @@ -43,7 +43,7 @@ const ( func NewMerkleEyesApp(dbName string, cacheSize int) *MerkleEyesApp { // start at 1 so the height returned by query is for the // next block, ie. the one that includes the AppHash for our current state - initialHeight := uint64(0) + initialHeight := uint64(1) // Non-persistent case if dbName == "" { @@ -85,12 +85,14 @@ func NewMerkleEyesApp(dbName string, cacheSize int) *MerkleEyesApp { fmt.Println("error reading MerkleEyesState") panic(err.Error()) } + tree.Load(eyesState.Hash) return &MerkleEyesApp{ state: NewState(tree, true), db: db, height: eyesState.Height, + hash: eyesState.Hash, } } @@ -100,10 +102,13 @@ func (app *MerkleEyesApp) CloseDB() { } } +// Info returns the height, hash and size (in the data) +// the height is the block that holds the transactions, not the apphash itself func (app *MerkleEyesApp) Info() abci.ResponseInfo { + fmt.Printf("Info height %d hash %x\n", app.height, app.hash) return abci.ResponseInfo{ Data: cmn.Fmt("size:%v", app.state.Committed().Size()), - LastBlockHeight: app.height, + LastBlockHeight: app.height - 1, LastBlockAppHash: app.hash, } } @@ -166,6 +171,7 @@ func (app *MerkleEyesApp) Commit() abci.Result { app.hash = app.state.Hash() app.height++ + fmt.Printf("height=%d,hash=%x\n", app.height, app.hash) if app.db != nil { // This is in the batch with the Save, but not in the tree @@ -200,7 +206,7 @@ func (app *MerkleEyesApp) Query(reqQuery abci.RequestQuery) (resQuery abci.Respo return } - // set the query response height + // set the query response height to current resQuery.Height = app.height switch reqQuery.Path { diff --git a/tests/tendermint/cleanup.sh b/tests/tendermint/cleanup.sh index 7636c58fb..8d6b683b0 100755 --- a/tests/tendermint/cleanup.sh +++ b/tests/tendermint/cleanup.sh @@ -2,7 +2,7 @@ echo "Cleaning up old test results" -rm -rf orphan-test-db -rm merkleeyes.log -rm tendermint.log -rm query.txt +rm -rf orphan-test-db 2>/dev/null +rm merkleeyes.log 2>/dev/null +rm tendermint.log 2>/dev/null +rm query.txt 2>/dev/null diff --git a/tests/tendermint/eightbytekey.go b/tests/tendermint/eightbytekey.go new file mode 100644 index 000000000..00c917fa5 --- /dev/null +++ b/tests/tendermint/eightbytekey.go @@ -0,0 +1,12 @@ +package main + +import ( + "crypto/rand" + "fmt" +) + +func main() { + buf := make([]byte, 8) + rand.Read(buf) + fmt.Printf("%x\n", buf) +} diff --git a/tests/tendermint/gen_merk_trans.sh b/tests/tendermint/gen_merk_trans.sh new file mode 100755 index 000000000..db67d9f43 --- /dev/null +++ b/tests/tendermint/gen_merk_trans.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ "$1" = "" ]; then + key=$(go run eightbytekey.go) +else + key=$1 +fi +key_size=0108 +value=33 +value_size=0101 + +echo -n 0x01${key_size}${key}${value_size}${value} + diff --git a/tests/tendermint/height.sh b/tests/tendermint/height.sh index 1e980d583..9dd0641aa 100755 --- a/tests/tendermint/height.sh +++ b/tests/tendermint/height.sh @@ -1,12 +1,56 @@ -#!/bin/sh +#!/bin/bash -curl http://localhost:46657/status 2>/dev/null | jq '.result | .latest_block_height, .latest_block_hash, .latest_app_hash' +echo "Sending a transaction" -# store query for consistent parsing -curl http://localhost:46657/abci_query\?data\=0x1234\&path\=\"/key\"\&prove=true 2>/dev/null > query.txt +key=$(go run eightbytekey.go) +tx=`./gen_merk_trans.sh ${key}` + +echo -n "Hash=" +curl http://localhost:46657/broadcast_tx_commit\?tx\=${tx} 2>/dev/null |\ +jq 'if .result == 0 then + "No Result" +elif .check_tx.log > 2 then + .result | .check_tx.log +else + .result | .hash +end' +echo "" + +echo "Checking its height" + +curl http://localhost:46657/status 2>/dev/null > status.txt +curl http://localhost:46657/abci_query\?data\=0x${key}\&path\=\"/key\"\&prove=true 2>/dev/null > query.txt + +echo -n "status height=" +cat status.txt | jq '.result.latest_block_height' + +echo -n "query height=" +cat query.txt | jq '.result.response.height' + +echo -n "status apphash=" +cat status.txt | jq '.result.latest_app_hash' + +# get the apphash from the proof +echo -n "root in proof=" +cat query.txt | jq '.result.response.proof' + +# A second time +sleep 1 +curl http://localhost:46657/status 2>/dev/null > status.txt +curl http://localhost:46657/abci_query\?data\=0x${key}\&path\=\"/key\"\&prove=true 2>/dev/null > query.txt + +echo -n "status height=" +cat status.txt | jq '.result.latest_block_height' + +echo -n "query height=" +cat query.txt | jq '.result.response.height' + +echo -n "status apphash=" +cat status.txt | jq '.result.latest_app_hash' # get the apphash from the proof -cat query.txt | jq '.result.response.proof' | cut -c8-47 +echo -n "root in proof=" +cat query.txt | jq '.result.response.proof' +#cat query.txt | jq '.result.response.proof' | cut -c8-47 -# get the height -cat query.txt | jq '.result.response' +echo "" diff --git a/tests/tendermint/height_test.sh b/tests/tendermint/height_test.sh index a6f2b6820..f8aacdf98 100755 --- a/tests/tendermint/height_test.sh +++ b/tests/tendermint/height_test.sh @@ -1,12 +1,17 @@ #!/bin/bash ./start-tendermerk.sh -sleep 5 +./transaction.sh +./height.sh +./transaction.sh +./height.sh +./transaction.sh ./height.sh ./kill-tendermerk.sh -sleep 5 ./restart-tendermerk.sh -sleep 5 +./transaction.sh +./height.sh +./transaction.sh ./height.sh ./kill-tendermerk.sh diff --git a/tests/tendermint/restart-tendermerk.sh b/tests/tendermint/restart-tendermerk.sh index d1ef3bfa2..f6468e47e 100755 --- a/tests/tendermint/restart-tendermerk.sh +++ b/tests/tendermint/restart-tendermerk.sh @@ -7,3 +7,9 @@ merkleeyes start -d orphan-test-db --address=tcp://127.0.0.1:46658 >> merkleeyes tendermint node >> tendermint.log & sleep 4 + +TPID=`pidof tendermint` +if [ -z "$TPID" ]; then + tail tendermint.log + exit 20 +fi diff --git a/tests/tendermint/start-tendermerk.sh b/tests/tendermint/start-tendermerk.sh index 8f0c72631..b7b1e8248 100755 --- a/tests/tendermint/start-tendermerk.sh +++ b/tests/tendermint/start-tendermerk.sh @@ -11,7 +11,3 @@ tendermint init tendermint node >> tendermint.log & sleep 5 - -curl http://localhost:46657/broadcast_tx_commit\?tx\=0x0101021234010177 - -sleep 5 diff --git a/tests/tendermint/transaction.sh b/tests/tendermint/transaction.sh new file mode 100755 index 000000000..904d8cc57 --- /dev/null +++ b/tests/tendermint/transaction.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Sending a transaction" + +echo -n "Hash=" +tx=`./gen_merk_trans.sh` + +curl http://localhost:46657/broadcast_tx_commit\?tx\=${tx} 2>/dev/null |\ +jq 'if .result == 0 then + "No Result" +elif .check_tx.log > 2 then + .result | .check_tx.log +else + .result | .hash +end' + +echo "" From 4a5f1e10767eff8c563d71e5ff27e702da279ced Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Thu, 15 Jun 2017 23:21:40 -0400 Subject: [PATCH 09/10] Formatting changes to tests --- tests/tendermint/height.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/tendermint/height.sh b/tests/tendermint/height.sh index 9dd0641aa..c1509183b 100755 --- a/tests/tendermint/height.sh +++ b/tests/tendermint/height.sh @@ -31,7 +31,7 @@ echo -n "status apphash=" cat status.txt | jq '.result.latest_app_hash' # get the apphash from the proof -echo -n "root in proof=" +echo -n "query proof=" cat query.txt | jq '.result.response.proof' # A second time @@ -49,8 +49,7 @@ echo -n "status apphash=" cat status.txt | jq '.result.latest_app_hash' # get the apphash from the proof -echo -n "root in proof=" +echo -n "query proof=" cat query.txt | jq '.result.response.proof' -#cat query.txt | jq '.result.response.proof' | cut -c8-47 echo "" From e8111896a9564ea7da789bf33750a24ec04b9142 Mon Sep 17 00:00:00 2001 From: "Paul W. Homer" Date: Wed, 21 Jun 2017 12:56:20 -0400 Subject: [PATCH 10/10] Removed unnecessary code and tightened the start-tendermerk script. --- app/state.go | 9 +-------- tests/tendermint/start-tendermerk.sh | 9 ++++++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/state.go b/app/state.go index f1fd19718..47c6d9b36 100644 --- a/app/state.go +++ b/app/state.go @@ -34,14 +34,7 @@ func (s State) Check() merkle.Tree { // Hash updates the tree func (s *State) Hash() []byte { - var hash []byte - if s.persistent { - // Don't save it right now, just calc the hash - hash = s.deliverTx.Hash() - } else { - hash = s.deliverTx.Hash() - } - return hash + return s.deliverTx.Hash() } // Commit save persistent nodes to the database and re-copies the trees diff --git a/tests/tendermint/start-tendermerk.sh b/tests/tendermint/start-tendermerk.sh index b7b1e8248..7a20bd37c 100755 --- a/tests/tendermint/start-tendermerk.sh +++ b/tests/tendermint/start-tendermerk.sh @@ -8,6 +8,13 @@ merkleeyes start -d orphan-test-db --address=tcp://127.0.0.1:46658 >> merkleeyes rm -rf ~/.tendermint tendermint init + tendermint node >> tendermint.log & -sleep 5 +sleep 4 + +TPID=`pidof tendermint` +if [ -z "$TPID" ]; then + tail tendermint.log + exit 20 +fi