Skip to content

Commit

Permalink
Revert writing to IPLD during defaultDecideProposal (#493)
Browse files Browse the repository at this point in the history
* Revert writing to IPLD during defaultDecideProposal

* remove the obsolete context objects from State struct
  • Loading branch information
liamsi authored Aug 17, 2021
1 parent 9dd09e0 commit d8f9402
Showing 1 changed file with 1 addition and 41 deletions.
42 changes: 1 addition & 41 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/celestiaorg/celestia-core/libs/service"
tmsync "github.com/celestiaorg/celestia-core/libs/sync"
"github.com/celestiaorg/celestia-core/p2p"
"github.com/celestiaorg/celestia-core/p2p/ipld"
tmproto "github.com/celestiaorg/celestia-core/proto/tendermint/types"
sm "github.com/celestiaorg/celestia-core/state"
"github.com/celestiaorg/celestia-core/types"
Expand Down Expand Up @@ -154,10 +153,6 @@ type State struct {

// for reporting metrics
metrics *Metrics

// context of the recent proposed block
proposalCtx context.Context
proposalCancel context.CancelFunc
}

// StateOption sets an optional parameter on the State.
Expand Down Expand Up @@ -1127,41 +1122,6 @@ func (cs *State) defaultDecideProposal(height int64, round int32) {
} else if !cs.replayMode {
cs.Logger.Error("enterPropose: Error signing proposal", "height", height, "round", round, "err", err)
}

// cancel ctx for previous proposal block to ensure block putting/providing does not queues up
if cs.proposalCancel != nil {
// FIXME(ismail): below commented out cancel tries to prevent block putting
// and providing no to queue up endlessly.
// But in a real network proposers should have enough time in between.
// And even if not, queuing up to a problematic extent will take a lot of time:
// Even on the Cosmos Hub the largest validator only proposes every 15 blocks.
// With an average block time of roughly 7.5 seconds this means almost
// two minutes between two different proposals by the same validator.
// For other validators much more time passes in between.
// In our case block interval times will likely be larger.
// And independent of this DHT providing will be made faster:
// - https://github.com/celestiaorg/celestia-core/issues/395
//
// Furthermore, and independent of all of the above,
// the provide timeout could still be larger than just the time between
// two consecutive proposals.
//
cs.proposalCancel()
}
cs.proposalCtx, cs.proposalCancel = context.WithCancel(context.TODO())
go func(ctx context.Context) {
cs.Logger.Info("Putting Block to IPFS", "height", block.Height)
err = ipld.PutBlock(ctx, cs.dag, block, cs.croute, cs.Logger)
if err != nil {
if errors.Is(err, context.Canceled) {
cs.Logger.Error("Putting Block didn't finish in time and was terminated", "height", block.Height)
return
}
cs.Logger.Error("Failed to put Block to IPFS", "err", err, "height", block.Height)
return
}
cs.Logger.Info("Finished putting block to IPFS", "height", block.Height)
}(cs.proposalCtx)
}

// Returns true if the proposal block is complete &&
Expand Down Expand Up @@ -1958,7 +1918,7 @@ func (cs *State) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, error) {
// 1) bad peer OR
// 2) not a bad peer? this can also err sometimes with "Unexpected step" OR
// 3) tmkms use with multiple validators connecting to a single tmkms instance
// (https://github.com/celestiaorg/celestia-core/issues/3839).
// (https://github.com/tendermint/tendermint/issues/3839).
cs.Logger.Info("Error attempting to add vote", "err", err)
return added, ErrAddingVote
}
Expand Down

0 comments on commit d8f9402

Please sign in to comment.