From 19999ea51751f461c2d5c0f9a8405f33dfac0c28 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 22 Jun 2017 20:32:22 -0400 Subject: [PATCH] ibc: UpdateChain fix blockid --- plugins/ibc/ibc.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/ibc/ibc.go b/plugins/ibc/ibc.go index eb8a27f1b0..3a9b0f8c6e 100644 --- a/plugins/ibc/ibc.go +++ b/plugins/ibc/ibc.go @@ -570,7 +570,17 @@ func verifyCommit(chainState BlockchainState, header *tm.Header, commit *tm.Comm chainID := chainState.ChainID vals := chainState.Validators valSet := tm.NewValidatorSet(vals) - blockID := commit.Precommits[0].BlockID // XXX: incorrect + + var blockID tm.BlockID + for _, pc := range commit.Precommits { + // XXX: incorrect. we want the one for +2/3, not just the first one + if pc != nil { + blockID = pc.BlockID + } + } + if blockID.IsZero() { + return errors.New("All precommits are nil!") + } // NOTE: Currently this only works with the exact same validator set. // Not this, but perhaps "ValidatorSet.VerifyCommitAny" should expose