Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade abci and tm versions #76

Merged
merged 3 commits into from
Jun 21, 2018
Merged

Upgrade abci and tm versions #76

merged 3 commits into from
Jun 21, 2018

Conversation

ruseinov
Copy link
Contributor

Get chainID from initChain again
Update tests
Update pubKey indexing according to the new message format

Get chainID from initChain again
Update tests
Update pubKey indexing according to the new message format
@ruseinov ruseinov requested a review from ethanfrey June 20, 2018 10:28
@ruseinov ruseinov changed the title Upgrade abci and tm versions WIP: Upgrade abci and tm versions Jun 20, 2018
@codecov
Copy link

codecov bot commented Jun 20, 2018

Codecov Report

Merging #76 into master will decrease coverage by 0.4%.
The diff coverage is 50%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #76     +/-   ##
========================================
- Coverage    77.9%   77.4%   -0.5%     
========================================
  Files          56      56             
  Lines        2399    2443     +44     
========================================
+ Hits         1869    1893     +24     
- Misses        425     445     +20     
  Partials      105     105
Impacted Files Coverage Δ
app/store.go 58.5% <50%> (-0.4%) ⬇️
x/persistent.go 83.3% <0%> (-8%) ⬇️
x/cash/handler.go 80% <0%> (-1.3%) ⬇️
conditions.go 100% <0%> (ø) ⬆️
x/cash/decorator.go 100% <0%> (ø) ⬆️
app/genesis.go 0% <0%> (ø) ⬆️
examples/mycoind/app/examples.go 0% <0%> (ø) ⬆️
x/sigs/decorator.go 94.1% <0%> (+0.7%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10b9ce2...833f5d7. Read the comment docs.

@ruseinov
Copy link
Contributor Author

@ethanfrey So we've got the following changes:

BREAKING CHANGES:

[example/dummy] Remove. See example/kvstore
[types] Upgrade many messages:
RequestInitChain takes all fields from a Genesis file - we don't really need anything, but the chainID retrieval here, which I have already implemented
RequestBeginBlock provides a list of all validators and whether or not they signed - do we need to store these?
Header: remove some fields, add proposer - probably does not matter for weave implementation
BlockID, PartSetHeader: remove - same as above
Validator: includes address - same as above
PubKey: new message with type and data - I have fixed the comparison
Evidence: add type and more fields - Does not seem to be used in weave
FEATURES:

[types] Add some fields - Anything here?
ResponseInitChain includes ConsensusParams and Validators
ResponseBeginBlock includes tags
ResponseEndBlock includes tags

@ethanfrey
Copy link
Contributor

What we care about:

RequestInitChain takes all fields from a Genesis file - we don't really need anything, but the chainID retrieval here, which I have already implemented

Yup. we will want to store the set of initial validators later, or pass down to the apps to store it. Not needed now, but I will create an issue.

RequestBeginBlock provides a list of all validators and whether or not they signed - do we need to store these?

We don't need to store them at all, but we may want to place them in the Context, so an application could take action. This is only really useful when we have actions that run every block in BeginBlock, so I will create a future issue for this as well.

Header: remove some fields, add proposer - probably does not matter for weave implementation
BlockID, PartSetHeader: remove - same as above

No one uses these fields now, they are all passed down the line. Good to go.

Validator: includes address - same as above

Validator in init genesis? I didn't think there was a validator in BeginBlock? But maybe I am wrong.
We want the validator format used in the EndBlock Diff to be totally compatible with tendermint. If we need to change something here, please do it.

PubKey: new message with type and data - I have fixed the comparison

👍 this is a key change we need, so the validator diff works with the new version.

Evidence: add type and more fields - Does not seem to be used in weave
[types] Add some fields - Anything here?

ResponseInitChain includes ConsensusParams and Validators

This one is interesting. What happens if we don't provide Validators??? It just uses the validators from the genesis file, right? Or do we have to explicitly return the same set as we get in from the input to InitChain? It would be good to investigate and add a comment on InitChain how this works. If we provide values, do they override the genesis value, or are the combined together (like the EndBlock Diff)?

ResponseBeginBlock includes tags
ResponseEndBlock includes tags

We do not use these now, but maybe add a // TODO or // NOTE: to these methods in app/store.go so we remember they are there... we will want to add a BeginBlock handler at some point to deal with repeating or delayed tasks and it is nice to know this can add tags.

Many of the features are added for the complex staking model used in cosmos, and they are not necessary for us now, but it is good to know they are there, and when we add an interface to handle BeginBlock, we should make sure to include that it can return Tags.

Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One suggestion for an enhancement

@@ -111,6 +111,11 @@ func (s *StoreApp) parseAppState(data []byte, init weave.Initializer) error {
return errors.WithCode(err, errors.CodeTxParseError)
}

err = s.storeChainID(chainID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -345,7 +342,7 @@ func (s *StoreApp) AddValChange(diffs []abci.Validator) {
// return index of list with validator of same PubKey, or -1 if no match
func pubKeyIndex(val abci.Validator, list []abci.Validator) int {
for i, v := range list {
if bytes.Equal(val.PubKey, v.PubKey) {
if val.PubKey.Type == v.PubKey.Type && bytes.Equal(val.PubKey.Data, v.PubKey.Data) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

// Commit first block, make sure non-nil hash
header := abci.Header{Height: h, ChainID: chainId}
header := abci.Header{Height: h}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better this way.
Just wondering, maybe we verify chainID of every header on BeginBlock? And return an error if it is present and different from the one stored in InitCHain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I was not sure it's necessary, but we can indeed panic with an error if stuff does not match. Kind of provides "extra security", but on the other hand this should not be happening if the init was correct, otherwise we can't trust tendermint at all. Unless I'm missing something.

What do you think?

I guess what I'm trying to say is: double checking is good, but it leads to more code and more things that could potentially break/need to be supported while sometimes providing us with no benefit. I used to do that a lot on every level of an application, but then learned to limit myself to what's necessary.

I might be wrong about this one, so I leave this call up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes me look ridiculous, fighting for one line of code here 🗡

Copy link
Contributor

@ethanfrey ethanfrey Jun 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave the tests as is.

I just got contacted from some people, where they ended up replaying blocks from the wrong chain in some dev setup. I thought a second check would not be bad.

But on reflection, the Info method on handshake will show a different AppHash than the chain, so tendermint should prohibit that anyway.

Ignore the above comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethanfrey cool, not changing anything here then.

@ruseinov
Copy link
Contributor Author

@ethanfrey I will investigate the evidence stuff and put TODO's about other stuff as well these coming days.

@ruseinov ruseinov changed the title WIP: Upgrade abci and tm versions Upgrade abci and tm versions Jun 21, 2018
@ruseinov
Copy link
Contributor Author

@ethanfrey added some TODO's, ready for merge. Feel free to add tickets for whatever I might have missed.

@ethanfrey ethanfrey merged commit 9476ac7 into master Jun 21, 2018
@ethanfrey ethanfrey deleted the feature/upgrade-tm-0.20.0 branch June 21, 2018 14:51
alpe added a commit that referenced this pull request Oct 29, 2018
* Replace confio with iov packages

* Fix utils imports

* Fix test imports

* More imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants