Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prepare and Process Proposal ABCI++ methods #631

Merged
merged 19 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// to be driven by a blockchain-based replication engine via the ABCI.
// All methods take a RequestXxx argument and return a ResponseXxx argument,
// except CheckTx/DeliverTx, which take `tx []byte`, and `Commit`, which takes nothing.
// nolint:lll // ignore for interface
// ignore for interface
type Application interface {
// Info/Query Connection
Info(RequestInfo) ResponseInfo // Return application info
Expand Down
6 changes: 4 additions & 2 deletions consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St

// Create a new proposal block from state/txs from the mempool.
block1, blockParts1 := cs.createProposalBlock()
polRound, propBlockID := cs.TwoThirdPrevoteRound, types.BlockID{Hash: block1.Hash(), PartSetHeader: blockParts1.Header()}
polRound := cs.TwoThirdPrevoteRound
propBlockID := types.BlockID{Hash: block1.Hash(), PartSetHeader: blockParts1.Header()}
proposal1 := types.NewProposal(height, round, polRound, propBlockID)
p1 := proposal1.ToProto()
if err := cs.privValidator.SignProposal(cs.state.ChainID, p1); err != nil {
Expand All @@ -455,7 +456,8 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St

// Create a new proposal block from state/txs from the mempool.
block2, blockParts2 := cs.createProposalBlock()
polRound, propBlockID = cs.TwoThirdPrevoteRound, types.BlockID{Hash: block2.Hash(), PartSetHeader: blockParts2.Header()}
polRound = cs.TwoThirdPrevoteRound
propBlockID = types.BlockID{Hash: block2.Hash(), PartSetHeader: blockParts2.Header()}
proposal2 := types.NewProposal(height, round, polRound, propBlockID)
p2 := proposal2.ToProto()
if err := cs.privValidator.SignProposal(cs.state.ChainID, p2); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion consensus/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,5 @@ func (app *CounterApplication) Commit() abci.ResponseCommit {

func (app *CounterApplication) PrepareProposal(
req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
return abci.ResponsePrepareProposal{BlockData: req.BlockData} //nolint:gosimple
return abci.ResponsePrepareProposal{BlockData: req.BlockData}
}
8 changes: 7 additions & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,13 @@ func (cs *State) addVote(vote *types.Vote, peerID p2p.ID) (added bool, err error
// NOTE: our proposal block may be nil or not what received a polka..
if len(blockID.Hash) != 0 && (cs.TwoThirdPrevoteRound < vote.Round) && (vote.Round == cs.Round) {
if cs.ProposalBlock.HashesTo(blockID.Hash) {
cs.Logger.Debug("updating valid block because of POL", "valid_round", cs.TwoThirdPrevoteRound, "pol_round", vote.Round)
cs.Logger.Debug(
"updating valid block because of POL",
"valid_round",
cs.TwoThirdPrevoteRound,
"pol_round",
vote.Round,
)
cs.TwoThirdPrevoteRound = vote.Round
cs.TwoThirdPrevoteBlock = cs.ProposalBlock
cs.TwoThirdPrevoteBlockParts = cs.ProposalBlockParts
Expand Down
4 changes: 3 additions & 1 deletion state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
}

preparedProposal, err := blockExec.proxyApp.PrepareProposalSync(
abci.RequestPrepareProposal{BlockData: &tmproto.Data{Txs: txs.ToSliceOfBytes(), Evidence: *pevdData}, BlockDataSize: maxDataBytes},
abci.RequestPrepareProposal{
BlockData: &tmproto.Data{Txs: txs.ToSliceOfBytes(), Evidence: *pevdData},
BlockDataSize: maxDataBytes},
)
if err != nil {
// The App MUST ensure that only valid (and hence 'processable') transactions
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (app *Application) ApplySnapshotChunk(req abci.RequestApplySnapshotChunk) a

func (app *Application) PrepareProposal(
req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
return abci.ResponsePrepareProposal{BlockData: req.BlockData} //nolint:gosimple
return abci.ResponsePrepareProposal{BlockData: req.BlockData}
}

// validatorUpdates generates a validator set update.
Expand Down