This repository has been archived by the owner on Jul 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
merkleeyes to iavl #116
Merged
Merged
merkleeyes to iavl #116
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9aff9f9
dummy app now uses iavl
ethanfrey bae4e4a
Fix up commits, debug cli tests
ethanfrey d236e0e
Fix trailing whitespace in tutorial test
ethanfrey 46e1f1a
Cleaup based on Antons PR comments
ethanfrey 7aa00e9
Fix metalinter errors
ethanfrey 5162ed1
Remove gotype from metalinter so it passes (need newer go on circleci)
ethanfrey a4443dd
update persistent dummy for versioned iavl
ebuchman e7ebf62
Remove empty check after iavl fixup
ethanfrey 446e50c
Moved RandVal into test helper functions, as needed in other repos fo…
ethanfrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package dummy | ||
|
||
import ( | ||
"github.com/tendermint/abci/types" | ||
crypto "github.com/tendermint/go-crypto" | ||
cmn "github.com/tendermint/tmlibs/common" | ||
) | ||
|
||
// RandVal creates one random validator, with a key derived | ||
// from the input value | ||
func RandVal(i int) *types.Validator { | ||
pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(cmn.Fmt("test%d", i))).PubKey().Bytes() | ||
power := cmn.RandUint16() + 1 | ||
return &types.Validator{pubkey, uint64(power)} | ||
} | ||
|
||
// RandVals returns a list of cnt validators for initializing | ||
// the application. Note that the keys are deterministically | ||
// derived from the index in the array, while the power is | ||
// random (Change this if not desired) | ||
func RandVals(cnt int) []*types.Validator { | ||
res := make([]*types.Validator, cnt) | ||
for i := 0; i < cnt; i++ { | ||
res[i] = RandVal(i) | ||
} | ||
return res | ||
} | ||
|
||
// InitDummy initializes the dummy app with some data, | ||
// which allows tests to pass and is fine as long as you | ||
// don't make any tx that modify the validator state | ||
func InitDummy(app *PersistentDummyApplication) { | ||
app.InitChain(types.RequestInitChain{RandVals(1)}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this condition? I mean, by the time we commit the size should always be > 0, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. We have tests that commit a few empty blocks before adding a TX. They were returning errors here, which broke things. So I added tests. Thus the slack ping to alexis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. For the persistent dummy I ended up adding the constraint that InitChain must be called, which will make the state non-zero. In general would be nice if we could still get versions of empty trees so we dont have to worry about this edge condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use
!app.state.IsEmpty()
now which is a bit cleaner, but if a tree has no root, what are we saving exactly? We could potentially have it just save a version number but hmmm..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just for useability. The tree is still something the app thinks about and has a root (even if empty). And for recover logic, we like the tree version to equal the height, even if the tree hasn't changed.