add tx conversions to get consensus tests to pass

This commit is contained in:
William Banfield
2022-03-07 18:50:33 -05:00
parent 7f617af927
commit 778e2e8908
3 changed files with 23 additions and 1 deletions
+12
View File
@@ -202,3 +202,15 @@ func mustResultsToByteSlices(r []*ExecTxResult) [][]byte {
}
return s
}
// IncludedTxs returns all of the TxRecords that are marked for inclusion in the
// proposed block.
func (rpp *ResponsePrepareProposal) IncludedTxs() []*TxRecord {
trs := []*TxRecord{}
for _, tr := range rpp.TxRecords {
if tr.Action == TxRecord_ADDED || tr.Action == TxRecord_UNMODIFIED {
trs = append(trs, tr)
}
}
return trs
}
+1 -1
View File
@@ -144,7 +144,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
panic(fmt.Sprintf("application returned invalid ResponsePrepareProposal: %s", err))
}
return state.BlockFromResponsePrepareProposal(height, preparedProposal)
return state.MakeBlock(height, types.TxRecordsToTxs(preparedProposal.IncludedTxs()), commit, evidence, proposerAddr)
}
func (blockExec *BlockExecutor) ProcessProposal(
+10
View File
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/crypto/tmhash"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
@@ -102,6 +103,15 @@ func ToTxs(txs [][]byte) Txs {
return txBzs
}
// TxRecordsToTxs coverts from the abci Tx type to the a Txs type.
func TxRecordsToTxs(trs []*abci.TxRecord) Txs {
txs := make([]Tx, len(trs))
for i, tr := range trs {
txs[i] = Tx(tr.Tx)
}
return txs
}
// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
type TxProof struct {
RootHash tmbytes.HexBytes `json:"root_hash"`