Skip to content

Commit b9f8e54

Browse files
authored
Removed supertagged (#4014)
1 parent 8efbbe9 commit b9f8e54

File tree

147 files changed

+972
-915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+972
-915
lines changed

benchmark/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Jmh / version := "1.37"
55
libraryDependencies ++= Seq(
66
"org.scodec" %% "scodec-core" % "2.3.3",
77
"org.eclipse.collections" % "eclipse-collections" % "13.0.0",
8-
"commons-codec" % "commons-codec" % "1.19.0"
8+
"commons-codec" % "commons-codec" % "1.20.0"
99
) ++ Dependencies.logDeps
1010

1111
// https://github.com/ktoso/sbt-jmh#adding-to-your-project

benchmark/src/test/scala/com/wavesplatform/RollbackBenchmark.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.wavesplatform.common.state.ByteStr
88
import com.wavesplatform.common.utils.EitherExt2.*
99
import com.wavesplatform.database.{RDB, RocksDBWriter}
1010
import com.wavesplatform.protobuf.transaction.PBRecipients
11-
import com.wavesplatform.state.{Portfolio, StateSnapshot}
11+
import com.wavesplatform.state.{Height, Portfolio, StateSnapshot}
1212
import com.wavesplatform.transaction.Asset.IssuedAsset
1313
import com.wavesplatform.transaction.assets.IssueTransaction
1414
import com.wavesplatform.transaction.{GenesisTransaction, Proofs, TxDecimals, TxPositiveAmount}
@@ -108,7 +108,7 @@ object RollbackBenchmark extends ScorexLogging {
108108

109109
log.info("Rolling back")
110110
val start = System.nanoTime()
111-
rocksDBWriter.rollbackTo(1)
111+
rocksDBWriter.rollbackTo(Height(1))
112112
val end = System.nanoTime()
113113
log.info(f"Rollback took ${(end - start) * 1e-6}%.3f ms")
114114
rocksDBWriter.close()

benchmark/src/test/scala/com/wavesplatform/state/RocksDBWriterBenchmark.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ object RocksDBWriterBenchmark {
9090

9191
val db = RocksDBWriter(rawDB, wavesSettings.blockchainSettings, wavesSettings.dbSettings, wavesSettings.enableLightMode)
9292

93-
def loadBlockInfoAt(height: Int): Option[(BlockMeta, Seq[(TxMeta, Transaction)])] =
93+
def loadBlockInfoAt(height: Height): Option[(BlockMeta, Seq[(TxMeta, Transaction)])] =
9494
loadBlockMetaAt(height).map { meta =>
95-
meta -> database.loadTransactions(Height(height), rawDB)
95+
meta -> database.loadTransactions(height, rawDB)
9696
}
9797

98-
def loadBlockMetaAt(height: Int): Option[BlockMeta] = rawDB.db.get(Keys.blockMetaAt(Height(height))).flatMap(BlockMeta.fromPb)
98+
def loadBlockMetaAt(height: Height): Option[BlockMeta] = rawDB.db.get(Keys.blockMetaAt(height)).flatMap(BlockMeta.fromPb)
9999

100100
val cba = CommonBlocksApi(db, loadBlockMetaAt, loadBlockInfoAt)
101101

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ lazy val `waves-node` = (project in file("."))
168168

169169
inScope(Global)(
170170
Seq(
171-
scalaVersion := "3.7.3",
171+
scalaVersion := "3.7.4",
172172
organization := "com.wavesplatform",
173173
organizationName := "Waves Platform",
174174
organizationHomepage := Some(url("https://wavesplatform.com")),

grpc-server/src/main/scala/com/wavesplatform/api/grpc/AccountsApiGrpcImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class AccountsApiGrpcImpl(commonApi: CommonAccountsApi)(implicit sc: Scheduler)
8989
ByteString.copyFrom(sender.bytes),
9090
Some(PBRecipients.create(recipient)),
9191
amount,
92-
height
92+
height.toInt
9393
)
9494
}
9595
responseObserver.completeWith(result)

grpc-server/src/main/scala/com/wavesplatform/api/grpc/AssetsApiGrpcImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ class AssetsApiGrpcImpl(assetsApi: CommonAssetsApi, accountsApi: CommonAccountsA
5959
},
6060
d.sponsorship,
6161
sequenceInBlock = d.sequenceInBlock,
62-
issueHeight = d.issueHeight
62+
issueHeight = d.issueHeight.toInt
6363
)
6464
}

grpc-server/src/main/scala/com/wavesplatform/api/grpc/BlocksApiGrpcImpl.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.wavesplatform.api.grpc.BlockRequest.Request
99
import com.wavesplatform.api.http.ApiError.BlockDoesNotExist
1010
import com.wavesplatform.protobuf.*
1111
import com.wavesplatform.protobuf.block.PBBlock
12-
import com.wavesplatform.state.TxMeta
12+
import com.wavesplatform.state.{Height, TxMeta}
1313
import com.wavesplatform.transaction.Transaction
1414
import io.grpc.stub.StreamObserver
1515
import monix.execution.Scheduler
@@ -20,18 +20,18 @@ class BlocksApiGrpcImpl(commonApi: CommonBlocksApi)(implicit sc: Scheduler) exte
2020
import BlocksApiGrpcImpl.*
2121

2222
override def getCurrentHeight(request: Empty): Future[Int] = {
23-
Future.successful(commonApi.currentHeight)
23+
Future.successful(commonApi.currentHeight.toInt)
2424
}
2525

2626
override def getBlockRange(request: BlockRangeRequest, responseObserver: StreamObserver[BlockWithHeight]): Unit = responseObserver.interceptErrors {
2727
val stream =
2828
if (request.includeTransactions)
2929
commonApi
30-
.blocksRange(request.fromHeight, request.toHeight)
30+
.blocksRange(Height(request.fromHeight), Height(request.toHeight))
3131
.map(toBlockWithHeight)
3232
else
3333
commonApi
34-
.metaRange(request.fromHeight, request.toHeight)
34+
.metaRange(Height(request.fromHeight), Height(request.toHeight))
3535
.map(toBlockWithHeight)
3636

3737
responseObserver.completeWith(request.filter match {
@@ -51,7 +51,7 @@ class BlocksApiGrpcImpl(commonApi: CommonBlocksApi)(implicit sc: Scheduler) exte
5151
else commonApi.meta(blockId.toByteStr).map(toBlockWithHeight)
5252

5353
case Request.Height(height) =>
54-
val actualHeight = if (height > 0) height else commonApi.currentHeight + height
54+
val actualHeight = if (height > 0) Height(height) else commonApi.currentHeight + height
5555
if (request.includeTransactions)
5656
commonApi
5757
.blockAtHeight(actualHeight)

grpc-server/src/main/scala/com/wavesplatform/api/grpc/TransactionsApiGrpcImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class TransactionsApiGrpcImpl(blockchain: Blockchain, commonApi: CommonTransacti
122122
commonApi.transactionById(txId.toByteStr).map { m =>
123123
val status = applicationStatusFromTxStatus(m.status)
124124

125-
TransactionStatus(txId, TransactionStatus.Status.CONFIRMED, m.height, status)
125+
TransactionStatus(txId, TransactionStatus.Status.CONFIRMED, m.height.toInt, status)
126126
}
127127
}
128128
.getOrElse(TransactionStatus(txId, TransactionStatus.Status.NOT_EXISTS))
@@ -153,7 +153,7 @@ private object TransactionsApiGrpcImpl {
153153
case _ => None
154154
}
155155

156-
TransactionResponse(transactionId, meta.height, Some(meta.transaction.toPB), status, invokeScriptResult)
156+
TransactionResponse(transactionId, meta.height.toInt, Some(meta.transaction.toPB), status, invokeScriptResult)
157157
}
158158

159159
def applicationStatusFromTxStatus(status: TxMeta.Status): ApplicationStatus.Recognized =

grpc-server/src/main/scala/com/wavesplatform/events/BlockchainUpdates.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.wavesplatform.common.state.ByteStr
55
import com.wavesplatform.events.api.grpc.protobuf.BlockchainUpdatesApiGrpc
66
import com.wavesplatform.events.settings.BlockchainUpdatesSettings
77
import com.wavesplatform.extensions.{Context, Extension}
8-
import com.wavesplatform.state.{Blockchain, StateSnapshot}
8+
import com.wavesplatform.state.{Blockchain, Height, StateSnapshot}
99
import com.wavesplatform.utils.{Schedulers, ScorexLogging}
1010
import io.grpc.netty.NettyServerBuilder
1111
import io.grpc.protobuf.services.ProtoReflectionServiceV1
@@ -65,10 +65,10 @@ class BlockchainUpdates(private val context: Context) extends Extension with Sco
6565

6666
if (extensionHeight > nodeHeight) {
6767
log.info(s"Rolling back from $extensionHeight to node height $nodeHeight")
68-
repo.rollbackData(nodeHeight)
68+
repo.rollbackData(Height(nodeHeight))
6969
}
7070

71-
val lastUpdateId = Try(ByteStr(repo.getBlockUpdate(nodeHeight).getUpdate.id.toByteArray)).toOption
71+
val lastUpdateId = Try(ByteStr(repo.getBlockUpdate(Height(nodeHeight)).getUpdate.id.toByteArray)).toOption
7272
val lastBlockId = context.blockchain.blockHeader(nodeHeight).map(_.id())
7373

7474
if (lastUpdateId != lastBlockId)

grpc-server/src/main/scala/com/wavesplatform/events/Loader.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.wavesplatform.events
22

3-
import com.google.common.primitives.Ints
43
import com.wavesplatform.api.common.CommonBlocksApi
54
import com.wavesplatform.api.grpc.*
65
import com.wavesplatform.common.state.ByteStr
76
import com.wavesplatform.common.utils.Base58
87
import com.wavesplatform.database.{DBExt, DBResource}
9-
import com.wavesplatform.events.protobuf.BlockchainUpdated.Append.Body
108
import com.wavesplatform.events.protobuf.BlockchainUpdated as PBBlockchainUpdated
9+
import com.wavesplatform.events.protobuf.BlockchainUpdated.Append.Body
1110
import com.wavesplatform.protobuf.*
1211
import com.wavesplatform.protobuf.block.PBBlock
12+
import com.wavesplatform.state.Height
1313
import com.wavesplatform.utils.ScorexLogging
1414
import monix.reactive.Observable
1515
import org.rocksdb.RocksDB
@@ -18,16 +18,16 @@ import scala.collection.mutable.ArrayBuffer
1818
import scala.util.{Failure, Success, Try}
1919

2020
class Loader(db: RocksDB, blocksApi: CommonBlocksApi, target: Option[(Int, ByteStr)], streamId: String) extends ScorexLogging {
21-
private def loadBatch(res: DBResource, fromHeight: Int): Try[Seq[PBBlockchainUpdated]] = Try {
22-
res.fullIterator.seek(Ints.toByteArray(fromHeight))
21+
private def loadBatch(res: DBResource, fromHeight: Height): Try[Seq[PBBlockchainUpdated]] = Try {
22+
res.fullIterator.seek(fromHeight.toByteArray)
2323
val buffer = ArrayBuffer[PBBlockchainUpdated]()
2424

25-
while (res.fullIterator.isValid && buffer.size < 100 && target.forall { case (h, _) => fromHeight + buffer.size <= h }) {
25+
while (res.fullIterator.isValid && buffer.size < 100 && target.forall { case (h, _) => fromHeight + buffer.size <= Height(h) }) {
2626
buffer.append(Loader.parseUpdate(res.fullIterator.value(), blocksApi, fromHeight + buffer.size))
2727
res.fullIterator.next()
2828
}
2929

30-
for ((h, id) <- target if h == fromHeight + buffer.size - 1; u <- buffer.lastOption) {
30+
for ((h, id) <- target if h == fromHeight.toInt + buffer.size - 1; u <- buffer.lastOption) {
3131
require(
3232
u.id.toByteArray.sameElements(id.arr),
3333
s"Stored update ${Base58.encode(u.id.toByteArray)} at ${u.height} does not match target $id at $h"
@@ -37,7 +37,7 @@ class Loader(db: RocksDB, blocksApi: CommonBlocksApi, target: Option[(Int, ByteS
3737
buffer.toSeq
3838
}
3939

40-
private def streamFrom(fromHeight: Int): Observable[PBBlockchainUpdated] = db.resourceObservable.flatMap { res =>
40+
private def streamFrom(fromHeight: Height): Observable[PBBlockchainUpdated] = db.resourceObservable.flatMap { res =>
4141
loadBatch(res, fromHeight) match {
4242
case Success(nextBatch) =>
4343
if (nextBatch.isEmpty) Observable.empty[PBBlockchainUpdated]
@@ -46,14 +46,14 @@ class Loader(db: RocksDB, blocksApi: CommonBlocksApi, target: Option[(Int, ByteS
4646
}
4747
}
4848

49-
def loadUpdates(fromHeight: Int): Observable[PBBlockchainUpdated] = {
49+
def loadUpdates(fromHeight: Height): Observable[PBBlockchainUpdated] = {
5050
log.trace(s"[$streamId] Loading stored updates from $fromHeight up to ${target.fold("the most recent one") { case (h, id) => s"$id at $h" }}")
5151
streamFrom(fromHeight)
5252
}
5353
}
5454

5555
object Loader {
56-
def parseUpdate(bs: Array[Byte], blocksApi: CommonBlocksApi, height: Int): PBBlockchainUpdated =
56+
def parseUpdate(bs: Array[Byte], blocksApi: CommonBlocksApi, height: Height): PBBlockchainUpdated =
5757
PBBlockchainUpdated
5858
.parseFrom(bs)
5959
.update(
@@ -68,7 +68,7 @@ object Loader {
6868
)
6969
)
7070

71-
def loadUpdate(res: DBResource, blocksApi: CommonBlocksApi, height: Int): PBBlockchainUpdated =
71+
def loadUpdate(res: DBResource, blocksApi: CommonBlocksApi, height: Height): PBBlockchainUpdated =
7272
parseUpdate(res.get(Repo.keyForHeight(height)), blocksApi, height)
7373

7474
}

0 commit comments

Comments
 (0)