Skip to content

Commit

Permalink
Set LastProofHash when statesync
Browse files Browse the repository at this point in the history
  • Loading branch information
tnasu committed Jul 27, 2021
1 parent 2b03bf8 commit f24370b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions state/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ func (store dbStore) Bootstrap(state State) error {
return err
}

if err := store.saveVoterParams(height+1, state.VoterParams); err != nil {
if err := store.saveVoterParams(height, state.VoterParams); err != nil {
return err
}

if err := store.saveProofHash(height+1, state.LastProofHash); err != nil {
if err := store.saveProofHash(height, state.LastProofHash); err != nil {
return err
}
return store.db.SetSync(stateKey, state.Bytes())
Expand Down
9 changes: 9 additions & 0 deletions statesync/stateprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
"time"

"github.com/line/ostracon/crypto/vrf"

dbm "github.com/tendermint/tm-db"

"github.com/line/ostracon/libs/log"
Expand Down Expand Up @@ -169,6 +171,12 @@ func (s *lightClientStateProvider) State(ctx context.Context, height uint64) (sm
return sm.State{}, err
}

// VRF proof
proofHash, err := vrf.ProofToHash(lastLightBlock.Proof.Bytes())
if err != nil {
return sm.State{}, err
}

state.LastBlockHeight = lastLightBlock.Height
state.LastBlockTime = lastLightBlock.Time
state.LastBlockID = lastLightBlock.Commit.BlockID
Expand All @@ -179,6 +187,7 @@ func (s *lightClientStateProvider) State(ctx context.Context, height uint64) (sm
state.Voters = currentLightBlock.VoterSet
state.NextValidators = nextLightBlock.ValidatorSet
state.LastHeightValidatorsChanged = nextLightBlock.Height
state.LastProofHash = proofHash

// We'll also need to fetch consensus params via RPC, using light client verification.
primaryURL, ok := s.providers[s.lc.Primary()]
Expand Down

0 comments on commit f24370b

Please sign in to comment.