Skip to content

Commit 00187c8

Browse files
Fix empty epoch reporting (#57)
1 parent d3420a3 commit 00187c8

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

consensus-client-it/src/test/scala/units/EmptyEpochMinerEvictionTestSuite.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package units
22

33
import com.wavesplatform.account.Address
44
import com.wavesplatform.state.{Height, IntegerDataEntry, StringDataEntry}
5+
import com.wavesplatform.common.state.ByteStr
56
import com.wavesplatform.transaction.TxHelpers
67

78
class EmptyEpochMinerEvictionTestSuite extends BaseDockerTestSuite {
@@ -34,9 +35,10 @@ class EmptyEpochMinerEvictionTestSuite extends BaseDockerTestSuite {
3435
// Wait for another idle miner epoch
3536
waves1.api.waitForHeight(prevReportedHeight + 1)
3637
chainContract.waitForMinerEpoch(idleMiner)
37-
38+
val lastWavesBlock = waves1.api.blockHeader(waves1.api.height()).value
39+
val vrf = ByteStr.decodeBase58(lastWavesBlock.VRF).get
3840
// Report empty epoch
39-
val reportResult = waves1.api.broadcastAndWait(ChainContract.reportEmptyEpoch(reporter))
41+
val reportResult = waves1.api.broadcastAndWait(ChainContract.reportEmptyEpoch(reporter, vrf))
4042
reportResult.height
4143
})
4244

contracts/waves/src/main.ride

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,8 @@ func setup(genesisBlockHashHex: String, minerRewardInGwei: Int, daoAddress: Stri
10931093
}
10941094

10951095
@Callable(i)
1096-
func reportEmptyEpoch() = {
1096+
func reportEmptyEpoch(vrf: ByteVector) = {
1097+
strict checkEpoch = ensureCorrectEpoch(vrf)
10971098
strict checkEpochEmpty = match epochMeta(height) {
10981099
case u: Unit => unit
10991100
case _ => throw("Current epoch is non-empty")

src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,11 @@ trait HasConsensusLayerDappTxHelpers {
360360
fee = withdrawFee
361361
)
362362

363-
def reportEmptyEpoch(minerAccount: KeyPair): InvokeScriptTransaction = TxHelpers.invoke(
363+
def reportEmptyEpoch(minerAccount: KeyPair, vrf: ByteStr = currentHitSource): InvokeScriptTransaction = TxHelpers.invoke(
364364
invoker = minerAccount,
365365
dApp = chainContractAddress,
366366
func = "reportEmptyEpoch".some,
367+
args = List(Terms.CONST_BYTESTR(vrf).explicitGet()),
367368
fee = reportEmptyEpochFee
368369
)
369370

0 commit comments

Comments
 (0)