Search in sources :

Example 1 with GenesisConfig

use of org.ethereum.config.blockchain.GenesisConfig in project rskj by rsksmart.

the class ImportLightTest method createBlockchain.

public static BlockChainImpl createBlockchain(Genesis genesis) {
    RskSystemProperties config = new RskSystemProperties();
    config.setBlockchainConfig(new GenesisConfig(new GenesisConfig.GenesisConstants() {

        @Override
        public BlockDifficulty getMinimumDifficulty() {
            return new BlockDifficulty(BigInteger.ONE);
        }
    }));
    IndexedBlockStore blockStore = new IndexedBlockStore(new HashMap<>(), new HashMapDB(), null);
    Repository repository = new RepositoryImpl(config, new TrieStoreImpl(new HashMapDB()));
    EthereumListenerAdapter listener = new EthereumListenerAdapter();
    KeyValueDataSource ds = new HashMapDB();
    ds.init();
    ReceiptStore receiptStore = new ReceiptStoreImpl(ds);
    BlockChainImpl blockchain = new BlockChainImpl(config, repository, blockStore, receiptStore, null, listener, new AdminInfo(), new DummyBlockValidator());
    blockchain.setNoValidation(true);
    TransactionPoolImpl transactionPool = new TransactionPoolImpl(config, repository, null, receiptStore, null, listener, 10, 100);
    blockchain.setTransactionPool(transactionPool);
    Repository track = repository.startTracking();
    for (RskAddress addr : genesis.getPremine().keySet()) {
        track.createAccount(addr);
        track.addBalance(addr, genesis.getPremine().get(addr).getAccountState().getBalance());
    }
    track.commit();
    genesis.setStateRoot(repository.getRoot());
    genesis.flushRLP();
    blockStore.saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
    blockchain.setBestBlock(genesis);
    blockchain.setTotalDifficulty(genesis.getCumulativeDifficulty());
    return blockchain;
}
Also used : TrieStoreImpl(co.rsk.trie.TrieStoreImpl) IndexedBlockStore(org.ethereum.db.IndexedBlockStore) AdminInfo(org.ethereum.manager.AdminInfo) BlockChainImpl(co.rsk.core.bc.BlockChainImpl) HashMapDB(org.ethereum.datasource.HashMapDB) EthereumListenerAdapter(org.ethereum.listener.EthereumListenerAdapter) ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) DummyBlockValidator(co.rsk.validators.DummyBlockValidator) BlockDifficulty(co.rsk.core.BlockDifficulty) TransactionPoolImpl(co.rsk.core.bc.TransactionPoolImpl) RepositoryImpl(co.rsk.db.RepositoryImpl) RskAddress(co.rsk.core.RskAddress) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) RskSystemProperties(co.rsk.config.RskSystemProperties) ReceiptStore(org.ethereum.db.ReceiptStore) GenesisConfig(org.ethereum.config.blockchain.GenesisConfig)

Example 2 with GenesisConfig

use of org.ethereum.config.blockchain.GenesisConfig in project rskj by rsksmart.

the class GitHubStateTest method setup.

@BeforeClass
public void setup() {
    // TODO remove this after Homestead launch and shacommit update with actual block number
    // for this JSON test commit the Homestead block was defined as 900000
    config = new RskSystemProperties();
    config.setBlockchainConfig(new AbstractNetConfig() {

        {
            add(0, new GenesisConfig());
        }
    });
}
Also used : AbstractNetConfig(org.ethereum.config.net.AbstractNetConfig) RskSystemProperties(co.rsk.config.RskSystemProperties) GenesisConfig(org.ethereum.config.blockchain.GenesisConfig)

Aggregations

RskSystemProperties (co.rsk.config.RskSystemProperties)2 GenesisConfig (org.ethereum.config.blockchain.GenesisConfig)2 BlockDifficulty (co.rsk.core.BlockDifficulty)1 RskAddress (co.rsk.core.RskAddress)1 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)1 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)1 RepositoryImpl (co.rsk.db.RepositoryImpl)1 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)1 DummyBlockValidator (co.rsk.validators.DummyBlockValidator)1 AbstractNetConfig (org.ethereum.config.net.AbstractNetConfig)1 HashMapDB (org.ethereum.datasource.HashMapDB)1 KeyValueDataSource (org.ethereum.datasource.KeyValueDataSource)1 IndexedBlockStore (org.ethereum.db.IndexedBlockStore)1 ReceiptStore (org.ethereum.db.ReceiptStore)1 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)1 EthereumListenerAdapter (org.ethereum.listener.EthereumListenerAdapter)1 AdminInfo (org.ethereum.manager.AdminInfo)1