Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ETCM-856] make stSLoadTest pass #995

Merged
merged 8 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.iohk.ethereum.txExecTest

import java.util.concurrent.Executors

import io.iohk.ethereum.domain.{Address, BlockchainImpl, Receipt, UInt256}
import io.iohk.ethereum.ledger._
import io.iohk.ethereum.txExecTest.util.FixtureProvider
import io.iohk.ethereum.utils.{BlockchainConfig, MonetaryPolicyConfig}
import io.iohk.ethereum.utils.{BlockchainConfig, ForkBlockNumbers, MonetaryPolicyConfig}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

Expand All @@ -22,16 +21,26 @@ class ECIP1017Test extends AnyFlatSpec with Matchers {
maxCodeSize = None,
chainId = 0x3d.toByte,
networkId = 1,
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
eip106BlockNumber = Long.MaxValue,
eip150BlockNumber = 2500000,
eip160BlockNumber = 3000000,
eip155BlockNumber = 3000000,
eip161BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
forkBlockNumbers = ForkBlockNumbers(
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
eip106BlockNumber = Long.MaxValue,
eip150BlockNumber = 2500000,
eip160BlockNumber = 3000000,
eip155BlockNumber = 3000000,
eip161BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
),
customGenesisFileOpt = None,
customGenesisJsonOpt = None,
daoForkConfig = None,
Expand All @@ -42,15 +51,7 @@ class ECIP1017Test extends AnyFlatSpec with Matchers {
accountStartNonce = UInt256.Zero,
ethCompatibleStorage = true,
gasTieBreaker = false,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
treasuryAddress = Address(0),
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
treasuryAddress = Address(0)
)
val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(4))

Expand Down
41 changes: 21 additions & 20 deletions src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.iohk.ethereum.txExecTest

import java.util.concurrent.Executors

import io.iohk.ethereum.domain.{Address, BlockchainImpl, Receipt, UInt256}
import io.iohk.ethereum.ledger.{BlockExecution, BlockQueue, BlockValidation}
import io.iohk.ethereum.txExecTest.util.FixtureProvider
import io.iohk.ethereum.utils.{BlockchainConfig, MonetaryPolicyConfig}
import io.iohk.ethereum.utils.{BlockchainConfig, ForkBlockNumbers, MonetaryPolicyConfig}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

Expand All @@ -16,40 +15,42 @@ class ForksTest extends AnyFlatSpec with Matchers {

trait TestSetup extends ScenarioSetup {
override lazy val blockchainConfig = BlockchainConfig(
frontierBlockNumber = 0,
homesteadBlockNumber = 3,
eip150BlockNumber = 5,
eip160BlockNumber = 7,
eip155BlockNumber = 0,
eip106BlockNumber = Long.MaxValue,
forkBlockNumbers = ForkBlockNumbers(
frontierBlockNumber = 0,
homesteadBlockNumber = 3,
eip150BlockNumber = 5,
eip160BlockNumber = 7,
eip155BlockNumber = 0,
eip106BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
),
chainId = 0x3d.toByte,
monetaryPolicyConfig = MonetaryPolicyConfig(5000000, 0.2, 5000000000000000000L, 3000000000000000000L),
// unused
bootstrapNodes = Set(),
networkId = 1,
maxCodeSize = None,
eip161BlockNumber = Long.MaxValue,
customGenesisFileOpt = None,
customGenesisJsonOpt = None,
difficultyBombPauseBlockNumber = Long.MaxValue,
difficultyBombContinueBlockNumber = Long.MaxValue,
difficultyBombRemovalBlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
accountStartNonce = UInt256.Zero,
daoForkConfig = None,
gasTieBreaker = false,
ethCompatibleStorage = true,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
treasuryAddress = Address(0),
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
)

val noErrors = a[Right[_, Seq[Receipt]]]
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/conf/testmode.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ mantis {
}
}

network.rpc {
apis = "eth,web3,net,personal,mantis,test,iele,debug,qa,checkpointing"
network {
rpc.apis = "eth,web3,net,personal,mantis,test,iele,debug,qa,checkpointing"
automatic-port-forwarding = false
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class BlockGeneratorSkeleton(
x: Ommers
): BlockHeader = {
val extraFields =
if (blockNumber >= blockchainConfig.ecip1097BlockNumber)
if (blockNumber >= blockchainConfig.forkBlockNumbers.ecip1097BlockNumber)
HefPostEcip1097(None)
else
HefEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PoWConsensus private (
node.ethMiningService,
blockCreator,
blockchain,
blockchainConfig.ecip1049BlockNumber
blockchainConfig.forkBlockNumbers.ecip1049BlockNumber
),
"PoWMinerCoordinator",
DispatcherSelector.fromConfig(BlockForgerDispatcherId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.iohk.ethereum.utils.BlockchainConfig

class EthashDifficultyCalculator(blockchainConfig: BlockchainConfig) extends DifficultyCalculator {
import blockchainConfig._
import blockchainConfig.forkBlockNumbers._
import DifficultyCalculator._

private val ExpDifficultyPeriod: Int = 100000
Expand All @@ -19,7 +20,7 @@ class EthashDifficultyCalculator(blockchainConfig: BlockchainConfig) extends Dif
val c: BigInt =
if (blockNumber < homesteadBlockNumber) {
if (blockTimestamp < parentHeader.unixTimestamp + 13) 1 else -1
} else if (blockNumber >= byzantiumBlockNumber || blockNumber >= blockchainConfig.atlantisBlockNumber) {
} else if (blockNumber >= byzantiumBlockNumber || blockNumber >= atlantisBlockNumber) {
val parentUncleFactor = if (parentHeader.ommersHash == BlockHeader.EmptyOmmers) 1 else 2
math.max(parentUncleFactor - (timestampDiff / 9), FrontierTimestampDiffLimit)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class EthashDAGManager(blockCreator: PoWBlockCreator) extends Logger {
(currentEpoch, currentEpochDag, currentEpochDagSize) match {
case (Some(`epoch`), Some(dag), Some(dagSize)) => (dag, dagSize)
case _ =>
val seed = EthashUtils.seed(blockNumber, blockCreator.blockchainConfig.ecip1099BlockNumber.toLong)
val seed =
EthashUtils.seed(blockNumber, blockCreator.blockchainConfig.forkBlockNumbers.ecip1099BlockNumber.toLong)
val dagSize = EthashUtils.dagSize(epoch)
val dagNumHashes = (dagSize / EthashUtils.HASH_BYTES).toInt
val dag =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class EthashMiner(

private def doMining(blockNumber: Long, block: Block): (Long, MiningResult) = {
val epoch =
EthashUtils.epoch(blockNumber, blockCreator.blockchainConfig.ecip1099BlockNumber.toLong)
EthashUtils.epoch(blockNumber, blockCreator.blockchainConfig.forkBlockNumbers.ecip1099BlockNumber.toLong)
val (dag, dagSize) = dagManager.calculateDagSize(blockNumber, epoch)
val headerHash = crypto.kec256(BlockHeader.getEncodedWithoutNonce(block.header))
val startTime = System.nanoTime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class EthashBlockHeaderValidator(blockchainConfig: BlockchainConfig) {
}
}

val epoch = EthashUtils.epoch(blockHeader.number.toLong, blockchainConfig.ecip1099BlockNumber.toLong)
val seed = EthashUtils.seed(blockHeader.number.toLong, blockchainConfig.ecip1099BlockNumber.toLong)
val epoch =
EthashUtils.epoch(blockHeader.number.toLong, blockchainConfig.forkBlockNumbers.ecip1099BlockNumber.toLong)
val seed = EthashUtils.seed(blockHeader.number.toLong, blockchainConfig.forkBlockNumbers.ecip1099BlockNumber.toLong)
val powCacheData = getPowCacheData(epoch, seed)

val proofOfWork = hashimotoLight(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PoWBlockHeaderValidator(blockchainConfig: BlockchainConfig)
else ethashBlockHeaderValidator.validateHeader(blockHeader)

private def isKeccak(currentBlockNumber: BigInt): Boolean =
blockchainConfig.ecip1049BlockNumber match {
blockchainConfig.forkBlockNumbers.ecip1049BlockNumber match {
case Some(keccakBlock) => currentBlockNumber >= keccakBlock
case None => false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ abstract class BlockHeaderValidatorSkeleton(blockchainConfig: BlockchainConfig)
parentHeader: BlockHeader
): Either[BlockHeaderError, BlockHeaderValid] = {

if (blockHeader.gasLimit > MaxGasLimit && blockHeader.number >= blockchainConfig.eip106BlockNumber)
if (blockHeader.gasLimit > MaxGasLimit && blockHeader.number >= blockchainConfig.forkBlockNumbers.eip106BlockNumber)
Left(HeaderGasLimitError)
else {
val gasLimitDiff = (blockHeader.gasLimit - parentHeader.gasLimit).abs
Expand Down Expand Up @@ -226,8 +226,8 @@ abstract class BlockHeaderValidatorSkeleton(blockchainConfig: BlockchainConfig)
* @return BlockHeader if valid, an [[HeaderExtraFieldsError]] otherwise
*/
private def validateExtraFields(blockHeader: BlockHeader): Either[BlockHeaderError, BlockHeaderValid] = {
val isECIP1098Activated = blockHeader.number >= blockchainConfig.ecip1098BlockNumber
val isECIP1097Activated = blockHeader.number >= blockchainConfig.ecip1097BlockNumber
val isECIP1098Activated = blockHeader.number >= blockchainConfig.forkBlockNumbers.ecip1098BlockNumber
val isECIP1097Activated = blockHeader.number >= blockchainConfig.forkBlockNumbers.ecip1097BlockNumber

blockHeader.extraFields match {
case HefPostEcip1097(_) if isECIP1097Activated && isECIP1098Activated => Right(BlockHeaderValid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class StdSignedTransactionValidator(blockchainConfig: BlockchainConfig) extends
val r = stx.signature.r
val s = stx.signature.s

val beforeHomestead = blockNumber < blockchainConfig.homesteadBlockNumber
val beforeEIP155 = blockNumber < blockchainConfig.eip155BlockNumber
val beforeHomestead = blockNumber < blockchainConfig.forkBlockNumbers.homesteadBlockNumber
val beforeEIP155 = blockNumber < blockchainConfig.forkBlockNumbers.eip155BlockNumber

val validR = r > 0 && r < secp256k1n
val validS = s > 0 && s < (if (beforeHomestead) secp256k1n else secp256k1n / 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class EthMiningService(
Right(
GetWorkResponse(
powHeaderHash = ByteString(kec256(BlockHeader.getEncodedWithoutNonce(pb.block.header))),
dagSeed = EthashUtils.seed(pb.block.header.number.toLong, blockchainConfig.ecip1099BlockNumber.toLong),
dagSeed = EthashUtils
.seed(pb.block.header.number.toLong, blockchainConfig.forkBlockNumbers.ecip1099BlockNumber.toLong),
target = ByteString((BigInt(2).pow(256) / pb.block.header.difficulty).toByteArray)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class PersonalService(
val maybeNextTxNonce = maybeLatestPendingTxNonce.map(_ + 1) orElse maybeCurrentNonce
val tx = request.toTransaction(maybeNextTxNonce.getOrElse(blockchainConfig.accountStartNonce))

val stx = if (blockchain.getBestBlockNumber() >= blockchainConfig.eip155BlockNumber) {
val stx = if (blockchain.getBestBlockNumber() >= blockchainConfig.forkBlockNumbers.eip155BlockNumber) {
wallet.signTx(tx, Some(blockchainConfig.chainId))
} else {
wallet.signTx(tx, None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ object TestJsonMethodsImplicits extends JsonMethodsImplicits {
constantinopleForkBlock <- optionalQuantity(blockchainParamsJson \ "constantinopleForkBlock")
istanbulForkBlock <- optionalQuantity(blockchainParamsJson \ "istanbulForkBlock")
} yield BlockchainParams(
eIP150ForkBlock.getOrElse(0),
eIP158ForkBlock.getOrElse(0),
accountStartNonce.getOrElse(0),
allowFutureBlocks,
blockReward.getOrElse(0),
byzantiumForkBlock.getOrElse(0),
homesteadForkBlock.getOrElse(0),
0,
constantinopleForkBlock.getOrElse(0),
istanbulForkBlock.getOrElse(0)
EIP150ForkBlock = eIP150ForkBlock,
EIP158ForkBlock = eIP158ForkBlock,
accountStartNonce = accountStartNonce.getOrElse(0),
allowFutureBlocks = allowFutureBlocks,
blockReward = blockReward.getOrElse(0),
byzantiumForkBlock = byzantiumForkBlock,
homesteadForkBlock = homesteadForkBlock,
maximumExtraDataSize = 0,
constantinopleForkBlock = constantinopleForkBlock,
istanbulForkBlock = istanbulForkBlock
)
}

Expand Down
Loading