Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
3e0cd1a
Add `CMT_HOME` (or remove it?) (backport #983) (#999)
mergify[bot] Jun 19, 2023
36ceb60
build(deps): Bump bufbuild/buf-setup-action from 1.21.0 to 1.22.0 (#1…
dependabot[bot] Jun 26, 2023
b60b805
docs: Added double quotes to /abci_query path param (#1015) (#1046)
mergify[bot] Jun 28, 2023
5806f5a
Clarifies that processProposal may be called for set of transactions …
mergify[bot] Jun 29, 2023
75f090d
v0.37.x: backport of new content on spec/p2p (#1004)
Jun 29, 2023
c7eed7e
build(deps): Bump bufbuild/buf-setup-action from 1.22.0 to 1.23.1 (#1…
dependabot[bot] Jul 4, 2023
c6d6c7c
build(deps): Bump docker/setup-buildx-action from 2.7.0 to 2.8.0 (#1062)
dependabot[bot] Jul 4, 2023
e94a9dd
build(deps): Bump docker/setup-buildx-action from 2.8.0 to 2.9.0 (#1104)
dependabot[bot] Jul 10, 2023
edffdc5
build(deps): Bump docker/setup-buildx-action from 2.9.0 to 2.9.1 (#1129)
dependabot[bot] Jul 17, 2023
75b81ab
build(deps): Bump bufbuild/buf-setup-action from 1.23.1 to 1.24.0 (#1…
dependabot[bot] Jul 17, 2023
f689a1c
p2p: Remove UPnP functionality (backport #1114) (#1126)
mergify[bot] Jul 17, 2023
20f3c57
crypto/sr25519: upgrade to go-schnorrkel@v1.0.0 (#1151)
Pitasi Jul 20, 2023
3f79321
build(deps): Bump bufbuild/buf-setup-action from 1.24.0 to 1.25.0 (#1…
dependabot[bot] Jul 24, 2023
7c001da
build(deps): Bump bufbuild/buf-setup-action from 1.25.0 to 1.25.1 (#1…
dependabot[bot] Aug 8, 2023
83ff5be
Close evidence.db OnStop (#1210) (#1225)
mergify[bot] Aug 10, 2023
88ce9ee
Log proposer's address when correctly accepting a proposal (backport …
mergify[bot] Aug 10, 2023
4560c11
build(deps): Bump bufbuild/buf-setup-action from 1.25.1 to 1.26.0 (#1…
dependabot[bot] Aug 14, 2023
80cfaed
build(deps): Bump bufbuild/buf-setup-action from 1.26.0 to 1.26.1 (#1…
dependabot[bot] Aug 21, 2023
cfc87ac
build(deps): Bump docker/setup-buildx-action from 2.9.1 to 2.10.0 (#1…
dependabot[bot] Sep 4, 2023
790d57e
feat: make handshake cancelable (backport #857) (#1013)
Sep 5, 2023
11f2dcc
build(deps): Bump docker/build-push-action from 4.1.1 to 4.2.1 (#1314)
dependabot[bot] Sep 11, 2023
11f6090
build(deps): Bump actions/checkout from 3 to 4 (#1315)
dependabot[bot] Sep 11, 2023
be0df2e
Fix typo: exent -> event (#1329)
p-offtermatt Sep 12, 2023
63ef8c8
build(deps): Bump docker/build-push-action from 4.2.1 to 5.0.0 (#1356)
dependabot[bot] Sep 20, 2023
bf8fd8c
build(deps): Bump docker/login-action from 2.2.0 to 3.0.0 (#1359)
dependabot[bot] Sep 20, 2023
24d3670
build(deps): Bump docker/setup-buildx-action from 2.10.0 to 3.0.0 (#1…
dependabot[bot] Sep 20, 2023
46df7b5
build(deps): Bump goreleaser/goreleaser-action from 4 to 5 (#1357)
dependabot[bot] Sep 20, 2023
8d18d1d
Update to string (#1385) (#1390)
mergify[bot] Sep 23, 2023
cd9d6d7
doc: improve documentation of BlockParams.MaxBytes (backport #1405) (…
mergify[bot] Sep 28, 2023
fb5f179
update language (backport #1263) (#1268)
mergify[bot] Oct 3, 2023
8b3bad5
build(deps): Bump styfle/cancel-workflow-action from 0.11.0 to 0.12.0…
dependabot[bot] Oct 10, 2023
fe17b83
build(deps): Bump bufbuild/buf-setup-action from 1.26.1 to 1.27.0 (#1…
dependabot[bot] Oct 10, 2023
05b2347
build(deps): Bump pillow from 9.3.0 to 10.0.1 in /scripts/qa/reportin…
mergify[bot] Oct 18, 2023
522f666
build(deps): Bump bufbuild/buf-setup-action from 1.27.0 to 1.27.1 (#1…
dependabot[bot] Oct 23, 2023
ca5cbfb
state: node bootstrap in v0.37.x (#1514)
jmalicevic Oct 26, 2023
60ee8ca
indexer-respect-height-params-on-query (backport #1529) (#1543)
mergify[bot] Oct 26, 2023
f565f92
build(deps): Bump bufbuild/buf-setup-action from 1.27.1 to 1.27.2 (#1…
dependabot[bot] Oct 30, 2023
36c3976
Updates grpc and net dependencies to avoid https://pkg.go.dev/vuln/GO…
lasarojc Nov 10, 2023
46951c9
mempool: Add metric size of pool in bytes (backport #1512) (#1567)
mergify[bot] Nov 12, 2023
5b1e711
build(deps): Bump bufbuild/buf-setup-action from 1.27.2 to 1.28.0 (#1…
dependabot[bot] Nov 13, 2023
47ffffa
Backports #1558 and #1584 to 0.38.x (#1592) (#1611)
lasarojc Nov 15, 2023
8b25893
This commit makes the test be the same as in main, that is, it ignore…
lasarojc Nov 16, 2023
9d26fa4
v0.37.x: Bump Go version to v1.21 (#1625)
thanethomson Nov 16, 2023
4c6e83d
Update SECURITY.md (backport #1626) (#1634)
mergify[bot] Nov 16, 2023
7a084a1
Comment that feature only applies to v0 mempool (#1631)
hvanz Nov 16, 2023
b640900
Release v0.37.3 (#1640)
thanethomson Nov 17, 2023
8c17e63
proto: Prepare for publishing v0.37.x protos to Buf registry (#1646)
thanethomson Nov 17, 2023
f474267
proto: Update README (backport #1648) (#1652)
mergify[bot] Nov 17, 2023
9e9064f
build(deps): Bump docker/build-push-action from 5.0.0 to 5.1.0 (#1656)
dependabot[bot] Nov 20, 2023
cf52e51
build(deps): Bump bufbuild/buf-setup-action from 1.28.0 to 1.28.1 (#1…
dependabot[bot] Nov 20, 2023
c89ad98
v0.37.x: Restore minimum Go version (#1669)
thanethomson Nov 20, 2023
ba3c8d8
mempool: add `nop` mempool (backport #1643) (#1681)
mergify[bot] Nov 23, 2023
656c1e4
docs: various small improvements (part 2) (backport #1683) (#1686)
mergify[bot] Nov 23, 2023
7dae514
Do not block indefinitely on the semaphore (backport #1654) (#1689)
mergify[bot] Nov 24, 2023
cce2e5d
Release v0.37.4 (#1699)
lasarojc Nov 27, 2023
936d5cc
types: validate Validator#Address field (backport #1715) (#1722)
mergify[bot] Dec 2, 2023
b9e4fe6
fix: increase abci socket message size limit to 2GB (backport #1730) …
mergify[bot] Dec 5, 2023
68cd34a
fix: Txs Validate (#1687) (#1752)
mergify[bot] Dec 5, 2023
bb0c411
Update CODE_OF_CONDUCT.md (#1708) (#1767)
mergify[bot] Dec 7, 2023
1b0372e
[e2e] Fixes prepareProposal not to return oversized set of transactio…
mergify[bot] Dec 7, 2023
cefbecd
Add test missing in #1687 (backport #1712) (#1760)
mergify[bot] Dec 8, 2023
4d6b504
build(deps): Bump actions/setup-go from 4 to 5 (#1792)
dependabot[bot] Dec 11, 2023
8b360e1
build(deps): Bump actions/stale from 8 to 9 (#1793)
dependabot[bot] Dec 11, 2023
43cfd0d
Introduce `countAllSignatures` in `VerifyCommitLight` & `VerifyCommit…
sergio-mena Dec 13, 2023
e2be737
Add changelog for #1749 (#1807) (#1820)
mergify[bot] Dec 13, 2023
8cba200
ci: fix failing golangci-lint action (#1833)
melekes Dec 18, 2023
5bbb06b
consensus: return last saved BeginBlock, not a empty one (#1782)
melekes Dec 18, 2023
4cb106a
build(deps): Bump actions/upload-artifact from 3 to 4 (#1840)
dependabot[bot] Dec 18, 2023
cde066f
Updates go crypto package to v0.17.0 (backport #1859) (#1864)
mergify[bot] Dec 19, 2023
b0127b5
Allow blocksync to not verify all signatures (backport #1858) (#1871)
mergify[bot] Dec 20, 2023
d0b139e
docs: Fix Discord links in README (backport #1874) (#1895)
mergify[bot] Jan 4, 2024
14aabc3
build(deps): Bump bufbuild/buf-setup-action from 1.28.1 to 1.29.0 (#2…
dependabot[bot] Jan 29, 2024
7b08918
build(deps): Bump slackapi/slack-github-action from 1.24.0 to 1.25.0 …
dependabot[bot] Jan 29, 2024
bd21a66
build(deps): Bump styfle/cancel-workflow-action from 0.12.0 to 0.12.1…
dependabot[bot] Jan 29, 2024
f379190
build(deps): Bump github.com/cloudflare/circl from 1.3.3 to 1.3.7 (ba…
mergify[bot] Feb 7, 2024
0401888
feat(consensus): additional sanity checks for the size of proposed bl…
mergify[bot] Feb 9, 2024
ad304d0
build(deps): Bump golangci/golangci-lint-action from 3 to 4 (#2297)
dependabot[bot] Feb 12, 2024
d954826
docs: images not rendering properly in docs (backport #2331) (#2339)
mergify[bot] Feb 14, 2024
1437879
ci: check metrics generation in CI checks (backport #2483) (#2486)
mergify[bot] Feb 29, 2024
0641e47
build(deps): Bump docker/setup-buildx-action from 3.0.0 to 3.1.0 (#2510)
dependabot[bot] Mar 4, 2024
a940dc8
build(deps): Bump docker/build-push-action from 5.1.0 to 5.2.0 (#2556)
dependabot[bot] Mar 11, 2024
3caf4a4
build(deps): Bump bufbuild/buf-setup-action from 1.29.0 to 1.30.0 (#2…
dependabot[bot] Mar 11, 2024
1bb0bd5
fix(docker-compose): fix subnet (backport #2383) (#2582)
mergify[bot] Mar 11, 2024
fd52ab7
feat(blocksync): set the max number of (concurrently) downloaded bloc…
melekes Mar 12, 2024
15d4d91
feat(blocksync): sort peers by download rate & multiple requests for …
mergify[bot] Mar 12, 2024
17419f9
fix(blocksync): use timer instead of time.After (backport #2584) (#2588)
mergify[bot] Mar 12, 2024
07493f4
Release v0.37.5 (#2591)
melekes Mar 13, 2024
0741a78
Merge tag 'v0.37.5' into HEAD
faddat Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
state: node bootstrap in v0.37.x (cometbft#1514)
* node/state:bootstrap state api (cometbft#1057)

* add bootstrap state cmd

* add a missing line

* Initial API impl

* Added error message for missing appHash

* Added changelog, removed cli

* Added PR number

* Unified hex encoding with rest of the code

* Applied PR review comments

* Proper blockstore initialization in case of offline statesync

* Reverted forcing blocksync, not needed for correct operation

* Added changelog and comments

* Removed printfs, added check for empty state store

* Fixed linter

* Apply minor suggestions from code review

Co-authored-by: Thane Thomson <connect@thanethomson.com>

* Moved the appHash check up

* Apply minor suggestions from code review

Co-authored-by: Sergio Mena <sergio@informal.systems>

* Apply suggestions from code review

Co-authored-by: Sergio Mena <sergio@informal.systems>

* Fixed linter

* Do not look for VE when starting up after offline statesync

* Extracted  check for offline statesync outside load commit

* Reconstruct seen commit after offline statesync

* Call reconstructSeenCommit from reconstructLastCommit

* Reading offline statesync height only once and passing it as a parameter

* Moved up option initialization to make sure offline statesync is enabled

* Added error to panic message

* Update consensus/state.go

Co-authored-by: Sergio Mena <sergio@informal.systems>

* Apply suggestions from code review

Co-authored-by: Sergio Mena <sergio@informal.systems>

* Adjusted new lines

* Added unit test to test int conversion and fixed linter

* Apply suggestions from code review

Co-authored-by: Thane Thomson <connect@thanethomson.com>

* Replaced closing ifs with defer, added errors to error messages

* linter fix

* Adapted bootstrap code to use proper genesis file functions

* Reverted genesis doc changes

* Moved deferred closing before checking for whether the store is empty

* Moved deferred close before error check

---------

Co-authored-by: HuangYi <huang@crypto.com>
Co-authored-by: yihuang <yi.codeplayer@gmail.com>
Co-authored-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Sergio Mena <sergio@informal.systems>

* Fixed cherry pick conflicts

* Removed go API changes in state store

* Remove breaking go API changes in the blocksync reactor

* Removed breaking changelog and fixed mocks

* [pair programming] Found a more readable way to add the methods needed for the store

* Removed duplicated code from blocksync reactor

* Apply suggestions from code review

Co-authored-by: Sergio Mena <sergio@informal.systems>

* Removed comments

* Removed unused variable from state

---------

Co-authored-by: HuangYi <huang@crypto.com>
Co-authored-by: yihuang <yi.codeplayer@gmail.com>
Co-authored-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Sergio Mena <sergio@informal.systems>
  • Loading branch information
5 people authored Oct 26, 2023
commit ca5cbfbec5ef569ea02874d75e6aab55e4bc6722
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/1057-bootstrap-state-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[node/state]` Add Go API to bootstrap block store and state store to a height
([\#1057](https://github.com/tendermint/tendermint/pull/#1057)) (@yihuang)
34 changes: 25 additions & 9 deletions blocksync/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,29 @@ type Reactor struct {
errorsCh <-chan peerError
}

// NewReactor returns new reactor instance.
func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore,
blockSync bool) *Reactor {

if state.LastBlockHeight != store.Height() {
panic(fmt.Sprintf("state (%v) and store (%v) height mismatch", state.LastBlockHeight,
store.Height()))
func NewReactorWithOfflineStateSync(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore,
blockSync bool, offlineStateSyncHeight int64) *Reactor {

storeHeight := store.Height()
if storeHeight == 0 {
// If state sync was performed offline and the stores were bootstrapped to height H
// the state store's lastHeight will be H while blockstore's Height and Base are still 0
// 1. This scenario should not lead to a panic in this case, which is indicated by
// having a OfflineStateSyncHeight > 0
// 2. We need to instruct the blocksync reactor to start fetching blocks from H+1
// instead of 0.
storeHeight = offlineStateSyncHeight
}
if state.LastBlockHeight != storeHeight {
panic(fmt.Sprintf("state (%v) and store (%v) height mismatch, stores were left in an inconsistent state", state.LastBlockHeight,
storeHeight))
}

requestsCh := make(chan BlockRequest, maxTotalRequesters)

const capacity = 1000 // must be bigger than peers count
errorsCh := make(chan peerError, capacity) // so we don't block in #Receive#pool.AddBlock

startHeight := store.Height() + 1
startHeight := storeHeight + 1
if startHeight == 1 {
startHeight = state.InitialHeight
}
Expand All @@ -93,6 +101,14 @@ func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockS
return bcR
}

// NewReactor returns new reactor instance.
func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore,
blockSync bool) *Reactor {

return NewReactorWithOfflineStateSync(state, blockExec, store, blockSync, 0)

}

// SetLogger implements service.Service by setting the logger on reactor and pool.
func (bcR *Reactor) SetLogger(l log.Logger) {
bcR.BaseService.Logger = l
Expand Down
12 changes: 8 additions & 4 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,21 @@ func NewState(
evsw: cmtevents.NewEventSwitch(),
metrics: NopMetrics(),
}

for _, option := range options {
option(cs)
}
// set function defaults (may be overwritten before calling Start)
cs.decideProposal = cs.defaultDecideProposal
cs.doPrevote = cs.defaultDoPrevote
cs.setProposal = cs.defaultSetProposal

// We have no votes, so reconstruct LastCommit from SeenCommit.
if state.LastBlockHeight > 0 {
// In case of out of band performed statesync, the state store
// will have a state but no extended commit (as no block has been downloaded).
// If the height at which the vote extensions are enabled is lower
// than the height at which we statesync, consensus will panic because
// it will try to reconstruct the extended commit here.
cs.reconstructLastCommit(state)
}

Expand All @@ -187,9 +194,6 @@ func NewState(
// NOTE: we do not call scheduleRound0 yet, we do that upon Start()

cs.BaseService = *service.NewBaseService(nil, "State", cs)
for _, option := range options {
option(cs)
}

return cs
}
Expand Down
143 changes: 137 additions & 6 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net"
"net/http"
"os"
"strings"
"time"

Expand All @@ -21,12 +22,13 @@ import (
cs "github.com/cometbft/cometbft/consensus"
"github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/evidence"
"github.com/cometbft/cometbft/light"

cmtjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
cmtpubsub "github.com/cometbft/cometbft/libs/pubsub"
"github.com/cometbft/cometbft/libs/service"
"github.com/cometbft/cometbft/light"

mempl "github.com/cometbft/cometbft/mempool"
mempoolv0 "github.com/cometbft/cometbft/mempool/v0"
mempoolv1 "github.com/cometbft/cometbft/mempool/v1" //nolint:staticcheck // SA1019 Priority mempool deprecated but still supported in this release.
Expand Down Expand Up @@ -188,6 +190,124 @@ func StateProvider(stateProvider statesync.StateProvider) Option {
}
}

// BootstrapState synchronizes the stores with the application after state sync
// has been performed offline. It is expected that the block store and state
// store are empty at the time the function is called.
//
// If the block store is not empty, the function returns an error.
func BootstrapState(ctx context.Context, config *cfg.Config, dbProvider DBProvider, height uint64, appHash []byte) (err error) {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
if ctx == nil {
ctx = context.Background()
}

if config == nil {
logger.Info("no config provided, using default configuration")
config = cfg.DefaultConfig()
}

if dbProvider == nil {
dbProvider = DefaultDBProvider
}
blockStore, stateDB, err := initDBs(config, dbProvider)

defer func() {
if derr := blockStore.Close(); derr != nil {
logger.Error("Failed to close blockstore", "err", derr)
// Set the return value
err = derr
}
}()

if err != nil {
return err
}

if !blockStore.IsEmpty() {
return fmt.Errorf("blockstore not empty, trying to initialize non empty state")
}

stateStore := sm.NewBootstrapStore(stateDB, sm.StoreOptions{
DiscardABCIResponses: config.Storage.DiscardABCIResponses,
})

defer func() {
if derr := stateStore.Close(); derr != nil {
logger.Error("Failed to close statestore", "err", derr)
// Set the return value
err = derr
}
}()
state, err := stateStore.Load()
if err != nil {
return err
}

if !state.IsEmpty() {
return fmt.Errorf("state not empty, trying to initialize non empty state")
}

genState, _, err := LoadStateFromDBOrGenesisDocProvider(stateDB, DefaultGenesisDocProviderFunc(config))
if err != nil {
return err
}

stateProvider, err := statesync.NewLightClientStateProvider(
ctx,
genState.ChainID, genState.Version, genState.InitialHeight,
config.StateSync.RPCServers, light.TrustOptions{
Period: config.StateSync.TrustPeriod,
Height: config.StateSync.TrustHeight,
Hash: config.StateSync.TrustHashBytes(),
}, logger.With("module", "light"))
if err != nil {
return fmt.Errorf("failed to set up light client state provider: %w", err)
}

state, err = stateProvider.State(ctx, height)
if err != nil {
return err
}
if appHash == nil {
logger.Info("warning: cannot verify appHash. Verification will happen when node boots up!")
} else {
if !bytes.Equal(appHash, state.AppHash) {
if err := blockStore.Close(); err != nil {
logger.Error("failed to close blockstore: %w", err)
}
if err := stateStore.Close(); err != nil {
logger.Error("failed to close statestore: %w", err)
}
return fmt.Errorf("the app hash returned by the light client does not match the provided appHash, expected %X, got %X", state.AppHash, appHash)
}
}

commit, err := stateProvider.Commit(ctx, height)
if err != nil {
return err
}

if err = stateStore.Bootstrap(state); err != nil {
return err
}

err = blockStore.SaveSeenCommit(state.LastBlockHeight, commit)
if err != nil {
return err
}

// Once the stores are bootstrapped, we need to set the height at which the node has finished
// statesyncing. This will allow the blocksync reactor to fetch blocks at a proper height.
// In case this operation fails, it is equivalent to a failure in online state sync where the operator
// needs to manually delete the state and blockstores and rerun the bootstrapping process.
err = stateStore.SetOfflineStateSyncHeight(state.LastBlockHeight)
if err != nil {
return fmt.Errorf("failed to set synced height: %w", err)
}

return err
}

//------------------------------------------------------------------------------

// Node is the highest level interface to a full CometBFT node.
Expand Down Expand Up @@ -448,10 +568,11 @@ func createBlockchainReactor(config *cfg.Config,
blockStore *store.BlockStore,
blockSync bool,
logger log.Logger,
offlineStateSyncHeight int64,
) (bcReactor p2p.Reactor, err error) {
switch config.BlockSync.Version {
case "v0":
bcReactor = bc.NewReactor(state.Copy(), blockExec, blockStore, blockSync)
bcReactor = bc.NewReactorWithOfflineStateSync(state.Copy(), blockExec, blockStore, blockSync, offlineStateSyncHeight)
case "v1", "v2":
return nil, fmt.Errorf("block sync version %s has been deprecated. Please use v0", config.BlockSync.Version)
default:
Expand Down Expand Up @@ -718,7 +839,6 @@ func NewNode(config *cfg.Config,
metricsProvider, logger, options...)
}

// NewNodeWithContext is cancellable version of NewNode.
func NewNodeWithContext(ctx context.Context,
config *cfg.Config,
privValidator types.PrivValidator,
Expand All @@ -730,12 +850,13 @@ func NewNodeWithContext(ctx context.Context,
logger log.Logger,
options ...Option,
) (*Node, error) {

blockStore, stateDB, err := initDBs(config, dbProvider)
if err != nil {
return nil, err
}

stateStore := sm.NewStore(stateDB, sm.StoreOptions{
stateStore := sm.NewBootstrapStore(stateDB, sm.StoreOptions{
DiscardABCIResponses: config.Storage.DiscardABCIResponses,
})

Expand Down Expand Up @@ -830,9 +951,15 @@ func NewNodeWithContext(ctx context.Context,
evidencePool,
sm.BlockExecutorWithMetrics(smMetrics),
)

offlineStateSyncHeight := int64(0)
if blockStore.Height() == 0 {
offlineStateSyncHeight, err = stateStore.GetOfflineStateSyncHeight()
if err != nil && err.Error() != "value empty" {
panic(fmt.Sprintf("failed to retrieve statesynced height from store %s; expected state store height to be %v", err, state.LastBlockHeight))
}
}
// Make BlockchainReactor. Don't start block sync if we're doing a state sync first.
bcReactor, err := createBlockchainReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger)
bcReactor, err := createBlockchainReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger, offlineStateSyncHeight)
if err != nil {
return nil, fmt.Errorf("could not create blockchain reactor: %w", err)
}
Expand All @@ -848,6 +975,10 @@ func NewNodeWithContext(ctx context.Context,
config, state, blockExec, blockStore, mempool, evidencePool,
privValidator, csMetrics, stateSync || blockSync, eventBus, consensusLogger,
)
err = stateStore.SetOfflineStateSyncHeight(0)
if err != nil {
panic(fmt.Sprintf("failed to reset the offline state sync height %s", err))
}

// Set up state sync reactor, and schedule a sync if requested.
// FIXME The way we do phased startups (e.g. replay -> block sync -> consensus) is very messy,
Expand Down
8 changes: 8 additions & 0 deletions state/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ func SaveValidatorsInfo(db dbm.DB, height, lastHeightChanged int64, valSet *type
stateStore := dbStore{db, StoreOptions{DiscardABCIResponses: false}}
return stateStore.saveValidatorsInfo(height, lastHeightChanged, valSet)
}

func Int64ToBytes(val int64) []byte {
return int64ToBytes(val)
}

func Int64FromBytes(val []byte) int64 {
return int64FromBytes(val)
}
Loading