From 102a53aa5279aef1507a85c572ce57405a29c0e3 Mon Sep 17 00:00:00 2001 From: Sergey Nazarov Date: Fri, 24 Sep 2021 17:17:56 +0300 Subject: [PATCH] Fix StateUpdate removal on rollback (#3549) --- .../scala/com/wavesplatform/events/BlockchainUpdates.scala | 2 +- .../src/main/scala/com/wavesplatform/events/Repo.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grpc-server/src/main/scala/com/wavesplatform/events/BlockchainUpdates.scala b/grpc-server/src/main/scala/com/wavesplatform/events/BlockchainUpdates.scala index 11d8ab5f1af..4953b974443 100644 --- a/grpc-server/src/main/scala/com/wavesplatform/events/BlockchainUpdates.scala +++ b/grpc-server/src/main/scala/com/wavesplatform/events/BlockchainUpdates.scala @@ -73,7 +73,7 @@ class BlockchainUpdates(private val context: Context) extends Extension with Sco if (lastUpdateId != lastBlockId) throw new IllegalStateException(s"Last update ID $lastUpdateId does not match last block ID $lastBlockId at height $nodeHeight") - log.info(s"BlockchainUpdates startup check successful at height $extensionHeight") + log.info(s"BlockchainUpdates startup check successful at height $nodeHeight") grpcServer.start() log.info(s"BlockchainUpdates extension started gRPC API on port ${settings.grpcPort}") diff --git a/grpc-server/src/main/scala/com/wavesplatform/events/Repo.scala b/grpc-server/src/main/scala/com/wavesplatform/events/Repo.scala index 9f5671df90c..80648cae19e 100644 --- a/grpc-server/src/main/scala/com/wavesplatform/events/Repo.scala +++ b/grpc-server/src/main/scala/com/wavesplatform/events/Repo.scala @@ -98,7 +98,7 @@ class Repo(dbDirectory: String, blocksApi: CommonBlocksApi)(implicit s: Schedule log.debug(s"Rolling back to $toHeight") var buf: List[BlockAppended] = Nil Using(rw.newIterator) { iter => - iter.seek(Ints.toByteArray(toHeight + 1)) + iter.seek(keyForHeight(toHeight + 1)) while (iter.hasNext) { val e = iter.next() val height = Ints.fromByteArray(e.getKey) @@ -110,7 +110,7 @@ class Repo(dbDirectory: String, blocksApi: CommonBlocksApi)(implicit s: Schedule (1 to buf.size).foreach { offset => val height = toHeight + offset log.debug(s"Deleting update at $height") - rw.delete(Ints.toByteArray(height)) + rw.delete(keyForHeight(height)) } buf