Browse Source

state sync: last consensus params height is not set (#5889)

pull/5891/head
Callum Waters 4 years ago
committed by GitHub
parent
commit
bada08c50c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions
  1. +2
    -1
      CHANGELOG_PENDING.md
  2. +2
    -1
      state/store.go
  3. +6
    -5
      statesync/stateprovider.go

+ 2
- 1
CHANGELOG_PENDING.md View File

@ -67,4 +67,5 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [blockchain/v1] [\#5701](https://github.com/tendermint/tendermint/pull/5701) Handle peers without blocks (@melekes) - [blockchain/v1] [\#5701](https://github.com/tendermint/tendermint/pull/5701) Handle peers without blocks (@melekes)
- [blockchain/v1] \#5711 Fix deadlock (@melekes) - [blockchain/v1] \#5711 Fix deadlock (@melekes)
- [evidence] \#5890 Add a buffer to evidence from consensus to avoid broadcasting and proposing evidence before the - [evidence] \#5890 Add a buffer to evidence from consensus to avoid broadcasting and proposing evidence before the
height of such an evidence has finished (@cmwaters)
height of such an evidence has finished (@cmwaters)
- [statesync] \#5889 Set `LastHeightConsensusParamsChanged` when bootstrapping Tendermint state (@cmwaters)

+ 2
- 1
state/store.go View File

@ -222,7 +222,8 @@ func (store dbStore) Bootstrap(state State) error {
return err return err
} }
if err := store.saveConsensusParamsInfo(height, height, state.ConsensusParams); err != nil {
if err := store.saveConsensusParamsInfo(height,
state.LastHeightConsensusParamsChanged, state.ConsensusParams); err != nil {
return err return err
} }


+ 6
- 5
statesync/stateprovider.go View File

@ -150,7 +150,7 @@ func (s *lightClientStateProvider) State(ctx context.Context, height uint64) (sm
if err != nil { if err != nil {
return sm.State{}, err return sm.State{}, err
} }
curLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, int64(height+1), time.Now())
currentLightBlock, err := s.lc.VerifyLightBlockAtHeight(ctx, int64(height+1), time.Now())
if err != nil { if err != nil {
return sm.State{}, err return sm.State{}, err
} }
@ -162,10 +162,10 @@ func (s *lightClientStateProvider) State(ctx context.Context, height uint64) (sm
state.LastBlockHeight = lastLightBlock.Height state.LastBlockHeight = lastLightBlock.Height
state.LastBlockTime = lastLightBlock.Time state.LastBlockTime = lastLightBlock.Time
state.LastBlockID = lastLightBlock.Commit.BlockID state.LastBlockID = lastLightBlock.Commit.BlockID
state.AppHash = curLightBlock.AppHash
state.LastResultsHash = curLightBlock.LastResultsHash
state.AppHash = currentLightBlock.AppHash
state.LastResultsHash = currentLightBlock.LastResultsHash
state.LastValidators = lastLightBlock.ValidatorSet state.LastValidators = lastLightBlock.ValidatorSet
state.Validators = curLightBlock.ValidatorSet
state.Validators = currentLightBlock.ValidatorSet
state.NextValidators = nextLightBlock.ValidatorSet state.NextValidators = nextLightBlock.ValidatorSet
state.LastHeightValidatorsChanged = nextLightBlock.Height state.LastHeightValidatorsChanged = nextLightBlock.Height
@ -179,12 +179,13 @@ func (s *lightClientStateProvider) State(ctx context.Context, height uint64) (sm
return sm.State{}, fmt.Errorf("unable to create RPC client: %w", err) return sm.State{}, fmt.Errorf("unable to create RPC client: %w", err)
} }
rpcclient := lightrpc.NewClient(primaryRPC, s.lc) rpcclient := lightrpc.NewClient(primaryRPC, s.lc)
result, err := rpcclient.ConsensusParams(ctx, &nextLightBlock.Height)
result, err := rpcclient.ConsensusParams(ctx, &currentLightBlock.Height)
if err != nil { if err != nil {
return sm.State{}, fmt.Errorf("unable to fetch consensus parameters for height %v: %w", return sm.State{}, fmt.Errorf("unable to fetch consensus parameters for height %v: %w",
nextLightBlock.Height, err) nextLightBlock.Height, err)
} }
state.ConsensusParams = result.ConsensusParams state.ConsensusParams = result.ConsensusParams
state.LastHeightConsensusParamsChanged = currentLightBlock.Height
return state, nil return state, nil
} }


Loading…
Cancel
Save