Search in sources :

Example 6 with BuildInfo

use of org.ethereum.util.BuildInfo in project rskj by rsksmart.

the class Web3ImplTest method createWeb3.

private Web3Impl createWeb3(Ethereum eth, Blockchain blockchain, RepositoryLocator repositoryLocator, TransactionPool transactionPool, BlockStore blockStore, BlockProcessor nodeBlockProcessor, ConfigCapabilities configCapabilities, ReceiptStore receiptStore) {
    MiningMainchainView miningMainchainViewMock = mock(MiningMainchainView.class);
    ExecutionBlockRetriever executionBlockRetriever = mock(ExecutionBlockRetriever.class);
    wallet = WalletFactory.createWallet();
    PersonalModuleWalletEnabled personalModule = new PersonalModuleWalletEnabled(config, eth, wallet, transactionPool);
    ReversibleTransactionExecutor executor = new ReversibleTransactionExecutor(repositoryLocator, buildTransactionExecutorFactory(blockStore, null));
    Web3InformationRetriever retriever = new Web3InformationRetriever(transactionPool, blockchain, repositoryLocator, executionBlockRetriever);
    TransactionGateway transactionGateway = new TransactionGateway(new SimpleChannelManager(), transactionPool);
    EthModule ethModule = new EthModule(config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, executor, new ExecutionBlockRetriever(miningMainchainViewMock, blockchain, null, null), repositoryLocator, new EthModuleWalletEnabled(wallet), new EthModuleTransactionBase(config.getNetworkConstants(), wallet, transactionPool, transactionGateway), new BridgeSupportFactory(null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig()), config.getGasEstimationCap());
    TxPoolModule txPoolModule = new TxPoolModuleImpl(transactionPool);
    DebugModule debugModule = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null);
    RskModule rskModule = new RskModuleImpl(blockchain, blockStore, receiptStore, retriever);
    MinerClient minerClient = new SimpleMinerClient();
    ChannelManager channelManager = new SimpleChannelManager();
    return new Web3RskImpl(eth, blockchain, config, minerClient, Web3Mocks.getMockMinerServer(), personalModule, ethModule, null, txPoolModule, null, debugModule, null, rskModule, channelManager, null, null, blockStore, receiptStore, null, nodeBlockProcessor, null, configCapabilities, new BuildInfo("test", "test"), null, retriever, syncProcessor);
}
Also used : EthModuleTransactionBase(co.rsk.rpc.modules.eth.EthModuleTransactionBase) ChannelManager(org.ethereum.net.server.ChannelManager) RskModule(co.rsk.rpc.modules.rsk.RskModule) Web3RskImpl(co.rsk.rpc.Web3RskImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) DebugModuleImpl(co.rsk.rpc.modules.debug.DebugModuleImpl) PersonalModuleWalletEnabled(co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled) TransactionGateway(co.rsk.net.TransactionGateway) MiningMainchainView(co.rsk.core.bc.MiningMainchainView) EthModuleWalletEnabled(co.rsk.rpc.modules.eth.EthModuleWalletEnabled) MinerClient(co.rsk.mine.MinerClient) Web3InformationRetriever(co.rsk.rpc.Web3InformationRetriever) EthModule(co.rsk.rpc.modules.eth.EthModule) BuildInfo(org.ethereum.util.BuildInfo) DebugModule(co.rsk.rpc.modules.debug.DebugModule) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) RskModuleImpl(co.rsk.rpc.modules.rsk.RskModuleImpl)

Example 7 with BuildInfo

use of org.ethereum.util.BuildInfo in project rskj by rsksmart.

the class Web3ImplSnapshotTest method getMinerServerForTest.

private MinerServer getMinerServerForTest(SimpleEthereum ethereum, MinerClock clock) {
    BlockValidationRule rule = new MinerManagerTest.BlockValidationRuleDummy();
    DifficultyCalculator difficultyCalculator = new DifficultyCalculator(config.getActivationConfig(), config.getNetworkConstants());
    MiningConfig miningConfig = ConfigUtils.getDefaultMiningConfig();
    return new MinerServerImpl(config, ethereum, mainchainView, factory.getNodeBlockProcessor(), new ProofOfWorkRule(config).setFallbackMiningEnabled(false), new BlockToMineBuilder(config.getActivationConfig(), miningConfig, factory.getRepositoryLocator(), factory.getBlockStore(), factory.getTransactionPool(), difficultyCalculator, new GasLimitCalculator(config.getNetworkConstants()), new ForkDetectionDataCalculator(), rule, clock, blockFactory, factory.getBlockExecutor(), new MinimumGasPriceCalculator(Coin.valueOf(miningConfig.getMinGasPriceTarget())), new MinerUtils()), clock, blockFactory, new BuildInfo("cb7f28e", "master"), miningConfig);
}
Also used : DifficultyCalculator(co.rsk.core.DifficultyCalculator) MiningConfig(co.rsk.config.MiningConfig) BuildInfo(org.ethereum.util.BuildInfo) BlockValidationRule(co.rsk.validators.BlockValidationRule) ProofOfWorkRule(co.rsk.validators.ProofOfWorkRule)

Example 8 with BuildInfo

use of org.ethereum.util.BuildInfo in project rskj by rsksmart.

the class Web3ImplTest method createWeb3CallNoReturn.

private Web3Impl createWeb3CallNoReturn(Ethereum eth, Blockchain blockchain, RepositoryLocator repositoryLocator, TransactionPool transactionPool, BlockStore blockStore, BlockProcessor nodeBlockProcessor, ConfigCapabilities configCapabilities, ReceiptStore receiptStore) {
    MiningMainchainView miningMainchainViewMock = mock(MiningMainchainView.class);
    ExecutionBlockRetriever executionBlockRetriever = mock(ExecutionBlockRetriever.class);
    wallet = WalletFactory.createWallet();
    PersonalModuleWalletEnabled personalModule = new PersonalModuleWalletEnabled(config, eth, wallet, transactionPool);
    ReversibleTransactionExecutor executor = mock(ReversibleTransactionExecutor.class);
    ProgramResult res = new ProgramResult();
    res.setHReturn(new byte[0]);
    when(executor.executeTransaction(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(res);
    Web3InformationRetriever retriever = new Web3InformationRetriever(transactionPool, blockchain, repositoryLocator, executionBlockRetriever);
    EthModule ethModule = new EthModule(config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, executor, new ExecutionBlockRetriever(miningMainchainViewMock, blockchain, null, null), repositoryLocator, new EthModuleWalletEnabled(wallet), new EthModuleTransactionBase(config.getNetworkConstants(), wallet, transactionPool, null), new BridgeSupportFactory(null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig()), config.getGasEstimationCap());
    TxPoolModule txPoolModule = new TxPoolModuleImpl(transactionPool);
    DebugModule debugModule = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null);
    RskModule rskModule = new RskModuleImpl(blockchain, blockStore, receiptStore, retriever);
    MinerClient minerClient = new SimpleMinerClient();
    ChannelManager channelManager = new SimpleChannelManager();
    return new Web3RskImpl(eth, blockchain, config, minerClient, Web3Mocks.getMockMinerServer(), personalModule, ethModule, null, txPoolModule, null, debugModule, null, rskModule, channelManager, null, null, blockStore, receiptStore, null, nodeBlockProcessor, null, configCapabilities, new BuildInfo("test", "test"), null, retriever, null);
}
Also used : EthModuleTransactionBase(co.rsk.rpc.modules.eth.EthModuleTransactionBase) ChannelManager(org.ethereum.net.server.ChannelManager) ProgramResult(org.ethereum.vm.program.ProgramResult) RskModule(co.rsk.rpc.modules.rsk.RskModule) Web3RskImpl(co.rsk.rpc.Web3RskImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) DebugModuleImpl(co.rsk.rpc.modules.debug.DebugModuleImpl) PersonalModuleWalletEnabled(co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled) MiningMainchainView(co.rsk.core.bc.MiningMainchainView) EthModuleWalletEnabled(co.rsk.rpc.modules.eth.EthModuleWalletEnabled) MinerClient(co.rsk.mine.MinerClient) Web3InformationRetriever(co.rsk.rpc.Web3InformationRetriever) EthModule(co.rsk.rpc.modules.eth.EthModule) BuildInfo(org.ethereum.util.BuildInfo) DebugModule(co.rsk.rpc.modules.debug.DebugModule) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) RskModuleImpl(co.rsk.rpc.modules.rsk.RskModuleImpl)

Example 9 with BuildInfo

use of org.ethereum.util.BuildInfo in project rskj by rsksmart.

the class MinerServerTest method extraDataNotInitializedWithClientData.

@Test
public void extraDataNotInitializedWithClientData() {
    MinerServer minerServer = new MinerServerImpl(config, null, null, null, null, null, null, null, new BuildInfo("cb7f28e", "master"), ConfigUtils.getDefaultMiningConfig());
    byte[] extraData = minerServer.getExtraData();
    RLPList decodedExtraData = RLP.decodeList(extraData);
    assertEquals(2, decodedExtraData.size());
    byte[] firstItem = decodedExtraData.get(0).getRLPData();
    assertNotNull(firstItem);
    assertEquals(1, (RLP.decodeInt(firstItem, 0)));
    byte[] secondItem = decodedExtraData.get(1).getRLPData();
    assertNotNull(secondItem);
    assertEquals(config.projectVersionModifier().concat("-cb7f28e"), new String(secondItem));
}
Also used : BuildInfo(org.ethereum.util.BuildInfo) RLPList(org.ethereum.util.RLPList) Test(org.junit.Test)

Example 10 with BuildInfo

use of org.ethereum.util.BuildInfo in project rskj by rsksmart.

the class TransactionModuleTest method internalCreateEnvironment.

private Web3Impl internalCreateEnvironment(Blockchain blockchain, MiningMainchainView mainchainView, ReceiptStore receiptStore, TransactionPool transactionPool, BlockStore blockStore, boolean mineInstant, StateRootHandler stateRootHandler, RepositoryLocator repositoryLocator, TransactionGateway transactionGateway, TransactionExecutorFactory transactionExecutorFactory) {
    transactionPool.processBest(blockchain.getBestBlock());
    ConfigCapabilities configCapabilities = new SimpleConfigCapabilities();
    CompositeEthereumListener compositeEthereumListener = new CompositeEthereumListener();
    Ethereum eth = new EthereumImpl(new ChannelManagerImpl(config, new SyncPool(compositeEthereumListener, blockchain, config, null, null, null)), transactionGateway, compositeEthereumListener, blockchain);
    MinerClock minerClock = new MinerClock(true, Clock.systemUTC());
    this.transactionExecutorFactory = transactionExecutorFactory;
    MiningConfig miningConfig = ConfigUtils.getDefaultMiningConfig();
    BlockExecutor blockExecutor = new BlockExecutor(config.getActivationConfig(), repositoryLocator, // stateRootHandler,
    this.transactionExecutorFactory);
    MinerServer minerServer = new MinerServerImpl(config, eth, mainchainView, null, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), new BlockToMineBuilder(config.getActivationConfig(), miningConfig, repositoryLocator, blockStore, transactionPool, new DifficultyCalculator(config.getActivationConfig(), config.getNetworkConstants()), new GasLimitCalculator(config.getNetworkConstants()), new ForkDetectionDataCalculator(), mock(BlockUnclesValidationRule.class), minerClock, blockFactory, blockExecutor, new MinimumGasPriceCalculator(Coin.valueOf(miningConfig.getMinGasPriceTarget())), new MinerUtils()), minerClock, blockFactory, new BuildInfo("cb7f28e", "master"), miningConfig);
    Wallet wallet = WalletFactory.createWallet();
    PersonalModuleWalletEnabled personalModule = new PersonalModuleWalletEnabled(config, eth, wallet, transactionPool);
    MinerClient minerClient = new MinerClientImpl(null, minerServer, config.minerClientDelayBetweenBlocks(), config.minerClientDelayBetweenRefreshes());
    EthModuleTransaction transactionModule;
    ReversibleTransactionExecutor reversibleTransactionExecutor1 = new ReversibleTransactionExecutor(repositoryLocator, this.transactionExecutorFactory);
    if (mineInstant) {
        transactionModule = new EthModuleTransactionInstant(config.getNetworkConstants(), wallet, transactionPool, minerServer, minerClient, blockchain, transactionGateway, blockExecutor);
    } else {
        transactionModule = new EthModuleTransactionBase(config.getNetworkConstants(), wallet, transactionPool, transactionGateway);
    }
    final RepositoryBtcBlockStoreWithCache.Factory btcBlockStoreFactory = new RepositoryBtcBlockStoreWithCache.Factory(config.getNetworkConstants().getBridgeConstants().getBtcParams());
    EthModule ethModule = new EthModule(config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, reversibleTransactionExecutor1, new ExecutionBlockRetriever(mainchainView, blockchain, null, null), repositoryLocator, new EthModuleWalletEnabled(wallet), transactionModule, new BridgeSupportFactory(btcBlockStoreFactory, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig()), config.getGasEstimationCap());
    TxPoolModule txPoolModule = new TxPoolModuleImpl(transactionPool);
    DebugModule debugModule = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null);
    ChannelManager channelManager = new SimpleChannelManager();
    return new Web3RskImpl(eth, blockchain, config, minerClient, Web3Mocks.getMockMinerServer(), personalModule, ethModule, null, txPoolModule, null, debugModule, null, null, channelManager, null, null, blockStore, receiptStore, null, null, null, configCapabilities, null, null, null, null);
}
Also used : ConfigCapabilities(org.ethereum.net.client.ConfigCapabilities) SimpleConfigCapabilities(org.ethereum.rpc.Simples.SimpleConfigCapabilities) Web3RskImpl(co.rsk.rpc.Web3RskImpl) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) PersonalModuleWalletEnabled(co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled) ProofOfWorkRule(co.rsk.validators.ProofOfWorkRule) RepositoryBtcBlockStoreWithCache(co.rsk.peg.RepositoryBtcBlockStoreWithCache) SimpleChannelManager(org.ethereum.rpc.Simples.SimpleChannelManager) SyncPool(org.ethereum.sync.SyncPool) Ethereum(org.ethereum.facade.Ethereum) DebugModule(co.rsk.rpc.modules.debug.DebugModule) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) ChannelManagerImpl(org.ethereum.net.server.ChannelManagerImpl) SimpleChannelManager(org.ethereum.rpc.Simples.SimpleChannelManager) ChannelManager(org.ethereum.net.server.ChannelManager) EthereumImpl(org.ethereum.facade.EthereumImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) DebugModuleImpl(co.rsk.rpc.modules.debug.DebugModuleImpl) MiningConfig(co.rsk.config.MiningConfig) CompositeEthereumListener(org.ethereum.listener.CompositeEthereumListener) BuildInfo(org.ethereum.util.BuildInfo) SimpleConfigCapabilities(org.ethereum.rpc.Simples.SimpleConfigCapabilities) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule)

Aggregations

BuildInfo (org.ethereum.util.BuildInfo)12 ProofOfWorkRule (co.rsk.validators.ProofOfWorkRule)6 Test (org.junit.Test)6 EthereumImpl (org.ethereum.facade.EthereumImpl)4 MiningConfig (co.rsk.config.MiningConfig)3 BridgeSupportFactory (co.rsk.peg.BridgeSupportFactory)3 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)3 Web3RskImpl (co.rsk.rpc.Web3RskImpl)3 DebugModule (co.rsk.rpc.modules.debug.DebugModule)3 DebugModuleImpl (co.rsk.rpc.modules.debug.DebugModuleImpl)3 PersonalModuleWalletEnabled (co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled)3 TxPoolModule (co.rsk.rpc.modules.txpool.TxPoolModule)3 TxPoolModuleImpl (co.rsk.rpc.modules.txpool.TxPoolModuleImpl)3 ChannelManager (org.ethereum.net.server.ChannelManager)3 RLPList (org.ethereum.util.RLPList)3 DifficultyCalculator (co.rsk.core.DifficultyCalculator)2 BlockChainImplTest (co.rsk.core.bc.BlockChainImplTest)2 MiningMainchainView (co.rsk.core.bc.MiningMainchainView)2 MinerClient (co.rsk.mine.MinerClient)2 Web3InformationRetriever (co.rsk.rpc.Web3InformationRetriever)2