diff --git a/lite/dynamic_test.go b/lite/dynamic_test.go index 12db1946..acbd1e65 100644 --- a/lite/dynamic_test.go +++ b/lite/dynamic_test.go @@ -46,7 +46,7 @@ func TestDynamicCert(t *testing.T) { for _, tc := range cases { check := tc.keys.GenCommit(chainID, tc.height, nil, tc.vals, - []byte("bar"), tc.first, tc.last) + []byte("bar"), []byte("params"), tc.first, tc.last) err := cert.Certify(check) if tc.proper { assert.Nil(err, "%+v", err) @@ -71,7 +71,7 @@ func TestDynamicUpdate(t *testing.T) { // one valid block to give us a sense of time h := int64(100) - good := keys.GenCommit(chainID, h, nil, vals, []byte("foo"), 0, len(keys)) + good := keys.GenCommit(chainID, h, nil, vals, []byte("foo"), []byte("params"), 0, len(keys)) err := cert.Certify(good) require.Nil(err, "%+v", err) @@ -109,7 +109,7 @@ func TestDynamicUpdate(t *testing.T) { for _, tc := range cases { fc := tc.keys.GenFullCommit(chainID, tc.height, nil, tc.vals, - []byte("bar"), tc.first, tc.last) + []byte("bar"), []byte("params"), tc.first, tc.last) err := cert.Update(fc) if tc.proper { assert.Nil(err, "%d: %+v", tc.height, err) diff --git a/lite/files/commit_test.go b/lite/files/commit_test.go index c2124379..f6cb2a73 100644 --- a/lite/files/commit_test.go +++ b/lite/files/commit_test.go @@ -29,7 +29,7 @@ func TestSerializeFullCommits(t *testing.T) { // build a fc keys := lite.GenValKeys(5) vals := keys.ToValidators(10, 0) - fc := keys.GenFullCommit(chainID, h, nil, vals, appHash, 0, 5) + fc := keys.GenFullCommit(chainID, h, nil, vals, appHash, []byte("params"), 0, 5) require.Equal(h, fc.Height()) require.Equal(vals.Hash(), fc.ValidatorsHash()) diff --git a/lite/files/provider_test.go b/lite/files/provider_test.go index b8d8e88b..e50d3461 100644 --- a/lite/files/provider_test.go +++ b/lite/files/provider_test.go @@ -46,7 +46,7 @@ func TestFileProvider(t *testing.T) { // (10, 0), (10, 1), (10, 1), (10, 2), (10, 2), ... vals := keys.ToValidators(10, int64(count/2)) h := int64(20 + 10*i) - check := keys.GenCommit(chainID, h, nil, vals, appHash, 0, 5) + check := keys.GenCommit(chainID, h, nil, vals, appHash, []byte("params"), 0, 5) seeds[i] = lite.NewFullCommit(check, vals) } diff --git a/lite/helpers.go b/lite/helpers.go index f8d90de5..394cd666 100644 --- a/lite/helpers.go +++ b/lite/helpers.go @@ -110,7 +110,7 @@ func makeVote(header *types.Header, vals *types.ValidatorSet, key crypto.PrivKey // Silences warning that vals can also be merkle.Hashable // nolint: interfacer func genHeader(chainID string, height int64, txs types.Txs, - vals *types.ValidatorSet, appHash []byte) *types.Header { + vals *types.ValidatorSet, appHash, consHash []byte) *types.Header { return &types.Header{ ChainID: chainID, @@ -123,14 +123,15 @@ func genHeader(chainID string, height int64, txs types.Txs, ValidatorsHash: vals.Hash(), DataHash: txs.Hash(), AppHash: appHash, + ConsensusHash: consHash, } } // GenCommit calls genHeader and signHeader and combines them into a Commit. func (v ValKeys) GenCommit(chainID string, height int64, txs types.Txs, - vals *types.ValidatorSet, appHash []byte, first, last int) Commit { + vals *types.ValidatorSet, appHash, consHash []byte, first, last int) Commit { - header := genHeader(chainID, height, txs, vals, appHash) + header := genHeader(chainID, height, txs, vals, appHash, consHash) check := Commit{ Header: header, Commit: v.signHeader(header, first, last), @@ -140,9 +141,9 @@ func (v ValKeys) GenCommit(chainID string, height int64, txs types.Txs, // GenFullCommit calls genHeader and signHeader and combines them into a Commit. func (v ValKeys) GenFullCommit(chainID string, height int64, txs types.Txs, - vals *types.ValidatorSet, appHash []byte, first, last int) FullCommit { + vals *types.ValidatorSet, appHash, consHash []byte, first, last int) FullCommit { - header := genHeader(chainID, height, txs, vals, appHash) + header := genHeader(chainID, height, txs, vals, appHash, consHash) commit := Commit{ Header: header, Commit: v.signHeader(header, first, last), diff --git a/lite/inquirer_test.go b/lite/inquirer_test.go index c30d8209..eb45eb3c 100644 --- a/lite/inquirer_test.go +++ b/lite/inquirer_test.go @@ -22,6 +22,7 @@ func TestInquirerValidPath(t *testing.T) { // construct a bunch of commits, each with one more height than the last chainID := "inquiry-test" + consHash := []byte("params") count := 50 commits := make([]lite.FullCommit, count) for i := 0; i < count; i++ { @@ -30,7 +31,7 @@ func TestInquirerValidPath(t *testing.T) { vals := keys.ToValidators(vote, 0) h := int64(20 + 10*i) appHash := []byte(fmt.Sprintf("h=%d", h)) - commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, 0, len(keys)) + commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, consHash, 0, len(keys)) } // initialize a certifier with the initial state @@ -69,6 +70,7 @@ func TestInquirerMinimalPath(t *testing.T) { // construct a bunch of commits, each with one more height than the last chainID := "minimal-path" + consHash := []byte("other-params") count := 12 commits := make([]lite.FullCommit, count) for i := 0; i < count; i++ { @@ -77,7 +79,7 @@ func TestInquirerMinimalPath(t *testing.T) { vals := keys.ToValidators(vote, 0) h := int64(5 + 10*i) appHash := []byte(fmt.Sprintf("h=%d", h)) - commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, 0, len(keys)) + commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, consHash, 0, len(keys)) } // initialize a certifier with the initial state @@ -117,6 +119,7 @@ func TestInquirerVerifyHistorical(t *testing.T) { // construct a bunch of commits, each with one more height than the last chainID := "inquiry-test" count := 10 + consHash := []byte("special-params") commits := make([]lite.FullCommit, count) for i := 0; i < count; i++ { // extend the keys by 1 each time @@ -124,7 +127,7 @@ func TestInquirerVerifyHistorical(t *testing.T) { vals := keys.ToValidators(vote, 0) h := int64(20 + 10*i) appHash := []byte(fmt.Sprintf("h=%d", h)) - commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, 0, len(keys)) + commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, consHash, 0, len(keys)) } // initialize a certifier with the initial state diff --git a/lite/performance_test.go b/lite/performance_test.go index e01b8993..af6eacc3 100644 --- a/lite/performance_test.go +++ b/lite/performance_test.go @@ -33,7 +33,7 @@ func benchmarkGenCommit(b *testing.B, keys lite.ValKeys) { for i := 0; i < b.N; i++ { h := int64(1 + i) appHash := []byte(fmt.Sprintf("h=%d", h)) - keys.GenCommit(chainID, h, nil, vals, appHash, 0, len(keys)) + keys.GenCommit(chainID, h, nil, vals, appHash, []byte("params"), 0, len(keys)) } } @@ -105,7 +105,7 @@ func benchmarkCertifyCommit(b *testing.B, keys lite.ValKeys) { chainID := "bench-certify" vals := keys.ToValidators(20, 10) cert := lite.NewStatic(chainID, vals) - check := keys.GenCommit(chainID, 123, nil, vals, []byte("foo"), 0, len(keys)) + check := keys.GenCommit(chainID, 123, nil, vals, []byte("foo"), []byte("params"), 0, len(keys)) for i := 0; i < b.N; i++ { err := cert.Certify(check) if err != nil { diff --git a/lite/provider_test.go b/lite/provider_test.go index f1165619..09ad0aa8 100644 --- a/lite/provider_test.go +++ b/lite/provider_test.go @@ -58,7 +58,7 @@ func checkProvider(t *testing.T, p lite.Provider, chainID, app string) { // (10, 0), (10, 1), (10, 1), (10, 2), (10, 2), ... vals := keys.ToValidators(10, int64(count/2)) h := int64(20 + 10*i) - commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, 0, 5) + commits[i] = keys.GenFullCommit(chainID, h, nil, vals, appHash, []byte("params"), 0, 5) } // check provider is empty @@ -129,7 +129,7 @@ func TestCacheGetsBestHeight(t *testing.T) { for i := 0; i < count; i++ { vals := keys.ToValidators(10, int64(count/2)) h := int64(10 * (i + 1)) - fc := keys.GenFullCommit(chainID, h, nil, vals, appHash, 0, 5) + fc := keys.GenFullCommit(chainID, h, nil, vals, appHash, []byte("params"), 0, 5) err := p2.StoreCommit(fc) require.NoError(err) } diff --git a/lite/static_test.go b/lite/static_test.go index e4bf435c..d0a1e685 100644 --- a/lite/static_test.go +++ b/lite/static_test.go @@ -44,7 +44,7 @@ func TestStaticCert(t *testing.T) { for _, tc := range cases { check := tc.keys.GenCommit(chainID, tc.height, nil, tc.vals, - []byte("foo"), tc.first, tc.last) + []byte("foo"), []byte("params"), tc.first, tc.last) err := cert.Certify(check) if tc.proper { assert.Nil(err, "%+v", err)