Skip to content

Commit b2478c2

Browse files
evan-forbesliamsi
andauthored
Patch missing functionality needed for app in tendermint v0.35 (#747)
* 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 <Ismail.Khoffi@gmail.com> * spel Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * fix old spelling error * use correct repo when comparing proto files Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com>
1 parent 4f1c343 commit b2478c2

File tree

10 files changed

+255
-241
lines changed

10 files changed

+255
-241
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ endif
1515

1616
LD_FLAGS = -X github.com/tendermint/tendermint/version.TMVersion=$(VERSION)
1717
BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
18-
HTTPS_GIT := https://github.com/tendermint/tendermint.git
18+
HTTPS_GIT := https://github.com/celestiaorg/celestia-core.git
1919
BUILD_IMAGE := ghcr.io/tendermint/docker-build-proto
2020
BASE_BRANCH := v0.35.x-celestia
2121
DOCKER_PROTO := docker run -v $(shell pwd):/workspace --workdir /workspace $(BUILD_IMAGE)

abci/example/kvstore/persistent_kvstore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (app *PersistentKVStoreApplication) PrepareProposal(
177177

178178
func (app *PersistentKVStoreApplication) ProcessProposal(
179179
req types.RequestProcessProposal) types.ResponseProcessProposal {
180-
for _, tx := range req.Txs {
180+
for _, tx := range req.BlockData.Txs {
181181
if len(tx) == 0 {
182182
return types.ResponseProcessProposal{Result: types.ResponseProcessProposal_REJECT}
183183
}

abci/types/types.pb.go

Lines changed: 222 additions & 217 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/mempool/v0/clist_mempool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@ func (mem *CListMempool) Update(
631631
// see if the transaction is a child transaction of a some parent
632632
// transaction that exists in the mempool
633633
} else if originalHash, _, isMalleated := types.UnwrapMalleatedTx(tx); isMalleated {
634-
var origianlKey [sha256.Size]byte
635-
copy(origianlKey[:], originalHash)
636-
err := mem.RemoveTxByKey(origianlKey)
634+
var originalKey [sha256.Size]byte
635+
copy(originalKey[:], originalHash)
636+
err := mem.RemoveTxByKey(originalKey)
637637
if err != nil {
638638
return err
639639
}

internal/mempool/v1/mempool.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v1
33
import (
44
"bytes"
55
"context"
6+
"crypto/sha256"
67
"errors"
78
"fmt"
89
"reflect"
@@ -461,6 +462,12 @@ func (txmp *TxMempool) Update(
461462
// remove the committed transaction from the transaction store and indexes
462463
if wtx := txmp.txStore.GetTxByHash(tx.Key()); wtx != nil {
463464
txmp.removeTx(wtx, false)
465+
} else if originalHash, _, isMalleated := types.UnwrapMalleatedTx(tx); isMalleated {
466+
var originalKey [sha256.Size]byte
467+
copy(originalKey[:], originalHash)
468+
if wtx := txmp.txStore.GetTxByHash(originalKey); wtx != nil {
469+
txmp.removeTx(wtx, false)
470+
}
464471
}
465472
}
466473

internal/state/execution.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ func (blockExec *BlockExecutor) ProcessProposal(
183183
block *types.Block,
184184
) (bool, error) {
185185
ctx := context.Background()
186+
data := block.Data.ToProto()
186187
req := abci.RequestProcessProposal{
187-
Txs: block.Data.Txs.ToSliceOfBytes(),
188-
Header: *block.Header.ToProto(),
188+
BlockData: &data,
189+
Header: *block.Header.ToProto(),
189190
}
190191

191192
resp, err := blockExec.proxyApp.ProcessProposalSync(ctx, req)

internal/state/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (app *testApp) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQue
306306
}
307307

308308
func (app *testApp) ProcessProposal(req abci.RequestProcessProposal) abci.ResponseProcessProposal {
309-
for _, tx := range req.Txs {
309+
for _, tx := range req.BlockData.Txs {
310310
if len(tx) == 0 {
311311
return abci.ResponseProcessProposal{Result: abci.ResponseProcessProposal_REJECT}
312312
}

pkg/prove/proof_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,14 @@ func Test_genOrigRowShares(t *testing.T) {
137137
Messages: generateRandomlySizedMessages(10, 1500),
138138
}
139139

140-
allShares, _, _ := typicalBlockData.ComputeShares(8)
140+
allShares, _, err := typicalBlockData.ComputeShares(16)
141+
require.NoError(t, err)
141142
rawShares := allShares.RawShares()
142143

143-
genShares := genOrigRowShares(typicalBlockData, 8, 0, 7)
144+
genShares := genOrigRowShares(typicalBlockData, 16, 0, 15)
144145

145-
require.Equal(t, len(allShares), len(genShares))
146-
assert.Equal(t, rawShares, genShares)
146+
require.Equal(t, len(allShares), len(genShares), typicalBlockData)
147+
require.Equal(t, rawShares, genShares)
147148
}
148149

149150
func joinByteSlices(s ...[]byte) string {

proto/tendermint/abci/types.proto

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ message Request {
3636
RequestLoadSnapshotChunk load_snapshot_chunk = 13;
3737
RequestApplySnapshotChunk apply_snapshot_chunk = 14;
3838
RequestPrepareProposal prepare_proposal = 15;
39-
RequestProcessProposal process_proposal = 16;
39+
RequestProcessProposal process_proposal = 16;
4040
}
4141
}
4242

@@ -129,8 +129,8 @@ message RequestPrepareProposal {
129129
}
130130

131131
message RequestProcessProposal {
132-
tendermint.types.Header header = 1 [(gogoproto.nullable) = false];
133-
repeated bytes txs = 2;
132+
tendermint.types.Header header = 1 [(gogoproto.nullable) = false];
133+
tendermint.types.Data block_data = 2;
134134
}
135135

136136
//----------------------------------------
@@ -154,7 +154,7 @@ message Response {
154154
ResponseLoadSnapshotChunk load_snapshot_chunk = 14;
155155
ResponseApplySnapshotChunk apply_snapshot_chunk = 15;
156156
ResponsePrepareProposal prepare_proposal = 16;
157-
ResponseProcessProposal process_proposal = 17;
157+
ResponseProcessProposal process_proposal = 17;
158158
}
159159
}
160160

@@ -285,13 +285,13 @@ message ResponsePrepareProposal {
285285
}
286286

287287
message ResponseProcessProposal {
288-
Result result = 1;
288+
Result result = 1;
289289
repeated bytes evidence = 2;
290290

291291
enum Result {
292-
UNKNOWN = 0; // Unknown result, invalidate
293-
ACCEPT = 1; // proposal verified, vote on the proposal
294-
REJECT = 2; // proposal invalidated
292+
UNKNOWN = 0; // Unknown result, invalidate
293+
ACCEPT = 1; // proposal verified, vote on the proposal
294+
REJECT = 2; // proposal invalidated
295295
}
296296
}
297297

proto/tendermint/types/types.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ message Data {
8989
repeated bytes txs = 1;
9090

9191
// field number 2 is reserved for intermediate state roots
92-
EvidenceList evidence = 3 [(gogoproto.nullable) = false];
93-
Messages messages = 4 [(gogoproto.nullable) = false];
94-
uint64 original_square_size = 5;
95-
bytes hash = 6;
92+
EvidenceList evidence = 3 [(gogoproto.nullable) = false];
93+
Messages messages = 4 [(gogoproto.nullable) = false];
94+
uint64 original_square_size = 5;
95+
bytes hash = 6;
9696
}
9797

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

0 commit comments

Comments
 (0)