Browse Source

unimplemented method stubs. compiles

wb/txrset
William Banfield 3 years ago
parent
commit
b0aa4b0ba8
No known key found for this signature in database GPG Key ID: EFAD3442BF29E3AC
2 changed files with 41 additions and 14 deletions
  1. +30
    -14
      internal/state/execution.go
  2. +11
    -0
      internal/state/state.go

+ 30
- 14
internal/state/execution.go View File

@ -113,15 +113,21 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
maxDataBytes := types.MaxDataBytes(maxBytes, evSize, state.Validators.Size()) maxDataBytes := types.MaxDataBytes(maxBytes, evSize, state.Validators.Size())
txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas) 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( preparedProposal, err := blockExec.appClient.PrepareProposal(
ctx, ctx,
abci.RequestPrepareProposal{ 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 { if err != nil {
// The App MUST ensure that only valid (and hence 'processable') transactions // 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 // 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. // purpose for now.
panic(err) 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( 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, func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate,
params types.ValidatorParams) error { params types.ValidatorParams) error {
for _, valUpdate := range abciUpdates { for _, valUpdate := range abciUpdates {


+ 11
- 0
internal/state/state.go View File

@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/libs/time" tmtime "github.com/tendermint/tendermint/libs/time"
@ -282,6 +283,16 @@ func (state State) MakeBlock(
return block, bps, nil 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 // Genesis


Loading…
Cancel
Save