diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index c319abb18..f4ff98039 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -36,7 +36,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi - [evidence] [\#4780](https://github.com/tendermint/tendermint/pull/4780) Cap evidence to an absolute number (@cmwaters) - Add `max_num` to consensus evidence parameters (default: 50 items). - [evidence] \#4725 Remove `Pubkey` from `DuplicateVoteEvidence` - - [state] \#4845 Include `BeginBlock#Events`, `EndBlock#Events`, `DeliverTx#Events`, `GasWanted` and `GasUsed` into `LastResultsHash` (@melekes) + - [state] \#4845 Include `GasWanted` and `GasUsed` into `LastResultsHash` (@melekes) - [types] [\#4792](https://github.com/tendermint/tendermint/pull/4792) Sort validators by voting power to enable faster commit verification (@melekes) - On-disk serialization diff --git a/Vagrantfile b/Vagrantfile index aedd198e2..00fd2b310 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/xenial64" + config.vm.box = "ubuntu/focal64" config.vm.provider "virtualbox" do |v| v.memory = 4096 @@ -19,20 +19,24 @@ Vagrant.configure("2") do |config| # install docker apt-get install -y --no-install-recommends apt-transport-https \ - ca-certificates curl software-properties-common + ca-certificates \ + curl \ + gnupg-agent \ + software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" + apt-get update apt-get install -y docker-ce - usermod -a -G docker vagrant + usermod -aG docker vagrant # install go wget -q https://dl.google.com/go/go1.14.linux-amd64.tar.gz tar -xvf go1.14.linux-amd64.tar.gz mv go /usr/local - rm -f go1.13.linux-amd64.tar.gz + rm -f go1.14.linux-amd64.tar.gz # install nodejs (for docs) curl -sL https://deb.nodesource.com/setup_11.x | bash - diff --git a/state/store.go b/state/store.go index 4ec66e9c5..915f31572 100644 --- a/state/store.go +++ b/state/store.go @@ -7,7 +7,6 @@ import ( dbm "github.com/tendermint/tm-db" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/merkle" tmmath "github.com/tendermint/tendermint/libs/math" tmos "github.com/tendermint/tendermint/libs/os" tmstate "github.com/tendermint/tendermint/proto/tendermint/state" @@ -269,34 +268,12 @@ func PruneStates(db dbm.DB, from int64, to int64) error { //------------------------------------------------------------------------ -// ABCIResponsesResultsHash returns the root hash of a Merkle tree with 3 leafs: -// 1) proto encoded ResponseBeginBlock.Events -// 2) root hash of a Merkle tree of ResponseDeliverTx responses (see ABCIResults.Hash) -// 3) proto encoded ResponseEndBlock.Events +// ABCIResponsesResultsHash returns the root hash of a Merkle tree of +// ResponseDeliverTx responses (see ABCIResults.Hash) // // See merkle.SimpleHashFromByteSlices func ABCIResponsesResultsHash(ar *tmstate.ABCIResponses) []byte { - // proto-encode BeginBlock events. - bbeBytes, err := proto.Marshal(&abci.ResponseBeginBlock{ - Events: ar.BeginBlock.Events, - }) - if err != nil { - panic(err) - } - - // Build a Merkle tree of proto-encoded DeliverTx results and get a hash. - results := types.NewResults(ar.DeliverTxs) - - // proto-encode EndBlock events. - ebeBytes, err := proto.Marshal(&abci.ResponseEndBlock{ - Events: ar.EndBlock.Events, - }) - if err != nil { - panic(err) - } - - // Build a Merkle tree out of the above 3 binary slices. - return merkle.HashFromByteSlices([][]byte{bbeBytes, results.Hash(), ebeBytes}) + return types.NewResults(ar.DeliverTxs).Hash() } // LoadABCIResponses loads the ABCIResponses for the given height from the diff --git a/state/store_test.go b/state/store_test.go index daab6cac0..80df1a961 100644 --- a/state/store_test.go +++ b/state/store_test.go @@ -5,7 +5,6 @@ import ( "os" "testing" - "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -15,7 +14,6 @@ import ( cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/merkle" tmrand "github.com/tendermint/tendermint/libs/rand" tmstate "github.com/tendermint/tendermint/proto/tendermint/state" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -201,14 +199,15 @@ func TestABCIResponsesResultsHash(t *testing.T) { root := sm.ABCIResponsesResultsHash(responses) - bbeBytes, _ := proto.Marshal(responses.BeginBlock) + // root should be Merkle tree root of DeliverTxs responses results := types.NewResults(responses.DeliverTxs) - ebeBytes, _ := proto.Marshal(responses.EndBlock) + assert.Equal(t, root, results.Hash()) - root2, proofs := merkle.ProofsFromByteSlices([][]byte{bbeBytes, results.Hash(), ebeBytes}) - - assert.Equal(t, root2, root) - assert.NoError(t, proofs[1].Verify(root, results.Hash())) + // test we can prove first DeliverTx + proof := results.ProveResult(0) + bz, err := results[0].Marshal() + require.NoError(t, err) + assert.NoError(t, proof.Verify(root, bz)) } func sliceToMap(s []int64) map[int64]bool { diff --git a/types/results.go b/types/results.go index 0f41fab3c..9181450bc 100644 --- a/types/results.go +++ b/types/results.go @@ -50,6 +50,5 @@ func deterministicResponseDeliverTx(response *abci.ResponseDeliverTx) *abci.Resp Data: response.Data, GasWanted: response.GasWanted, GasUsed: response.GasUsed, - Events: response.Events, } }