From cacc4c7e3bb934bc2bc6a8339c1587959e72917f Mon Sep 17 00:00:00 2001
From: Alex Sharov <AskAlexSharov@gmail.com>
Date: Sun, 15 Aug 2021 16:47:44 +0700
Subject: [PATCH] fix integration trie nil pointer (#2533)

* fix integration trie

* fix integration trie
---
 cmd/integration/commands/snapshot_check.go | 2 +-
 cmd/integration/commands/stages.go         | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmd/integration/commands/snapshot_check.go b/cmd/integration/commands/snapshot_check.go
index c817d3c7d4..4cf29d2ac2 100644
--- a/cmd/integration/commands/snapshot_check.go
+++ b/cmd/integration/commands/snapshot_check.go
@@ -264,7 +264,7 @@ func snapshotCheck(ctx context.Context, db kv.RwDB, isNew bool, tmpDir string) (
 		stage6 := stage(sync, tx, nil, stages.IntermediateHashes)
 		stage6.BlockNumber = blockNumber - 1
 		log.Info("Stage6", "progress", stage6.BlockNumber)
-		if _, err = stagedsync.SpawnIntermediateHashesStage(stage5, nil /* Unwinder */, tx, stagedsync.StageTrieCfg(db, true, true, tmpDir), ctx); err != nil {
+		if _, err = stagedsync.SpawnIntermediateHashesStage(stage5, sync /* Unwinder */, tx, stagedsync.StageTrieCfg(db, true, true, tmpDir), ctx); err != nil {
 			log.Error("Error on ih", "err", err, "block", blockNumber)
 			return fmt.Errorf("spawnIntermediateHashesStage %w", err)
 		}
diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go
index 747585dca7..290fdb7be0 100644
--- a/cmd/integration/commands/stages.go
+++ b/cmd/integration/commands/stages.go
@@ -498,7 +498,10 @@ func stageTrie(db kv.RwDB, ctx context.Context) error {
 	defer tx.Rollback()
 
 	if reset {
-		return stagedsync.ResetIH(tx)
+		if err := stagedsync.ResetIH(tx); err != nil {
+			return err
+		}
+		return tx.Commit()
 	}
 	execStage := stage(sync, tx, nil, stages.Execution)
 	s := stage(sync, tx, nil, stages.IntermediateHashes)
@@ -529,7 +532,7 @@ func stageTrie(db kv.RwDB, ctx context.Context) error {
 			return err
 		}
 	} else {
-		if _, err := stagedsync.SpawnIntermediateHashesStage(s, nil /* Unwinder */, tx, cfg, ctx); err != nil {
+		if _, err := stagedsync.SpawnIntermediateHashesStage(s, sync /* Unwinder */, tx, cfg, ctx); err != nil {
 			return err
 		}
 	}
-- 
GitLab