Skip to content

Commit 4111670

Browse files
committed
wip
1 parent 8c332b9 commit 4111670

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

consensus-client-it/src/test/scala/units/block/validation/BaseBlockValidationSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ trait BaseBlockValidationSuite extends BaseDockerTestSuite {
237237
transferAssetTokenToClSender()
238238
leaveSetupMinerAndJoinOthers()
239239
}
240-
240+
241241
protected def getMainChainLastBlock: EcBlock = {
242242
val mainChainId = waves1.api.dataByKey(chainContractAddress, "mainChainId").collect { case i: IntegerDataEntry => i.value }.getOrElse(0L)
243243
val elParentBlockId = waves1.api.dataByKey(chainContractAddress, f"chain_$mainChainId%08d").collect {
244244
case s: StringDataEntry => BlockHash("0x" + s.value.split(",")(1))
245245
}.get
246-
246+
247247
ec1.engineApi.getBlockByHash(elParentBlockId).explicitGet().get
248248
}
249249
}

consensus-client-it/src/test/scala/units/docker/BaseContainer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ abstract class BaseContainer(val hostName: String) {
1818
}
1919

2020
def stop(): Unit = {
21+
container.getDockerClient.stopContainerCmd(container.getContainerId).exec()
2122
container.stop()
2223
}
2324

consensus-client-it/src/test/scala/units/docker/DockerImages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import units.test.TestEnvironment.WavesDockerImage
55

66
object DockerImages {
77
val WavesNode = parse(WavesDockerImage)
8-
val OpGethExecutionClient = parse("ghcr.io/unitsnetwork/op-geth:v1.101603.0-1")
8+
val OpGethExecutionClient = parse("ghcr.io/unitsnetwork/op-geth:1.6.3-race-detector")
99
}

consensus-client-it/src/test/scala/units/docker/WavesNodeContainer.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class WavesNodeContainer(
6666
.withStopTimeout(5) // Otherwise we don't have logs in the end
6767
}
6868

69-
lazy val apiPort = container.getMappedPort(ApiPort)
69+
lazy val apiPort = container.getMappedPort(ApiPort)
7070
lazy val unitsNetworkPort = container.getMappedPort(UnitsNetworkPort)
7171

7272
lazy val api = new NodeHttpApi(uri"http://${container.getHost}:$apiPort", httpClientBackend)
@@ -75,7 +75,7 @@ class WavesNodeContainer(
7575
}
7676

7777
object WavesNodeContainer {
78-
val ApiPort = 6869
78+
val ApiPort = 6869
7979
val UnitsNetworkPort = 6865
8080

8181
val GenesisTemplateFile = new File(s"$ConfigsDir/wavesnode/genesis-template.conf")
@@ -89,12 +89,8 @@ object WavesNodeContainer {
8989
val templateFile = ConfigsDir.resolve("wavesnode/genesis-template.conf").toAbsolutePath
9090

9191
val origConfig = ConfigFactory.parseFile(templateFile.toFile)
92-
val gap = 25.seconds // To force node mining at start, otherwise it schedules
93-
val overrides = ConfigFactory.parseString(
94-
s"""genesis-generator {
95-
| timestamp = ${System.currentTimeMillis() - gap.toMillis}
96-
|}""".stripMargin
97-
)
92+
// To force node mining at start, otherwise it schedules
93+
val overrides = ConfigFactory.parseString(s"genesis-generator.timestamp = ${System.currentTimeMillis() - 25.seconds.toMillis}")
9894

9995
val genesisSettings = GenesisBlockGenerator.parseSettings(overrides.withFallback(origConfig))
10096

consensus-client-it/src/test/scala/units/http/OkHttpLogger.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object OkHttpLogger extends Interceptor with ScorexLogging {
1212
val req = chain.request()
1313
val bodyStr = readRequestBody(req)
1414

15-
val currRequestId = (Json.parse(bodyStr) \ "id").asOpt[Long].getOrElse(LoggingUtil.currRequestId.toLong)
15+
val currRequestId = (Json.parse(bodyStr) \ "id").as[Long]
1616
log.debug(s"[$currRequestId] ${req.method()} ${req.url()}: body=$bodyStr")
1717
val res = chain.proceed(req)
1818
log.debug(s"[$currRequestId] HTTP ${res.code()}: body=${readResponseBody(res)}")

contracts/waves/src/main.ride

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,12 @@ func join(rewardAddressHex: String) = {
848848
let normalizedRewardAddress = normalizeEthAddress(rewardAddressHex)
849849
strict checkNotOverride = ensureNotOverrideOtherMinerPk(normalizedRewardAddress)
850850

851+
let minerLeftKey = "miner_" + newMiner + "_left"
852+
let minerCanJoinAtHeight = this.getInteger(minerLeftKey).valueOrElse(-20) + 20
853+
854+
strict minerCanJoin = height >= minerCanJoinAtHeight ||
855+
throw("Miner can join after height " + minerCanJoinAtHeight.toString())
856+
851857
# Here is 980 complexity consumed, all code below spent more than 1000 of free complexity
852858

853859
# If a miner changed the reward address, we need to delete the previous mapping
@@ -863,7 +869,8 @@ func join(rewardAddressHex: String) = {
863869
[
864870
StringEntry(allMinersKey, updatedAllMiners),
865871
StringEntry(minerRewardAddressKey(newMiner), "0x" + normalizedRewardAddress),
866-
BinaryEntry(minerPkKey(normalizedRewardAddress), i.originCallerPublicKey)
872+
BinaryEntry(minerPkKey(normalizedRewardAddress), i.originCallerPublicKey),
873+
DeleteEntry(minerLeftKey)
867874
] ++ deletePrevRewardAddressPk
868875
}
869876

@@ -877,9 +884,9 @@ func leave() = {
877884
let rewardAddrKey = minerRewardAddressKey(leavingMiner)
878885
strict prevRewardAddress = this.getString(rewardAddrKey).valueOrErrorMessage("miner has never joined")
879886

880-
if (thisEpochMiner == i.originCaller) then throw("designated miner can't leave")
881-
else [
882-
StringEntry(allMinersKey, remainingMiners.makeString_2C(SEP))
887+
[
888+
StringEntry(allMinersKey, remainingMiners.makeString_2C(SEP)),
889+
IntegerEntry("miner_" + leavingMiner + "_left", height)
883890
# TODO Get miner info at epoch start
884891
# DeleteEntry(rewardAddrKey), # Can cause empty miner reward address for next blocks
885892
# DeleteEntry(minerPkKey(prevRewardAddress))

0 commit comments

Comments
 (0)