mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-23 05:02:50 +00:00
Compare commits
4 Commits
wb/simul-q
...
tmp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
750f709b42 | ||
|
|
c9b775d2f0 | ||
|
|
a3889ee2cb | ||
|
|
87f4beb374 |
@@ -52,7 +52,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
|
|||||||
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
|
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
|
||||||
defer os.RemoveAll(thisConfig.RootDir)
|
defer os.RemoveAll(thisConfig.RootDir)
|
||||||
|
|
||||||
ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
ensureDir(t, path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
||||||
app := appFunc()
|
app := appFunc()
|
||||||
vals := types.TM2PB.ValidatorUpdates(state.Validators)
|
vals := types.TM2PB.ValidatorUpdates(state.Validators)
|
||||||
app.InitChain(abci.RequestInitChain{Validators: vals})
|
app.InitChain(abci.RequestInitChain{Validators: vals})
|
||||||
|
|||||||
@@ -69,9 +69,10 @@ func configSetup(t *testing.T) *cfg.Config {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureDir(dir string, mode os.FileMode) {
|
func ensureDir(t *testing.T, dir string, mode os.FileMode) {
|
||||||
|
t.Helper()
|
||||||
if err := tmos.EnsureDir(dir, mode); err != nil {
|
if err := tmos.EnsureDir(dir, mode); err != nil {
|
||||||
panic(err)
|
t.Fatalf("error opening directory: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,18 +222,20 @@ func startTestRound(cs *State, height int64, round int32) {
|
|||||||
|
|
||||||
// Create proposal block from cs1 but sign it with vs.
|
// Create proposal block from cs1 but sign it with vs.
|
||||||
func decideProposal(
|
func decideProposal(
|
||||||
|
t *testing.T,
|
||||||
cs1 *State,
|
cs1 *State,
|
||||||
vs *validatorStub,
|
vs *validatorStub,
|
||||||
height int64,
|
height int64,
|
||||||
round int32,
|
round int32,
|
||||||
) (proposal *types.Proposal, block *types.Block) {
|
) (proposal *types.Proposal, block *types.Block) {
|
||||||
|
t.Helper()
|
||||||
cs1.mtx.Lock()
|
cs1.mtx.Lock()
|
||||||
block, blockParts := cs1.createProposalBlock()
|
block, blockParts := cs1.createProposalBlock()
|
||||||
validRound := cs1.ValidRound
|
validRound := cs1.ValidRound
|
||||||
chainID := cs1.state.ChainID
|
chainID := cs1.state.ChainID
|
||||||
cs1.mtx.Unlock()
|
cs1.mtx.Unlock()
|
||||||
if block == nil {
|
if block == nil {
|
||||||
panic("Failed to createProposalBlock. Did you forget to add commit for previous block?")
|
t.Fatal("Failed to createProposalBlock. Did you forget to add commit for previous block?")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make proposal
|
// Make proposal
|
||||||
@@ -240,7 +243,7 @@ func decideProposal(
|
|||||||
proposal = types.NewProposal(height, round, polRound, propBlockID)
|
proposal = types.NewProposal(height, round, polRound, propBlockID)
|
||||||
p := proposal.ToProto()
|
p := proposal.ToProto()
|
||||||
if err := vs.SignProposal(context.Background(), chainID, p); err != nil {
|
if err := vs.SignProposal(context.Background(), chainID, p); err != nil {
|
||||||
panic(err)
|
t.Fatalf("error signing proposal: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
proposal.Signature = p.Signature
|
proposal.Signature = p.Signature
|
||||||
@@ -267,36 +270,38 @@ func signAddVotes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func validatePrevote(t *testing.T, cs *State, round int32, privVal *validatorStub, blockHash []byte) {
|
func validatePrevote(t *testing.T, cs *State, round int32, privVal *validatorStub, blockHash []byte) {
|
||||||
|
t.Helper()
|
||||||
prevotes := cs.Votes.Prevotes(round)
|
prevotes := cs.Votes.Prevotes(round)
|
||||||
pubKey, err := privVal.GetPubKey(context.Background())
|
pubKey, err := privVal.GetPubKey(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
address := pubKey.Address()
|
address := pubKey.Address()
|
||||||
var vote *types.Vote
|
var vote *types.Vote
|
||||||
if vote = prevotes.GetByAddress(address); vote == nil {
|
if vote = prevotes.GetByAddress(address); vote == nil {
|
||||||
panic("Failed to find prevote from validator")
|
t.Fatalf("Failed to find prevote from validator")
|
||||||
}
|
}
|
||||||
if blockHash == nil {
|
if blockHash == nil {
|
||||||
if vote.BlockID.Hash != nil {
|
if vote.BlockID.Hash != nil {
|
||||||
panic(fmt.Sprintf("Expected prevote to be for nil, got %X", vote.BlockID.Hash))
|
t.Fatalf("Expected prevote to be for nil, got %X", vote.BlockID.Hash)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if !bytes.Equal(vote.BlockID.Hash, blockHash) {
|
if !bytes.Equal(vote.BlockID.Hash, blockHash) {
|
||||||
panic(fmt.Sprintf("Expected prevote to be for %X, got %X", blockHash, vote.BlockID.Hash))
|
t.Fatalf("Expected prevote to be for %X, got %X", blockHash, vote.BlockID.Hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateLastPrecommit(t *testing.T, cs *State, privVal *validatorStub, blockHash []byte) {
|
func validateLastPrecommit(t *testing.T, cs *State, privVal *validatorStub, blockHash []byte) {
|
||||||
|
t.Helper()
|
||||||
votes := cs.LastCommit
|
votes := cs.LastCommit
|
||||||
pv, err := privVal.GetPubKey(context.Background())
|
pv, err := privVal.GetPubKey(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
address := pv.Address()
|
address := pv.Address()
|
||||||
var vote *types.Vote
|
var vote *types.Vote
|
||||||
if vote = votes.GetByAddress(address); vote == nil {
|
if vote = votes.GetByAddress(address); vote == nil {
|
||||||
panic("Failed to find precommit from validator")
|
t.Fatalf("Failed to find precommit from validator")
|
||||||
}
|
}
|
||||||
if !bytes.Equal(vote.BlockID.Hash, blockHash) {
|
if !bytes.Equal(vote.BlockID.Hash, blockHash) {
|
||||||
panic(fmt.Sprintf("Expected precommit to be for %X, got %X", blockHash, vote.BlockID.Hash))
|
t.Fatalf("Expected precommit to be for %X, got %X", blockHash, vote.BlockID.Hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,41 +314,42 @@ func validatePrecommit(
|
|||||||
votedBlockHash,
|
votedBlockHash,
|
||||||
lockedBlockHash []byte,
|
lockedBlockHash []byte,
|
||||||
) {
|
) {
|
||||||
|
t.Helper()
|
||||||
precommits := cs.Votes.Precommits(thisRound)
|
precommits := cs.Votes.Precommits(thisRound)
|
||||||
pv, err := privVal.GetPubKey(context.Background())
|
pv, err := privVal.GetPubKey(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
address := pv.Address()
|
address := pv.Address()
|
||||||
var vote *types.Vote
|
var vote *types.Vote
|
||||||
if vote = precommits.GetByAddress(address); vote == nil {
|
if vote = precommits.GetByAddress(address); vote == nil {
|
||||||
panic("Failed to find precommit from validator")
|
t.Fatalf("Failed to find precommit from validator")
|
||||||
}
|
}
|
||||||
|
|
||||||
if votedBlockHash == nil {
|
if votedBlockHash == nil {
|
||||||
if vote.BlockID.Hash != nil {
|
if vote.BlockID.Hash != nil {
|
||||||
panic("Expected precommit to be for nil")
|
t.Fatalf("Expected precommit to be for nil")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if !bytes.Equal(vote.BlockID.Hash, votedBlockHash) {
|
if !bytes.Equal(vote.BlockID.Hash, votedBlockHash) {
|
||||||
panic("Expected precommit to be for proposal block")
|
t.Fatalf("Expected precommit to be for proposal block")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if lockedBlockHash == nil {
|
if lockedBlockHash == nil {
|
||||||
if cs.LockedRound != lockRound || cs.LockedBlock != nil {
|
if cs.LockedRound != lockRound || cs.LockedBlock != nil {
|
||||||
panic(fmt.Sprintf(
|
t.Fatalf(
|
||||||
"Expected to be locked on nil at round %d. Got locked at round %d with block %v",
|
"Expected to be locked on nil at round %d. Got locked at round %d with block %v",
|
||||||
lockRound,
|
lockRound,
|
||||||
cs.LockedRound,
|
cs.LockedRound,
|
||||||
cs.LockedBlock))
|
cs.LockedBlock)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if cs.LockedRound != lockRound || !bytes.Equal(cs.LockedBlock.Hash(), lockedBlockHash) {
|
if cs.LockedRound != lockRound || !bytes.Equal(cs.LockedBlock.Hash(), lockedBlockHash) {
|
||||||
panic(fmt.Sprintf(
|
t.Fatalf(
|
||||||
"Expected block to be locked on round %d, got %d. Got locked block %X, expected %X",
|
"Expected block to be locked on round %d, got %d. Got locked block %X, expected %X",
|
||||||
lockRound,
|
lockRound,
|
||||||
cs.LockedRound,
|
cs.LockedRound,
|
||||||
cs.LockedBlock.Hash(),
|
cs.LockedBlock.Hash(),
|
||||||
lockedBlockHash))
|
lockedBlockHash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -357,6 +363,7 @@ func validatePrevoteAndPrecommit(
|
|||||||
votedBlockHash,
|
votedBlockHash,
|
||||||
lockedBlockHash []byte,
|
lockedBlockHash []byte,
|
||||||
) {
|
) {
|
||||||
|
t.Helper()
|
||||||
// verify the prevote
|
// verify the prevote
|
||||||
validatePrevote(t, cs, thisRound, privVal, votedBlockHash)
|
validatePrevote(t, cs, thisRound, privVal, votedBlockHash)
|
||||||
// verify precommit
|
// verify precommit
|
||||||
@@ -444,13 +451,14 @@ func newStateWithConfigAndBlockStore(
|
|||||||
return cs
|
return cs
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadPrivValidator(config *cfg.Config) *privval.FilePV {
|
func loadPrivValidator(t *testing.T, config *cfg.Config) *privval.FilePV {
|
||||||
|
t.Helper()
|
||||||
privValidatorKeyFile := config.PrivValidator.KeyFile()
|
privValidatorKeyFile := config.PrivValidator.KeyFile()
|
||||||
ensureDir(filepath.Dir(privValidatorKeyFile), 0700)
|
ensureDir(t, filepath.Dir(privValidatorKeyFile), 0700)
|
||||||
privValidatorStateFile := config.PrivValidator.StateFile()
|
privValidatorStateFile := config.PrivValidator.StateFile()
|
||||||
privValidator, err := privval.LoadOrGenFilePV(privValidatorKeyFile, privValidatorStateFile)
|
privValidator, err := privval.LoadOrGenFilePV(privValidatorKeyFile, privValidatorStateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
t.Fatalf("error generating validator file: %s", err)
|
||||||
}
|
}
|
||||||
privValidator.Reset()
|
privValidator.Reset()
|
||||||
return privValidator
|
return privValidator
|
||||||
@@ -475,220 +483,238 @@ func randState(config *cfg.Config, nValidators int) (*State, []*validatorStub) {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
|
||||||
func ensureNoNewEvent(ch <-chan tmpubsub.Message, timeout time.Duration,
|
func ensureNoNewEvent(t *testing.T, ch <-chan tmpubsub.Message, timeout time.Duration,
|
||||||
errorMessage string) {
|
errorMessage string) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
break
|
break
|
||||||
case <-ch:
|
case <-ch:
|
||||||
panic(errorMessage)
|
t.Fatalf("unexpected event: %s", errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNoNewEventOnChannel(ch <-chan tmpubsub.Message) {
|
func ensureNoNewEventOnChannel(t *testing.T, ch <-chan tmpubsub.Message) {
|
||||||
|
t.Helper()
|
||||||
ensureNoNewEvent(
|
ensureNoNewEvent(
|
||||||
|
t,
|
||||||
ch,
|
ch,
|
||||||
ensureTimeout,
|
ensureTimeout,
|
||||||
"We should be stuck waiting, not receiving new event on the channel")
|
"We should be stuck waiting, not receiving new event on the channel")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNoNewRoundStep(stepCh <-chan tmpubsub.Message) {
|
func ensureNoNewRoundStep(t *testing.T, stepCh <-chan tmpubsub.Message) {
|
||||||
|
t.Helper()
|
||||||
ensureNoNewEvent(
|
ensureNoNewEvent(
|
||||||
|
t,
|
||||||
stepCh,
|
stepCh,
|
||||||
ensureTimeout,
|
ensureTimeout,
|
||||||
"We should be stuck waiting, not receiving NewRoundStep event")
|
"We should be stuck waiting, not receiving NewRoundStep event")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNoNewUnlock(unlockCh <-chan tmpubsub.Message) {
|
func ensureNoNewTimeout(t *testing.T, stepCh <-chan tmpubsub.Message, timeout int64) {
|
||||||
ensureNoNewEvent(
|
t.Helper()
|
||||||
unlockCh,
|
|
||||||
ensureTimeout,
|
|
||||||
"We should be stuck waiting, not receiving Unlock event")
|
|
||||||
}
|
|
||||||
|
|
||||||
func ensureNoNewTimeout(stepCh <-chan tmpubsub.Message, timeout int64) {
|
|
||||||
timeoutDuration := time.Duration(timeout*10) * time.Nanosecond
|
timeoutDuration := time.Duration(timeout*10) * time.Nanosecond
|
||||||
ensureNoNewEvent(
|
ensureNoNewEvent(
|
||||||
|
t,
|
||||||
stepCh,
|
stepCh,
|
||||||
timeoutDuration,
|
timeoutDuration,
|
||||||
"We should be stuck waiting, not receiving NewTimeout event")
|
"We should be stuck waiting, not receiving NewTimeout event")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewEvent(ch <-chan tmpubsub.Message, height int64, round int32, timeout time.Duration, errorMessage string) {
|
func ensureNewEvent(t *testing.T, ch <-chan tmpubsub.Message, height int64, round int32, timeout time.Duration, errorMessage string) { // nolint: lll
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
panic(errorMessage)
|
t.Fatalf("timed out waiting for new event: %s", errorMessage)
|
||||||
case msg := <-ch:
|
case msg := <-ch:
|
||||||
roundStateEvent, ok := msg.Data().(types.EventDataRoundState)
|
roundStateEvent, ok := msg.Data().(types.EventDataRoundState)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("expected a EventDataRoundState, got %T. Wrong subscription channel?",
|
t.Fatalf("expected a EventDataRoundState, got %T. Wrong subscription channel?", msg.Data())
|
||||||
msg.Data()))
|
|
||||||
}
|
}
|
||||||
if roundStateEvent.Height != height {
|
if roundStateEvent.Height != height {
|
||||||
panic(fmt.Sprintf("expected height %v, got %v", height, roundStateEvent.Height))
|
t.Fatalf("expected height %v, got %v", height, roundStateEvent.Height)
|
||||||
}
|
}
|
||||||
if roundStateEvent.Round != round {
|
if roundStateEvent.Round != round {
|
||||||
panic(fmt.Sprintf("expected round %v, got %v", round, roundStateEvent.Round))
|
t.Fatalf("expected round %v, got %v", round, roundStateEvent.Round)
|
||||||
}
|
}
|
||||||
// TODO: We could check also for a step at this point!
|
// TODO: We could check also for a step at this point!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewRound(roundCh <-chan tmpubsub.Message, height int64, round int32) {
|
func ensureNewRound(t *testing.T, roundCh <-chan tmpubsub.Message, height int64, round int32) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for NewRound event")
|
t.Fatal("Timeout expired while waiting for NewRound event")
|
||||||
case msg := <-roundCh:
|
case msg := <-roundCh:
|
||||||
newRoundEvent, ok := msg.Data().(types.EventDataNewRound)
|
newRoundEvent, ok := msg.Data().(types.EventDataNewRound)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("expected a EventDataNewRound, got %T. Wrong subscription channel?",
|
t.Fatalf("expected a EventDataNewRound, got %T. Wrong subscription channel?", msg.Data())
|
||||||
msg.Data()))
|
|
||||||
}
|
}
|
||||||
if newRoundEvent.Height != height {
|
if newRoundEvent.Height != height {
|
||||||
panic(fmt.Sprintf("expected height %v, got %v", height, newRoundEvent.Height))
|
t.Fatalf("expected height %v, got %v", height, newRoundEvent.Height)
|
||||||
}
|
}
|
||||||
if newRoundEvent.Round != round {
|
if newRoundEvent.Round != round {
|
||||||
panic(fmt.Sprintf("expected round %v, got %v", round, newRoundEvent.Round))
|
t.Fatalf("expected round %v, got %v", round, newRoundEvent.Round)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewTimeout(timeoutCh <-chan tmpubsub.Message, height int64, round int32, timeout int64) {
|
func ensureNewTimeout(t *testing.T, timeoutCh <-chan tmpubsub.Message, height int64, round int32, timeout int64) {
|
||||||
|
t.Helper()
|
||||||
timeoutDuration := time.Duration(timeout*10) * time.Nanosecond
|
timeoutDuration := time.Duration(timeout*10) * time.Nanosecond
|
||||||
ensureNewEvent(timeoutCh, height, round, timeoutDuration,
|
ensureNewEvent(t, timeoutCh, height, round, timeoutDuration,
|
||||||
"Timeout expired while waiting for NewTimeout event")
|
"Timeout expired while waiting for NewTimeout event")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewProposal(proposalCh <-chan tmpubsub.Message, height int64, round int32) {
|
func ensureNewProposal(t *testing.T, proposalCh <-chan tmpubsub.Message, height int64, round int32) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for NewProposal event")
|
t.Fatalf("Timeout expired while waiting for NewProposal event")
|
||||||
case msg := <-proposalCh:
|
case msg := <-proposalCh:
|
||||||
proposalEvent, ok := msg.Data().(types.EventDataCompleteProposal)
|
proposalEvent, ok := msg.Data().(types.EventDataCompleteProposal)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("expected a EventDataCompleteProposal, got %T. Wrong subscription channel?",
|
t.Fatalf("expected a EventDataCompleteProposal, got %T. Wrong subscription channel?",
|
||||||
msg.Data()))
|
msg.Data())
|
||||||
}
|
}
|
||||||
if proposalEvent.Height != height {
|
if proposalEvent.Height != height {
|
||||||
panic(fmt.Sprintf("expected height %v, got %v", height, proposalEvent.Height))
|
t.Fatalf("expected height %v, got %v", height, proposalEvent.Height)
|
||||||
}
|
}
|
||||||
if proposalEvent.Round != round {
|
if proposalEvent.Round != round {
|
||||||
panic(fmt.Sprintf("expected round %v, got %v", round, proposalEvent.Round))
|
t.Fatalf("expected round %v, got %v", round, proposalEvent.Round)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewValidBlock(validBlockCh <-chan tmpubsub.Message, height int64, round int32) {
|
func ensureNewValidBlock(t *testing.T, validBlockCh <-chan tmpubsub.Message, height int64, round int32) {
|
||||||
ensureNewEvent(validBlockCh, height, round, ensureTimeout,
|
t.Helper()
|
||||||
|
ensureNewEvent(t, validBlockCh, height, round, ensureTimeout,
|
||||||
"Timeout expired while waiting for NewValidBlock event")
|
"Timeout expired while waiting for NewValidBlock event")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewBlock(blockCh <-chan tmpubsub.Message, height int64) {
|
func ensureNewBlock(t *testing.T, blockCh <-chan tmpubsub.Message, height int64) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for NewBlock event")
|
t.Fatalf("Timeout expired while waiting for NewBlock event")
|
||||||
case msg := <-blockCh:
|
case msg := <-blockCh:
|
||||||
blockEvent, ok := msg.Data().(types.EventDataNewBlock)
|
blockEvent, ok := msg.Data().(types.EventDataNewBlock)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("expected a EventDataNewBlock, got %T. Wrong subscription channel?",
|
t.Fatalf("expected a EventDataNewBlock, got %T. Wrong subscription channel?",
|
||||||
msg.Data()))
|
msg.Data())
|
||||||
}
|
}
|
||||||
if blockEvent.Block.Height != height {
|
if blockEvent.Block.Height != height {
|
||||||
panic(fmt.Sprintf("expected height %v, got %v", height, blockEvent.Block.Height))
|
t.Fatalf("expected height %v, got %v", height, blockEvent.Block.Height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewBlockHeader(blockCh <-chan tmpubsub.Message, height int64, blockHash tmbytes.HexBytes) {
|
func ensureNewBlockHeader(t *testing.T, blockCh <-chan tmpubsub.Message, height int64, blockHash tmbytes.HexBytes) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for NewBlockHeader event")
|
t.Fatalf("Timeout expired while waiting for NewBlockHeader event")
|
||||||
case msg := <-blockCh:
|
case msg := <-blockCh:
|
||||||
blockHeaderEvent, ok := msg.Data().(types.EventDataNewBlockHeader)
|
blockHeaderEvent, ok := msg.Data().(types.EventDataNewBlockHeader)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("expected a EventDataNewBlockHeader, got %T. Wrong subscription channel?",
|
t.Fatalf("expected a EventDataNewBlockHeader, got %T. Wrong subscription channel?",
|
||||||
msg.Data()))
|
msg.Data())
|
||||||
}
|
}
|
||||||
if blockHeaderEvent.Header.Height != height {
|
if blockHeaderEvent.Header.Height != height {
|
||||||
panic(fmt.Sprintf("expected height %v, got %v", height, blockHeaderEvent.Header.Height))
|
t.Fatalf("expected height %v, got %v", height, blockHeaderEvent.Header.Height)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(blockHeaderEvent.Header.Hash(), blockHash) {
|
if !bytes.Equal(blockHeaderEvent.Header.Hash(), blockHash) {
|
||||||
panic(fmt.Sprintf("expected header %X, got %X", blockHash, blockHeaderEvent.Header.Hash()))
|
t.Fatalf("expected header %X, got %X", blockHash, blockHeaderEvent.Header.Hash())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewUnlock(unlockCh <-chan tmpubsub.Message, height int64, round int32) {
|
func ensureLock(t *testing.T, lockCh <-chan tmpubsub.Message, height int64, round int32) {
|
||||||
ensureNewEvent(unlockCh, height, round, ensureTimeout,
|
t.Helper()
|
||||||
"Timeout expired while waiting for NewUnlock event")
|
ensureNewEvent(t, lockCh, height, round, ensureTimeout,
|
||||||
|
"Timeout expired while waiting for LockValue event")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureProposal(proposalCh <-chan tmpubsub.Message, height int64, round int32, propID types.BlockID) {
|
func ensureRelock(t *testing.T, relockCh <-chan tmpubsub.Message, height int64, round int32) {
|
||||||
|
t.Helper()
|
||||||
|
ensureNewEvent(t, relockCh, height, round, ensureTimeout,
|
||||||
|
"Timeout expired while waiting for RelockValue event")
|
||||||
|
}
|
||||||
|
|
||||||
|
func ensureProposal(t *testing.T, proposalCh <-chan tmpubsub.Message, height int64, round int32, propID types.BlockID) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for NewProposal event")
|
t.Fatalf("Timeout expired while waiting for NewProposal event")
|
||||||
case msg := <-proposalCh:
|
case msg := <-proposalCh:
|
||||||
proposalEvent, ok := msg.Data().(types.EventDataCompleteProposal)
|
proposalEvent, ok := msg.Data().(types.EventDataCompleteProposal)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("expected a EventDataCompleteProposal, got %T. Wrong subscription channel?",
|
t.Fatalf("expected a EventDataCompleteProposal, got %T. Wrong subscription channel?",
|
||||||
msg.Data()))
|
msg.Data())
|
||||||
}
|
}
|
||||||
if proposalEvent.Height != height {
|
if proposalEvent.Height != height {
|
||||||
panic(fmt.Sprintf("expected height %v, got %v", height, proposalEvent.Height))
|
t.Fatalf("expected height %v, got %v", height, proposalEvent.Height)
|
||||||
}
|
}
|
||||||
if proposalEvent.Round != round {
|
if proposalEvent.Round != round {
|
||||||
panic(fmt.Sprintf("expected round %v, got %v", round, proposalEvent.Round))
|
t.Fatalf("expected round %v, got %v", round, proposalEvent.Round)
|
||||||
}
|
}
|
||||||
if !proposalEvent.BlockID.Equals(propID) {
|
if !proposalEvent.BlockID.Equals(propID) {
|
||||||
panic(fmt.Sprintf("Proposed block does not match expected block (%v != %v)", proposalEvent.BlockID, propID))
|
t.Fatalf("Proposed block does not match expected block (%v != %v)", proposalEvent.BlockID, propID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensurePrecommit(voteCh <-chan tmpubsub.Message, height int64, round int32) {
|
func ensurePrecommit(t *testing.T, voteCh <-chan tmpubsub.Message, height int64, round int32) {
|
||||||
ensureVote(voteCh, height, round, tmproto.PrecommitType)
|
t.Helper()
|
||||||
|
ensureVote(t, voteCh, height, round, tmproto.PrecommitType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensurePrevote(voteCh <-chan tmpubsub.Message, height int64, round int32) {
|
func ensurePrevote(t *testing.T, voteCh <-chan tmpubsub.Message, height int64, round int32) {
|
||||||
ensureVote(voteCh, height, round, tmproto.PrevoteType)
|
t.Helper()
|
||||||
|
ensureVote(t, voteCh, height, round, tmproto.PrevoteType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureVote(voteCh <-chan tmpubsub.Message, height int64, round int32,
|
func ensureVote(t *testing.T, voteCh <-chan tmpubsub.Message, height int64, round int32,
|
||||||
voteType tmproto.SignedMsgType) {
|
voteType tmproto.SignedMsgType) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for NewVote event")
|
t.Fatalf("Timeout expired while waiting for NewVote event")
|
||||||
case msg := <-voteCh:
|
case msg := <-voteCh:
|
||||||
voteEvent, ok := msg.Data().(types.EventDataVote)
|
voteEvent, ok := msg.Data().(types.EventDataVote)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("expected a EventDataVote, got %T. Wrong subscription channel?",
|
t.Fatalf("expected a EventDataVote, got %T. Wrong subscription channel?",
|
||||||
msg.Data()))
|
msg.Data())
|
||||||
}
|
}
|
||||||
vote := voteEvent.Vote
|
vote := voteEvent.Vote
|
||||||
if vote.Height != height {
|
if vote.Height != height {
|
||||||
panic(fmt.Sprintf("expected height %v, got %v", height, vote.Height))
|
t.Fatalf("expected height %v, got %v", height, vote.Height)
|
||||||
}
|
}
|
||||||
if vote.Round != round {
|
if vote.Round != round {
|
||||||
panic(fmt.Sprintf("expected round %v, got %v", round, vote.Round))
|
t.Fatalf("expected round %v, got %v", round, vote.Round)
|
||||||
}
|
}
|
||||||
if vote.Type != voteType {
|
if vote.Type != voteType {
|
||||||
panic(fmt.Sprintf("expected type %v, got %v", voteType, vote.Type))
|
t.Fatalf("expected type %v, got %v", voteType, vote.Type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensurePrecommitTimeout(ch <-chan tmpubsub.Message) {
|
func ensurePrecommitTimeout(t *testing.T, ch <-chan tmpubsub.Message) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for the Precommit to Timeout")
|
t.Fatalf("Timeout expired while waiting for the Precommit to Timeout")
|
||||||
case <-ch:
|
case <-ch:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureNewEventOnChannel(ch <-chan tmpubsub.Message) {
|
func ensureNewEventOnChannel(t *testing.T, ch <-chan tmpubsub.Message) {
|
||||||
|
t.Helper()
|
||||||
select {
|
select {
|
||||||
case <-time.After(ensureTimeout):
|
case <-time.After(ensureTimeout):
|
||||||
panic("Timeout expired while waiting for new activity on the channel")
|
t.Fatalf("Timeout expired while waiting for new activity on the channel")
|
||||||
case <-ch:
|
case <-ch:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -711,6 +737,7 @@ func randConsensusState(
|
|||||||
appFunc func() abci.Application,
|
appFunc func() abci.Application,
|
||||||
configOpts ...func(*cfg.Config),
|
configOpts ...func(*cfg.Config),
|
||||||
) ([]*State, cleanupFunc) {
|
) ([]*State, cleanupFunc) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
genDoc, privVals := factory.RandGenesisDoc(config, nValidators, false, 30)
|
genDoc, privVals := factory.RandGenesisDoc(config, nValidators, false, 30)
|
||||||
css := make([]*State, nValidators)
|
css := make([]*State, nValidators)
|
||||||
@@ -731,7 +758,7 @@ func randConsensusState(
|
|||||||
opt(thisConfig)
|
opt(thisConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureDir(filepath.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
ensureDir(t, filepath.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
||||||
|
|
||||||
app := appFunc()
|
app := appFunc()
|
||||||
|
|
||||||
@@ -759,6 +786,7 @@ func randConsensusState(
|
|||||||
|
|
||||||
// nPeers = nValidators + nNotValidator
|
// nPeers = nValidators + nNotValidator
|
||||||
func randConsensusNetWithPeers(
|
func randConsensusNetWithPeers(
|
||||||
|
t *testing.T,
|
||||||
config *cfg.Config,
|
config *cfg.Config,
|
||||||
nValidators,
|
nValidators,
|
||||||
nPeers int,
|
nPeers int,
|
||||||
@@ -768,6 +796,7 @@ func randConsensusNetWithPeers(
|
|||||||
) ([]*State, *types.GenesisDoc, *cfg.Config, cleanupFunc) {
|
) ([]*State, *types.GenesisDoc, *cfg.Config, cleanupFunc) {
|
||||||
genDoc, privVals := factory.RandGenesisDoc(config, nValidators, false, testMinPower)
|
genDoc, privVals := factory.RandGenesisDoc(config, nValidators, false, testMinPower)
|
||||||
css := make([]*State, nPeers)
|
css := make([]*State, nPeers)
|
||||||
|
t.Helper()
|
||||||
logger := consensusLogger()
|
logger := consensusLogger()
|
||||||
|
|
||||||
var peer0Config *cfg.Config
|
var peer0Config *cfg.Config
|
||||||
@@ -776,7 +805,7 @@ func randConsensusNetWithPeers(
|
|||||||
state, _ := sm.MakeGenesisState(genDoc)
|
state, _ := sm.MakeGenesisState(genDoc)
|
||||||
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
|
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
|
||||||
configRootDirs = append(configRootDirs, thisConfig.RootDir)
|
configRootDirs = append(configRootDirs, thisConfig.RootDir)
|
||||||
ensureDir(filepath.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
ensureDir(t, filepath.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
peer0Config = thisConfig
|
peer0Config = thisConfig
|
||||||
}
|
}
|
||||||
@@ -786,16 +815,16 @@ func randConsensusNetWithPeers(
|
|||||||
} else {
|
} else {
|
||||||
tempKeyFile, err := ioutil.TempFile("", "priv_validator_key_")
|
tempKeyFile, err := ioutil.TempFile("", "priv_validator_key_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
t.Fatalf("error creating temp file for validator key: %s", err)
|
||||||
}
|
}
|
||||||
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
|
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
t.Fatalf("error loading validator state: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
privVal, err = privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), "")
|
privVal, err = privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
t.Fatalf("error generating validator key: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ func TestMempoolNoProgressUntilTxsAvailable(t *testing.T) {
|
|||||||
newBlockCh := subscribe(cs.eventBus, types.EventQueryNewBlock)
|
newBlockCh := subscribe(cs.eventBus, types.EventQueryNewBlock)
|
||||||
startTestRound(cs, height, round)
|
startTestRound(cs, height, round)
|
||||||
|
|
||||||
ensureNewEventOnChannel(newBlockCh) // first block gets committed
|
ensureNewEventOnChannel(t, newBlockCh) // first block gets committed
|
||||||
ensureNoNewEventOnChannel(newBlockCh)
|
ensureNoNewEventOnChannel(t, newBlockCh)
|
||||||
deliverTxsRange(cs, 0, 1)
|
deliverTxsRange(cs, 0, 1)
|
||||||
ensureNewEventOnChannel(newBlockCh) // commit txs
|
ensureNewEventOnChannel(t, newBlockCh) // commit txs
|
||||||
ensureNewEventOnChannel(newBlockCh) // commit updated app hash
|
ensureNewEventOnChannel(t, newBlockCh) // commit updated app hash
|
||||||
ensureNoNewEventOnChannel(newBlockCh)
|
ensureNoNewEventOnChannel(t, newBlockCh)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMempoolProgressAfterCreateEmptyBlocksInterval(t *testing.T) {
|
func TestMempoolProgressAfterCreateEmptyBlocksInterval(t *testing.T) {
|
||||||
@@ -63,9 +63,9 @@ func TestMempoolProgressAfterCreateEmptyBlocksInterval(t *testing.T) {
|
|||||||
newBlockCh := subscribe(cs.eventBus, types.EventQueryNewBlock)
|
newBlockCh := subscribe(cs.eventBus, types.EventQueryNewBlock)
|
||||||
startTestRound(cs, cs.Height, cs.Round)
|
startTestRound(cs, cs.Height, cs.Round)
|
||||||
|
|
||||||
ensureNewEventOnChannel(newBlockCh) // first block gets committed
|
ensureNewEventOnChannel(t, newBlockCh) // first block gets committed
|
||||||
ensureNoNewEventOnChannel(newBlockCh) // then we dont make a block ...
|
ensureNoNewEventOnChannel(t, newBlockCh) // then we dont make a block ...
|
||||||
ensureNewEventOnChannel(newBlockCh) // until the CreateEmptyBlocksInterval has passed
|
ensureNewEventOnChannel(t, newBlockCh) // until the CreateEmptyBlocksInterval has passed
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMempoolProgressInHigherRound(t *testing.T) {
|
func TestMempoolProgressInHigherRound(t *testing.T) {
|
||||||
@@ -93,19 +93,19 @@ func TestMempoolProgressInHigherRound(t *testing.T) {
|
|||||||
}
|
}
|
||||||
startTestRound(cs, height, round)
|
startTestRound(cs, height, round)
|
||||||
|
|
||||||
ensureNewRound(newRoundCh, height, round) // first round at first height
|
ensureNewRound(t, newRoundCh, height, round) // first round at first height
|
||||||
ensureNewEventOnChannel(newBlockCh) // first block gets committed
|
ensureNewEventOnChannel(t, newBlockCh) // first block gets committed
|
||||||
|
|
||||||
height++ // moving to the next height
|
height++ // moving to the next height
|
||||||
round = 0
|
round = 0
|
||||||
|
|
||||||
ensureNewRound(newRoundCh, height, round) // first round at next height
|
ensureNewRound(t, newRoundCh, height, round) // first round at next height
|
||||||
deliverTxsRange(cs, 0, 1) // we deliver txs, but dont set a proposal so we get the next round
|
deliverTxsRange(cs, 0, 1) // we deliver txs, but dont set a proposal so we get the next round
|
||||||
ensureNewTimeout(timeoutCh, height, round, cs.config.TimeoutPropose.Nanoseconds())
|
ensureNewTimeout(t, timeoutCh, height, round, cs.config.TimeoutPropose.Nanoseconds())
|
||||||
|
|
||||||
round++ // moving to the next round
|
round++ // moving to the next round
|
||||||
ensureNewRound(newRoundCh, height, round) // wait for the next round
|
ensureNewRound(t, newRoundCh, height, round) // wait for the next round
|
||||||
ensureNewEventOnChannel(newBlockCh) // now we can commit the block
|
ensureNewEventOnChannel(t, newBlockCh) // now we can commit the block
|
||||||
}
|
}
|
||||||
|
|
||||||
func deliverTxsRange(cs *State, start, end int) {
|
func deliverTxsRange(cs *State, start, end int) {
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ func TestReactorWithEvidence(t *testing.T) {
|
|||||||
|
|
||||||
defer os.RemoveAll(thisConfig.RootDir)
|
defer os.RemoveAll(thisConfig.RootDir)
|
||||||
|
|
||||||
ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
ensureDir(t, path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
|
||||||
app := appFunc()
|
app := appFunc()
|
||||||
vals := types.TM2PB.ValidatorUpdates(state.Validators)
|
vals := types.TM2PB.ValidatorUpdates(state.Validators)
|
||||||
app.InitChain(abci.RequestInitChain{Validators: vals})
|
app.InitChain(abci.RequestInitChain{Validators: vals})
|
||||||
@@ -627,6 +627,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
|
|||||||
nPeers := 7
|
nPeers := 7
|
||||||
nVals := 4
|
nVals := 4
|
||||||
states, _, _, cleanup := randConsensusNetWithPeers(
|
states, _, _, cleanup := randConsensusNetWithPeers(
|
||||||
|
t,
|
||||||
config,
|
config,
|
||||||
nVals,
|
nVals,
|
||||||
nPeers,
|
nPeers,
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func startNewStateAndWaitForBlock(t *testing.T, consensusReplayConfig *cfg.Confi
|
|||||||
logger := log.TestingLogger()
|
logger := log.TestingLogger()
|
||||||
state, err := sm.MakeGenesisStateFromFile(consensusReplayConfig.GenesisFile())
|
state, err := sm.MakeGenesisStateFromFile(consensusReplayConfig.GenesisFile())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
privValidator := loadPrivValidator(consensusReplayConfig)
|
privValidator := loadPrivValidator(t, consensusReplayConfig)
|
||||||
blockStore := store.NewBlockStore(dbm.NewMemDB())
|
blockStore := store.NewBlockStore(dbm.NewMemDB())
|
||||||
cs := newStateWithConfigAndBlockStore(
|
cs := newStateWithConfigAndBlockStore(
|
||||||
consensusReplayConfig,
|
consensusReplayConfig,
|
||||||
@@ -154,7 +154,7 @@ LOOP:
|
|||||||
blockStore := store.NewBlockStore(blockDB)
|
blockStore := store.NewBlockStore(blockDB)
|
||||||
state, err := sm.MakeGenesisStateFromFile(consensusReplayConfig.GenesisFile())
|
state, err := sm.MakeGenesisStateFromFile(consensusReplayConfig.GenesisFile())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
privValidator := loadPrivValidator(consensusReplayConfig)
|
privValidator := loadPrivValidator(t, consensusReplayConfig)
|
||||||
cs := newStateWithConfigAndBlockStore(
|
cs := newStateWithConfigAndBlockStore(
|
||||||
consensusReplayConfig,
|
consensusReplayConfig,
|
||||||
state,
|
state,
|
||||||
@@ -321,6 +321,7 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
nVals := 4
|
nVals := 4
|
||||||
|
|
||||||
css, genDoc, config, cleanup := randConsensusNetWithPeers(
|
css, genDoc, config, cleanup := randConsensusNetWithPeers(
|
||||||
|
t,
|
||||||
config,
|
config,
|
||||||
nVals,
|
nVals,
|
||||||
nPeers,
|
nPeers,
|
||||||
@@ -345,15 +346,15 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
// start the machine
|
// start the machine
|
||||||
startTestRound(css[0], height, round)
|
startTestRound(css[0], height, round)
|
||||||
incrementHeight(vss...)
|
incrementHeight(vss...)
|
||||||
ensureNewRound(newRoundCh, height, 0)
|
ensureNewRound(t, newRoundCh, height, 0)
|
||||||
ensureNewProposal(proposalCh, height, round)
|
ensureNewProposal(t, proposalCh, height, round)
|
||||||
rs := css[0].GetRoundState()
|
rs := css[0].GetRoundState()
|
||||||
|
|
||||||
signAddVotes(sim.Config, css[0], tmproto.PrecommitType,
|
signAddVotes(sim.Config, css[0], tmproto.PrecommitType,
|
||||||
rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(),
|
rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(),
|
||||||
vss[1:nVals]...)
|
vss[1:nVals]...)
|
||||||
|
|
||||||
ensureNewRound(newRoundCh, height+1, 0)
|
ensureNewRound(t, newRoundCh, height+1, 0)
|
||||||
|
|
||||||
// HEIGHT 2
|
// HEIGHT 2
|
||||||
height++
|
height++
|
||||||
@@ -380,12 +381,12 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ensureNewProposal(proposalCh, height, round)
|
ensureNewProposal(t, proposalCh, height, round)
|
||||||
rs = css[0].GetRoundState()
|
rs = css[0].GetRoundState()
|
||||||
signAddVotes(sim.Config, css[0], tmproto.PrecommitType,
|
signAddVotes(sim.Config, css[0], tmproto.PrecommitType,
|
||||||
rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(),
|
rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(),
|
||||||
vss[1:nVals]...)
|
vss[1:nVals]...)
|
||||||
ensureNewRound(newRoundCh, height+1, 0)
|
ensureNewRound(t, newRoundCh, height+1, 0)
|
||||||
|
|
||||||
// HEIGHT 3
|
// HEIGHT 3
|
||||||
height++
|
height++
|
||||||
@@ -412,12 +413,12 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ensureNewProposal(proposalCh, height, round)
|
ensureNewProposal(t, proposalCh, height, round)
|
||||||
rs = css[0].GetRoundState()
|
rs = css[0].GetRoundState()
|
||||||
signAddVotes(sim.Config, css[0], tmproto.PrecommitType,
|
signAddVotes(sim.Config, css[0], tmproto.PrecommitType,
|
||||||
rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(),
|
rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(),
|
||||||
vss[1:nVals]...)
|
vss[1:nVals]...)
|
||||||
ensureNewRound(newRoundCh, height+1, 0)
|
ensureNewRound(t, newRoundCh, height+1, 0)
|
||||||
|
|
||||||
// HEIGHT 4
|
// HEIGHT 4
|
||||||
height++
|
height++
|
||||||
@@ -471,7 +472,7 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ensureNewProposal(proposalCh, height, round)
|
ensureNewProposal(t, proposalCh, height, round)
|
||||||
|
|
||||||
removeValidatorTx2 := kvstore.MakeValSetChangeTx(newVal2ABCI, 0)
|
removeValidatorTx2 := kvstore.MakeValSetChangeTx(newVal2ABCI, 0)
|
||||||
err = assertMempool(css[0].txNotifier).CheckTx(context.Background(), removeValidatorTx2, nil, mempl.TxInfo{})
|
err = assertMempool(css[0].txNotifier).CheckTx(context.Background(), removeValidatorTx2, nil, mempl.TxInfo{})
|
||||||
@@ -487,7 +488,7 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
rs.ProposalBlockParts.Header(), newVss[i])
|
rs.ProposalBlockParts.Header(), newVss[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureNewRound(newRoundCh, height+1, 0)
|
ensureNewRound(t, newRoundCh, height+1, 0)
|
||||||
|
|
||||||
// HEIGHT 5
|
// HEIGHT 5
|
||||||
height++
|
height++
|
||||||
@@ -497,7 +498,7 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
newVss[newVssIdx].VotingPower = 25
|
newVss[newVssIdx].VotingPower = 25
|
||||||
sort.Sort(ValidatorStubsByPower(newVss))
|
sort.Sort(ValidatorStubsByPower(newVss))
|
||||||
selfIndex = valIndexFn(0)
|
selfIndex = valIndexFn(0)
|
||||||
ensureNewProposal(proposalCh, height, round)
|
ensureNewProposal(t, proposalCh, height, round)
|
||||||
rs = css[0].GetRoundState()
|
rs = css[0].GetRoundState()
|
||||||
for i := 0; i < nVals+1; i++ {
|
for i := 0; i < nVals+1; i++ {
|
||||||
if i == selfIndex {
|
if i == selfIndex {
|
||||||
@@ -507,7 +508,7 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
tmproto.PrecommitType, rs.ProposalBlock.Hash(),
|
tmproto.PrecommitType, rs.ProposalBlock.Hash(),
|
||||||
rs.ProposalBlockParts.Header(), newVss[i])
|
rs.ProposalBlockParts.Header(), newVss[i])
|
||||||
}
|
}
|
||||||
ensureNewRound(newRoundCh, height+1, 0)
|
ensureNewRound(t, newRoundCh, height+1, 0)
|
||||||
|
|
||||||
// HEIGHT 6
|
// HEIGHT 6
|
||||||
height++
|
height++
|
||||||
@@ -534,7 +535,7 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ensureNewProposal(proposalCh, height, round)
|
ensureNewProposal(t, proposalCh, height, round)
|
||||||
rs = css[0].GetRoundState()
|
rs = css[0].GetRoundState()
|
||||||
for i := 0; i < nVals+3; i++ {
|
for i := 0; i < nVals+3; i++ {
|
||||||
if i == selfIndex {
|
if i == selfIndex {
|
||||||
@@ -544,7 +545,7 @@ func setupSimulator(t *testing.T) *simulatorTestSuite {
|
|||||||
tmproto.PrecommitType, rs.ProposalBlock.Hash(),
|
tmproto.PrecommitType, rs.ProposalBlock.Hash(),
|
||||||
rs.ProposalBlockParts.Header(), newVss[i])
|
rs.ProposalBlockParts.Header(), newVss[i])
|
||||||
}
|
}
|
||||||
ensureNewRound(newRoundCh, height+1, 0)
|
ensureNewRound(t, newRoundCh, height+1, 0)
|
||||||
|
|
||||||
sim.Chain = make([]*types.Block, 0)
|
sim.Chain = make([]*types.Block, 0)
|
||||||
sim.Commits = make([]*types.Commit, 0)
|
sim.Commits = make([]*types.Commit, 0)
|
||||||
|
|||||||
@@ -1361,7 +1361,6 @@ func (cs *State) enterPrevoteWait(height int64, round int32) {
|
|||||||
// Enter: `timeoutPrecommit` after any +2/3 precommits.
|
// Enter: `timeoutPrecommit` after any +2/3 precommits.
|
||||||
// Enter: +2/3 precomits for block or nil.
|
// Enter: +2/3 precomits for block or nil.
|
||||||
// Lock & precommit the ProposalBlock if we have enough prevotes for it (a POL in this round)
|
// Lock & precommit the ProposalBlock if we have enough prevotes for it (a POL in this round)
|
||||||
// else, unlock an existing lock and precommit nil if +2/3 of prevotes were nil,
|
|
||||||
// else, precommit nil otherwise.
|
// else, precommit nil otherwise.
|
||||||
func (cs *State) enterPrecommit(height int64, round int32) {
|
func (cs *State) enterPrecommit(height int64, round int32) {
|
||||||
logger := cs.Logger.With("height", height, "round", round)
|
logger := cs.Logger.With("height", height, "round", round)
|
||||||
@@ -1408,21 +1407,9 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
|||||||
panic(fmt.Sprintf("this POLRound should be %v but got %v", round, polRound))
|
panic(fmt.Sprintf("this POLRound should be %v but got %v", round, polRound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// +2/3 prevoted nil. Unlock and precommit nil.
|
// +2/3 prevoted nil. Precommit nil.
|
||||||
if len(blockID.Hash) == 0 {
|
if blockID.IsNil() {
|
||||||
if cs.LockedBlock == nil {
|
logger.Debug("precommit step; +2/3 prevoted for nil")
|
||||||
logger.Debug("precommit step; +2/3 prevoted for nil")
|
|
||||||
} else {
|
|
||||||
logger.Debug("precommit step; +2/3 prevoted for nil; unlocking")
|
|
||||||
cs.LockedRound = -1
|
|
||||||
cs.LockedBlock = nil
|
|
||||||
cs.LockedBlockParts = nil
|
|
||||||
|
|
||||||
if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil {
|
|
||||||
logger.Error("failed publishing event unlock", "err", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{})
|
cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1429,9 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If +2/3 prevoted for proposal block, stage and precommit it
|
// If greater than 2/3 of the voting power on the network prevoted for
|
||||||
|
// the proposed block, update our locked block to this block and issue a
|
||||||
|
// precommit vote for it.
|
||||||
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||||
logger.Debug("precommit step; +2/3 prevoted proposal block; locking", "hash", blockID.Hash)
|
logger.Debug("precommit step; +2/3 prevoted proposal block; locking", "hash", blockID.Hash)
|
||||||
|
|
||||||
@@ -1464,23 +1453,14 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// There was a polka in this round for a block we don't have.
|
// There was a polka in this round for a block we don't have.
|
||||||
// Fetch that block, unlock, and precommit nil.
|
// Fetch that block, and precommit nil.
|
||||||
// The +2/3 prevotes for this round is the POL for our unlock.
|
|
||||||
logger.Debug("precommit step; +2/3 prevotes for a block we do not have; voting nil", "block_id", blockID)
|
logger.Debug("precommit step; +2/3 prevotes for a block we do not have; voting nil", "block_id", blockID)
|
||||||
|
|
||||||
cs.LockedRound = -1
|
|
||||||
cs.LockedBlock = nil
|
|
||||||
cs.LockedBlockParts = nil
|
|
||||||
|
|
||||||
if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) {
|
if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) {
|
||||||
cs.ProposalBlock = nil
|
cs.ProposalBlock = nil
|
||||||
cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader)
|
cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil {
|
|
||||||
logger.Error("failed publishing event unlock", "err", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{})
|
cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1588,7 +1568,7 @@ func (cs *State) tryFinalizeCommit(height int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority()
|
blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority()
|
||||||
if !ok || len(blockID.Hash) == 0 {
|
if !ok || blockID.IsNil() {
|
||||||
logger.Error("failed attempt to finalize commit; there was no +2/3 majority or +2/3 was for nil")
|
logger.Error("failed attempt to finalize commit; there was no +2/3 majority or +2/3 was for nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1921,7 +1901,7 @@ func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID types.NodeID
|
|||||||
// Update Valid* if we can.
|
// Update Valid* if we can.
|
||||||
prevotes := cs.Votes.Prevotes(cs.Round)
|
prevotes := cs.Votes.Prevotes(cs.Round)
|
||||||
blockID, hasTwoThirds := prevotes.TwoThirdsMajority()
|
blockID, hasTwoThirds := prevotes.TwoThirdsMajority()
|
||||||
if hasTwoThirds && !blockID.IsZero() && (cs.ValidRound < cs.Round) {
|
if hasTwoThirds && !blockID.IsNil() && (cs.ValidRound < cs.Round) {
|
||||||
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||||
cs.Logger.Debug(
|
cs.Logger.Debug(
|
||||||
"updating valid block to new proposal block",
|
"updating valid block to new proposal block",
|
||||||
@@ -2070,33 +2050,13 @@ func (cs *State) addVote(vote *types.Vote, peerID types.NodeID) (added bool, err
|
|||||||
prevotes := cs.Votes.Prevotes(vote.Round)
|
prevotes := cs.Votes.Prevotes(vote.Round)
|
||||||
cs.Logger.Debug("added vote to prevote", "vote", vote, "prevotes", prevotes.StringShort())
|
cs.Logger.Debug("added vote to prevote", "vote", vote, "prevotes", prevotes.StringShort())
|
||||||
|
|
||||||
// If +2/3 prevotes for a block or nil for *any* round:
|
// Check to see if >2/3 of the voting power on the network voted for any non-nil block.
|
||||||
if blockID, ok := prevotes.TwoThirdsMajority(); ok {
|
if blockID, ok := prevotes.TwoThirdsMajority(); ok && !blockID.IsNil() {
|
||||||
// There was a polka!
|
// Greater than 2/3 of the voting power on the network voted for some
|
||||||
// If we're locked but this is a recent polka, unlock.
|
// non-nil block
|
||||||
// If it matches our ProposalBlock, update the ValidBlock
|
|
||||||
|
|
||||||
// Unlock if `cs.LockedRound < vote.Round <= cs.Round`
|
|
||||||
// NOTE: If vote.Round > cs.Round, we'll deal with it when we get to vote.Round
|
|
||||||
if (cs.LockedBlock != nil) &&
|
|
||||||
(cs.LockedRound < vote.Round) &&
|
|
||||||
(vote.Round <= cs.Round) &&
|
|
||||||
!cs.LockedBlock.HashesTo(blockID.Hash) {
|
|
||||||
|
|
||||||
cs.Logger.Debug("unlocking because of POL", "locked_round", cs.LockedRound, "pol_round", vote.Round)
|
|
||||||
|
|
||||||
cs.LockedRound = -1
|
|
||||||
cs.LockedBlock = nil
|
|
||||||
cs.LockedBlockParts = nil
|
|
||||||
|
|
||||||
if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil {
|
|
||||||
return added, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Valid* if we can.
|
// Update Valid* if we can.
|
||||||
// NOTE: our proposal block may be nil or not what received a polka..
|
if cs.ValidRound < vote.Round && vote.Round == cs.Round {
|
||||||
if len(blockID.Hash) != 0 && (cs.ValidRound < vote.Round) && (vote.Round == cs.Round) {
|
|
||||||
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||||
cs.Logger.Debug("updating valid block because of POL", "valid_round", cs.ValidRound, "pol_round", vote.Round)
|
cs.Logger.Debug("updating valid block because of POL", "valid_round", cs.ValidRound, "pol_round", vote.Round)
|
||||||
cs.ValidRound = vote.Round
|
cs.ValidRound = vote.Round
|
||||||
@@ -2132,7 +2092,7 @@ func (cs *State) addVote(vote *types.Vote, peerID types.NodeID) (added bool, err
|
|||||||
|
|
||||||
case cs.Round == vote.Round && cstypes.RoundStepPrevote <= cs.Step: // current round
|
case cs.Round == vote.Round && cstypes.RoundStepPrevote <= cs.Step: // current round
|
||||||
blockID, ok := prevotes.TwoThirdsMajority()
|
blockID, ok := prevotes.TwoThirdsMajority()
|
||||||
if ok && (cs.isProposalComplete() || len(blockID.Hash) == 0) {
|
if ok && (cs.isProposalComplete() || blockID.IsNil()) {
|
||||||
cs.enterPrecommit(height, vote.Round)
|
cs.enterPrecommit(height, vote.Round)
|
||||||
} else if prevotes.HasTwoThirdsAny() {
|
} else if prevotes.HasTwoThirdsAny() {
|
||||||
cs.enterPrevoteWait(height, vote.Round)
|
cs.enterPrevoteWait(height, vote.Round)
|
||||||
@@ -2160,7 +2120,7 @@ func (cs *State) addVote(vote *types.Vote, peerID types.NodeID) (added bool, err
|
|||||||
cs.enterNewRound(height, vote.Round)
|
cs.enterNewRound(height, vote.Round)
|
||||||
cs.enterPrecommit(height, vote.Round)
|
cs.enterPrecommit(height, vote.Round)
|
||||||
|
|
||||||
if len(blockID.Hash) != 0 {
|
if !blockID.IsNil() {
|
||||||
cs.enterCommit(height, vote.Round)
|
cs.enterCommit(height, vote.Round)
|
||||||
if cs.config.SkipTimeoutCommit && precommits.HasAll() {
|
if cs.config.SkipTimeoutCommit && precommits.HasAll() {
|
||||||
cs.enterNewRound(cs.Height, 0)
|
cs.enterNewRound(cs.Height, 0)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,7 @@ func MakeHeader(h *types.Header) (*types.Header, error) {
|
|||||||
if h.Height == 0 {
|
if h.Height == 0 {
|
||||||
h.Height = 1
|
h.Height = 1
|
||||||
}
|
}
|
||||||
if h.LastBlockID.IsZero() {
|
if h.LastBlockID.IsNil() {
|
||||||
h.LastBlockID = MakeBlockID()
|
h.LastBlockID = MakeBlockID()
|
||||||
}
|
}
|
||||||
if h.ChainID == "" {
|
if h.ChainID == "" {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ type ConsensusParams struct {
|
|||||||
Evidence *EvidenceParams `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence,omitempty"`
|
Evidence *EvidenceParams `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence,omitempty"`
|
||||||
Validator *ValidatorParams `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,omitempty"`
|
Validator *ValidatorParams `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,omitempty"`
|
||||||
Version *VersionParams `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
|
Version *VersionParams `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
|
||||||
|
Timestamp *TimestampParams `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ConsensusParams) Reset() { *m = ConsensusParams{} }
|
func (m *ConsensusParams) Reset() { *m = ConsensusParams{} }
|
||||||
@@ -97,6 +98,13 @@ func (m *ConsensusParams) GetVersion() *VersionParams {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ConsensusParams) GetTimestamp() *TimestampParams {
|
||||||
|
if m != nil {
|
||||||
|
return m.Timestamp
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// BlockParams contains limits on the block size.
|
// BlockParams contains limits on the block size.
|
||||||
type BlockParams struct {
|
type BlockParams struct {
|
||||||
// Max block size, in bytes.
|
// Max block size, in bytes.
|
||||||
@@ -318,6 +326,66 @@ func (m *VersionParams) GetAppVersion() uint64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TimestampParams struct {
|
||||||
|
Accuracy time.Duration `protobuf:"bytes,1,opt,name=accuracy,proto3,stdduration" json:"accuracy"`
|
||||||
|
Precision time.Duration `protobuf:"bytes,2,opt,name=precision,proto3,stdduration" json:"precision"`
|
||||||
|
MessageDelay time.Duration `protobuf:"bytes,3,opt,name=message_delay,json=messageDelay,proto3,stdduration" json:"message_delay"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TimestampParams) Reset() { *m = TimestampParams{} }
|
||||||
|
func (m *TimestampParams) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*TimestampParams) ProtoMessage() {}
|
||||||
|
func (*TimestampParams) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_e12598271a686f57, []int{5}
|
||||||
|
}
|
||||||
|
func (m *TimestampParams) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *TimestampParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_TimestampParams.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *TimestampParams) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_TimestampParams.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *TimestampParams) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *TimestampParams) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_TimestampParams.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_TimestampParams proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *TimestampParams) GetAccuracy() time.Duration {
|
||||||
|
if m != nil {
|
||||||
|
return m.Accuracy
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TimestampParams) GetPrecision() time.Duration {
|
||||||
|
if m != nil {
|
||||||
|
return m.Precision
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TimestampParams) GetMessageDelay() time.Duration {
|
||||||
|
if m != nil {
|
||||||
|
return m.MessageDelay
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// HashedParams is a subset of ConsensusParams.
|
// HashedParams is a subset of ConsensusParams.
|
||||||
//
|
//
|
||||||
// It is hashed into the Header.ConsensusHash.
|
// It is hashed into the Header.ConsensusHash.
|
||||||
@@ -330,7 +398,7 @@ func (m *HashedParams) Reset() { *m = HashedParams{} }
|
|||||||
func (m *HashedParams) String() string { return proto.CompactTextString(m) }
|
func (m *HashedParams) String() string { return proto.CompactTextString(m) }
|
||||||
func (*HashedParams) ProtoMessage() {}
|
func (*HashedParams) ProtoMessage() {}
|
||||||
func (*HashedParams) Descriptor() ([]byte, []int) {
|
func (*HashedParams) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_e12598271a686f57, []int{5}
|
return fileDescriptor_e12598271a686f57, []int{6}
|
||||||
}
|
}
|
||||||
func (m *HashedParams) XXX_Unmarshal(b []byte) error {
|
func (m *HashedParams) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
@@ -379,45 +447,51 @@ func init() {
|
|||||||
proto.RegisterType((*EvidenceParams)(nil), "tendermint.types.EvidenceParams")
|
proto.RegisterType((*EvidenceParams)(nil), "tendermint.types.EvidenceParams")
|
||||||
proto.RegisterType((*ValidatorParams)(nil), "tendermint.types.ValidatorParams")
|
proto.RegisterType((*ValidatorParams)(nil), "tendermint.types.ValidatorParams")
|
||||||
proto.RegisterType((*VersionParams)(nil), "tendermint.types.VersionParams")
|
proto.RegisterType((*VersionParams)(nil), "tendermint.types.VersionParams")
|
||||||
|
proto.RegisterType((*TimestampParams)(nil), "tendermint.types.TimestampParams")
|
||||||
proto.RegisterType((*HashedParams)(nil), "tendermint.types.HashedParams")
|
proto.RegisterType((*HashedParams)(nil), "tendermint.types.HashedParams")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) }
|
func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) }
|
||||||
|
|
||||||
var fileDescriptor_e12598271a686f57 = []byte{
|
var fileDescriptor_e12598271a686f57 = []byte{
|
||||||
// 498 bytes of a gzipped FileDescriptorProto
|
// 577 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xc1, 0x6a, 0xd4, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4f, 0x6b, 0xd4, 0x40,
|
||||||
0x1c, 0xc6, 0x77, 0x9a, 0xda, 0xee, 0xfe, 0xe3, 0x76, 0xcb, 0x20, 0x18, 0x2b, 0xcd, 0xae, 0x39,
|
0x18, 0xc6, 0x37, 0xdd, 0xfe, 0xd9, 0x7d, 0xb7, 0xdb, 0x2d, 0x83, 0x60, 0xac, 0x34, 0x5b, 0x73,
|
||||||
0x48, 0x41, 0x48, 0xc4, 0x22, 0x22, 0x08, 0xe2, 0x56, 0xa9, 0x20, 0x15, 0x09, 0xea, 0xa1, 0x97,
|
0x90, 0x82, 0x90, 0x88, 0x45, 0x44, 0x10, 0x4a, 0xb7, 0x95, 0x16, 0xa4, 0x22, 0xa1, 0x7a, 0xe8,
|
||||||
0x30, 0xd9, 0x8c, 0x69, 0xe8, 0x4e, 0x66, 0xc8, 0x24, 0xcb, 0xee, 0xcd, 0x47, 0xf0, 0xe8, 0x23,
|
0x25, 0x4c, 0xb2, 0x63, 0x1a, 0xba, 0x93, 0x19, 0x32, 0x49, 0xd9, 0x7c, 0x0b, 0x8f, 0x7e, 0x04,
|
||||||
0xe8, 0x9b, 0xf4, 0xd8, 0xa3, 0x27, 0x95, 0xdd, 0x17, 0x91, 0x4c, 0x32, 0xa6, 0x9b, 0xf6, 0x36,
|
0xfd, 0x18, 0xde, 0x7a, 0xec, 0xd1, 0x93, 0x95, 0xed, 0x17, 0x91, 0x4c, 0x66, 0x36, 0xdd, 0xad,
|
||||||
0x33, 0xdf, 0xef, 0x9b, 0xe1, 0xfb, 0x86, 0x3f, 0xec, 0xe7, 0x34, 0x8d, 0x68, 0xc6, 0x92, 0x34,
|
0x42, 0xbd, 0x25, 0xf3, 0x3e, 0xbf, 0x79, 0x79, 0x9f, 0xf7, 0x61, 0x60, 0x33, 0x23, 0xc9, 0x90,
|
||||||
0xf7, 0xf2, 0x85, 0xa0, 0xd2, 0x13, 0x24, 0x23, 0x4c, 0xba, 0x22, 0xe3, 0x39, 0xc7, 0xbb, 0x8d,
|
0xa4, 0x34, 0x4e, 0x32, 0x37, 0x2b, 0x38, 0x11, 0x2e, 0xc7, 0x29, 0xa6, 0xc2, 0xe1, 0x29, 0xcb,
|
||||||
0xec, 0x2a, 0x79, 0xef, 0x4e, 0xcc, 0x63, 0xae, 0x44, 0xaf, 0x5c, 0x55, 0xdc, 0x9e, 0x1d, 0x73,
|
0x18, 0x5a, 0xaf, 0xcb, 0x8e, 0x2c, 0x6f, 0x3c, 0x88, 0x58, 0xc4, 0x64, 0xd1, 0x2d, 0xbf, 0x2a,
|
||||||
0x1e, 0x4f, 0xa9, 0xa7, 0x76, 0x61, 0xf1, 0xc5, 0x8b, 0x8a, 0x8c, 0xe4, 0x09, 0x4f, 0x2b, 0xdd,
|
0xdd, 0x86, 0x15, 0x31, 0x16, 0x8d, 0x88, 0x2b, 0xff, 0x82, 0xfc, 0xb3, 0x3b, 0xcc, 0x53, 0x9c,
|
||||||
0xf9, 0xba, 0x01, 0x83, 0x23, 0x9e, 0x4a, 0x9a, 0xca, 0x42, 0x7e, 0x50, 0x2f, 0xe0, 0x43, 0xb8,
|
0xc5, 0x2c, 0xa9, 0xea, 0xf6, 0x8f, 0x05, 0xe8, 0xed, 0xb3, 0x44, 0x90, 0x44, 0xe4, 0xe2, 0x83,
|
||||||
0x15, 0x4e, 0xf9, 0xe4, 0xdc, 0x42, 0x23, 0x74, 0x60, 0x3e, 0xd9, 0x77, 0xdb, 0x6f, 0xb9, 0xe3,
|
0xec, 0x80, 0x76, 0x60, 0x29, 0x18, 0xb1, 0xf0, 0xdc, 0x34, 0xb6, 0x8c, 0xed, 0xce, 0x8b, 0x4d,
|
||||||
0x52, 0xae, 0x68, 0xbf, 0x62, 0xf1, 0x0b, 0xe8, 0xd2, 0x59, 0x12, 0xd1, 0x74, 0x42, 0xad, 0x0d,
|
0x67, 0xbe, 0x97, 0x33, 0x28, 0xcb, 0x95, 0xda, 0xab, 0xb4, 0xe8, 0x0d, 0xb4, 0xc8, 0x45, 0x3c,
|
||||||
0xe5, 0x1b, 0x5d, 0xf7, 0xbd, 0xa9, 0x89, 0xda, 0xfa, 0xdf, 0x81, 0x5f, 0x42, 0x6f, 0x46, 0xa6,
|
0x24, 0x49, 0x48, 0xcc, 0x05, 0xc9, 0x6d, 0xdd, 0xe5, 0xde, 0x2a, 0x85, 0x42, 0xa7, 0x04, 0xda,
|
||||||
0x49, 0x44, 0x72, 0x9e, 0x59, 0x86, 0xb2, 0x3f, 0xb8, 0x6e, 0xff, 0xac, 0x91, 0xda, 0xdf, 0x78,
|
0x85, 0xf6, 0x05, 0x1e, 0xc5, 0x43, 0x9c, 0xb1, 0xd4, 0x6c, 0x4a, 0xfc, 0xc9, 0x5d, 0xfc, 0x93,
|
||||||
0xf0, 0x73, 0xd8, 0x9e, 0xd1, 0x4c, 0x26, 0x3c, 0xb5, 0x36, 0x95, 0x7d, 0x78, 0x83, 0xbd, 0x02,
|
0x96, 0x28, 0xbe, 0x66, 0xd0, 0x6b, 0x58, 0xb9, 0x20, 0xa9, 0x88, 0x59, 0x62, 0x2e, 0x4a, 0xbc,
|
||||||
0x6a, 0xb3, 0xe6, 0x9d, 0x23, 0x30, 0xaf, 0xe4, 0xc1, 0xf7, 0xa1, 0xc7, 0xc8, 0x3c, 0x08, 0x17,
|
0xff, 0x17, 0xbc, 0x12, 0x28, 0x58, 0xeb, 0xcb, 0xde, 0x59, 0x4c, 0x89, 0xc8, 0x30, 0xe5, 0xe6,
|
||||||
0x39, 0x95, 0xaa, 0x01, 0xc3, 0xef, 0x32, 0x32, 0x1f, 0x97, 0x7b, 0x7c, 0x17, 0xb6, 0x4b, 0x31,
|
0xd2, 0xbf, 0x7a, 0x9f, 0x68, 0x89, 0xee, 0x3d, 0x65, 0xec, 0x7d, 0xe8, 0xdc, 0x32, 0x04, 0x3d,
|
||||||
0x26, 0x52, 0x85, 0x34, 0xfc, 0x2d, 0x46, 0xe6, 0xc7, 0x44, 0x3a, 0x3f, 0x11, 0xec, 0xac, 0xa7,
|
0x86, 0x36, 0xc5, 0x63, 0x3f, 0x28, 0x32, 0x22, 0xa4, 0x85, 0x4d, 0xaf, 0x45, 0xf1, 0x78, 0x50,
|
||||||
0xc3, 0x8f, 0x00, 0x97, 0x2c, 0x89, 0x69, 0x90, 0x16, 0x2c, 0x50, 0x35, 0xe9, 0x1b, 0x07, 0x8c,
|
0xfe, 0xa3, 0x87, 0xb0, 0x52, 0x16, 0x23, 0x2c, 0xa4, 0x4b, 0x4d, 0x6f, 0x99, 0xe2, 0xf1, 0x21,
|
||||||
0xcc, 0x5f, 0xc5, 0xf4, 0x7d, 0xc1, 0xd4, 0xd3, 0x12, 0x9f, 0xc0, 0xae, 0x86, 0xf5, 0x0f, 0xd5,
|
0x16, 0xf6, 0x77, 0x03, 0xd6, 0x66, 0xed, 0x41, 0xcf, 0x00, 0x95, 0x5a, 0x1c, 0x11, 0x3f, 0xc9,
|
||||||
0x35, 0xde, 0x73, 0xab, 0x2f, 0x74, 0xf5, 0x17, 0xba, 0xaf, 0x6b, 0x60, 0xdc, 0xbd, 0xf8, 0x3d,
|
0xa9, 0x2f, 0x7d, 0xd6, 0x37, 0xf6, 0x28, 0x1e, 0xef, 0x45, 0xe4, 0x7d, 0x4e, 0x65, 0x6b, 0x81,
|
||||||
0xec, 0x7c, 0xff, 0x33, 0x44, 0xfe, 0x4e, 0x75, 0x9f, 0x56, 0xd6, 0x43, 0x18, 0xeb, 0x21, 0x9c,
|
0x8e, 0x61, 0x5d, 0x8b, 0xf5, 0x8a, 0xd5, 0x1e, 0x1e, 0x39, 0x55, 0x06, 0x1c, 0x9d, 0x01, 0xe7,
|
||||||
0xa7, 0x30, 0x68, 0x35, 0x89, 0x1d, 0xe8, 0x8b, 0x22, 0x0c, 0xce, 0xe9, 0x22, 0x50, 0x5d, 0x59,
|
0x40, 0x09, 0x06, 0xad, 0xcb, 0x5f, 0xfd, 0xc6, 0xd7, 0xeb, 0xbe, 0xe1, 0xad, 0x55, 0xf7, 0xe9,
|
||||||
0x68, 0x64, 0x1c, 0xf4, 0x7c, 0x53, 0x14, 0xe1, 0x3b, 0xba, 0xf8, 0x58, 0x1e, 0x39, 0x8f, 0xa1,
|
0xca, 0xec, 0x10, 0xcd, 0xd9, 0x21, 0xec, 0x97, 0xd0, 0x9b, 0x5b, 0x05, 0xb2, 0xa1, 0xcb, 0xf3,
|
||||||
0xbf, 0xd6, 0x20, 0x1e, 0x82, 0x49, 0x84, 0x08, 0x74, 0xef, 0x65, 0xb2, 0x4d, 0x1f, 0x88, 0x10,
|
0xc0, 0x3f, 0x27, 0x85, 0x2f, 0xfd, 0x32, 0x8d, 0xad, 0xe6, 0x76, 0xdb, 0xeb, 0xf0, 0x3c, 0x78,
|
||||||
0x35, 0xe6, 0x9c, 0xc2, 0xed, 0xb7, 0x44, 0x9e, 0xd1, 0xa8, 0x36, 0x3c, 0x84, 0x81, 0x6a, 0x21,
|
0x47, 0x8a, 0x93, 0xf2, 0xc8, 0x7e, 0x0e, 0xdd, 0x99, 0x15, 0xa0, 0x3e, 0x74, 0x30, 0xe7, 0xbe,
|
||||||
0x68, 0x17, 0xdc, 0x57, 0xc7, 0x27, 0xba, 0x65, 0x07, 0xfa, 0x0d, 0xd7, 0x74, 0x6d, 0x6a, 0xea,
|
0x5e, 0x5c, 0x39, 0xd9, 0xa2, 0x07, 0x98, 0x73, 0x25, 0xb3, 0xaf, 0x0d, 0xe8, 0xcd, 0x19, 0x8f,
|
||||||
0x98, 0xc8, 0xf1, 0xa7, 0x1f, 0x4b, 0x1b, 0x5d, 0x2c, 0x6d, 0x74, 0xb9, 0xb4, 0xd1, 0xdf, 0xa5,
|
0x76, 0xa1, 0x85, 0xc3, 0x30, 0x4f, 0x71, 0x58, 0xa8, 0x80, 0xde, 0x6b, 0xc0, 0x29, 0x84, 0xf6,
|
||||||
0x8d, 0xbe, 0xad, 0xec, 0xce, 0xe5, 0xca, 0xee, 0xfc, 0x5a, 0xd9, 0x9d, 0xd3, 0x67, 0x71, 0x92,
|
0xa0, 0xcd, 0x53, 0x12, 0xc6, 0xe2, 0x3f, 0x2d, 0xaa, 0x29, 0x74, 0x04, 0x5d, 0x4a, 0x84, 0x90,
|
||||||
0x9f, 0x15, 0xa1, 0x3b, 0xe1, 0xcc, 0xbb, 0x3a, 0x48, 0xcd, 0xb2, 0x9a, 0x94, 0xf6, 0x90, 0x85,
|
0x66, 0x93, 0x11, 0x2e, 0x54, 0x64, 0xef, 0x75, 0xcd, 0xaa, 0x22, 0x0f, 0x4a, 0xd0, 0x3e, 0x85,
|
||||||
0x5b, 0xea, 0xfc, 0xf0, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x18, 0x54, 0x4f, 0xe1, 0x7f, 0x03,
|
0xd5, 0x23, 0x2c, 0xce, 0xc8, 0x50, 0x4d, 0xf7, 0x14, 0x7a, 0x72, 0xcf, 0xfe, 0x7c, 0x84, 0xba,
|
||||||
0x00, 0x00,
|
0xf2, 0xf8, 0x58, 0xe7, 0xc8, 0x86, 0x6e, 0xad, 0xab, 0xd3, 0xd4, 0xd1, 0xaa, 0x43, 0x2c, 0x06,
|
||||||
|
0x1f, 0xbf, 0x4d, 0x2c, 0xe3, 0x72, 0x62, 0x19, 0x57, 0x13, 0xcb, 0xf8, 0x3d, 0xb1, 0x8c, 0x2f,
|
||||||
|
0x37, 0x56, 0xe3, 0xea, 0xc6, 0x6a, 0xfc, 0xbc, 0xb1, 0x1a, 0xa7, 0xaf, 0xa2, 0x38, 0x3b, 0xcb,
|
||||||
|
0x03, 0x27, 0x64, 0xd4, 0xbd, 0xfd, 0xd6, 0xd4, 0x9f, 0xd5, 0x63, 0x32, 0xff, 0x0e, 0x05, 0xcb,
|
||||||
|
0xf2, 0x7c, 0xe7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x64, 0xc1, 0x5d, 0xa2, 0x04, 0x00,
|
||||||
|
0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ConsensusParams) Equal(that interface{}) bool {
|
func (this *ConsensusParams) Equal(that interface{}) bool {
|
||||||
@@ -451,6 +525,9 @@ func (this *ConsensusParams) Equal(that interface{}) bool {
|
|||||||
if !this.Version.Equal(that1.Version) {
|
if !this.Version.Equal(that1.Version) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if !this.Timestamp.Equal(that1.Timestamp) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (this *BlockParams) Equal(that interface{}) bool {
|
func (this *BlockParams) Equal(that interface{}) bool {
|
||||||
@@ -563,6 +640,36 @@ func (this *VersionParams) Equal(that interface{}) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
func (this *TimestampParams) Equal(that interface{}) bool {
|
||||||
|
if that == nil {
|
||||||
|
return this == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
that1, ok := that.(*TimestampParams)
|
||||||
|
if !ok {
|
||||||
|
that2, ok := that.(TimestampParams)
|
||||||
|
if ok {
|
||||||
|
that1 = &that2
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if that1 == nil {
|
||||||
|
return this == nil
|
||||||
|
} else if this == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if this.Accuracy != that1.Accuracy {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if this.Precision != that1.Precision {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if this.MessageDelay != that1.MessageDelay {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
func (this *HashedParams) Equal(that interface{}) bool {
|
func (this *HashedParams) Equal(that interface{}) bool {
|
||||||
if that == nil {
|
if that == nil {
|
||||||
return this == nil
|
return this == nil
|
||||||
@@ -610,6 +717,18 @@ func (m *ConsensusParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
|
if m.Timestamp != nil {
|
||||||
|
{
|
||||||
|
size, err := m.Timestamp.MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintParams(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x2a
|
||||||
|
}
|
||||||
if m.Version != nil {
|
if m.Version != nil {
|
||||||
{
|
{
|
||||||
size, err := m.Version.MarshalToSizedBuffer(dAtA[:i])
|
size, err := m.Version.MarshalToSizedBuffer(dAtA[:i])
|
||||||
@@ -719,12 +838,12 @@ func (m *EvidenceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
i--
|
i--
|
||||||
dAtA[i] = 0x18
|
dAtA[i] = 0x18
|
||||||
}
|
}
|
||||||
n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAgeDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAgeDuration):])
|
n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAgeDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAgeDuration):])
|
||||||
if err5 != nil {
|
if err6 != nil {
|
||||||
return 0, err5
|
return 0, err6
|
||||||
}
|
}
|
||||||
i -= n5
|
i -= n6
|
||||||
i = encodeVarintParams(dAtA, i, uint64(n5))
|
i = encodeVarintParams(dAtA, i, uint64(n6))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x12
|
dAtA[i] = 0x12
|
||||||
if m.MaxAgeNumBlocks != 0 {
|
if m.MaxAgeNumBlocks != 0 {
|
||||||
@@ -795,6 +914,53 @@ func (m *VersionParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *TimestampParams) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TimestampParams) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TimestampParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MessageDelay, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MessageDelay):])
|
||||||
|
if err7 != nil {
|
||||||
|
return 0, err7
|
||||||
|
}
|
||||||
|
i -= n7
|
||||||
|
i = encodeVarintParams(dAtA, i, uint64(n7))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x1a
|
||||||
|
n8, err8 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Precision, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Precision):])
|
||||||
|
if err8 != nil {
|
||||||
|
return 0, err8
|
||||||
|
}
|
||||||
|
i -= n8
|
||||||
|
i = encodeVarintParams(dAtA, i, uint64(n8))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
n9, err9 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Accuracy, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Accuracy):])
|
||||||
|
if err9 != nil {
|
||||||
|
return 0, err9
|
||||||
|
}
|
||||||
|
i -= n9
|
||||||
|
i = encodeVarintParams(dAtA, i, uint64(n9))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *HashedParams) Marshal() (dAtA []byte, err error) {
|
func (m *HashedParams) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
@@ -861,6 +1027,10 @@ func (m *ConsensusParams) Size() (n int) {
|
|||||||
l = m.Version.Size()
|
l = m.Version.Size()
|
||||||
n += 1 + l + sovParams(uint64(l))
|
n += 1 + l + sovParams(uint64(l))
|
||||||
}
|
}
|
||||||
|
if m.Timestamp != nil {
|
||||||
|
l = m.Timestamp.Size()
|
||||||
|
n += 1 + l + sovParams(uint64(l))
|
||||||
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,6 +1093,21 @@ func (m *VersionParams) Size() (n int) {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *TimestampParams) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Accuracy)
|
||||||
|
n += 1 + l + sovParams(uint64(l))
|
||||||
|
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Precision)
|
||||||
|
n += 1 + l + sovParams(uint64(l))
|
||||||
|
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MessageDelay)
|
||||||
|
n += 1 + l + sovParams(uint64(l))
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
func (m *HashedParams) Size() (n int) {
|
func (m *HashedParams) Size() (n int) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return 0
|
return 0
|
||||||
@@ -1117,6 +1302,42 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
|
case 5:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowParams
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if m.Timestamp == nil {
|
||||||
|
m.Timestamp = &TimestampParams{}
|
||||||
|
}
|
||||||
|
if err := m.Timestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipParams(dAtA[iNdEx:])
|
skippy, err := skipParams(dAtA[iNdEx:])
|
||||||
@@ -1498,6 +1719,155 @@ func (m *VersionParams) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (m *TimestampParams) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowParams
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: TimestampParams: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: TimestampParams: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Accuracy", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowParams
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Accuracy, dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Precision", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowParams
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Precision, dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 3:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field MessageDelay", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowParams
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MessageDelay, dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipParams(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthParams
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func (m *HashedParams) Unmarshal(dAtA []byte) error {
|
func (m *HashedParams) Unmarshal(dAtA []byte) error {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ message ConsensusParams {
|
|||||||
EvidenceParams evidence = 2;
|
EvidenceParams evidence = 2;
|
||||||
ValidatorParams validator = 3;
|
ValidatorParams validator = 3;
|
||||||
VersionParams version = 4;
|
VersionParams version = 4;
|
||||||
|
TimestampParams timestamp = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockParams contains limits on the block size.
|
// BlockParams contains limits on the block size.
|
||||||
@@ -60,6 +61,15 @@ message VersionParams {
|
|||||||
uint64 app_version = 1;
|
uint64 app_version = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message TimestampParams {
|
||||||
|
google.protobuf.Duration accuracy = 1
|
||||||
|
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
|
||||||
|
google.protobuf.Duration precision = 2
|
||||||
|
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
|
||||||
|
google.protobuf.Duration message_delay = 3
|
||||||
|
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
|
||||||
|
}
|
||||||
|
|
||||||
// HashedParams is a subset of ConsensusParams.
|
// HashedParams is a subset of ConsensusParams.
|
||||||
//
|
//
|
||||||
// It is hashed into the Header.ConsensusHash.
|
// It is hashed into the Header.ConsensusHash.
|
||||||
|
|||||||
@@ -883,7 +883,7 @@ func (commit *Commit) ValidateBasic() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if commit.Height >= 1 {
|
if commit.Height >= 1 {
|
||||||
if commit.BlockID.IsZero() {
|
if commit.BlockID.IsNil() {
|
||||||
return errors.New("commit cannot be for nil block")
|
return errors.New("commit cannot be for nil block")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1204,8 +1204,8 @@ func (blockID BlockID) ValidateBasic() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsZero returns true if this is the BlockID of a nil block.
|
// IsNil returns true if this is the BlockID of a nil block.
|
||||||
func (blockID BlockID) IsZero() bool {
|
func (blockID BlockID) IsNil() bool {
|
||||||
return len(blockID.Hash) == 0 &&
|
return len(blockID.Hash) == 0 &&
|
||||||
blockID.PartSetHeader.IsZero()
|
blockID.PartSetHeader.IsZero()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func CanonicalizeBlockID(bid tmproto.BlockID) *tmproto.CanonicalBlockID {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
var cbid *tmproto.CanonicalBlockID
|
var cbid *tmproto.CanonicalBlockID
|
||||||
if rbid == nil || rbid.IsZero() {
|
if rbid == nil || rbid.IsNil() {
|
||||||
cbid = nil
|
cbid = nil
|
||||||
} else {
|
} else {
|
||||||
cbid = &tmproto.CanonicalBlockID{
|
cbid = &tmproto.CanonicalBlockID{
|
||||||
|
|||||||
@@ -221,10 +221,6 @@ func (b *EventBus) PublishEventPolka(data EventDataRoundState) error {
|
|||||||
return b.Publish(EventPolkaValue, data)
|
return b.Publish(EventPolkaValue, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EventBus) PublishEventUnlock(data EventDataRoundState) error {
|
|
||||||
return b.Publish(EventUnlockValue, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *EventBus) PublishEventRelock(data EventDataRoundState) error {
|
func (b *EventBus) PublishEventRelock(data EventDataRoundState) error {
|
||||||
return b.Publish(EventRelockValue, data)
|
return b.Publish(EventRelockValue, data)
|
||||||
}
|
}
|
||||||
@@ -301,10 +297,6 @@ func (NopEventBus) PublishEventPolka(data EventDataRoundState) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (NopEventBus) PublishEventUnlock(data EventDataRoundState) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (NopEventBus) PublishEventRelock(data EventDataRoundState) error {
|
func (NopEventBus) PublishEventRelock(data EventDataRoundState) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,8 +362,6 @@ func TestEventBusPublish(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = eventBus.PublishEventPolka(EventDataRoundState{})
|
err = eventBus.PublishEventPolka(EventDataRoundState{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = eventBus.PublishEventUnlock(EventDataRoundState{})
|
|
||||||
require.NoError(t, err)
|
|
||||||
err = eventBus.PublishEventRelock(EventDataRoundState{})
|
err = eventBus.PublishEventRelock(EventDataRoundState{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = eventBus.PublishEventLock(EventDataRoundState{})
|
err = eventBus.PublishEventLock(EventDataRoundState{})
|
||||||
@@ -475,7 +473,6 @@ var events = []string{
|
|||||||
EventTimeoutProposeValue,
|
EventTimeoutProposeValue,
|
||||||
EventCompleteProposalValue,
|
EventCompleteProposalValue,
|
||||||
EventPolkaValue,
|
EventPolkaValue,
|
||||||
EventUnlockValue,
|
|
||||||
EventLockValue,
|
EventLockValue,
|
||||||
EventRelockValue,
|
EventRelockValue,
|
||||||
EventTimeoutWaitValue,
|
EventTimeoutWaitValue,
|
||||||
@@ -497,7 +494,6 @@ var queries = []tmpubsub.Query{
|
|||||||
EventQueryTimeoutPropose,
|
EventQueryTimeoutPropose,
|
||||||
EventQueryCompleteProposal,
|
EventQueryCompleteProposal,
|
||||||
EventQueryPolka,
|
EventQueryPolka,
|
||||||
EventQueryUnlock,
|
|
||||||
EventQueryLock,
|
EventQueryLock,
|
||||||
EventQueryRelock,
|
EventQueryRelock,
|
||||||
EventQueryTimeoutWait,
|
EventQueryTimeoutWait,
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ const (
|
|||||||
EventStateSyncStatusValue = "StateSyncStatus"
|
EventStateSyncStatusValue = "StateSyncStatus"
|
||||||
EventTimeoutProposeValue = "TimeoutPropose"
|
EventTimeoutProposeValue = "TimeoutPropose"
|
||||||
EventTimeoutWaitValue = "TimeoutWait"
|
EventTimeoutWaitValue = "TimeoutWait"
|
||||||
EventUnlockValue = "Unlock"
|
|
||||||
EventValidBlockValue = "ValidBlock"
|
EventValidBlockValue = "ValidBlock"
|
||||||
EventVoteValue = "Vote"
|
EventVoteValue = "Vote"
|
||||||
)
|
)
|
||||||
@@ -223,7 +222,6 @@ var (
|
|||||||
EventQueryTimeoutPropose = QueryForEvent(EventTimeoutProposeValue)
|
EventQueryTimeoutPropose = QueryForEvent(EventTimeoutProposeValue)
|
||||||
EventQueryTimeoutWait = QueryForEvent(EventTimeoutWaitValue)
|
EventQueryTimeoutWait = QueryForEvent(EventTimeoutWaitValue)
|
||||||
EventQueryTx = QueryForEvent(EventTxValue)
|
EventQueryTx = QueryForEvent(EventTxValue)
|
||||||
EventQueryUnlock = QueryForEvent(EventUnlockValue)
|
|
||||||
EventQueryValidatorSetUpdates = QueryForEvent(EventValidatorSetUpdatesValue)
|
EventQueryValidatorSetUpdates = QueryForEvent(EventValidatorSetUpdatesValue)
|
||||||
EventQueryValidBlock = QueryForEvent(EventValidBlockValue)
|
EventQueryValidBlock = QueryForEvent(EventValidBlockValue)
|
||||||
EventQueryVote = QueryForEvent(EventVoteValue)
|
EventQueryVote = QueryForEvent(EventVoteValue)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ type ConsensusParams struct {
|
|||||||
Evidence EvidenceParams `json:"evidence"`
|
Evidence EvidenceParams `json:"evidence"`
|
||||||
Validator ValidatorParams `json:"validator"`
|
Validator ValidatorParams `json:"validator"`
|
||||||
Version VersionParams `json:"version"`
|
Version VersionParams `json:"version"`
|
||||||
|
Timestamp TimestampParams `json:"timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HashedParams is a subset of ConsensusParams.
|
// HashedParams is a subset of ConsensusParams.
|
||||||
@@ -65,6 +66,14 @@ type EvidenceParams struct {
|
|||||||
MaxBytes int64 `json:"max_bytes"`
|
MaxBytes int64 `json:"max_bytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TimestampParams define the acceptable amount of clock skew among different
|
||||||
|
// validators on a network.
|
||||||
|
type TimestampParams struct {
|
||||||
|
Accuracy time.Duration `json:"accuracy"`
|
||||||
|
Precision time.Duration `json:"precision"`
|
||||||
|
MessageDelay time.Duration `json:"message_delay"`
|
||||||
|
}
|
||||||
|
|
||||||
// ValidatorParams restrict the public key types validators can use.
|
// ValidatorParams restrict the public key types validators can use.
|
||||||
// NOTE: uses ABCI pubkey naming, not Amino names.
|
// NOTE: uses ABCI pubkey naming, not Amino names.
|
||||||
type ValidatorParams struct {
|
type ValidatorParams struct {
|
||||||
@@ -235,6 +244,11 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusPa
|
|||||||
if params2.Version != nil {
|
if params2.Version != nil {
|
||||||
res.Version.AppVersion = params2.Version.AppVersion
|
res.Version.AppVersion = params2.Version.AppVersion
|
||||||
}
|
}
|
||||||
|
if params2.Timestamp != nil {
|
||||||
|
res.Timestamp.Accuracy = params2.Timestamp.Accuracy
|
||||||
|
res.Timestamp.Precision = params2.Timestamp.Precision
|
||||||
|
res.Timestamp.MessageDelay = params2.Timestamp.MessageDelay
|
||||||
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +269,11 @@ func (params *ConsensusParams) ToProto() tmproto.ConsensusParams {
|
|||||||
Version: &tmproto.VersionParams{
|
Version: &tmproto.VersionParams{
|
||||||
AppVersion: params.Version.AppVersion,
|
AppVersion: params.Version.AppVersion,
|
||||||
},
|
},
|
||||||
|
Timestamp: &tmproto.TimestampParams{
|
||||||
|
Accuracy: params.Timestamp.Accuracy,
|
||||||
|
Precision: params.Timestamp.Precision,
|
||||||
|
MessageDelay: params.Timestamp.MessageDelay,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,5 +294,10 @@ func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams
|
|||||||
Version: VersionParams{
|
Version: VersionParams{
|
||||||
AppVersion: pbParams.Version.AppVersion,
|
AppVersion: pbParams.Version.AppVersion,
|
||||||
},
|
},
|
||||||
|
Timestamp: TimestampParams{
|
||||||
|
Accuracy: pbParams.Timestamp.Accuracy,
|
||||||
|
Precision: pbParams.Timestamp.Precision,
|
||||||
|
MessageDelay: pbParams.Timestamp.MessageDelay,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func (vote *Vote) CommitSig() CommitSig {
|
|||||||
switch {
|
switch {
|
||||||
case vote.BlockID.IsComplete():
|
case vote.BlockID.IsComplete():
|
||||||
blockIDFlag = BlockIDFlagCommit
|
blockIDFlag = BlockIDFlagCommit
|
||||||
case vote.BlockID.IsZero():
|
case vote.BlockID.IsNil():
|
||||||
blockIDFlag = BlockIDFlagNil
|
blockIDFlag = BlockIDFlagNil
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Invalid vote %v - expected BlockID to be either empty or complete", vote))
|
panic(fmt.Sprintf("Invalid vote %v - expected BlockID to be either empty or complete", vote))
|
||||||
@@ -177,7 +177,7 @@ func (vote *Vote) ValidateBasic() error {
|
|||||||
|
|
||||||
// BlockID.ValidateBasic would not err if we for instance have an empty hash but a
|
// BlockID.ValidateBasic would not err if we for instance have an empty hash but a
|
||||||
// non-empty PartsSetHeader:
|
// non-empty PartsSetHeader:
|
||||||
if !vote.BlockID.IsZero() && !vote.BlockID.IsComplete() {
|
if !vote.BlockID.IsNil() && !vote.BlockID.IsComplete() {
|
||||||
return fmt.Errorf("blockID must be either empty or complete, got: %v", vote.BlockID)
|
return fmt.Errorf("blockID must be either empty or complete, got: %v", vote.BlockID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func TestVoteSet_AddVote_Good(t *testing.T) {
|
|||||||
assert.Nil(t, voteSet.GetByAddress(val0Addr))
|
assert.Nil(t, voteSet.GetByAddress(val0Addr))
|
||||||
assert.False(t, voteSet.BitArray().GetIndex(0))
|
assert.False(t, voteSet.BitArray().GetIndex(0))
|
||||||
blockID, ok := voteSet.TwoThirdsMajority()
|
blockID, ok := voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(), "there should be no 2/3 majority")
|
assert.False(t, ok || !blockID.IsNil(), "there should be no 2/3 majority")
|
||||||
|
|
||||||
vote := &Vote{
|
vote := &Vote{
|
||||||
ValidatorAddress: val0Addr,
|
ValidatorAddress: val0Addr,
|
||||||
@@ -44,7 +44,7 @@ func TestVoteSet_AddVote_Good(t *testing.T) {
|
|||||||
assert.NotNil(t, voteSet.GetByAddress(val0Addr))
|
assert.NotNil(t, voteSet.GetByAddress(val0Addr))
|
||||||
assert.True(t, voteSet.BitArray().GetIndex(0))
|
assert.True(t, voteSet.BitArray().GetIndex(0))
|
||||||
blockID, ok = voteSet.TwoThirdsMajority()
|
blockID, ok = voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(), "there should be no 2/3 majority")
|
assert.False(t, ok || !blockID.IsNil(), "there should be no 2/3 majority")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVoteSet_AddVote_Bad(t *testing.T) {
|
func TestVoteSet_AddVote_Bad(t *testing.T) {
|
||||||
@@ -145,7 +145,7 @@ func TestVoteSet_2_3Majority(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
blockID, ok := voteSet.TwoThirdsMajority()
|
blockID, ok := voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(), "there should be no 2/3 majority")
|
assert.False(t, ok || !blockID.IsNil(), "there should be no 2/3 majority")
|
||||||
|
|
||||||
// 7th validator voted for some blockhash
|
// 7th validator voted for some blockhash
|
||||||
{
|
{
|
||||||
@@ -156,7 +156,7 @@ func TestVoteSet_2_3Majority(t *testing.T) {
|
|||||||
_, err = signAddVote(privValidators[6], withBlockHash(vote, tmrand.Bytes(32)), voteSet)
|
_, err = signAddVote(privValidators[6], withBlockHash(vote, tmrand.Bytes(32)), voteSet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
blockID, ok = voteSet.TwoThirdsMajority()
|
blockID, ok = voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(), "there should be no 2/3 majority")
|
assert.False(t, ok || !blockID.IsNil(), "there should be no 2/3 majority")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8th validator voted for nil.
|
// 8th validator voted for nil.
|
||||||
@@ -168,7 +168,7 @@ func TestVoteSet_2_3Majority(t *testing.T) {
|
|||||||
_, err = signAddVote(privValidators[7], vote, voteSet)
|
_, err = signAddVote(privValidators[7], vote, voteSet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
blockID, ok = voteSet.TwoThirdsMajority()
|
blockID, ok = voteSet.TwoThirdsMajority()
|
||||||
assert.True(t, ok || blockID.IsZero(), "there should be 2/3 majority for nil")
|
assert.True(t, ok || blockID.IsNil(), "there should be 2/3 majority for nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
blockID, ok := voteSet.TwoThirdsMajority()
|
blockID, ok := voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(),
|
assert.False(t, ok || !blockID.IsNil(),
|
||||||
"there should be no 2/3 majority")
|
"there should be no 2/3 majority")
|
||||||
|
|
||||||
// 67th validator voted for nil
|
// 67th validator voted for nil
|
||||||
@@ -212,7 +212,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
|
|||||||
_, err = signAddVote(privValidators[66], withBlockHash(vote, nil), voteSet)
|
_, err = signAddVote(privValidators[66], withBlockHash(vote, nil), voteSet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
blockID, ok = voteSet.TwoThirdsMajority()
|
blockID, ok = voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(),
|
assert.False(t, ok || !blockID.IsNil(),
|
||||||
"there should be no 2/3 majority: last vote added was nil")
|
"there should be no 2/3 majority: last vote added was nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
|
|||||||
_, err = signAddVote(privValidators[67], withBlockPartSetHeader(vote, blockPartsHeader), voteSet)
|
_, err = signAddVote(privValidators[67], withBlockPartSetHeader(vote, blockPartsHeader), voteSet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
blockID, ok = voteSet.TwoThirdsMajority()
|
blockID, ok = voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(),
|
assert.False(t, ok || !blockID.IsNil(),
|
||||||
"there should be no 2/3 majority: last vote added had different PartSetHeader Hash")
|
"there should be no 2/3 majority: last vote added had different PartSetHeader Hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
|
|||||||
_, err = signAddVote(privValidators[68], withBlockPartSetHeader(vote, blockPartsHeader), voteSet)
|
_, err = signAddVote(privValidators[68], withBlockPartSetHeader(vote, blockPartsHeader), voteSet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
blockID, ok = voteSet.TwoThirdsMajority()
|
blockID, ok = voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(),
|
assert.False(t, ok || !blockID.IsNil(),
|
||||||
"there should be no 2/3 majority: last vote added had different PartSetHeader Total")
|
"there should be no 2/3 majority: last vote added had different PartSetHeader Total")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
|
|||||||
_, err = signAddVote(privValidators[69], withBlockHash(vote, tmrand.Bytes(32)), voteSet)
|
_, err = signAddVote(privValidators[69], withBlockHash(vote, tmrand.Bytes(32)), voteSet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
blockID, ok = voteSet.TwoThirdsMajority()
|
blockID, ok = voteSet.TwoThirdsMajority()
|
||||||
assert.False(t, ok || !blockID.IsZero(),
|
assert.False(t, ok || !blockID.IsNil(),
|
||||||
"there should be no 2/3 majority: last vote added had different BlockHash")
|
"there should be no 2/3 majority: last vote added had different BlockHash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user