Skip to content

Commit 693484d

Browse files
authored
OpenAPI and improvements (#4034)
* OpenAPI: - /transactions/sign: added an info about new fields to description - New components: BlsPublicKey, BlsSignature, GeneratorIndex, BlockEndorsement, FinalizationVoting - Added finalizationVoting to block headers * Better logs and more filters for endorsements (exclusion of miner endorsements) * OpenAPI: Added CommitToGenerationTransaction * OpenAPI: added /addresses/bls/{address} * OpenAPI, added: - GET /blocks/height/finalized - GET /blocks/headers/finalized - GET /blocks/finalized/at/{height} * OpenAPI: New fields "nextCommittedGeneratorsHash" and "committedGeneratorBalancesHash" in `/debug/stateHash/last` and `/debug/stateHash/{height}` after finality feature activation * OpenAPI: new endpoint `/generators/at/{height}` * OpenAPI: new field nextCommittedGenerators in TransactionSnapshot * OpenAPI: only few transaction types has `feeAssetId`: InvokeExpressionTransaction, InvokeScriptTransaction, TransferTransaction, UpdateAssetInfoTransaction * Updated tests * Forced rollback fix * Updated Swagger UI to 5.31.1 * Swagger UI: enable "Try it" mode always, hide "Try it out" button * Swagger UI: Disable "Explore" functionality * Swagger UI: Disable choosing other server * OpenAPI: transaction schema changes to help Swagger UI show precise types instead of "object" * OpenAPI: - Added WavesOrAssetId and DebugStateHashes schemas - Eliminate deprecated "nullable" - Right types for assetId-like fields - Chores * OpenAPI: Added AssetPair * DB Keys: ported finalizedHeight parsing * Open API: Fixes * Removed obsolete code * New balance tests, common error format WIP * New balance tests, common error format WIP (2) * HTTP API: TransactionId and BlockId matchers blocked route fallback by throwing * CommitToGenerationTransaction: precise balance validation * Fixed a keyblock validation against the latest removed microblock * New test for appending after removing the last microblock * Added comments * Fixed tests, backported MiningFailuresSuite * Additional test * Miner forges after right liquid block * Additional test in LastMicroBlockSuite * Do not try to apply same block twice * Fixed order of logs * Fixed liquid block forging * Finalization height and voting from right liquid block, NgState refactor * Refactor NgState (2): VectorMap instead of Vector+List for micro blocks * Refactor NgState (3): cleanup * Refactor NgState (4): cleanup * Refactor NgState (5): minor fixes * Refactor NgState (6): linter fixes * Fixes in BLS validation, new tests * Fixes in Importer * BLS related code improvements * BlockAppenderAfterFinalizationSpec: finalization checks * MinerWithFinalitySuite: additional checks * New tests * New tests, cleanup * Disable endorsing of challenging block * CommitToGenerationTransactionDiffTest * CommitToGenerationTransactionDiff: additional tests * Tests added and updated * Always endorse with the latest finalized block * Cleanup * Cleanup, additional check in test * GET /generators/at/$height shows generators those committed on next period * Exporter fixes * Swagger UI: change the document title to info.title of OpenAPI spec * Tests: createBlock has a default value for block version argument, formatting * Cleanup * PBTransactions: fixed CreateAliasTransaction creation in createVanillaUnsafe
1 parent 5c34710 commit 693484d

File tree

122 files changed

+3438
-2431
lines changed

Some content is hidden

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

122 files changed

+3438
-2431
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ inScope(Global)(
218218
)
219219
)
220220

221-
commands += Command.command("packageAll"){ state =>
221+
commands += Command.command("packageAll") { state =>
222222
"node / assembly" :: "ride-runner / assembly" :: "buildDebPackages" :: "buildTarballsForDocker" :: state
223223
}
224224

grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/AccountsApiGrpcSpec.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ import com.google.protobuf.ByteString
44
import com.wavesplatform.TestValues
55
import com.wavesplatform.account.{Address, KeyPair}
66
import com.wavesplatform.api.grpc.*
7-
import com.wavesplatform.block.Block
87
import com.wavesplatform.common.state.ByteStr
98
import com.wavesplatform.crypto.DigestLength
109
import com.wavesplatform.db.WithDomain
1110
import com.wavesplatform.db.WithState.AddrWithBalance
1211
import com.wavesplatform.history.Domain
1312
import com.wavesplatform.protobuf.Amount
1413
import com.wavesplatform.protobuf.transaction.{DataEntry, Recipient}
15-
import com.wavesplatform.state.{Height, BlockRewardCalculator, EmptyDataEntry, IntegerDataEntry}
14+
import com.wavesplatform.state.{BlockRewardCalculator, EmptyDataEntry, Height, IntegerDataEntry}
1615
import com.wavesplatform.test.*
16+
import com.wavesplatform.test.DomainPresets.*
1717
import com.wavesplatform.transaction.Asset.Waves
1818
import com.wavesplatform.transaction.TxHelpers
1919
import com.wavesplatform.utils.{DiffMatchers, Schedulers}
20-
import org.scalatest.{Assertion, BeforeAndAfterAll}
21-
import com.wavesplatform.test.DomainPresets.*
2220
import monix.execution.ExecutionModel.SynchronousExecution
2321
import monix.execution.Scheduler
22+
import org.scalatest.{Assertion, BeforeAndAfterAll}
2423

2524
import scala.concurrent.Await
2625
import scala.concurrent.duration.{DurationInt, FiniteDuration}
@@ -189,7 +188,10 @@ class AccountsApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffMatch
189188

190189
val sender = TxHelpers.signer(1)
191190
val challengedMiner = TxHelpers.signer(2)
192-
withDomain(TransactionStateSnapshot.configure(_.copy(lightNodeBlockFieldsAbsenceInterval = 0)), balances = AddrWithBalance.enoughBalances(sender)) { d =>
191+
withDomain(
192+
TransactionStateSnapshot.configure(_.copy(lightNodeBlockFieldsAbsenceInterval = 0)),
193+
balances = AddrWithBalance.enoughBalances(sender)
194+
) { d =>
193195
val grpcApi = getGrpcApi(d)
194196

195197
val challengingMiner = d.wallet.generateNewAccount().get
@@ -206,8 +208,6 @@ class AccountsApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffMatch
206208

207209
val invalidStateHash = ByteStr.fill(DigestLength)(1)
208210
val originalBlock = d.createBlock(
209-
Block.ProtoBlockVersion,
210-
Seq.empty,
211211
strictTime = true,
212212
generator = challengedMiner,
213213
stateHash = Some(Some(invalidStateHash))

grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/AssetsApiGrpcSpec.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.wavesplatform.api.grpc.test
33
import com.google.protobuf.ByteString
44
import com.wavesplatform.account.KeyPair
55
import com.wavesplatform.api.grpc.{AssetInfoResponse, AssetsApiGrpcImpl, NFTRequest, NFTResponse}
6-
import com.wavesplatform.block.Block.ProtoBlockVersion
76
import com.wavesplatform.db.WithDomain
87
import com.wavesplatform.db.WithState.AddrWithBalance
98
import com.wavesplatform.features.BlockchainFeatures
@@ -18,7 +17,7 @@ import org.scalatest.BeforeAndAfterAll
1817

1918
class AssetsApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffMatchers with WithDomain with GrpcApiHelpers {
2019
private given scheduler: Scheduler = Schedulers.singleThread("grpc", executionModel = SynchronousExecution)
21-
val sender: KeyPair = TxHelpers.signer(1)
20+
val sender: KeyPair = TxHelpers.signer(1)
2221

2322
"GetNFTList should work" in withDomain(RideV6.addFeatures(BlockchainFeatures.ReduceNFTFee), AddrWithBalance.enoughBalances(sender)) { d =>
2423
val grpcApi = getGrpcApi(d)
@@ -75,7 +74,7 @@ class AssetsApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffMatcher
7574
check()
7675

7776
// liquid afterId
78-
d.appendBlock(d.createBlock(ProtoBlockVersion, nftIssues.drop(afterId + 1), Some(mb1)))
77+
d.appendBlock(d.createBlock(nftIssues.drop(afterId + 1), Some(mb1)))
7978
d.rocksDBWriter.containsTransaction(nftIssues(afterId)) shouldBe true
8079
d.rocksDBWriter.containsTransaction(nftIssues(afterId + 1)) shouldBe false
8180
check()

grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/BlocksApiGrpcSpec.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class BlocksApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffMatcher
269269

270270
val invalidStateHash = ByteStr.fill(DigestLength)(1)
271271
val originalBlock = d.createBlock(
272-
Block.ProtoBlockVersion,
273272
Seq(TxHelpers.transfer(sender)),
274273
strictTime = true,
275274
stateHash = Some(Some(invalidStateHash))
@@ -323,7 +322,6 @@ class BlocksApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffMatcher
323322

324323
val invalidStateHash = ByteStr.fill(DigestLength)(1)
325324
val originalBlock = d.createBlock(
326-
Block.ProtoBlockVersion,
327325
Seq(TxHelpers.transfer(sender)),
328326
strictTime = true,
329327
stateHash = Some(Some(invalidStateHash))

grpc-server/src/test/scala/com/wavesplatform/api/grpc/test/TransactionsApiGrpcSpec.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ package com.wavesplatform.api.grpc.test
22

33
import com.google.protobuf.ByteString
44
import com.wavesplatform.account.KeyPair
5-
import com.wavesplatform.api.grpc.{ApplicationStatus, TransactionResponse, TransactionSnapshotResponse, TransactionSnapshotsRequest, TransactionsApiGrpcImpl, TransactionsRequest}
6-
import com.wavesplatform.block.Block
5+
import com.wavesplatform.api.grpc.{
6+
ApplicationStatus,
7+
TransactionResponse,
8+
TransactionSnapshotResponse,
9+
TransactionSnapshotsRequest,
10+
TransactionsApiGrpcImpl,
11+
TransactionsRequest
12+
}
713
import com.wavesplatform.common.state.ByteStr
814
import com.wavesplatform.common.utils.EitherExt2.*
915
import com.wavesplatform.crypto.DigestLength
@@ -13,7 +19,7 @@ import com.wavesplatform.history.Domain
1319
import com.wavesplatform.protobuf.transaction.{PBTransactions, Recipient}
1420
import com.wavesplatform.protobuf.{PBSnapshots, toByteString}
1521
import com.wavesplatform.state.diffs.ENOUGH_AMT
16-
import com.wavesplatform.state.{StateSnapshot, TxMeta, Height}
22+
import com.wavesplatform.state.{Height, StateSnapshot, TxMeta}
1723
import com.wavesplatform.test.*
1824
import com.wavesplatform.test.DomainPresets.*
1925
import com.wavesplatform.transaction.Asset.Waves
@@ -229,7 +235,6 @@ class TransactionsApiGrpcSpec extends FreeSpec with BeforeAndAfterAll with DiffM
229235
val resenderTxs = Seq(TxHelpers.transfer(resender, recipient.toAddress, 1.waves), TxHelpers.transfer(resender, recipient.toAddress, 2.waves))
230236
val challengedBlockTx = TxHelpers.transfer(challengedMiner, resender.toAddress, 1001.waves)
231237
val originalBlock = d.createBlock(
232-
Block.ProtoBlockVersion,
233238
challengedBlockTx +: resenderTxs,
234239
strictTime = true,
235240
generator = challengedMiner,

grpc-server/src/test/scala/com/wavesplatform/events/BlockchainUpdatesSpec.scala

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ import com.google.common.primitives.Longs
44
import com.google.protobuf.ByteString
55
import com.wavesplatform.TestValues
66
import com.wavesplatform.account.{Address, KeyPair}
7-
import com.wavesplatform.block.Block
87
import com.wavesplatform.common.state.ByteStr
98
import com.wavesplatform.common.utils.EitherExt2.*
109
import com.wavesplatform.crypto.DigestLength
1110
import com.wavesplatform.db.InterferableDB
1211
import com.wavesplatform.events.FakeObserver.*
1312
import com.wavesplatform.events.StateUpdate.LeaseUpdate.LeaseStatus
14-
import com.wavesplatform.events.StateUpdate.{AssetInfo, AssetStateUpdate, BalanceUpdate, DataEntryUpdate, LeaseUpdate, LeasingBalanceUpdate, ScriptUpdate}
13+
import com.wavesplatform.events.StateUpdate.{
14+
AssetInfo,
15+
AssetStateUpdate,
16+
BalanceUpdate,
17+
DataEntryUpdate,
18+
LeaseUpdate,
19+
LeasingBalanceUpdate,
20+
ScriptUpdate
21+
}
1522
import com.wavesplatform.events.api.grpc.protobuf.{GetBlockUpdateRequest, GetBlockUpdatesRangeRequest, SubscribeRequest}
1623
import com.wavesplatform.events.protobuf.BlockchainUpdated.Rollback.RollbackType
1724
import com.wavesplatform.events.protobuf.BlockchainUpdated.Update
@@ -56,7 +63,7 @@ import scala.util.Random
5663

5764
class BlockchainUpdatesSpec extends FreeSpec with WithBUDomain with ScalaFutures {
5865
private given scheduler: Scheduler = Schedulers.singleThread("grpc", executionModel = SynchronousExecution)
59-
66+
6067
val currentSettings: WavesSettings = RideV5
6168

6269
val transfer: TransferTransaction = TxHelpers.transfer()
@@ -828,7 +835,6 @@ class BlockchainUpdatesSpec extends FreeSpec with WithBUDomain with ScalaFutures
828835
TxHelpers.transfer(sender, recipient.toAddress, 2.waves, timestamp = txTimestamp + 1)
829836
)
830837
val originalBlock = d.createBlock(
831-
Block.ProtoBlockVersion,
832838
txs,
833839
generator = challengedMiner,
834840
stateHash = Some(Some(invalidStateHash))
@@ -1100,27 +1106,23 @@ class BlockchainUpdatesSpec extends FreeSpec with WithBUDomain with ScalaFutures
11001106
"should return correct updated_waves_amount when reward boost is active" in {
11011107
val settings = ConsensusImprovements
11021108
.setFeaturesHeight(
1103-
BlockchainFeatures.BlockReward -> 0,
1109+
BlockchainFeatures.BlockReward -> 0,
11041110
BlockchainFeatures.BlockRewardDistribution -> 0,
11051111
BlockchainFeatures.BoostBlockReward -> 5
11061112
)
1107-
.configure(fs =>
1108-
fs.copy(blockRewardBoostPeriod = 10)
1109-
)
1113+
.configure(fs => fs.copy(blockRewardBoostPeriod = 10))
11101114

11111115
withDomainAndRepo(settings) { case (d, repo) =>
11121116
d.appendBlock()
11131117
val subscription = repo.createFakeObserver(SubscribeRequest.of(1, 0))
11141118

11151119
(1 to 15).foreach(_ => d.appendBlock())
11161120

1117-
11181121
subscription
11191122
.fetchAllEvents(d.blockchain)
1120-
.map(_.getUpdate.getAppend.getBlock.updatedWavesAmount) shouldBe
1123+
.map(_.getUpdate.getAppend.getBlock.updatedWavesAmount) shouldBe
11211124
(2 to 16).scanLeft(100_000_000.waves) { (total, height) => total + 6.waves * d.blockchain.blockRewardBoost(Height(height)) }
11221125

1123-
11241126
}
11251127
}
11261128
}

node-it/src/test/resources/template.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ waves {
112112
rest-api {
113113
enable = yes
114114
bind-address = 0.0.0.0
115-
api-key-hash = 7L6GpLHhA5KyJTAVc8WFHwEcyTY8fC8rRbyMCiFnM4i
115+
api-key-hash = 7L6GpLHhA5KyJTAVc8WFHwEcyTY8fC8rRbyMCiFnM4i # integration-test-rest-api
116116
minimum-peers = 0
117117
}
118118
wallet {

node-it/src/test/scala/com/wavesplatform/it/NodeConfigs.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ object NodeConfigs {
5151
val totalEntities = defaultEntities + specialsConfigs.size
5252
require(totalEntities <= NonConflictingNodes.size)
5353

54-
val (defaultNodes: Seq[Config], specialNodes: Seq[Config]) = baseConfigs.zipWithIndex
54+
val bc =
55+
if (totalEntities > 1) baseConfigs
56+
else baseConfigs.map(ConfigFactory.parseString("waves.network.max-outbound-connections = 0").withFallback)
57+
58+
val (defaultNodes: Seq[Config], specialNodes: Seq[Config]) = bc.zipWithIndex
5559
.collect { case (x, i) if NonConflictingNodes.contains(i + 1) => x }
5660
.splitAt(defaultEntities)
5761

node-it/src/test/scala/com/wavesplatform/it/sync/AddressApiSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class AddressApiSuite extends BaseTransactionSuite with NTPTime {
8383
)
8484
}
8585

86-
test("requests to the illegal height should be handled correctly ") {
86+
test("requests to the illegal height should be handled correctly") {
8787
val height = miner.height + 100
8888
assertApiError(
8989
miner.get(s"/addresses/balance?height=$height&address=$firstKeyPair"),

node-it/src/test/scala/com/wavesplatform/it/sync/finalization/TwoNodesFinalizationTestSuite.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ class TwoNodesFinalizationTestSuite extends BaseFreeSpec, OptionValues, ScorexLo
3434

3535
step("Commit to generation")
3636
val commitTxn1 = node1.sign(CommitToGenerationRequest(sender = Some(miner1Addr)))
37+
node1.broadcastRequest(commitTxn1)
38+
3739
val commitTxn2 = node2.sign(CommitToGenerationRequest(sender = Some(miner2Addr)))
38-
Seq(node1, node2).foreach { node =>
39-
node.broadcastRequest(commitTxn1)
40-
node.broadcastRequest(commitTxn2)
41-
}
40+
node2.broadcastRequest(commitTxn2)
41+
4242
node1.waitForGenerationPeriod(period1)
43-
node2.waitForGenerationPeriod(period1)
4443

4544
step("Generators")
4645
isolated {

0 commit comments

Comments
 (0)