File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -2628,7 +2628,15 @@ func (bc *BlockChain) SetShardEndHeight(height *uint64) error {
26282628 return fmt .Errorf ("End height cannot be before start height" )
26292629 }
26302630
2631- if height != nil && bc .CurrentHeader ().Number .Uint64 () > * height {
2631+ currentHeight := bc .CurrentHeader ().Number .Uint64 ()
2632+
2633+ if height != nil && currentHeight > * height {
2634+
2635+ // Check that if its not an archive node and that the height is still within state range.
2636+ // TrieDirtyDisabled is set to true for archive nodes.
2637+ if ! bc .cacheConfig .TrieDirtyDisabled && currentHeight > bc .cacheConfig .StateHistory && * height < currentHeight - bc .cacheConfig .StateHistory {
2638+ return errors .New ("Cannot set height before chain state." )
2639+ }
26322640 // rollback
26332641 if err := bc .SetHead (* height ); err != nil {
26342642 return err
You can’t perform that action at this time.
0 commit comments