Search in sources :

Example 6 with TransactionExecutorFactory

use of co.rsk.core.TransactionExecutorFactory in project rskj by rsksmart.

the class BlockChainBuilder method build.

public BlockChainImpl build() {
    BlocksIndex blocksIndex = new HashMapBlocksIndex();
    if (config == null) {
        config = new TestSystemProperties();
    }
    if (trieStore == null) {
        trieStore = new TrieStoreImpl(new HashMapDB().setClearOnClose(false));
    }
    if (repository == null) {
        repository = new MutableRepository(trieStore, new Trie(trieStore));
    }
    if (stateRootHandler == null) {
        stateRootHandler = new StateRootHandler(config.getActivationConfig(), new StateRootsStoreImpl(new HashMapDB()));
    }
    if (genesis == null) {
        genesis = new BlockGenerator().getGenesisBlock();
    }
    GenesisLoaderImpl.loadGenesisInitalState(repository, genesis);
    repository.commit();
    genesis.setStateRoot(repository.getRoot());
    genesis.flushRLP();
    BlockFactory blockFactory = new BlockFactory(config.getActivationConfig());
    if (blockStore == null) {
        blockStore = new IndexedBlockStore(blockFactory, new HashMapDB(), blocksIndex);
    }
    if (receiptStore == null) {
        KeyValueDataSource ds = new HashMapDB();
        ds.init();
        receiptStore = new ReceiptStoreImpl(ds);
    }
    if (listener == null) {
        listener = new BlockExecutorTest.SimpleEthereumListener();
    }
    if (bridgeSupportFactory == null) {
        bridgeSupportFactory = new BridgeSupportFactory(new RepositoryBtcBlockStoreWithCache.Factory(config.getNetworkConstants().getBridgeConstants().getBtcParams()), config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig());
    }
    BlockValidatorBuilder validatorBuilder = new BlockValidatorBuilder();
    validatorBuilder.addBlockRootValidationRule().addBlockUnclesValidationRule(blockStore).addBlockTxsValidationRule(trieStore).blockStore(blockStore);
    BlockValidator blockValidator = validatorBuilder.build();
    ReceivedTxSignatureCache receivedTxSignatureCache = new ReceivedTxSignatureCache();
    BlockTxSignatureCache blockTxSignatureCache = new BlockTxSignatureCache(receivedTxSignatureCache);
    TransactionExecutorFactory transactionExecutorFactory = new TransactionExecutorFactory(config, blockStore, receiptStore, blockFactory, new ProgramInvokeFactoryImpl(), new PrecompiledContracts(config, bridgeSupportFactory), blockTxSignatureCache);
    repositoryLocator = new RepositoryLocator(trieStore, stateRootHandler);
    transactionPool = new TransactionPoolImpl(config, repositoryLocator, this.blockStore, blockFactory, new TestCompositeEthereumListener(), transactionExecutorFactory, new ReceivedTxSignatureCache(), 10, 100);
    BlockExecutor blockExecutor = new BlockExecutor(config.getActivationConfig(), repositoryLocator, transactionExecutorFactory);
    BlockChainImpl blockChain = new BlockChainLoader(blockStore, receiptStore, transactionPool, listener, blockValidator, blockExecutor, genesis, stateRootHandler, repositoryLocator).loadBlockchain();
    if (this.testing) {
        blockChain.setBlockValidator(new DummyBlockValidator());
        blockChain.setNoValidation(true);
    }
    blockStore.saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
    if (this.blocks != null) {
        for (Block b : this.blocks) {
            blockExecutor.executeAndFillAll(b, blockChain.getBestBlock().getHeader());
            blockChain.tryToConnect(b);
        }
    }
    return blockChain;
}
Also used : BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) BlockValidator(co.rsk.validators.BlockValidator) DummyBlockValidator(co.rsk.validators.DummyBlockValidator) ProgramInvokeFactoryImpl(org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory) DummyBlockValidator(co.rsk.validators.DummyBlockValidator) TestCompositeEthereumListener(org.ethereum.listener.TestCompositeEthereumListener) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) Trie(co.rsk.trie.Trie) TrieStoreImpl(co.rsk.trie.TrieStoreImpl) BlockChainLoader(org.ethereum.core.genesis.BlockChainLoader) HashMapDB(org.ethereum.datasource.HashMapDB) PrecompiledContracts(org.ethereum.vm.PrecompiledContracts) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) TestSystemProperties(co.rsk.config.TestSystemProperties)

Example 7 with TransactionExecutorFactory

use of co.rsk.core.TransactionExecutorFactory in project rskj by rsksmart.

the class BlockBuilder method build.

public Block build() {
    Block block = blockGenerator.createChildBlock(parent, txs, uncles, difficulty, this.minGasPrice, gasLimit);
    if (blockChain != null) {
        final TestSystemProperties config = new TestSystemProperties();
        StateRootHandler stateRootHandler = new StateRootHandler(config.getActivationConfig(), new StateRootsStoreImpl(new HashMapDB()));
        BlockExecutor executor = new BlockExecutor(config.getActivationConfig(), new RepositoryLocator(trieStore, stateRootHandler), new TransactionExecutorFactory(config, blockStore, null, new BlockFactory(config.getActivationConfig()), new ProgramInvokeFactoryImpl(), new PrecompiledContracts(config, bridgeSupportFactory), new BlockTxSignatureCache(new ReceivedTxSignatureCache())));
        executor.executeAndFill(block, parent.getHeader());
    }
    return block;
}
Also used : StateRootsStoreImpl(co.rsk.db.StateRootsStoreImpl) BlockExecutor(co.rsk.core.bc.BlockExecutor) HashMapDB(org.ethereum.datasource.HashMapDB) ProgramInvokeFactoryImpl(org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory) StateRootHandler(co.rsk.db.StateRootHandler) RepositoryLocator(co.rsk.db.RepositoryLocator) PrecompiledContracts(org.ethereum.vm.PrecompiledContracts) TestSystemProperties(co.rsk.config.TestSystemProperties)

Example 8 with TransactionExecutorFactory

use of co.rsk.core.TransactionExecutorFactory in project rskj by rsksmart.

the class TransactionTest method executeTransaction.

private TransactionExecutor executeTransaction(Blockchain blockchain, BlockStore blockStore, Transaction tx, Repository repository, BlockTxSignatureCache blockTxSignatureCache) {
    Repository track = repository.startTracking();
    BridgeSupportFactory bridgeSupportFactory = new BridgeSupportFactory(new RepositoryBtcBlockStoreWithCache.Factory(config.getNetworkConstants().getBridgeConstants().getBtcParams()), config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig());
    TransactionExecutorFactory transactionExecutorFactory = new TransactionExecutorFactory(config, blockStore, null, blockFactory, new ProgramInvokeFactoryImpl(), new PrecompiledContracts(config, bridgeSupportFactory), blockTxSignatureCache);
    TransactionExecutor executor = transactionExecutorFactory.newInstance(tx, 0, RskAddress.nullAddress(), repository, blockchain.getBestBlock(), 0);
    executor.executeTransaction();
    track.commit();
    return executor;
}
Also used : RepositoryBtcBlockStoreWithCache(co.rsk.peg.RepositoryBtcBlockStoreWithCache) MutableRepository(org.ethereum.db.MutableRepository) PrecompiledContracts(org.ethereum.vm.PrecompiledContracts) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) ProgramInvokeFactoryImpl(org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory)

Example 9 with TransactionExecutorFactory

use of co.rsk.core.TransactionExecutorFactory in project rskj by rsksmart.

the class EthModuleTestUtils method buildBasicEthModuleForGasEstimation.

public static EthModuleGasEstimation buildBasicEthModuleForGasEstimation(World world) {
    TestSystemProperties config = new TestSystemProperties();
    TransactionExecutorFactory executor = buildBasicExecutorFactory(world, config);
    return new EthModuleGasEstimation(null, Constants.REGTEST_CHAIN_ID, world.getBlockChain(), null, new ReversibleTransactionExecutor(world.getRepositoryLocator(), executor), new ExecutionBlockRetriever(null, world.getBlockChain(), null, null), null, null, null, world.getBridgeSupportFactory(), config.getGasEstimationCap());
}
Also used : ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TestSystemProperties(co.rsk.config.TestSystemProperties) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory)

Example 10 with TransactionExecutorFactory

use of co.rsk.core.TransactionExecutorFactory in project rskj by rsksmart.

the class EthModuleTestUtils method buildBasicEthModule.

public static EthModule buildBasicEthModule(World world) {
    TestSystemProperties config = new TestSystemProperties();
    TransactionExecutorFactory executor = buildBasicExecutorFactory(world, config);
    return new EthModule(null, Constants.REGTEST_CHAIN_ID, world.getBlockChain(), null, new ReversibleTransactionExecutor(world.getRepositoryLocator(), executor), new ExecutionBlockRetriever(null, world.getBlockChain(), null, null), null, null, null, world.getBridgeSupportFactory(), config.getGasEstimationCap());
}
Also used : EthModule(co.rsk.rpc.modules.eth.EthModule) ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TestSystemProperties(co.rsk.config.TestSystemProperties) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory)

Aggregations

TransactionExecutorFactory (co.rsk.core.TransactionExecutorFactory)18 ProgramInvokeFactoryImpl (org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl)13 PrecompiledContracts (org.ethereum.vm.PrecompiledContracts)11 TestSystemProperties (co.rsk.config.TestSystemProperties)8 BlockExecutor (co.rsk.core.bc.BlockExecutor)8 BridgeSupportFactory (co.rsk.peg.BridgeSupportFactory)8 HashMapDB (org.ethereum.datasource.HashMapDB)7 RskAddress (co.rsk.core.RskAddress)5 RepositoryLocator (co.rsk.db.RepositoryLocator)5 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)4 StateRootHandler (co.rsk.db.StateRootHandler)4 StateRootsStoreImpl (co.rsk.db.StateRootsStoreImpl)4 RepositoryBtcBlockStoreWithCache (co.rsk.peg.RepositoryBtcBlockStoreWithCache)4 ReversibleTransactionExecutor (co.rsk.core.ReversibleTransactionExecutor)3 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)3 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)3 DummyBlockValidator (co.rsk.validators.DummyBlockValidator)3 KeyValueDataSource (org.ethereum.datasource.KeyValueDataSource)3 TestCompositeEthereumListener (org.ethereum.listener.TestCompositeEthereumListener)3 Coin (co.rsk.core.Coin)2