Skip to content

Commit

Permalink
chore: cherry pick tx status
Browse files Browse the repository at this point in the history
  • Loading branch information
ninabarbakadze committed Jun 28, 2024
1 parent a5a2a3a commit 1d2e339
Show file tree
Hide file tree
Showing 18 changed files with 639 additions and 146 deletions.
2 changes: 1 addition & 1 deletion consensus/replay_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusCo
}

mempool, evpool := emptyMempool{}, sm.EmptyEvidencePool{}
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool)
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool, sm.WithBlockStore(blockStore))

consensusState := NewState(csConfig, state.Copy(), blockExec,
blockStore, mempool, evpool)
Expand Down
17 changes: 12 additions & 5 deletions consensus/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestMain(m *testing.M) {
// the `Handshake Tests` are for failures in applying the block.
// With the help of the WAL, we can recover from it all!

//------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
// WAL Tests

// TODO: It would be better to verify explicitly which states we can recover from without the wal
Expand Down Expand Up @@ -320,7 +320,7 @@ var (
sim testSim
)

//---------------------------------------
// ---------------------------------------
// Test handshake/replay

// 0 - all synced up
Expand Down Expand Up @@ -1041,7 +1041,7 @@ func (app *badApp) Commit() abci.ResponseCommit {
panic("either allHashesAreWrong or onlyLastHashIsWrong must be set")
}

//--------------------------
// --------------------------
// utils for making blocks

func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) {
Expand Down Expand Up @@ -1187,8 +1187,9 @@ func stateAndStore(
return stateDB, state, store
}

//----------------------------------
// ----------------------------------
// mock block store
var _ sm.BlockStore = &mockBlockStore{}

type mockBlockStore struct {
config *cfg.Config
Expand Down Expand Up @@ -1222,6 +1223,10 @@ func (bs *mockBlockStore) LoadBlockMeta(height int64) *types.BlockMeta {
func (bs *mockBlockStore) LoadBlockPart(height int64, index int) *types.Part { return nil }
func (bs *mockBlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) {
}
func (bs *mockBlockStore) SaveTxInfo(block *types.Block, txResponseCode []uint32) error {
return nil
}
func (bs *mockBlockStore) LoadTxInfo(hash []byte) *cmtstore.TxInfo { return &cmtstore.TxInfo{} }

func (bs *mockBlockStore) LoadBlockCommit(height int64) *types.Commit {
return bs.commits[height-1]
Expand All @@ -1242,7 +1247,9 @@ func (bs *mockBlockStore) PruneBlocks(height int64) (uint64, error) {
return pruned, nil
}

//---------------------------------------
func (bs *mockBlockStore) DeleteLatestBlock() error { return nil }

// ---------------------------------------
// Test handshake/init chain

func TestHandshakeUpdatesValidators(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion consensus/wal_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) {
})
mempool := emptyMempool{}
evpool := sm.EmptyEvidencePool{}
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool)
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool, sm.WithBlockStore(blockStore))
consensusState := NewState(config.Consensus, state.Copy(), blockExec, blockStore, mempool, evpool)
consensusState.SetLogger(logger)
consensusState.SetEventBus(eventBus)
Expand Down
7 changes: 0 additions & 7 deletions mempool/cat/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,6 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
memR.Switch.StopPeerForError(e.Src, err)
return
}
schema.WriteMempoolPeerState(
memR.traceClient,
string(e.Src.ID()),
schema.WantTx,
txKey[:],
schema.Download,
)
tx, has := memR.mempool.GetTxByKey(txKey)
if has && !memR.opts.ListenOnly {
peerID := memR.ids.GetIDForPeer(e.Src.ID())
Expand Down
1 change: 1 addition & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ func NewNode(config *cfg.Config,
mempool,
evidencePool,
sm.BlockExecutorWithMetrics(smMetrics),
sm.WithBlockStore(blockStore),
)

// Make BlockchainReactor. Don't start fast sync if we're doing a state sync first.
Expand Down
241 changes: 235 additions & 6 deletions proto/tendermint/store/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions proto/tendermint/store/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ message BlockStoreState {
int64 base = 1;
int64 height = 2;
}

// TxInfo describes the location of a tx inside a committed block
// as well as the result of executing the transaction.
message TxInfo {
int64 height = 1;
uint32 index = 2;
// The response code of executing the tx. 0 means
// successfully executed, all others are error codes.
uint32 code = 3;
}
Loading

0 comments on commit 1d2e339

Please sign in to comment.