diff --git a/pkg/app_manager.go b/pkg/app_manager.go index 08c3925..eff74eb 100644 --- a/pkg/app_manager.go +++ b/pkg/app_manager.go @@ -214,7 +214,7 @@ func (a *AppManager) ProcessSnapshot(block *types.Block) { blocksCount := a.StateManager.GetBlocksCountSinceLatest(a.Config.BlocksWindow) - neededBlocks := utils.MinInt64(a.Config.BlocksWindow, a.StateManager.GetLastBlockHeight()) + neededBlocks := utils.MinInt64(a.Config.BlocksWindow, a.StateManager.GetLastBlockHeight()-a.Config.FirstBlock) hasEnoughBlocks := blocksCount >= neededBlocks if !hasEnoughBlocks { diff --git a/pkg/config/chain.go b/pkg/config/chain.go index 481ba47..5fade49 100644 --- a/pkg/config/chain.go +++ b/pkg/config/chain.go @@ -23,6 +23,7 @@ type ChainConfig struct { BlocksWindow int64 `default:"10000" toml:"blocks-window"` MinSignedPerWindow float64 `default:"0.05" toml:"min-signed-per-window"` SnapshotsInterval int64 `default:"1" toml:"snapshots-interval"` + FirstBlock int64 `default:"0" toml:"first-block"` Pagination ChainPagination `toml:"pagination"` Intervals IntervalsConfig `toml:"intervals"` diff --git a/pkg/state/manager.go b/pkg/state/manager.go index 9a9a0c8..d288728 100644 --- a/pkg/state/manager.go +++ b/pkg/state/manager.go @@ -140,7 +140,7 @@ func (m *Manager) GetSnapshot() (snapshotPkg.Snapshot, error) { validators := m.state.GetValidators() entries := make(types.Entries, len(validators)) - neededBlocks := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight()) + neededBlocks := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight()-m.config.FirstBlock) for _, validator := range validators { // Taking the active status from the last block, as there might be a case @@ -238,7 +238,7 @@ func (m *Manager) GetBlockTime() time.Duration { } func (m *Manager) GetValidatorMissedBlocks(validator *types.Validator) (types.SignatureInto, error) { - blocksToCheck := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight()) + blocksToCheck := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight()-m.config.FirstBlock) return m.state.GetValidatorMissedBlocks(validator, blocksToCheck) }