Skip to content

Commit

Permalink
Patch missing functionality needed for app in tendermint v0.35 (#747)
Browse files Browse the repository at this point in the history
* pass the entire block data while processing proposal

* remove malleated txs from the prioritized v1 mempool

* patch flaky test

* spelling

Co-authored-by: Ismail Khoffi <[email protected]>

* spel

Co-authored-by: Ismail Khoffi <[email protected]>

* fix old spelling error

* use correct repo when comparing proto files

Co-authored-by: Ismail Khoffi <[email protected]>
  • Loading branch information
evan-forbes and liamsi authored May 13, 2022
1 parent 4f1c343 commit b2478c2
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 241 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif

LD_FLAGS = -X github.com/tendermint/tendermint/version.TMVersion=$(VERSION)
BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
HTTPS_GIT := https://github.com/tendermint/tendermint.git
HTTPS_GIT := https://github.com/celestiaorg/celestia-core.git
BUILD_IMAGE := ghcr.io/tendermint/docker-build-proto
BASE_BRANCH := v0.35.x-celestia
DOCKER_PROTO := docker run -v $(shell pwd):/workspace --workdir /workspace $(BUILD_IMAGE)
Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (app *PersistentKVStoreApplication) PrepareProposal(

func (app *PersistentKVStoreApplication) ProcessProposal(
req types.RequestProcessProposal) types.ResponseProcessProposal {
for _, tx := range req.Txs {
for _, tx := range req.BlockData.Txs {
if len(tx) == 0 {
return types.ResponseProcessProposal{Result: types.ResponseProcessProposal_REJECT}
}
Expand Down
439 changes: 222 additions & 217 deletions abci/types/types.pb.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions internal/mempool/v0/clist_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ func (mem *CListMempool) Update(
// see if the transaction is a child transaction of a some parent
// transaction that exists in the mempool
} else if originalHash, _, isMalleated := types.UnwrapMalleatedTx(tx); isMalleated {
var origianlKey [sha256.Size]byte
copy(origianlKey[:], originalHash)
err := mem.RemoveTxByKey(origianlKey)
var originalKey [sha256.Size]byte
copy(originalKey[:], originalHash)
err := mem.RemoveTxByKey(originalKey)
if err != nil {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions internal/mempool/v1/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1
import (
"bytes"
"context"
"crypto/sha256"
"errors"
"fmt"
"reflect"
Expand Down Expand Up @@ -461,6 +462,12 @@ func (txmp *TxMempool) Update(
// remove the committed transaction from the transaction store and indexes
if wtx := txmp.txStore.GetTxByHash(tx.Key()); wtx != nil {
txmp.removeTx(wtx, false)
} else if originalHash, _, isMalleated := types.UnwrapMalleatedTx(tx); isMalleated {
var originalKey [sha256.Size]byte
copy(originalKey[:], originalHash)
if wtx := txmp.txStore.GetTxByHash(originalKey); wtx != nil {
txmp.removeTx(wtx, false)
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions internal/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ func (blockExec *BlockExecutor) ProcessProposal(
block *types.Block,
) (bool, error) {
ctx := context.Background()
data := block.Data.ToProto()
req := abci.RequestProcessProposal{
Txs: block.Data.Txs.ToSliceOfBytes(),
Header: *block.Header.ToProto(),
BlockData: &data,
Header: *block.Header.ToProto(),
}

resp, err := blockExec.proxyApp.ProcessProposalSync(ctx, req)
Expand Down
2 changes: 1 addition & 1 deletion internal/state/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (app *testApp) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQue
}

func (app *testApp) ProcessProposal(req abci.RequestProcessProposal) abci.ResponseProcessProposal {
for _, tx := range req.Txs {
for _, tx := range req.BlockData.Txs {
if len(tx) == 0 {
return abci.ResponseProcessProposal{Result: abci.ResponseProcessProposal_REJECT}
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/prove/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ func Test_genOrigRowShares(t *testing.T) {
Messages: generateRandomlySizedMessages(10, 1500),
}

allShares, _, _ := typicalBlockData.ComputeShares(8)
allShares, _, err := typicalBlockData.ComputeShares(16)
require.NoError(t, err)
rawShares := allShares.RawShares()

genShares := genOrigRowShares(typicalBlockData, 8, 0, 7)
genShares := genOrigRowShares(typicalBlockData, 16, 0, 15)

require.Equal(t, len(allShares), len(genShares))
assert.Equal(t, rawShares, genShares)
require.Equal(t, len(allShares), len(genShares), typicalBlockData)
require.Equal(t, rawShares, genShares)
}

func joinByteSlices(s ...[]byte) string {
Expand Down
16 changes: 8 additions & 8 deletions proto/tendermint/abci/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ message Request {
RequestLoadSnapshotChunk load_snapshot_chunk = 13;
RequestApplySnapshotChunk apply_snapshot_chunk = 14;
RequestPrepareProposal prepare_proposal = 15;
RequestProcessProposal process_proposal = 16;
RequestProcessProposal process_proposal = 16;
}
}

Expand Down Expand Up @@ -129,8 +129,8 @@ message RequestPrepareProposal {
}

message RequestProcessProposal {
tendermint.types.Header header = 1 [(gogoproto.nullable) = false];
repeated bytes txs = 2;
tendermint.types.Header header = 1 [(gogoproto.nullable) = false];
tendermint.types.Data block_data = 2;
}

//----------------------------------------
Expand All @@ -154,7 +154,7 @@ message Response {
ResponseLoadSnapshotChunk load_snapshot_chunk = 14;
ResponseApplySnapshotChunk apply_snapshot_chunk = 15;
ResponsePrepareProposal prepare_proposal = 16;
ResponseProcessProposal process_proposal = 17;
ResponseProcessProposal process_proposal = 17;
}
}

Expand Down Expand Up @@ -285,13 +285,13 @@ message ResponsePrepareProposal {
}

message ResponseProcessProposal {
Result result = 1;
Result result = 1;
repeated bytes evidence = 2;

enum Result {
UNKNOWN = 0; // Unknown result, invalidate
ACCEPT = 1; // proposal verified, vote on the proposal
REJECT = 2; // proposal invalidated
UNKNOWN = 0; // Unknown result, invalidate
ACCEPT = 1; // proposal verified, vote on the proposal
REJECT = 2; // proposal invalidated
}
}

Expand Down
8 changes: 4 additions & 4 deletions proto/tendermint/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ message Data {
repeated bytes txs = 1;

// field number 2 is reserved for intermediate state roots
EvidenceList evidence = 3 [(gogoproto.nullable) = false];
Messages messages = 4 [(gogoproto.nullable) = false];
uint64 original_square_size = 5;
bytes hash = 6;
EvidenceList evidence = 3 [(gogoproto.nullable) = false];
Messages messages = 4 [(gogoproto.nullable) = false];
uint64 original_square_size = 5;
bytes hash = 6;
}

// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes.
Expand Down

0 comments on commit b2478c2

Please sign in to comment.