Browse Source

Fixing handling of contexts in the ABCI++ rebased branch (#7768)

* Fixing context

* Removed logger change

* Fixing UTs

* Bump
pull/7780/head
Sergio Mena 3 years ago
committed by GitHub
parent
commit
854fd07461
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 21 deletions
  1. +1
    -1
      internal/consensus/byzantine_test.go
  2. +1
    -1
      internal/consensus/common_test.go
  3. +1
    -1
      internal/consensus/pbts_test.go
  4. +4
    -4
      internal/consensus/replay_test.go
  5. +5
    -5
      internal/consensus/state.go
  6. +4
    -4
      internal/consensus/state_test.go
  7. +4
    -5
      internal/state/execution.go
  8. +3
    -0
      node/node_test.go

+ 1
- 1
internal/consensus/byzantine_test.go View File

@ -205,7 +205,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
proposerAddr := lazyNodeState.privValidatorPubKey.Address()
block, blockParts, err := lazyNodeState.blockExec.CreateProposalBlock(
lazyNodeState.Height, lazyNodeState.state, commit, proposerAddr,
ctx, lazyNodeState.Height, lazyNodeState.state, commit, proposerAddr,
)
require.NoError(t, err)


+ 1
- 1
internal/consensus/common_test.go View File

@ -240,7 +240,7 @@ func decideProposal(
t.Helper()
cs1.mtx.Lock()
block, blockParts, err := cs1.createProposalBlock()
block, blockParts, err := cs1.createProposalBlock(ctx)
require.NoError(t, err)
validRound := cs1.ValidRound
chainID := cs1.state.ChainID


+ 1
- 1
internal/consensus/pbts_test.go View File

@ -203,7 +203,7 @@ func (p *pbtsTestHarness) nextHeight(ctx context.Context, t *testing.T, proposer
ensureNewRound(t, p.roundCh, p.currentHeight, p.currentRound)
b, _, err := p.observedState.createProposalBlock()
b, _, err := p.observedState.createProposalBlock(ctx)
require.NoError(t, err)
b.Height = p.currentHeight
b.Header.Height = p.currentHeight


+ 4
- 4
internal/consensus/replay_test.go View File

@ -383,7 +383,7 @@ func setupSimulator(ctx context.Context, t *testing.T) *simulatorTestSuite {
newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower)
err = assertMempool(t, css[0].txNotifier).CheckTx(ctx, newValidatorTx1, nil, mempool.TxInfo{})
assert.NoError(t, err)
propBlock, _, err := css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
propBlock, _, err := css[0].createProposalBlock(ctx) // changeProposer(t, cs1, vs2)
require.NoError(t, err)
propBlockParts, err := propBlock.MakePartSet(partSize)
require.NoError(t, err)
@ -417,7 +417,7 @@ func setupSimulator(ctx context.Context, t *testing.T) *simulatorTestSuite {
updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25)
err = assertMempool(t, css[0].txNotifier).CheckTx(ctx, updateValidatorTx1, nil, mempool.TxInfo{})
assert.NoError(t, err)
propBlock, _, err = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
propBlock, _, err = css[0].createProposalBlock(ctx) // changeProposer(t, cs1, vs2)
require.NoError(t, err)
propBlockParts, err = propBlock.MakePartSet(partSize)
require.NoError(t, err)
@ -458,7 +458,7 @@ func setupSimulator(ctx context.Context, t *testing.T) *simulatorTestSuite {
newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower)
err = assertMempool(t, css[0].txNotifier).CheckTx(ctx, newValidatorTx3, nil, mempool.TxInfo{})
assert.NoError(t, err)
propBlock, _, err = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
propBlock, _, err = css[0].createProposalBlock(ctx) // changeProposer(t, cs1, vs2)
require.NoError(t, err)
propBlockParts, err = propBlock.MakePartSet(partSize)
require.NoError(t, err)
@ -546,7 +546,7 @@ func setupSimulator(ctx context.Context, t *testing.T) *simulatorTestSuite {
removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0)
err = assertMempool(t, css[0].txNotifier).CheckTx(ctx, removeValidatorTx3, nil, mempool.TxInfo{})
assert.NoError(t, err)
propBlock, _, err = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
propBlock, _, err = css[0].createProposalBlock(ctx) // changeProposer(t, cs1, vs2)
require.NoError(t, err)
propBlockParts, err = propBlock.MakePartSet(partSize)
require.NoError(t, err)


+ 5
- 5
internal/consensus/state.go View File

@ -1268,7 +1268,7 @@ func (cs *State) defaultDecideProposal(ctx context.Context, height int64, round
} else {
// Create a new proposal block from state/txs from the mempool.
var err error
block, blockParts, err = cs.createProposalBlock()
block, blockParts, err = cs.createProposalBlock(ctx)
if block == nil || err != nil {
return
}
@ -1328,7 +1328,7 @@ func (cs *State) isProposalComplete() bool {
//
// NOTE: keep it side-effect free for clarity.
// CONTRACT: cs.privValidator is not nil.
func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.PartSet, err error) {
func (cs *State) createProposalBlock(ctx context.Context) (block *types.Block, blockParts *types.PartSet, err error) {
if cs.privValidator == nil {
return nil, nil, errors.New("entered createProposalBlock with privValidator being nil")
}
@ -1358,7 +1358,7 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa
proposerAddr := cs.privValidatorPubKey.Address()
return cs.blockExec.CreateProposalBlock(cs.Height, cs.state, commit, proposerAddr)
return cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, commit, proposerAddr)
}
// Enter: `timeoutPropose` after entering Propose.
@ -2235,7 +2235,7 @@ func (cs *State) addVote(
// Verify VoteExtension if precommit
if vote.Type == tmproto.PrecommitType {
if err = cs.blockExec.VerifyVoteExtension(vote); err != nil {
if err = cs.blockExec.VerifyVoteExtension(ctx, vote); err != nil {
return false, err
}
}
@ -2385,7 +2385,7 @@ func (cs *State) signVote(
case tmproto.PrecommitType:
timeout = cs.config.TimeoutPrecommit
// if the signedMessage type is for a precommit, add VoteExtension
ext, err := cs.blockExec.ExtendVote(vote)
ext, err := cs.blockExec.ExtendVote(ctx, vote)
if err != nil {
return nil, err
}


+ 4
- 4
internal/consensus/state_test.go View File

@ -221,7 +221,7 @@ func TestStateBadProposal(t *testing.T) {
proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
propBlock, _, err := cs1.createProposalBlock() // changeProposer(t, cs1, vs2)
propBlock, _, err := cs1.createProposalBlock(ctx) // changeProposer(t, cs1, vs2)
require.NoError(t, err)
// make the second validator the proposer by incrementing round
@ -284,7 +284,7 @@ func TestStateOversizedBlock(t *testing.T) {
timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
propBlock, _, err := cs1.createProposalBlock()
propBlock, _, err := cs1.createProposalBlock(ctx)
require.NoError(t, err)
propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)}
propBlock.Header.DataHash = propBlock.Data.Hash()
@ -2535,7 +2535,7 @@ func TestStateTimestamp_ProposalNotMatch(t *testing.T) {
addr := pv1.Address()
voteCh := subscribeToVoter(ctx, t, cs1, addr)
propBlock, _, err := cs1.createProposalBlock()
propBlock, _, err := cs1.createProposalBlock(ctx)
require.NoError(t, err)
round++
incrementRound(vss[1:]...)
@ -2584,7 +2584,7 @@ func TestStateTimestamp_ProposalMatch(t *testing.T) {
addr := pv1.Address()
voteCh := subscribeToVoter(ctx, t, cs1, addr)
propBlock, _, err := cs1.createProposalBlock()
propBlock, _, err := cs1.createProposalBlock(ctx)
require.NoError(t, err)
round++
incrementRound(vss[1:]...)


+ 4
- 5
internal/state/execution.go View File

@ -102,6 +102,7 @@ func (blockExec *BlockExecutor) SetEventBus(eventBus types.BlockEventPublisher)
//
// Contract: application will not return more bytes than are sent over the wire.
func (blockExec *BlockExecutor) CreateProposalBlock(
ctx context.Context,
height int64,
state State, commit *types.Commit,
proposerAddr []byte,
@ -118,7 +119,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas)
preparedProposal, err := blockExec.proxyApp.PrepareProposal(
context.Background(),
ctx,
abci.RequestPrepareProposal{BlockData: txs.ToSliceOfBytes(), BlockDataSize: maxDataBytes},
)
if err != nil {
@ -260,8 +261,7 @@ func (blockExec *BlockExecutor) ApplyBlock(
return state, nil
}
func (blockExec *BlockExecutor) ExtendVote(vote *types.Vote) (types.VoteExtension, error) {
ctx := context.Background()
func (blockExec *BlockExecutor) ExtendVote(ctx context.Context, vote *types.Vote) (types.VoteExtension, error) {
req := abci.RequestExtendVote{
Vote: vote.ToProto(),
}
@ -274,8 +274,7 @@ func (blockExec *BlockExecutor) ExtendVote(vote *types.Vote) (types.VoteExtensio
return types.VoteExtensionFromProto(resp.VoteExtension), nil
}
func (blockExec *BlockExecutor) VerifyVoteExtension(vote *types.Vote) error {
ctx := context.Background()
func (blockExec *BlockExecutor) VerifyVoteExtension(ctx context.Context, vote *types.Vote) error {
req := abci.RequestVerifyVoteExtension{
Vote: vote.ToProto(),
}


+ 3
- 0
node/node_test.go View File

@ -336,6 +336,7 @@ func TestCreateProposalBlock(t *testing.T) {
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
block, _, err := blockExec.CreateProposalBlock(
ctx,
height,
state, commit,
proposerAddr,
@ -410,6 +411,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) {
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
block, _, err := blockExec.CreateProposalBlock(
ctx,
height,
state, commit,
proposerAddr,
@ -520,6 +522,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
}
block, partSet, err := blockExec.CreateProposalBlock(
ctx,
math.MaxInt64,
state, commit,
proposerAddr,


Loading…
Cancel
Save