Browse Source

Merge branch 'develop' into 564-add-app-options-to-genesis-resp

pull/721/head
Ethan Buchman 7 years ago
parent
commit
a75bccfbc4
27 changed files with 370 additions and 316 deletions
  1. +10
    -2
      consensus/common_test.go
  2. +3
    -3
      consensus/replay_test.go
  3. +29
    -27
      consensus/test_data/build.sh
  4. +9
    -9
      consensus/test_data/empty_block.cswal
  5. +59
    -59
      consensus/test_data/many_blocks.cswal
  6. +9
    -9
      consensus/test_data/small_block1.cswal
  7. +12
    -14
      consensus/test_data/small_block2.cswal
  8. +43
    -38
      glide.lock
  9. +4
    -4
      glide.yaml
  10. +10
    -7
      mempool/mempool.go
  11. +19
    -17
      node/node.go
  12. +6
    -15
      rpc/client/httpclient.go
  13. +4
    -7
      rpc/client/localclient.go
  14. +5
    -11
      rpc/client/mock/abci.go
  15. +1
    -3
      rpc/client/mock/client.go
  16. +4
    -7
      rpc/client/mock/status.go
  17. +3
    -3
      rpc/client/rpc_test.go
  18. +6
    -3
      rpc/lib/client/http_client.go
  19. +1
    -1
      rpc/lib/client/ws_client.go
  20. +8
    -1
      rpc/lib/types/types.go
  21. +17
    -0
      rpc/lib/types/types_test.go
  22. +63
    -47
      state/state.go
  23. +28
    -11
      state/state_test.go
  24. +7
    -10
      state/txindex/indexer.go
  25. +5
    -3
      state/txindex/kv/kv.go
  26. +2
    -2
      state/txindex/null/null.go
  27. +3
    -3
      types/block.go

+ 10
- 2
consensus/common_test.go View File

@ -347,7 +347,11 @@ func randConsensusNet(nValidators int, testName string, tickerFunc func() Timeou
opt(thisConfig)
}
ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
css[i] = newConsensusStateWithConfig(thisConfig, state, privVals[i], appFunc())
app := appFunc()
vals := types.TM2PB.Validators(state.Validators)
app.InitChain(abci.RequestInitChain{Validators: vals})
css[i] = newConsensusStateWithConfig(thisConfig, state, privVals[i], app)
css[i].SetLogger(logger.With("validator", i))
css[i].SetTimeoutTicker(tickerFunc())
}
@ -373,7 +377,11 @@ func randConsensusNetWithPeers(nValidators, nPeers int, testName string, tickerF
privVal = types.GenPrivValidatorFS(tempFilePath)
}
css[i] = newConsensusStateWithConfig(thisConfig, state, privVal, appFunc())
app := appFunc()
vals := types.TM2PB.Validators(state.Validators)
app.InitChain(abci.RequestInitChain{Validators: vals})
css[i] = newConsensusStateWithConfig(thisConfig, state, privVal, app)
css[i].SetLogger(log.TestingLogger())
css[i].SetTimeoutTicker(tickerFunc())
}


+ 3
- 3
consensus/replay_test.go View File

@ -58,9 +58,9 @@ var baseStepChanges = []int{3, 6, 8}
// test recovery from each line in each testCase
var testCases = []*testCase{
newTestCase("empty_block", baseStepChanges), // empty block (has 1 block part)
newTestCase("small_block1", baseStepChanges), // small block with txs in 1 block part
newTestCase("small_block2", []int{3, 11, 13}), // small block with txs across 6 smaller block parts
newTestCase("empty_block", baseStepChanges), // empty block (has 1 block part)
newTestCase("small_block1", baseStepChanges), // small block with txs in 1 block part
newTestCase("small_block2", []int{3, 9, 11}), // small block with txs across 6 smaller block parts
}
type testCase struct {


+ 29
- 27
consensus/test_data/build.sh View File

@ -6,7 +6,7 @@ cd "$GOPATH/src/github.com/tendermint/tendermint" || exit 1
# Make sure we have a tendermint command.
if ! hash tendermint 2>/dev/null; then
make install
make install
fi
# specify a dir to copy
@ -14,13 +14,14 @@ fi
DIR_TO_COPY=$HOME/.tendermint_test/consensus_state_test
TMHOME="$HOME/.tendermint"
rm -rf "$TMHOME"
cp -r "$DIR_TO_COPY" "$TMHOME"
cp $TMHOME/config.toml $TMHOME/config.toml.bak
#rm -rf "$TMHOME"
#cp -r "$DIR_TO_COPY" "$TMHOME"
#mv $TMHOME/config.toml $TMHOME/config.toml.bak
cp $TMHOME/genesis.json $TMHOME/genesis.json.bak
function reset(){
tendermint unsafe_reset_all
cp $TMHOME/config.toml.bak $TMHOME/config.toml
tendermint unsafe_reset_all
cp $TMHOME/genesis.json.bak $TMHOME/genesis.json
}
reset
@ -34,6 +35,7 @@ killall tendermint
# /q would print up to and including the match, then quit.
# /Q doesn't include the match.
# http://unix.stackexchange.com/questions/11305/grep-show-all-the-file-up-to-the-match
# note on macbook we need `gnu-sed` for Q to work
sed '/ENDHEIGHT: 1/Q' ~/.tendermint/data/cs.wal/wal > consensus/test_data/empty_block.cswal
reset
@ -44,7 +46,7 @@ function many_blocks(){
bash scripts/txs/random.sh 1000 36657 &> /dev/null &
PID=$!
tendermint node --proxy_app=persistent_dummy &> /dev/null &
sleep 7
sleep 10
killall tendermint
kill -9 $PID
@ -71,12 +73,12 @@ reset
# small block 2 (part size = 512)
function small_block2(){
echo "" >> ~/.tendermint/config.toml
echo "block_part_size = 512" >> ~/.tendermint/config.toml
cat ~/.tendermint/genesis.json | jq '. + {"consensus_params": {"block_size_params": {"max_bytes":1000000}, "block_gossip_params": {"block_part_size_bytes":512}}}' > genesis.json.new
mv genesis.json.new ~/.tendermint/genesis.json
bash scripts/txs/random.sh 1000 36657 &> /dev/null &
PID=$!
tendermint node --proxy_app=persistent_dummy &> /dev/null &
sleep 5
sleep 10
killall tendermint
kill -9 $PID
@ -88,23 +90,23 @@ reset
case "$1" in
"small_block1")
small_block1
;;
"small_block2")
small_block2
;;
"empty_block")
empty_block
;;
"many_blocks")
many_blocks
;;
*)
small_block1
small_block2
empty_block
many_blocks
"small_block1")
small_block1
;;
"small_block2")
small_block2
;;
"empty_block")
empty_block
;;
"many_blocks")
many_blocks
;;
*)
small_block1
small_block2
empty_block
many_blocks
esac

+ 9
- 9
consensus/test_data/empty_block.cswal View File

@ -1,10 +1,10 @@
#ENDHEIGHT: 0
{"time":"2017-04-27T22:24:01.346Z","msg":[3,{"duration":972946821,"height":1,"round":0,"step":1}]}
{"time":"2017-04-27T22:24:01.349Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPropose"}]}
{"time":"2017-04-27T22:24:01.349Z","msg":[2,{"msg":[17,{"Proposal":{"height":1,"round":0,"block_parts_header":{"total":1,"hash":"ACED4A95DDEBD24E66A681F7EAB4CA22C4B8546D"},"pol_round":-1,"pol_block_id":{"hash":"","parts":{"total":0,"hash":""}},"signature":[1,"E785764AED6D92D7CC65C0A3A4ED9C8465198A05142C3E6C7F3EF601FDCD3A604900B77B7B87C046221EF99FD038A960398385BD5BBAA50EE4F86DE757B8F704"]}}],"peer_key":""}]}
{"time":"2017-04-27T22:24:01.350Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":0,"bytes":"0101010F74656E6465726D696E745F74657374010114B96165CF4496C00000000000000114354594CBFC1A7BCA1AD0050ED6AA010023EADA390001000100000000","proof":{"aunts":[]}}}],"peer_key":""}]}
{"time":"2017-04-27T22:24:01.351Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrevote"}]}
{"time":"2017-04-27T22:24:01.351Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":1,"block_id":{"hash":"F3BBFBE7E4A5D619E2C498C3D1B912883786DD71","parts":{"total":1,"hash":"ACED4A95DDEBD24E66A681F7EAB4CA22C4B8546D"}},"signature":[1,"35C937C78D061ECDC3770982A1330C9AA7F6FEF00835C43DEB50B8FCF69A3EEF221E675EE5E469114F64E4FBBABA414EB9170E1025FC47D3F0EADE46767D2E00"]}}],"peer_key":""}]}
{"time":"2017-04-27T22:24:01.352Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrecommit"}]}
{"time":"2017-04-27T22:24:01.352Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":2,"block_id":{"hash":"F3BBFBE7E4A5D619E2C498C3D1B912883786DD71","parts":{"total":1,"hash":"ACED4A95DDEBD24E66A681F7EAB4CA22C4B8546D"}},"signature":[1,"D1A7D27FCD5D352F3A3EDA8DE368520BC5B796662E32BCD8D91CDB8209A88DAF37CB7C4C93143D3C12B37C1435229268098CFFD0AD1400D88DA7606454692301"]}}],"peer_key":""}]}
{"time":"2017-04-27T22:24:01.352Z","msg":[1,{"height":1,"round":0,"step":"RoundStepCommit"}]}
{"time":"2017-10-23T13:26:49.706Z","msg":[3,{"duration":-2002813432,"height":1,"round":0,"step":1}]}
{"time":"2017-10-23T13:26:49.708Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPropose"}]}
{"time":"2017-10-23T13:26:49.708Z","msg":[2,{"msg":[17,{"Proposal":{"height":1,"round":0,"block_parts_header":{"total":1,"hash":"4595668C5D5D0A3670EBD56FB9D5A0F0B3252C07"},"pol_round":-1,"pol_block_id":{"hash":"","parts":{"total":0,"hash":""}},"signature":[1,"452FC4AC6B6313F2815671BE51EA6E56C267C18357655B960CC353CA73BE64A393D2840A36B48B73B01466C174F13CADD1AADCBFADA953D322BCDF00BD185C06"]}}],"peer_key":""}]}
{"time":"2017-10-23T13:26:49.708Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":0,"bytes":"0101010F74656E6465726D696E745F74657374010114F035F6E5FE6E8000000000000001147297262C6CD96190E46846C9A0DE1227E76077CF0001000100000000","proof":{"aunts":[]}}}],"peer_key":""}]}
{"time":"2017-10-23T13:26:49.709Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrevote"}]}
{"time":"2017-10-23T13:26:49.709Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":1,"block_id":{"hash":"717AD9D244E7BA9C76300185BC51D727D50E24AF","parts":{"total":1,"hash":"4595668C5D5D0A3670EBD56FB9D5A0F0B3252C07"}},"signature":[1,"3E7B4AF836F5A63A9636C5704155559607D25684DDF6C29D2E746942A6C828C8A5979909D7C393A46BB92AF99FCE258CCD7B8E1E59DE296FF7159E04C8D0F40B"]}}],"peer_key":""}]}
{"time":"2017-10-23T13:26:49.710Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrecommit"}]}
{"time":"2017-10-23T13:26:49.710Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":2,"block_id":{"hash":"717AD9D244E7BA9C76300185BC51D727D50E24AF","parts":{"total":1,"hash":"4595668C5D5D0A3670EBD56FB9D5A0F0B3252C07"}},"signature":[1,"B7106616D0C2173AB31A6D844AD0C01A4506287D6B88EC9EB91283FDE99232F1DADE2C44B8C67C46B154EA57E456AF82661FE61590C566560C202526BD971F09"]}}],"peer_key":""}]}
{"time":"2017-10-23T13:26:49.711Z","msg":[1,{"height":1,"round":0,"step":"RoundStepCommit"}]}

+ 59
- 59
consensus/test_data/many_blocks.cswal
File diff suppressed because it is too large
View File


+ 9
- 9
consensus/test_data/small_block1.cswal
File diff suppressed because it is too large
View File


+ 12
- 14
consensus/test_data/small_block2.cswal View File

@ -1,15 +1,13 @@
#ENDHEIGHT: 0
{"time":"2017-04-27T22:23:56.310Z","msg":[3,{"duration":969732098,"height":1,"round":0,"step":1}]}
{"time":"2017-04-27T22:23:56.312Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPropose"}]}
{"time":"2017-04-27T22:23:56.312Z","msg":[2,{"msg":[17,{"Proposal":{"height":1,"round":0,"block_parts_header":{"total":6,"hash":"A3C176F13F5CBC7C48EE27A472800410C9D487DC"},"pol_round":-1,"pol_block_id":{"hash":"","parts":{"total":0,"hash":""}},"signature":[1,"7624F6E943B7A207E16D1FA87EA099BD924E930F98E7DECBC01DB37735C619409588A67C2EABA9845FD6B80FDB65ECFCDA5F0DEFCEF74B8C34DB8E0540480203"]}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.312Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":0,"bytes":"0101010F74656E6465726D696E745F74657374010114B96164A30A118001620000000001141F6753D22BACA2180B1EADD722434EB28444D91D0114354594CBFC1A7BCA1AD0050ED6AA010023EADA3900010162011A3631363236333634333133303344363436333632363133313330011A3631363236333634333133313344363436333632363133313331011A3631363236333634333133323344363436333632363133313332011A3631363236333634333133333344363436333632363133313333011A3631363236333634333133343344363436333632363133313334011A3631363236333634333133353344363436333632363133313335011A3631363236333634333133363344363436333632363133313336011A3631363236333634333133373344363436333632363133313337011A3631363236333634333133383344363436333632363133313338011A3631363236333634333133393344363436333632363133313339011A3631363236333634333233303344363436333632363133323330011A3631363236333634333233313344363436333632363133323331011A3631363236333634333233323344363436333632363133323332011A3631363236333634333233333344363436333632363133323333011A3631363236333634333233343344363436333632363133323334011A36313632363336","proof":{"aunts":["49F4B71E3D7C457415069E2EA916DB12F67AA8D0","D35A72BEDAAAAC17045D7BFAAFA94C2EC0B0A4C2","705BC647374F3495EE73C3F44C21E9BDB4731738"]}}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.312Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":1,"bytes":"34333233353344363436333632363133323335011A3631363236333634333233363344363436333632363133323336011A3631363236333634333233373344363436333632363133323337011A3631363236333634333233383344363436333632363133323338011A3631363236333634333233393344363436333632363133323339011A3631363236333634333333303344363436333632363133333330011A3631363236333634333333313344363436333632363133333331011A3631363236333634333333323344363436333632363133333332011A3631363236333634333333333344363436333632363133333333011A3631363236333634333333343344363436333632363133333334011A3631363236333634333333353344363436333632363133333335011A3631363236333634333333363344363436333632363133333336011A3631363236333634333333373344363436333632363133333337011A3631363236333634333333383344363436333632363133333338011A3631363236333634333333393344363436333632363133333339011A3631363236333634333433303344363436333632363133343330011A3631363236333634333433313344363436333632363133343331011A3631363236333634333433323344363436333632363133343332011A363136323633363433343333334436","proof":{"aunts":["5AD2A9A1A49A1FD6EF83F05FA4588F800B29DEF1","D35A72BEDAAAAC17045D7BFAAFA94C2EC0B0A4C2","705BC647374F3495EE73C3F44C21E9BDB4731738"]}}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.312Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":2,"bytes":"3436333632363133343333011A3631363236333634333433343344363436333632363133343334011A3631363236333634333433353344363436333632363133343335011A3631363236333634333433363344363436333632363133343336011A3631363236333634333433373344363436333632363133343337011A3631363236333634333433383344363436333632363133343338011A3631363236333634333433393344363436333632363133343339011A3631363236333634333533303344363436333632363133353330011A3631363236333634333533313344363436333632363133353331011A3631363236333634333533323344363436333632363133353332011A3631363236333634333533333344363436333632363133353333011A3631363236333634333533343344363436333632363133353334011A3631363236333634333533353344363436333632363133353335011A3631363236333634333533363344363436333632363133353336011A3631363236333634333533373344363436333632363133353337011A3631363236333634333533383344363436333632363133353338011A3631363236333634333533393344363436333632363133353339011A3631363236333634333633303344363436333632363133363330011A3631363236333634333633313344363436333632363133","proof":{"aunts":["8B5786C3D871EE37B0F4B2DECAC39E157340DFBE","705BC647374F3495EE73C3F44C21E9BDB4731738"]}}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.312Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":3,"bytes":"363331011A3631363236333634333633323344363436333632363133363332011A3631363236333634333633333344363436333632363133363333011A3631363236333634333633343344363436333632363133363334011A3631363236333634333633353344363436333632363133363335011A3631363236333634333633363344363436333632363133363336011A3631363236333634333633373344363436333632363133363337011A3631363236333634333633383344363436333632363133363338011A3631363236333634333633393344363436333632363133363339011A3631363236333634333733303344363436333632363133373330011A3631363236333634333733313344363436333632363133373331011A3631363236333634333733323344363436333632363133373332011A3631363236333634333733333344363436333632363133373333011A3631363236333634333733343344363436333632363133373334011A3631363236333634333733353344363436333632363133373335011A3631363236333634333733363344363436333632363133373336011A3631363236333634333733373344363436333632363133373337011A3631363236333634333733383344363436333632363133373338011A3631363236333634333733393344363436333632363133373339011A363136","proof":{"aunts":["56097661A1B2707588100586B3B1C2C8A51057D1","6DE889147DF528EEB5F7422E95DC45900CAFB619","247C721D5CEB90BB1FE389BA74C43DF0955E1647"]}}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.312Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":4,"bytes":"3236333634333833303344363436333632363133383330011A3631363236333634333833313344363436333632363133383331011A3631363236333634333833323344363436333632363133383332011A3631363236333634333833333344363436333632363133383333011A3631363236333634333833343344363436333632363133383334011A3631363236333634333833353344363436333632363133383335011A3631363236333634333833363344363436333632363133383336011A3631363236333634333833373344363436333632363133383337011A3631363236333634333833383344363436333632363133383338011A3631363236333634333833393344363436333632363133383339011A3631363236333634333933303344363436333632363133393330011A3631363236333634333933313344363436333632363133393331011A3631363236333634333933323344363436333632363133393332011A3631363236333634333933333344363436333632363133393333011A3631363236333634333933343344363436333632363133393334011A3631363236333634333933353344363436333632363133393335011A3631363236333634333933363344363436333632363133393336011A3631363236333634333933373344363436333632363133393337011A3631363236333634333933","proof":{"aunts":["081D3DC5F11850851D5F0D760B98EE87BFA6B8B0","6DE889147DF528EEB5F7422E95DC45900CAFB619","247C721D5CEB90BB1FE389BA74C43DF0955E1647"]}}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.313Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":5,"bytes":"383344363436333632363133393338011A3631363236333634333933393344363436333632363133393339011E363136323633363433313330333033443634363336323631333133303330011E363136323633363433313330333133443634363336323631333133303331011E363136323633363433313330333233443634363336323631333133303332011E363136323633363433313330333333443634363336323631333133303333011E363136323633363433313330333433443634363336323631333133303334011E363136323633363433313330333533443634363336323631333133303335011E363136323633363433313330333633443634363336323631333133303336011E3631363236333634333133303337334436343633363236313331333033370100000000","proof":{"aunts":["6AA912328C2B52EFA0ECE71F523E137E400EC484","247C721D5CEB90BB1FE389BA74C43DF0955E1647"]}}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.314Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrevote"}]}
{"time":"2017-04-27T22:23:56.314Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":1,"block_id":{"hash":"62371CF72F8662378691706DB256C833CF1AF81B","parts":{"total":6,"hash":"A3C176F13F5CBC7C48EE27A472800410C9D487DC"}},"signature":[1,"255906FAAA50C84E85DABF7DE73468E4F95DB4E46F598848145926E2FAD77CA682BF07E09E2F3EC81FFBD9A036B67914A3C02F819B69248D777AEBA792725907"]}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.315Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrecommit"}]}
{"time":"2017-04-27T22:23:56.315Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":2,"block_id":{"hash":"62371CF72F8662378691706DB256C833CF1AF81B","parts":{"total":6,"hash":"A3C176F13F5CBC7C48EE27A472800410C9D487DC"}},"signature":[1,"056CC15C748434D0A59B64B45CB56EDC1A437A426E68FA63DC7D61A7C17B0F768F207D81340D129A57C5A64195F8AFDD03B6BF28D7B2286290D61BCE88FCA304"]}}],"peer_key":""}]}
{"time":"2017-04-27T22:23:56.316Z","msg":[1,{"height":1,"round":0,"step":"RoundStepCommit"}]}
{"time":"2017-10-23T13:52:43.764Z","msg":[3,{"duration":-1002188229,"height":1,"round":0,"step":1}]}
{"time":"2017-10-23T13:52:43.766Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPropose"}]}
{"time":"2017-10-23T13:52:43.766Z","msg":[2,{"msg":[17,{"Proposal":{"height":1,"round":0,"block_parts_header":{"total":4,"hash":"6675CB6BFC1FA7C968167B59BC014D39BE9B34F7"},"pol_round":-1,"pol_block_id":{"hash":"","parts":{"total":0,"hash":""}},"signature":[1,"02579FC60A63CF9AB5E3130B2047EA89E7DEDA413216F59EFF4C848A25EBBC33F240678873950E79D8404F6AAB9951048E3B5EB80BE97E451D5176DBA1A39507"]}}],"peer_key":""}]}
{"time":"2017-10-23T13:52:43.767Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":0,"bytes":"0101010F74656E6465726D696E745F74657374010114F03760BB20E740017D00000000011439C793C92947F72D2E8966AE78E2867D6F0C50BA01147297262C6CD96190E46846C9A0DE1227E76077CF0001017D01087173CC16D9C0814A010CF20FDCCC1A5008B6F7993D33010CCBEE27B6B61EC1F485B33D34010CE427B2156CAD6E33386D3D35010CA199811DF5F7B29FC2473D3601055008D2BD7E010CDDC5A7FC7219747F980C3D38010C41973343FF3C0C9FACD03D39010DE20B823051A13A44FDF93D3130010C05FFE6A2F801CA5FD63D3131010D4830C1161B5B3C709D1C3D3132010DB4EA30086C4B0B5DD2723D3133010DDC9CE184674F8AE2C0EE3D3134010D6DE2ED95A1FC134B72D83D3135010D2293CFCE30C7612B6BA33D3136010DDEF4CEC7B546DA1539873D3137010DA63163F6F5DF6DD597EA3D3138010DAE3E756C4A67C6C193743D3139010D80196F7DBC7BAB885ABF3D3230010D269E5D80BA2B6BB449813D3231010DD590809C748158BE500F3D3232010DE38FD2021F8790BE31CA3D3233010DF6F3F3535ACDE33353893D3234010D406E0D85452EF05962543D3235010DB04C3D5203081FCBE4223D3236010D2CE3B7DA3647C64324D23D3237010D838BC6F8243ED6820B6A3D3238010DB98AFAEC0214B014BAE73D3239010DA0177349241C6F8581923D3330010D5643D684E3D3C979F3113D33","proof":{"aunts":["20F9BC2E0A99F7873C9E0E7590511D5625286F72","1E0E084FD092EBF0543348B48A235A1211D4FA93"]}}}],"peer_key":""}]}
{"time":"2017-10-23T13:52:43.767Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":1,"bytes":"3101033F0C56010D7B9B7BEE694B44EE81DD3D3333010CD6D3FAC782E251E45B3D3334010DEDF9B2B01CB717F0D4C63D3335010DBF0B1E93BD59C2EB230F3D3336010D66FBEF89AFAFCD6404F53D3337010D62379E91BCB215C004553D3338010D7337BF0281C85102D8F93D3339010C8AB5CB54B33BA2A6943D3430010DE0FE457D49AEE62E9CAB3D3431010D8882A50FCBCBC5E82B053D3432010D7703E3AD68607D1FC0A23D3433010C554B8281D22B749F4D3D3434010DA2CCAB661F40E85B61B93D343501052D70D2B077010C48FD771077B60D5A5E3D3437010CFD802EF9120EF968433D3438010DFD47F9B09218DD2F5D1D3D3439010D36DA6A808CD5E3BE8CA43D353001063272D269831E010D1A3FBEA427C90BB0DD553D35320108AB62E0A985116AB3010D4681027946A5DC5062B63D3534010DA7C0CDA742526C4CAFDB3D353501054EBDAF666F010D3028F736EE74ECEE9ADB3D3537010D8F9B82545F308ED3E8823D3538010D7345C8F5F56A270C40E83D3539010CADC20F1C4F889953623D3630010DE8032EDAA15EE4C2B3363D3631010DA18EC123561C02FFFEDA3D3632010D77CBACC0D1E1839194943D3633010DCC125243339AE2B804BC3D3634010DC087D1AAAE8722CE78193D3635010DF13259547F734882F2893D3636010D342F53A6AB5A0CDB794E3D3637010D3311FB75B3159EBAE6DE3D3638","proof":{"aunts":["FC15B0F6649B8EE1B09B55D94A17AEF4618D6E24","1E0E084FD092EBF0543348B48A235A1211D4FA93"]}}}],"peer_key":""}]}
{"time":"2017-10-23T13:52:43.767Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":2,"bytes":"010DA5AC3ACBD625E4AD6FBC3D3639010D142407FB6A91BA5D37E43D3730010DA34474DA8FD7E6EA81223D373101035D1D6B010DDDA37772953A2C8711FF3D3733010DA5ADCD38B9AB04FB53EC3D3734010CF19AE3CB7FC1DB766B3D3735010DDCC478D15149D0860CEF3D3736010D4C8EC65D0C0CEFB590AA3D3737010D9EAD73CB8FACB8392DEB3D37380108E4DA75D207146E920108CD339E193F162F5A010D529A51FEE9543803C5863D3831010DFE163440021CBF4E1F5C3D3832010D1FCA879072372487B7EA3D3833010D010DD579CA8543E714D43D3834010DF93DC09D60BA5F98045B3D3835010DEB2591C922EF1B3F3D653D3836010D66853A5F89E2D66D64343D3837010D98D0324472BE65F03E683D3838010DA202B986F80C5CC5B1993D3839010D4303125AE24AFDCFEB973D3930010DAA4C06FE5F06692AAF1F3D3931010D4D35E54FD3E3BD2266BE3D3932010D85EB155492DF9B42FEBD3D3933010D7DAB013468659C38E35D3D3934010D06C753CD41C31504AB3F3D3935010D93DC53BE7B84DDF2E26F3D3936010DB77767CFD59CB5D7DFEF3D3937010D99F6F9BC169A806C1A2D3D3938010D9B5E50A811CBFCE80B573D3939010D95B1B5C5A5ED60C96F3D313030010E90BD73C572B5FE324E963D313031010E7FFCC15A910D3CCC12A93D313032010E4E7214975DBDFADD01213D313033010EACEE55","proof":{"aunts":["45E2A8ACB043850B9A56FA5110ED5738B42B5AD4","34424C5B5321189CF133D2ED3CECFB0F1C1DAC0E"]}}}],"peer_key":""}]}
{"time":"2017-10-23T13:52:43.767Z","msg":[2,{"msg":[19,{"Height":1,"Round":0,"Part":{"index":3,"bytes":"F959F3FBB6A4D03D313034010D10AF79248E1C042A4D3D313035010E6A726EE9F664CA5228FF3D313036010EE490AF97552CAC083DD63D313037010EE18C71EC7159061713723D313038010E760E8663BFB2361607243D313039010E5FE47423F99EF78E93943D313130010E289EBA536A1F0FDEA57F3D313131010E680557784E3E13E0C1403D313132010EBFC86F58B0B6F00670D33D313133010EE7B7ACE102C48E9B8F743D313134010155010EDEEE7E9BE623C7482A463D313136010E29A53D807945BAEB49EF3D31313701050FE9C1DCB5010EA74CEB55E025ADD5AA683D313139010E84929712FF032B1B6DA33D313230010E9884326AF3AFB43CE9453D313231010E0C8E66526C05AD32282C3D313232010E1FD329B55358E376BB483D313233010EC159D142BEA977A6E8553D3132340105A2DFD0E176010EB84DD5EACD7074AF54803D3132360100000000","proof":{"aunts":["8D2111512C3EDA85DB8D1F5D807976814A040EC2","34424C5B5321189CF133D2ED3CECFB0F1C1DAC0E"]}}}],"peer_key":""}]}
{"time":"2017-10-23T13:52:43.769Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrevote"}]}
{"time":"2017-10-23T13:52:43.769Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":1,"block_id":{"hash":"CB6E7845598FAC92F2AE92DD8BEAB16EEA181600","parts":{"total":4,"hash":"6675CB6BFC1FA7C968167B59BC014D39BE9B34F7"}},"signature":[1,"D4C1B17B4818584752AD5EF4282396A8C6B4E2C2A243688AA707EC93114277129FA8361D06848E9AA8DC473EB2446D1C2AC350343D0EE5BE252C81D22BC68B0B"]}}],"peer_key":""}]}
{"time":"2017-10-23T13:52:43.770Z","msg":[1,{"height":1,"round":0,"step":"RoundStepPrecommit"}]}
{"time":"2017-10-23T13:52:43.770Z","msg":[2,{"msg":[20,{"Vote":{"validator_address":"D028C9981F7A87F3093672BF0D5B0E2A1B3ED456","validator_index":0,"height":1,"round":0,"type":2,"block_id":{"hash":"CB6E7845598FAC92F2AE92DD8BEAB16EEA181600","parts":{"total":4,"hash":"6675CB6BFC1FA7C968167B59BC014D39BE9B34F7"}},"signature":[1,"E0E079B157BE09B0C5F8CAAE98B9378927F6C21DA3E54FA010FF8E570378DABE4BA5537680B41A9C403CFB3307054028B80A29A72CD12098A3C844383DEDA50E"]}}],"peer_key":""}]}
{"time":"2017-10-23T13:52:43.771Z","msg":[1,{"height":1,"round":0,"step":"RoundStepCommit"}]}

+ 43
- 38
glide.lock View File

@ -1,18 +1,16 @@
hash: 816d84782ab66637e02bd0a3c7f652a9a31f9b88e3ae11438c5bf641cf585f19
updated: 2017-10-02T23:32:49.162422718-04:00
hash: 9867fa4543ca4daea1a96a3883a7f483819c067ca34ed6d3aa67aace4a289e93
updated: 2017-10-23T10:01:08.326324082-04:00
imports:
- name: github.com/btcsuite/btcd
version: b8df516b4b267acf2de46be593a9d948d1d2c420
version: c7588cbf7690cd9f047a28efa2dcd8f2435a4e5e
subpackages:
- btcec
- name: github.com/btcsuite/fastsha256
version: 637e656429416087660c84436a2a035d69d54e2e
- name: github.com/ebuchman/fail-test
version: 95f809107225be108efcf10a3509e4ea6ceef3c4
- name: github.com/fsnotify/fsnotify
version: 4da3e2cfbabc9f751898f250b49f2439785783a1
- name: github.com/go-kit/kit
version: d67bb4c202e3b91377d1079b110a6c9ce23ab2f8
version: e2b298466b32c7cd5579a9b9b07e968fc9d9452c
subpackages:
- log
- log/level
@ -20,28 +18,31 @@ imports:
- name: github.com/go-logfmt/logfmt
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
- name: github.com/go-playground/locales
version: 1e5f1161c6416a5ff48840eb8724a394e48cc534
version: e4cbcb5d0652150d40ad0646651076b6bd2be4f6
subpackages:
- currency
- name: github.com/go-playground/universal-translator
version: 71201497bace774495daed26a3874fd339e0b538
- name: github.com/go-stack/stack
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
version: 817915b46b97fd7bb80e8ab6b69f01a53ac3eebf
- name: github.com/gogo/protobuf
version: f7f1376d9d231a646d4e62fe1075623ced6db327
version: 117892bf1866fbaa2318c03e50e40564c8845457
subpackages:
- proto
- name: github.com/golang/protobuf
version: 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8
version: 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9
subpackages:
- proto
- ptypes
- ptypes/any
- ptypes/duration
- ptypes/timestamp
- name: github.com/golang/snappy
version: 553a641470496b2327abcac10b36396bd98e45c9
- name: github.com/gorilla/websocket
version: a91eba7f97777409bc2c443f5534d41dd20c5720
version: 71fa72d4842364bc5f74185f4161e0099ea3624a
- name: github.com/hashicorp/hcl
version: 392dba7d905ed5d04a5794ba89f558b27e2ba1ca
version: 23c074d0eceb2b8a5bfdbb271ab780cde70f05a8
subpackages:
- hcl/ast
- hcl/parser
@ -58,33 +59,31 @@ imports:
- name: github.com/kr/logfmt
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
- name: github.com/magiconair/properties
version: 51463bfca2576e06c62a8504b5c0f06d61312647
version: 8d7837e64d3c1ee4e54a880c5a920ab4316fc90a
- name: github.com/mitchellh/mapstructure
version: cc8532a8e9a55ea36402aa21efdf403a60d34096
- name: github.com/pelletier/go-buffruneio
version: c37440a7cf42ac63b919c752ca73a85067e05992
version: 06020f85339e21b2478f756a78e295255ffa4d6a
- name: github.com/pelletier/go-toml
version: 13d49d4606eb801b8f01ae542b4afc4c6ee3d84a
version: 8c31c2ec65b208cc2ad1608bf25a3ff91adf1944
- name: github.com/pkg/errors
version: 645ef00459ed84a119197bfb8d8205042c6df63d
- name: github.com/rcrowley/go-metrics
version: 1f30fe9094a513ce4c700b9a54458bbb0c96996c
- name: github.com/spf13/afero
version: 9be650865eab0c12963d8753212f4f9c66cdcf12
version: 5660eeed305fe5f69c8fc6cf899132a459a97064
subpackages:
- mem
- name: github.com/spf13/cast
version: acbeb36b902d72a7a4c18e8f3241075e7ab763e4
- name: github.com/spf13/cobra
version: 4cdb38c072b86bf795d2c81de50784d9fdd6eb77
version: 7b2c5ac9fc04fc5efafb60700713d4fa609b777b
- name: github.com/spf13/jwalterweatherman
version: 8f07c835e5cc1450c082fe3a439cf87b0cbb2d99
version: 12bd96e66386c1960ab0f74ced1362f66f552f7b
- name: github.com/spf13/pflag
version: e57e3eeb33f795204c1ca35f56c44f83227c6e66
version: 97afa5e7ca8a08a383cb259e06636b5e2cc7897f
- name: github.com/spf13/viper
version: 0967fc9aceab2ce9da34061253ac10fb99bba5b2
version: 8ef37cbca71638bf32f3d5e194117d4cb46da163
- name: github.com/syndtr/goleveldb
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
version: b89cc31ef7977104127d34c1bd31ebd1a9db2199
subpackages:
- leveldb
- leveldb/cache
@ -99,7 +98,7 @@ imports:
- leveldb/table
- leveldb/util
- name: github.com/tendermint/abci
version: 191c4b6d176169ffc7f9972d490fa362a3b7d940
version: bb9bb4aa465a31fd6a272765be381888e6898c74
subpackages:
- client
- example/counter
@ -118,12 +117,12 @@ imports:
subpackages:
- data
- data/base58
- name: github.com/tendermint/merkleeyes
version: 2a93256d2c6fbcc3b55673c0d2b96a7e32c6238b
- name: github.com/tendermint/iavl
version: 721710e7aa59f61dbfbf558943a207ba3fe6b926
subpackages:
- iavl
- name: github.com/tendermint/tmlibs
version: 096dcb90e60aa00b748b3fe49a4b95e48ebf1e13
version: 8e5266a9ef2527e68a1571f932db8228a331b556
subpackages:
- autofile
- cli
@ -137,7 +136,7 @@ imports:
- merkle
- test
- name: golang.org/x/crypto
version: c7af5bf2638a1164f2eb5467c39c6cffbd13a02e
version: edd5e9b0879d13ee6970a50153d85b8fec9f7686
subpackages:
- curve25519
- nacl/box
@ -148,7 +147,7 @@ imports:
- ripemd160
- salsa20/salsa
- name: golang.org/x/net
version: feeb485667d1fdabe727840fe00adc22431bc86e
version: cd69bc3fc700721b709c3a59e16e24c67b58f6ff
subpackages:
- context
- http2
@ -158,43 +157,49 @@ imports:
- lex/httplex
- trace
- name: golang.org/x/sys
version: e62c3de784db939836898e5c19ffd41bece347da
version: 8dbc5d05d6edcc104950cc299a1ce6641235bc86
subpackages:
- unix
- name: golang.org/x/text
version: 470f45bf29f4147d6fbd7dfd0a02a848e49f5bf4
version: c01e4764d870b77f8abe5096ee19ad20d80e8075
subpackages:
- secure/bidirule
- transform
- unicode/bidi
- unicode/norm
- name: google.golang.org/genproto
version: 411e09b969b1170a9f0c467558eb4c4c110d9c77
version: f676e0f3ac6395ff1a529ae59a6670878a8371a6
subpackages:
- googleapis/rpc/status
- name: google.golang.org/grpc
version: 844f573616520565fdc6fb4db242321b5456fd6d
version: a5986a5c88227370a9c0a82e5277167229c034cd
subpackages:
- balancer
- balancer/roundrobin
- codes
- connectivity
- credentials
- grpclb/grpc_lb_v1
- grpclb/grpc_lb_v1/messages
- grpclog
- internal
- keepalive
- metadata
- naming
- peer
- resolver
- resolver/dns
- resolver/passthrough
- stats
- status
- tap
- transport
- name: gopkg.in/go-playground/validator.v9
version: 6d8c18553ea1ac493d049edd6f102f52e618f085
version: 1304298bf10d085adec514b076772a79c9cadb6b
- name: gopkg.in/yaml.v2
version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
version: eb3733d160e74a9c7e442f435eb3bea458e1d19f
testImports:
- name: github.com/davecgh/go-spew
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
subpackages:
- spew
- name: github.com/pmezard/go-difflib
@ -202,7 +207,7 @@ testImports:
subpackages:
- difflib
- name: github.com/stretchr/testify
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
version: 2aa2c176b9dab406a6970f6a55f513e8a8c8b18f
subpackages:
- assert
- require

+ 4
- 4
glide.yaml View File

@ -14,7 +14,7 @@ import:
- package: github.com/spf13/cobra
- package: github.com/spf13/viper
- package: github.com/tendermint/abci
version: ~0.6.0
version: develop
subpackages:
- client
- example/dummy
@ -25,12 +25,12 @@ import:
version: ~0.6.2
subpackages:
- data
- package: github.com/tendermint/merkleeyes
version: master
- package: github.com/tendermint/iavl
version: develop
subpackages:
- iavl
- package: github.com/tendermint/tmlibs
version: ~0.3.2
version: develop
subpackages:
- autofile
- cli


+ 10
- 7
mempool/mempool.go View File

@ -50,9 +50,10 @@ TODO: Better handle abci client errors. (make it automatically handle connection
const cacheSize = 100000
// Mempool is an ordered in-memory pool for transactions before they are proposed in a consensus round.
// Transaction validity is checked using the CheckTx abci message before the transaction is added to the pool.
// The Mempool uses a concurrent list structure for storing transactions that can be efficiently accessed by multiple concurrent readers.
// Mempool is an ordered in-memory pool for transactions before they are proposed in a consensus
// round. Transaction validity is checked using the CheckTx abci message before the transaction is
// added to the pool. The Mempool uses a concurrent list structure for storing transactions that
// can be efficiently accessed by multiple concurrent readers.
type Mempool struct {
config *cfg.MempoolConfig
@ -78,6 +79,7 @@ type Mempool struct {
}
// NewMempool returns a new Mempool with the given configuration and connection to an application.
// TODO: Extract logger into arguments.
func NewMempool(config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, height int) *Mempool {
mempool := &Mempool{
config: config,
@ -269,7 +271,10 @@ func (mem *Mempool) resCbRecheck(req *abci.Request, res *abci.Response) {
atomic.StoreInt32(&mem.rechecking, 0)
mem.logger.Info("Done rechecking txs")
mem.notifyTxsAvailable()
// incase the recheck removed all txs
if mem.Size() > 0 {
mem.notifyTxsAvailable()
}
}
default:
// ignore other messages
@ -287,9 +292,7 @@ func (mem *Mempool) notifyTxsAvailable() {
if mem.Size() == 0 {
panic("notified txs available but mempool is empty!")
}
if mem.txsAvailable != nil &&
!mem.notifiedTxsAvailable {
if mem.txsAvailable != nil && !mem.notifiedTxsAvailable {
mem.notifiedTxsAvailable = true
mem.txsAvailable <- mem.height + 1
}


+ 19
- 17
node/node.go View File

@ -143,10 +143,7 @@ func NewNode(config *cfg.Config,
}
// save genesis doc to prevent a certain class of user errors (e.g. when it
// was changed, accidentally or not). Also good for audit trail.
err = saveGenesisDoc(stateDB, genDoc)
if err != nil {
return nil, fmt.Errorf("Failed to save genesis doc: %v", err)
}
saveGenesisDoc(stateDB, genDoc)
}
state := sm.LoadState(stateDB)
@ -320,6 +317,16 @@ func NewNode(config *cfg.Config,
// OnStart starts the Node. It implements cmn.Service.
func (n *Node) OnStart() error {
// Run the RPC server first
// so we can eg. receive txs for the first block
if n.config.RPC.ListenAddress != "" {
listeners, err := n.startRPC()
if err != nil {
return err
}
n.rpcListeners = listeners
}
// Create & add listener
protocol, address := cmn.ProtocolAndAddress(n.config.P2P.ListenAddress)
l := p2p.NewDefaultListener(protocol, address, n.config.P2P.SkipUPNP, n.Logger.With("module", "p2p"))
@ -342,15 +349,6 @@ func (n *Node) OnStart() error {
}
}
// Run the RPC server
if n.config.RPC.ListenAddress != "" {
listeners, err := n.startRPC()
if err != nil {
return err
}
n.rpcListeners = listeners
}
return nil
}
@ -552,6 +550,7 @@ var (
genesisDocKey = []byte("genesisDoc")
)
// panics if failed to unmarshal bytes
func loadGenesisDoc(db dbm.DB) (*types.GenesisDoc, error) {
bytes := db.Get(genesisDocKey)
if len(bytes) == 0 {
@ -559,15 +558,18 @@ func loadGenesisDoc(db dbm.DB) (*types.GenesisDoc, error) {
} else {
var genDoc *types.GenesisDoc
err := json.Unmarshal(bytes, &genDoc)
return genDoc, err
if err != nil {
cmn.PanicCrisis(fmt.Sprintf("Failed to load genesis doc due to unmarshaling error: %v (bytes: %X)", err, bytes))
}
return genDoc, nil
}
}
func saveGenesisDoc(db dbm.DB, genDoc *types.GenesisDoc) error {
// panics if failed to marshal the given genesis document
func saveGenesisDoc(db dbm.DB, genDoc *types.GenesisDoc) {
bytes, err := json.Marshal(genDoc)
if err != nil {
return err
cmn.PanicCrisis(fmt.Sprintf("Failed to save genesis doc due to marshaling error: %v", err))
}
db.SetSync(genesisDocKey, bytes)
return nil
}

+ 6
- 15
rpc/client/httpclient.go View File

@ -39,17 +39,12 @@ func NewHTTP(remote, wsEndpoint string) *HTTP {
}
}
func (c *HTTP) _assertIsClient() Client {
return c
}
func (c *HTTP) _assertIsNetworkClient() NetworkClient {
return c
}
func (c *HTTP) _assertIsEventSwitch() types.EventSwitch {
return c
}
var (
_ Client = (*HTTP)(nil)
_ NetworkClient = (*HTTP)(nil)
_ types.EventSwitch = (*HTTP)(nil)
_ types.EventSwitch = (*WSEvents)(nil)
)
func (c *HTTP) Status() (*ctypes.ResultStatus, error) {
result := new(ctypes.ResultStatus)
@ -220,10 +215,6 @@ func newWSEvents(remote, endpoint string) *WSEvents {
}
}
func (w *WSEvents) _assertIsEventSwitch() types.EventSwitch {
return w
}
// Start is the only way I could think the extend OnStart from
// events.eventSwitch. If only it wasn't private...
// BaseService.Start -> eventSwitch.OnStart -> WSEvents.Start


+ 4
- 7
rpc/client/localclient.go View File

@ -41,13 +41,10 @@ func NewLocal(node *nm.Node) Local {
}
}
func (c Local) _assertIsClient() Client {
return c
}
func (c Local) _assertIsNetworkClient() NetworkClient {
return c
}
var (
_ Client = Local{}
_ NetworkClient = Local{}
)
func (c Local) Status() (*ctypes.ResultStatus, error) {
return core.Status()


+ 5
- 11
rpc/client/mock/abci.go View File

@ -16,9 +16,11 @@ type ABCIApp struct {
App abci.Application
}
func (a ABCIApp) _assertABCIClient() client.ABCIClient {
return a
}
var (
_ client.ABCIClient = ABCIApp{}
_ client.ABCIClient = ABCIMock{}
_ client.ABCIClient = (*ABCIRecorder)(nil)
)
func (a ABCIApp) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
return &ctypes.ResultABCIInfo{a.App.Info(abci.RequestInfo{version.Version})}, nil
@ -71,10 +73,6 @@ type ABCIMock struct {
Broadcast Call
}
func (m ABCIMock) _assertABCIClient() client.ABCIClient {
return m
}
func (m ABCIMock) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
res, err := m.Info.GetResponse(nil)
if err != nil {
@ -134,10 +132,6 @@ func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder {
}
}
func (r *ABCIRecorder) _assertABCIClient() client.ABCIClient {
return r
}
type QueryArgs struct {
Path string
Data data.Bytes


+ 1
- 3
rpc/client/mock/client.go View File

@ -37,9 +37,7 @@ type Client struct {
types.EventSwitch
}
func (c Client) _assertIsClient() client.Client {
return c
}
var _ client.Client = Client{}
// Call is used by recorders to save a call and response.
// It can also be used to configure mock responses.


+ 4
- 7
rpc/client/mock/status.go View File

@ -10,9 +10,10 @@ type StatusMock struct {
Call
}
func (m *StatusMock) _assertStatusClient() client.StatusClient {
return m
}
var (
_ client.StatusClient = (*StatusMock)(nil)
_ client.StatusClient = (*StatusRecorder)(nil)
)
func (m *StatusMock) Status() (*ctypes.ResultStatus, error) {
res, err := m.GetResponse(nil)
@ -36,10 +37,6 @@ func NewStatusRecorder(client client.StatusClient) *StatusRecorder {
}
}
func (r *StatusRecorder) _assertStatusClient() client.StatusClient {
return r
}
func (r *StatusRecorder) addCall(call Call) {
r.Calls = append(r.Calls, call)
}


+ 3
- 3
rpc/client/rpc_test.go View File

@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/merkleeyes/iavl" //TODO use tendermint/iavl ?
"github.com/tendermint/iavl"
"github.com/tendermint/tendermint/rpc/client"
rpctest "github.com/tendermint/tendermint/rpc/test"
"github.com/tendermint/tendermint/types"
@ -191,13 +191,13 @@ func TestAppCalls(t *testing.T) {
// and we got a proof that works!
pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: false})
if assert.Nil(err) && assert.True(pres.Code.IsOK()) {
proof, err := iavl.ReadProof(pres.Proof)
proof, err := iavl.ReadKeyExistsProof(pres.Proof)
if assert.Nil(err) {
key := pres.Key
value := pres.Value
assert.EqualValues(appHash, proof.RootHash)
valid := proof.Verify(key, value, appHash)
assert.True(valid)
assert.Nil(valid)
}
}
}


+ 6
- 3
rpc/lib/client/http_client.go View File

@ -12,6 +12,7 @@ import (
"strings"
"github.com/pkg/errors"
types "github.com/tendermint/tendermint/rpc/lib/types"
)
@ -41,7 +42,8 @@ func makeHTTPDialer(remoteAddr string) (string, func(string, string) (net.Conn,
protocol = "tcp"
}
trimmedAddress := strings.Replace(address, "/", ".", -1) // replace / with . for http requests (dummy domain)
// replace / with . for http requests (dummy domain)
trimmedAddress := strings.Replace(address, "/", ".", -1)
return trimmedAddress, func(proto, addr string) (net.Conn, error) {
return net.Dial(protocol, address)
}
@ -60,12 +62,13 @@ func makeHTTPClient(remoteAddr string) (string, *http.Client) {
//------------------------------------------------------------------------------------
// JSON rpc takes params as a slice
// JSONRPCClient takes params as a slice
type JSONRPCClient struct {
address string
client *http.Client
}
// NewJSONRPCClient returns a JSONRPCClient pointed at the given address.
func NewJSONRPCClient(remote string) *JSONRPCClient {
address, client := makeHTTPClient(remote)
return &JSONRPCClient{
@ -147,7 +150,7 @@ func unmarshalResponseBytes(responseBytes []byte, result interface{}) (interface
return nil, errors.Errorf("Error unmarshalling rpc response: %v", err)
}
if response.Error != nil {
return nil, errors.Errorf("Response error: %v", response.Error.Message)
return nil, errors.Errorf("Response error: %v", response.Error)
}
// unmarshal the RawMessage into the result
err = json.Unmarshal(*response.Result, result)


+ 1
- 1
rpc/lib/client/ws_client.go View File

@ -437,7 +437,7 @@ func (c *WSClient) readRoutine() {
continue
}
if response.Error != nil {
c.ErrorsCh <- errors.New(response.Error.Message)
c.ErrorsCh <- response.Error
continue
}
c.Logger.Info("got response", "resp", response.Result)


+ 8
- 1
rpc/lib/types/types.go View File

@ -6,7 +6,6 @@ import (
"strings"
"github.com/pkg/errors"
events "github.com/tendermint/tmlibs/events"
)
@ -60,6 +59,14 @@ type RPCError struct {
Data string `json:"data,omitempty"`
}
func (err RPCError) Error() string {
const baseFormat = "RPC error %v - %s"
if err.Data != "" {
return fmt.Sprintf(baseFormat+": %s", err.Code, err.Message, err.Data)
}
return fmt.Sprintf(baseFormat, err.Code, err.Message)
}
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID string `json:"id"`


+ 17
- 0
rpc/lib/types/types_test.go View File

@ -4,6 +4,8 @@ import (
"encoding/json"
"testing"
"fmt"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
@ -30,3 +32,18 @@ func TestResponses(t *testing.T) {
i := `{"jsonrpc":"2.0","id":"2","error":{"code":-32601,"message":"Method not found"}}`
assert.Equal(string(h), string(i))
}
func TestRPCError(t *testing.T) {
assert.Equal(t, "RPC error 12 - Badness: One worse than a code 11",
fmt.Sprintf("%v", &RPCError{
Code: 12,
Message: "Badness",
Data: "One worse than a code 11",
}))
assert.Equal(t, "RPC error 12 - Badness",
fmt.Sprintf("%v", &RPCError{
Code: 12,
Message: "Badness",
}))
}

+ 63
- 47
state/state.go View File

@ -8,11 +8,13 @@ import (
"time"
abci "github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/state/txindex/null"
"github.com/tendermint/tendermint/types"
@ -50,18 +52,18 @@ type State struct {
LastBlockTime time.Time
Validators *types.ValidatorSet
LastValidators *types.ValidatorSet
// AppHash is updated after Commit
AppHash []byte
TxIndexer txindex.TxIndexer `json:"-"` // Transaction indexer
// When a block returns a validator set change via EndBlock,
// the change only applies to the next block.
// So, if s.LastBlockHeight causes a valset change,
// we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1
LastHeightValidatorsChanged int
// AppHash is updated after Commit
AppHash []byte
// TxIndexer indexes transactions
TxIndexer txindex.TxIndexer `json:"-"`
logger log.Logger
}
@ -88,19 +90,21 @@ func LoadState(db dbm.DB) *State {
}
func loadState(db dbm.DB, key []byte) *State {
s := &State{db: db, TxIndexer: &null.TxIndex{}}
buf := db.Get(key)
if len(buf) == 0 {
return nil
} else {
r, n, err := bytes.NewReader(buf), new(int), new(error)
wire.ReadBinaryPtr(&s, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt("LoadState: Data has been corrupted or its spec has changed: %v\n", *err))
}
// TODO: ensure that buf is completely read.
}
s := &State{db: db, TxIndexer: &null.TxIndex{}}
r, n, err := bytes.NewReader(buf), new(int), new(error)
wire.ReadBinaryPtr(&s, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt(`LoadState: Data has been corrupted or its spec has changed:
%v\n`, *err))
}
// TODO: ensure that buf is completely read.
return s
}
@ -110,6 +114,8 @@ func (s *State) SetLogger(l log.Logger) {
}
// Copy makes a copy of the State for mutating.
// NOTE: Does not create a copy of TxIndexer. It creates a new pointer that points to the same
// underlying TxIndexer.
func (s *State) Copy() *State {
return &State{
db: s.db,
@ -119,7 +125,7 @@ func (s *State) Copy() *State {
Validators: s.Validators.Copy(),
LastValidators: s.LastValidators.Copy(),
AppHash: s.AppHash,
TxIndexer: s.TxIndexer, // pointer here, not value
TxIndexer: s.TxIndexer,
LastHeightValidatorsChanged: s.LastHeightValidatorsChanged,
logger: s.logger,
ChainID: s.ChainID,
@ -131,6 +137,7 @@ func (s *State) Copy() *State {
func (s *State) Save() {
s.mtx.Lock()
defer s.mtx.Unlock()
s.saveValidatorsInfo()
s.db.SetSync(stateKey, s.Bytes())
}
@ -142,38 +149,43 @@ func (s *State) SaveABCIResponses(abciResponses *ABCIResponses) {
}
// LoadABCIResponses loads the ABCIResponses from the database.
// This is useful for recovering from crashes where we called app.Commit and before we called
// s.Save()
func (s *State) LoadABCIResponses() *ABCIResponses {
abciResponses := new(ABCIResponses)
buf := s.db.Get(abciResponsesKey)
if len(buf) != 0 {
r, n, err := bytes.NewReader(buf), new(int), new(error)
wire.ReadBinaryPtr(abciResponses, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt("LoadABCIResponses: Data has been corrupted or its spec has changed: %v\n", *err))
}
// TODO: ensure that buf is completely read.
if len(buf) == 0 {
return nil
}
abciResponses := new(ABCIResponses)
r, n, err := bytes.NewReader(buf), new(int), new(error)
wire.ReadBinaryPtr(abciResponses, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt(`LoadABCIResponses: Data has been corrupted or its spec has
changed: %v\n`, *err))
}
// TODO: ensure that buf is completely read.
return abciResponses
}
// LoadValidators loads the ValidatorSet for a given height.
func (s *State) LoadValidators(height int) (*types.ValidatorSet, error) {
v := s.loadValidators(height)
if v == nil {
valInfo := s.loadValidators(height)
if valInfo == nil {
return nil, ErrNoValSetForHeight{height}
}
if v.ValidatorSet == nil {
v = s.loadValidators(v.LastHeightChanged)
if v == nil {
cmn.PanicSanity(fmt.Sprintf(`Couldn't find validators at
height %d as last changed from height %d`, v.LastHeightChanged, height))
if valInfo.ValidatorSet == nil {
valInfo = s.loadValidators(valInfo.LastHeightChanged)
if valInfo == nil {
cmn.PanicSanity(fmt.Sprintf(`Couldn't find validators at height %d as
last changed from height %d`, valInfo.LastHeightChanged, height))
}
}
return v.ValidatorSet, nil
return valInfo.ValidatorSet, nil
}
func (s *State) loadValidators(height int) *ValidatorsInfo {
@ -187,9 +199,11 @@ func (s *State) loadValidators(height int) *ValidatorsInfo {
wire.ReadBinaryPtr(v, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt("LoadValidators: Data has been corrupted or its spec has changed: %v\n", *err))
cmn.Exit(cmn.Fmt(`LoadValidators: Data has been corrupted or its spec has changed:
%v\n`, *err))
}
// TODO: ensure that buf is completely read.
return v
}
@ -200,13 +214,13 @@ func (s *State) loadValidators(height int) *ValidatorsInfo {
func (s *State) saveValidatorsInfo() {
changeHeight := s.LastHeightValidatorsChanged
nextHeight := s.LastBlockHeight + 1
vi := &ValidatorsInfo{
valInfo := &ValidatorsInfo{
LastHeightChanged: changeHeight,
}
if changeHeight == nextHeight {
vi.ValidatorSet = s.Validators
valInfo.ValidatorSet = s.Validators
}
s.db.SetSync(calcValidatorsKey(nextHeight), vi.Bytes())
s.db.SetSync(calcValidatorsKey(nextHeight), valInfo.Bytes())
}
// Equals returns true if the States are identical.
@ -219,8 +233,10 @@ func (s *State) Bytes() []byte {
return wire.BinaryBytes(s)
}
// SetBlockAndValidators mutates State variables to update block and validators after running EndBlock.
func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader types.PartSetHeader, abciResponses *ABCIResponses) {
// SetBlockAndValidators mutates State variables
// to update block and validators after running EndBlock.
func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader types.PartSetHeader,
abciResponses *ABCIResponses) {
// copy the valset so we can apply changes from EndBlock
// and update s.LastValidators and s.Validators
@ -248,8 +264,7 @@ func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader typ
}
func (s *State) setBlockAndValidators(
height int, blockID types.BlockID, blockTime time.Time,
func (s *State) setBlockAndValidators(height int, blockID types.BlockID, blockTime time.Time,
prevValSet, nextValSet *types.ValidatorSet) {
s.LastBlockHeight = height
@ -260,7 +275,7 @@ func (s *State) setBlockAndValidators(
}
// GetValidators returns the last and current validator sets.
func (s *State) GetValidators() (*types.ValidatorSet, *types.ValidatorSet) {
func (s *State) GetValidators() (last *types.ValidatorSet, current *types.ValidatorSet) {
return s.LastValidators, s.Validators
}
@ -293,15 +308,15 @@ func (a *ABCIResponses) Bytes() []byte {
//-----------------------------------------------------------------------------
// ValidatorsInfo represents the latest validator set, or the last time it changed
// ValidatorsInfo represents the latest validator set, or the last height it changed
type ValidatorsInfo struct {
ValidatorSet *types.ValidatorSet
LastHeightChanged int
}
// Bytes serializes the ValidatorsInfo using go-wire
func (vi *ValidatorsInfo) Bytes() []byte {
return wire.BinaryBytes(*vi)
func (valInfo *ValidatorsInfo) Bytes() []byte {
return wire.BinaryBytes(*valInfo)
}
//------------------------------------------------------------------------
@ -353,6 +368,7 @@ func MakeGenesisState(db dbm.DB, genDoc *types.GenesisDoc) (*State, error) {
}
}
// we do not need indexer during replay and in tests
return &State{
db: db,
@ -365,7 +381,7 @@ func MakeGenesisState(db dbm.DB, genDoc *types.GenesisDoc) (*State, error) {
Validators: types.NewValidatorSet(validators),
LastValidators: types.NewValidatorSet(nil),
AppHash: genDoc.AppHash,
TxIndexer: &null.TxIndex{}, // we do not need indexer during replay and in tests
TxIndexer: &null.TxIndex{},
LastHeightValidatorsChanged: 1,
}, nil
}

+ 28
- 11
state/state_test.go View File

@ -7,15 +7,16 @@ import (
"github.com/stretchr/testify/assert"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/types"
abci "github.com/tendermint/abci/types"
crypto "github.com/tendermint/go-crypto"
cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/types"
)
// setupTestCase does setup common to all test cases
@ -31,22 +32,29 @@ func setupTestCase(t *testing.T) (func(t *testing.T), dbm.DB, *State) {
return tearDown, stateDB, state
}
// TestStateCopy tests the correct copying behaviour of State.
func TestStateCopy(t *testing.T) {
tearDown, _, state := setupTestCase(t)
defer tearDown(t)
// nolint: vetshadow
assert := assert.New(t)
stateCopy := state.Copy()
assert.True(state.Equals(stateCopy),
cmn.Fmt("expected state and its copy to be identical. got %v\n expected %v\n", stateCopy, state))
cmn.Fmt(`expected state and its copy to be identical. got %v\n expected %v\n`,
stateCopy, state))
stateCopy.LastBlockHeight++
assert.False(state.Equals(stateCopy), cmn.Fmt("expected states to be different. got same %v", state))
assert.False(state.Equals(stateCopy), cmn.Fmt(`expected states to be different. got same
%v`, state))
}
// TestStateSaveLoad tests saving and loading State from a db.
func TestStateSaveLoad(t *testing.T) {
tearDown, stateDB, state := setupTestCase(t)
defer tearDown(t)
// nolint: vetshadow
assert := assert.New(t)
state.LastBlockHeight++
@ -54,12 +62,15 @@ func TestStateSaveLoad(t *testing.T) {
loadedState := LoadState(stateDB)
assert.True(state.Equals(loadedState),
cmn.Fmt("expected state and its copy to be identical. got %v\n expected %v\n", loadedState, state))
cmn.Fmt(`expected state and its copy to be identical. got %v\n expected %v\n`,
loadedState, state))
}
// TestABCIResponsesSaveLoad tests saving and loading ABCIResponses.
func TestABCIResponsesSaveLoad(t *testing.T) {
tearDown, _, state := setupTestCase(t)
defer tearDown(t)
// nolint: vetshadow
assert := assert.New(t)
state.LastBlockHeight++
@ -78,17 +89,20 @@ func TestABCIResponsesSaveLoad(t *testing.T) {
abciResponses.txs = nil
state.SaveABCIResponses(abciResponses)
abciResponses2 := state.LoadABCIResponses()
assert.Equal(abciResponses, abciResponses2,
cmn.Fmt("ABCIResponses don't match: Got %v, Expected %v", abciResponses2, abciResponses))
loadedAbciResponses := state.LoadABCIResponses()
assert.Equal(abciResponses, loadedAbciResponses,
cmn.Fmt(`ABCIResponses don't match: Got %v, Expected %v`, loadedAbciResponses,
abciResponses))
}
// TestValidatorSimpleSaveLoad tests saving and loading validators.
func TestValidatorSimpleSaveLoad(t *testing.T) {
tearDown, _, state := setupTestCase(t)
defer tearDown(t)
// nolint: vetshadow
assert := assert.New(t)
// cant load anything for height 0
// can't load anything for height 0
v, err := state.LoadValidators(0)
assert.IsType(ErrNoValSetForHeight{}, err, "expected err at height 0")
@ -116,9 +130,11 @@ func TestValidatorSimpleSaveLoad(t *testing.T) {
assert.IsType(ErrNoValSetForHeight{}, err, "expected err at unknown height")
}
// TestValidatorChangesSaveLoad tests saving and loading a validator set with changes.
func TestValidatorChangesSaveLoad(t *testing.T) {
tearDown, _, state := setupTestCase(t)
defer tearDown(t)
// nolint: vetshadow
assert := assert.New(t)
// change vals at these heights
@ -171,7 +187,8 @@ func TestValidatorChangesSaveLoad(t *testing.T) {
assert.Equal(v.Size(), 1, "validator set size is greater than 1: %d", v.Size())
addr, _ := v.GetByIndex(0)
assert.Equal(addr, testCase.vals.Address(), fmt.Sprintf("unexpected pubkey at height %d", testCase.height))
assert.Equal(addr, testCase.vals.Address(), fmt.Sprintf(`unexpected pubkey at
height %d`, testCase.height))
}
}


+ 7
- 10
state/txindex/indexer.go View File

@ -6,17 +6,16 @@ import (
"github.com/tendermint/tendermint/types"
)
// Indexer interface defines methods to index and search transactions.
// TxIndexer interface defines methods to index and search transactions.
type TxIndexer interface {
// Batch analyzes, indexes or stores a batch of transactions.
//
// NOTE We do not specify Index method for analyzing a single transaction
// AddBatch analyzes, indexes or stores a batch of transactions.
// NOTE: We do not specify Index method for analyzing a single transaction
// here because it bears heavy perfomance loses. Almost all advanced indexers
// support batching.
AddBatch(b *Batch) error
// Tx returns specified transaction or nil if the transaction is not indexed
// Get returns the transaction specified by hash or nil if the transaction is not indexed
// or stored.
Get(hash []byte) (*types.TxResult, error)
}
@ -24,10 +23,8 @@ type TxIndexer interface {
//----------------------------------------------------
// Txs are written as a batch
// A Batch groups together multiple Index operations you would like performed
// at the same time. The Batch structure is NOT thread-safe. You should only
// perform operations on a batch from a single thread at a time. Once batch
// execution has started, you may not modify it.
// Batch groups together multiple Index operations to be performed at the same time.
// NOTE: Batch is NOT thread-safe and must not be modified after starting its execution.
type Batch struct {
Ops []types.TxResult
}
@ -39,7 +36,7 @@ func NewBatch(n int) *Batch {
}
}
// Index adds or updates entry for the given result.Index.
// Add or update an entry for the given result.Index.
func (b *Batch) Add(result types.TxResult) error {
b.Ops[result.Index] = result
return nil


+ 5
- 3
state/txindex/kv/kv.go View File

@ -4,14 +4,16 @@ import (
"bytes"
"fmt"
db "github.com/tendermint/tmlibs/db"
"github.com/tendermint/go-wire"
db "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/types"
)
// TxIndex is the simplest possible indexer, backed by Key-Value storage (levelDB).
// It could only index transaction by its identifier.
// It can only index transaction by its identifier.
type TxIndex struct {
store db.DB
}
@ -44,7 +46,7 @@ func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
return txResult, nil
}
// Batch writes a batch of transactions into the TxIndex storage.
// AddBatch writes a batch of transactions into the TxIndex storage.
func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
storeBatch := txi.store.NewBatch()
for _, result := range b.Ops {


+ 2
- 2
state/txindex/null/null.go View File

@ -10,12 +10,12 @@ import (
// TxIndex acts as a /dev/null.
type TxIndex struct{}
// Tx panics.
// Get on a TxIndex is disabled and panics when invoked.
func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
return nil, errors.New(`Indexing is disabled (set 'tx_index = "kv"' in config)`)
}
// Batch returns nil.
// AddBatch is a noop and always returns nil.
func (txi *TxIndex) AddBatch(batch *txindex.Batch) error {
return nil
}

+ 3
- 3
types/block.go View File

@ -14,15 +14,15 @@ import (
"github.com/tendermint/tmlibs/merkle"
)
// Block defines the atomic unit of a Tendermint blockchain
// Block defines the atomic unit of a Tendermint blockchain.
type Block struct {
*Header `json:"header"`
*Data `json:"data"`
LastCommit *Commit `json:"last_commit"`
}
// MakeBlock returns a new block and corresponding part set from the given information
// TODO: version
// MakeBlock returns a new block and corresponding partset from the given information.
// TODO: Add version information to the Block struct.
func MakeBlock(height int, chainID string, txs []Tx, commit *Commit,
prevBlockID BlockID, valHash, appHash []byte, partSize int) (*Block, *PartSet) {
block := &Block{


Loading…
Cancel
Save