From b0aa4b0ba8243a4d8b914b8a3c3b4a08eeb879df Mon Sep 17 00:00:00 2001 From: William Banfield Date: Mon, 7 Mar 2022 12:44:03 -0500 Subject: [PATCH] unimplemented method stubs. compiles --- internal/state/execution.go | 44 +++++++++++++++++++++++++------------ internal/state/state.go | 11 ++++++++++ 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/internal/state/execution.go b/internal/state/execution.go index ef242b567..6daea338b 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -113,15 +113,21 @@ func (blockExec *BlockExecutor) CreateProposalBlock( maxDataBytes := types.MaxDataBytes(maxBytes, evSize, state.Validators.Size()) txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas) + block, _, err := state.MakeBlock(height, txs, commit, evidence, proposerAddr) + localLastCommit := buildLastCommitInfo(block, blockExec.store, state.InitialHeight) preparedProposal, err := blockExec.appClient.PrepareProposal( ctx, abci.RequestPrepareProposal{ - BlockData: txs.ToSliceOfBytes(), - BlockDataSize: maxDataBytes, - Votes: types.VotesToProto(votes), + Hash: block.Hash(), + Header: *block.Header.ToProto(), + Txs: block.Txs.ToSliceOfBytes(), + LocalLastCommit: extendedCommitInfo(localLastCommit), + ByzantineValidators: block.Evidence.ToABCI(), + MaxTxBytes: maxBytes, }, ) + if err != nil { // The App MUST ensure that only valid (and hence 'processable') transactions // enter the mempool. Hence, at this point, we can't have any non-processable @@ -133,19 +139,11 @@ func (blockExec *BlockExecutor) CreateProposalBlock( // purpose for now. panic(err) } - newTxs := preparedProposal.GetBlockData() - var txSize int - for _, tx := range newTxs { - txSize += len(tx) - - if maxDataBytes < int64(txSize) { - panic("block data exceeds max amount of allowed bytes") - } + if err := state.ValidateResponsePrepareProposal(preparedProposal); err != nil { + panic(fmt.Sprintf("application returned invalid ResponsePrepareProposal: %s", err)) } - modifiedTxs := types.ToTxs(preparedProposal.GetBlockData()) - - return state.MakeBlock(height, modifiedTxs, commit, evidence, proposerAddr) + return state.BlockFromResponsePrepareProposal(height, preparedProposal) } func (blockExec *BlockExecutor) ProcessProposal( @@ -410,6 +408,24 @@ func buildLastCommitInfo(block *types.Block, store Store, initialHeight int64) a } } +func extendedCommitInfo(c abci.CommitInfo) abci.ExtendedCommitInfo { + vs := make([]abci.ExtendedVoteInfo, len(c.Votes)) + for i := range vs { + vs[i] = abci.ExtendedVoteInfo{ + Validator: c.Votes[i].Validator, + SignedLastBlock: c.Votes[i].SignedLastBlock, + /* + TODO: Include extended vote information once vote extension vote is complete. + VoteExtension: []byte{}, + */ + } + } + return abci.ExtendedCommitInfo{ + Round: c.Round, + Votes: vs, + } +} + func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, params types.ValidatorParams) error { for _, valUpdate := range abciUpdates { diff --git a/internal/state/state.go b/internal/state/state.go index 6a39e2c08..b1ca3009a 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -8,6 +8,7 @@ import ( "time" "github.com/gogo/protobuf/proto" + abci "github.com/tendermint/tendermint/abci/types" tmtime "github.com/tendermint/tendermint/libs/time" @@ -282,6 +283,16 @@ func (state State) MakeBlock( return block, bps, nil } +func (state State) BlockFromResponsePrepareProposal(height int64, rpp *abci.ResponsePrepareProposal) (*types.Block, *types.PartSet, error) { + // TODO: Implement logic create new block. + return &types.Block{}, &types.PartSet{}, nil +} + +func (state State) ValidateResponsePrepareProposal(rpp *abci.ResponsePrepareProposal) error { + // TODO: Implement logic to validate block. + return nil +} + //------------------------------------------------------------------------ // Genesis