### Question:
TrieCopier { public static void trieContractStateCopy(TrieStore target, Blockchain blockchain, long initialHeight, long finalHeight, Repository repository, UscAddress contractAddress) { long h = initialHeight; List<Block> blocks = blockchain.getBlocksByNumber(h); while (!blocks.isEmpty()) { for (Block block : blocks) { Repository stateRepository = repository.getSnapshotTo(block.getStateRoot()); AccountState accountState = stateRepository.getAccountState(contractAddress); ContractDetailsImpl contractDetails = (ContractDetailsImpl)stateRepository.getContractDetails(contractAddress); TrieImpl trie = (TrieImpl)contractDetails.getTrie(); trieStateCopy(trie.getStore(), target, new Keccak256(accountState.getStateRoot())); } h++; if (finalHeight > 0 && finalHeight < h) { break; } blocks = blockchain.getBlocksByNumber(h); } } private  TrieCopier(); static void trieStateCopy(TrieStore source, TrieStore target, Keccak256 hash); static void trieStateCopy(TrieStore source, TrieStore target, Blockchain blockchain, int initialHeight); static void trieContractStateCopy(TrieStore target, Blockchain blockchain, long initialHeight, long finalHeight, Repository repository, UscAddress contractAddress);  }### Answer:
@Test public void copyBlockchainHeightTwoContractStates() { TrieStore store = new TrieStoreImpl(new HashMapDB().setClearOnClose(false)); TrieStore store2 = new TrieStoreImpl(new HashMapDB().setClearOnClose(false)); Repository repository = new RepositoryImpl(store, new TrieStorePoolOnMemory(), config.detailsInMemoryStorageLimit()); World world = new World(repository); Blockchain blockchain = createBlockchain(world); addBlocks(world, blockchain, 100); byte[] state99 = blockchain.getBlockByNumber(99).getStateRoot(); TrieCopier.trieContractStateCopy(store2, blockchain, 99, 100, world.getRepository(), PrecompiledContracts.REMASC_ADDR); Repository repository99 = repository.getSnapshotTo(state99); AccountState accountState99 = repository99.getAccountState(PrecompiledContracts.REMASC_ADDR); Assert.assertNotNull(store2.retrieve(accountState99.getStateRoot())); }