Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] parity warp-like state sync #3594

Closed
wants to merge 1 commit into from

Conversation

ackratos
Copy link
Contributor

@ackratos ackratos commented Apr 25, 2019

follow up of #3243
A new state sync proposal: https://docs.google.com/document/d/1npGTAa1qxe8EQZ1wG0a0Sip9t5oX2vYZNUDwr_LVRR4/edit?usp=sharing

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

app: app,
config: config,
pool: pool,
stateSync: config.StateSync,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.StateSync undefined (type *config.Config has no field or method StateSync) (from typecheck)

}

func (mgr *SnapshotManager) restoreBlock(block *types.Block, seenCommit *types.Commit) {
mgr.blockStore.SetHeight(block.Height - 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mgr.blockStore.SetHeight undefined (type *blockchain.BlockStore has no field or method SetHeight) (from typecheck)

}

func (mgr *SnapshotManager) snapshotTMState() error {
if state := sm.LoadStateForHeight(mgr.stateDB, mgr.height); state != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoadStateForHeight not declared by package state (from typecheck)

node/node.go Outdated
@@ -351,6 +354,26 @@ func NewNode(config *cfg.Config,
evidenceReactor := evidence.NewEvidenceReactor(evidencePool)
evidenceReactor.SetLogger(evidenceLogger)

if state.Validators.Size() == 1 {
addr, _ := state.Validators.GetByIndex(0)
if bytes.Equal(privValidator.GetAddress(), addr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

privValidator.GetAddress undefined (type types.PrivValidator has no field or method GetAddress) (from typecheck)

if state.Validators.Size() == 1 {
addr, _ := state.Validators.GetByIndex(0)
if bytes.Equal(privValidator.GetAddress(), addr) {
config.StateSync = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.StateSync undefined (type *config.Config has no field or method StateSync) (from typecheck)

// numPending=0 total=0 outbound=1 inbound=0 height=6601 blocksSynced=0 poolHeight=6601 poolstarttime=2019-02-22T09:02:07.881888662Z poolMaxPeerHeight=6437 poolHeight=6601
// we need make sure blockstore has a block because when switch to consensus, it will verify the commit between block and state
// refer to `cs.blockStore.LoadSeenCommit(state.LastBlockHeight)`
if bcR.pool.IsCaughtUp() && (height == bcR.pool.initHeight || blocksSynced > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bcR.pool.initHeight undefined (type *BlockPool has no field or method initHeight) (from typecheck)

if state != nil {
bcR.initialState = *state
bcR.pool.height = state.LastBlockHeight + 1
bcR.store.SetHeight(state.LastBlockHeight)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bcR.store.SetHeight undefined (type *BlockStore has no field or method SetHeight) (from typecheck)

StateSyncChannel = byte(0x35)

// ====== move to config ======
stateSyncPriority = 10 // channel priority of state sync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not gofmt-ed with -s (from gofmt)

@@ -37,6 +37,7 @@ import (
grpccore "github.com/tendermint/tendermint/rpc/grpc"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/snapshot"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not gofmt-ed with -s (from gofmt)

"crypto/sha256"
"errors"
"fmt"
"github.com/golang/snappy"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not goimports-ed (from goimports)


func (mgr *SnapshotManager) snapshotTMState() error {
if state := sm.LoadStateForHeight(mgr.stateDB, mgr.height); state != nil {
stateChunk := &abci.StateChunk{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composites: github.com/tendermint/tendermint/abci/types.StateChunk composite literal uses unkeyed fields (from govet)

return fmt.Errorf("block %d to be snapshoted is not expected %d", block.Height, mgr.height)
}
seenCommit := mgr.blockStore.LoadSeenCommit(mgr.height)
blockChunk := &abci.BlockChunk{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composites: github.com/tendermint/tendermint/abci/types.BlockChunk composite literal uses unkeyed fields (from govet)

snapshot/pool.go Outdated
if manifest.Version == abci.ManifestVersion {
return hash, &manifest, nil
} else {
return hash, nil, fmt.Errorf("snapshot manifest version mismatch", "expected", abci.ManifestVersion, "actual", manifest.Version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printf: Errorf call has arguments but no formatting directives (from govet)

const latestStateToKeep int64 = 1 << 20

func calcStateKey(height int64) []byte {
return []byte(fmt.Sprintf("stateKey:%v", height % latestStateToKeep))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not gofmt-ed with -s (from gofmt)

mtx sync.Mutex
manifest *abci.Manifest
manifestHash abci.SHA256Sum
dummyHash abci.SHA256Sum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not gofmt-ed with -s (from gofmt)

@ackratos ackratos force-pushed the issue828_statesync2 branch 2 times, most recently from ecd10ba to ffa7978 Compare May 8, 2019 06:13
)

const (
ManifestVersion int32 = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not gofmt-ed with -s (from gofmt)

@tac0turtle tac0turtle changed the base branch from develop to master June 26, 2019 15:43
@tac0turtle
Copy link
Contributor

Will close this PR in favor of the discussion being made in #3769, @ackratos I see you have commented on the PR a bit, thank you for the contribution and helping drive state-sync forward. Any contributions that you can make will be invaluable.

@tac0turtle tac0turtle closed this Jul 6, 2019
@ackratos
Copy link
Contributor Author

ackratos commented Jul 8, 2019

Will close this PR in favor of the discussion being made in #3769, @ackratos I see you have commented on the PR a bit, thank you for the contribution and helping drive state-sync forward. Any contributions that you can make will be invaluable.

It's my honor. But I still prefer to open this PR for people's reference. If you think this PR is kind of broken, I can rebase the latest develop branch. Or you would like to accept PR until discussion in #3769 reaches a conclusion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants