Search in sources :

Example 1 with MiningConfig

use of co.rsk.config.MiningConfig in project rskj by rsksmart.

the class MainNetMinerTest method blockToMineBuilder.

private BlockToMineBuilder blockToMineBuilder() {
    BlockUnclesValidationRule unclesValidationRule = Mockito.mock(BlockUnclesValidationRule.class);
    when(unclesValidationRule.isValid(Mockito.any())).thenReturn(true);
    MinerClock clock = new MinerClock(true, Clock.systemUTC());
    MiningConfig miningConfig = ConfigUtils.getDefaultMiningConfig();
    return new BlockToMineBuilder(config.getActivationConfig(), miningConfig, repositoryLocator, blockStore, transactionPool, new DifficultyCalculator(config.getActivationConfig(), config.getNetworkConstants()), new GasLimitCalculator(config.getNetworkConstants()), new ForkDetectionDataCalculator(), unclesValidationRule, clock, blockFactory, blockExecutor, new MinimumGasPriceCalculator(Coin.valueOf(miningConfig.getMinGasPriceTarget())), new MinerUtils());
}
Also used : MiningConfig(co.rsk.config.MiningConfig) DifficultyCalculator(co.rsk.core.DifficultyCalculator) BlockUnclesValidationRule(co.rsk.validators.BlockUnclesValidationRule)

Example 2 with MiningConfig

use of co.rsk.config.MiningConfig in project rskj by rsksmart.

the class MinerManagerTest method getMinerServer.

private MinerServerImpl getMinerServer() {
    SimpleEthereum ethereum = new SimpleEthereum();
    ethereum.blockchain = blockchain;
    DifficultyCalculator difficultyCalculator = new DifficultyCalculator(config.getActivationConfig(), config.getNetworkConstants());
    MinerClock clock = new MinerClock(true, Clock.systemUTC());
    MiningConfig miningConfig = ConfigUtils.getDefaultMiningConfig();
    return new MinerServerImpl(config, ethereum, miningMainchainView, null, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), new BlockToMineBuilder(config.getActivationConfig(), miningConfig, repositoryLocator, blockStore, transactionPool, difficultyCalculator, new GasLimitCalculator(config.getNetworkConstants()), new ForkDetectionDataCalculator(), new BlockValidationRuleDummy(), clock, blockFactory, blockExecutor, new MinimumGasPriceCalculator(Coin.valueOf(miningConfig.getMinGasPriceTarget())), new MinerUtils()), clock, blockFactory, new BuildInfo("cb7f28e", "master"), miningConfig);
}
Also used : ProofOfWorkRule(co.rsk.validators.ProofOfWorkRule) DifficultyCalculator(co.rsk.core.DifficultyCalculator) MiningConfig(co.rsk.config.MiningConfig) BuildInfo(org.ethereum.util.BuildInfo) SimpleEthereum(org.ethereum.rpc.Simples.SimpleEthereum)

Example 3 with MiningConfig

use of co.rsk.config.MiningConfig in project rskj by rsksmart.

the class SubmissionRateLimitHandlerTest method ofMiningConfig_WhenRateLimitIsPositive_ThenHandlerShouldBeEnabled.

@Test
public void ofMiningConfig_WhenRateLimitIsPositive_ThenHandlerShouldBeEnabled() {
    MiningConfig miningConfig = mock(MiningConfig.class);
    doReturn(1L).when(miningConfig).getWorkSubmissionRateLimitInMills();
    assertTrue(SubmissionRateLimitHandler.ofMiningConfig(miningConfig).isEnabled());
}
Also used : MiningConfig(co.rsk.config.MiningConfig) Test(org.junit.Test)

Example 4 with MiningConfig

use of co.rsk.config.MiningConfig in project rskj by rsksmart.

the class SubmissionRateLimitHandlerTest method ofMiningConfig_WhenRateLimitIsNegative_ThenHandlerShouldBeDisabled.

@Test
public void ofMiningConfig_WhenRateLimitIsNegative_ThenHandlerShouldBeDisabled() {
    MiningConfig miningConfig = mock(MiningConfig.class);
    doReturn(-1L).when(miningConfig).getWorkSubmissionRateLimitInMills();
    assertFalse(SubmissionRateLimitHandler.ofMiningConfig(miningConfig).isEnabled());
}
Also used : MiningConfig(co.rsk.config.MiningConfig) Test(org.junit.Test)

Example 5 with MiningConfig

use of co.rsk.config.MiningConfig in project rskj by rsksmart.

the class BlockToMineBuilderTest method setUp.

@Before
public void setUp() {
    validationRules = mock(BlockValidationRule.class);
    RepositoryLocator repositoryLocator = mock(RepositoryLocator.class);
    StateRootHandler stateRootHandler = mock(StateRootHandler.class);
    MiningConfig miningConfig = mock(MiningConfig.class);
    DifficultyCalculator difficultyCalculator = mock(DifficultyCalculator.class);
    MinimumGasPriceCalculator minimumGasPriceCalculator = mock(MinimumGasPriceCalculator.class);
    MinerUtils minerUtils = mock(MinerUtils.class);
    activationConfig = mock(ActivationConfig.class);
    blockExecutor = mock(BlockExecutor.class);
    blockBuilder = new BlockToMineBuilder(activationConfig, miningConfig, repositoryLocator, mock(BlockStore.class), mock(TransactionPool.class), difficultyCalculator, new GasLimitCalculator(Constants.mainnet()), new ForkDetectionDataCalculator(), validationRules, mock(MinerClock.class), new BlockFactory(activationConfig), blockExecutor, minimumGasPriceCalculator, minerUtils);
    BlockDifficulty blockDifficulty = mock(BlockDifficulty.class);
    Repository snapshot = mock(Repository.class);
    GasLimitConfig gasLimitConfig = new GasLimitConfig(0, 0, false);
    when(minerUtils.getAllTransactions(any())).thenReturn(new ArrayList<>());
    when(minerUtils.filterTransactions(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
    when(repositoryLocator.snapshotAt(any())).thenReturn(snapshot);
    when(minimumGasPriceCalculator.calculate(any())).thenReturn(mock(Coin.class));
    when(stateRootHandler.translate(any())).thenReturn(TestUtils.randomHash());
    when(miningConfig.getGasLimit()).thenReturn(gasLimitConfig);
    when(miningConfig.getUncleListLimit()).thenReturn(10);
    when(miningConfig.getCoinbaseAddress()).thenReturn(TestUtils.randomAddress());
    when(difficultyCalculator.calcDifficulty(any(), any())).thenReturn(blockDifficulty);
}
Also used : BlockExecutor(co.rsk.core.bc.BlockExecutor) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) RepositoryLocator(co.rsk.db.RepositoryLocator) StateRootHandler(co.rsk.db.StateRootHandler) MiningConfig(co.rsk.config.MiningConfig) DifficultyCalculator(co.rsk.core.DifficultyCalculator) BlockDifficulty(co.rsk.core.BlockDifficulty) Coin(co.rsk.core.Coin) GasLimitConfig(co.rsk.config.GasLimitConfig) BlockValidationRule(co.rsk.validators.BlockValidationRule) Before(org.junit.Before)

Aggregations

MiningConfig (co.rsk.config.MiningConfig)8 DifficultyCalculator (co.rsk.core.DifficultyCalculator)4 ProofOfWorkRule (co.rsk.validators.ProofOfWorkRule)3 BuildInfo (org.ethereum.util.BuildInfo)3 Test (org.junit.Test)3 BlockValidationRule (co.rsk.validators.BlockValidationRule)2 GasLimitConfig (co.rsk.config.GasLimitConfig)1 BlockDifficulty (co.rsk.core.BlockDifficulty)1 Coin (co.rsk.core.Coin)1 BlockExecutor (co.rsk.core.bc.BlockExecutor)1 RepositoryLocator (co.rsk.db.RepositoryLocator)1 StateRootHandler (co.rsk.db.StateRootHandler)1 BridgeSupportFactory (co.rsk.peg.BridgeSupportFactory)1 RepositoryBtcBlockStoreWithCache (co.rsk.peg.RepositoryBtcBlockStoreWithCache)1 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)1 Web3RskImpl (co.rsk.rpc.Web3RskImpl)1 DebugModule (co.rsk.rpc.modules.debug.DebugModule)1 DebugModuleImpl (co.rsk.rpc.modules.debug.DebugModuleImpl)1 PersonalModuleWalletEnabled (co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled)1 TxPoolModule (co.rsk.rpc.modules.txpool.TxPoolModule)1