Bitcoin Forum
November 06, 2024, 04:28:57 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Alternate cryptocurrencies / Altcoin Discussion / Ethereum Cache Generation Examples on: November 04, 2017, 03:52:24 PM
Does anyone have an example of Ethereum cache generation with the first few bytes of the cache after the initial dataset creation, then after each round of RandMemoHash?  I'm trying to re-create the code done here: https://github.com/ethereum/wiki/wiki/Ethash in Scala.  I'm getting the wrong results and want to check my work.  If anyone does Scala and wants to see the code, it's below.  I think my problem probably has something to do with byte ordering and I'd like something to check it against.  Thanks.

Code:
import org.bouncycastle.jcajce.provider.digest.SHA3
import org.bouncycastle.util.encoders.Hex

object Ethash {
 
  val CACHE_BYTES_INIT:Long   = Math.pow(2, 24).toLong
  val CACHE_BYTES_GROWTH:Long = Math.pow(2, 17).toLong
  val EPOCH_LENGTH:Long       = 30000
  val HASH_BYTES:Int          = 64
  val CACHE_ROUNDS:Int        = 3
 
  def cacheSize(blockNumber:Long):Long = {
    val linearSize:Long = CACHE_BYTES_INIT + CACHE_BYTES_GROWTH * (blockNumber / EPOCH_LENGTH) - HASH_BYTES
    Stream.from(0).map(x => linearSize - (2*x*HASH_BYTES)).filter(x => Utilities.isPrime(x/HASH_BYTES)).head
  }
 
  def makeCache(size:Long, seed:Array[Byte]):Array[Byte] = {
    import Utilities.sha3_512
    val n:Int = (size/HASH_BYTES).toInt
   
    //Sequentially produce initial dataset
    val ans = Stream.iterate(seed){x => Utilities.sha3_512(x)}.drop(1).flatten.take(size.toInt).toArray
    val hashes:Array[Sha3Hash] = ans.sliding(64, 64).map { x => new Sha3Hash(x) }.toArray
   
    //Use a low-round version of randmemohash
    0.to(CACHE_ROUNDS-1).foreach{ _ =>
      0.to(n - 1).foreach{ i =>
        val v = (hashes(i).bytes.head & 0xFF) % n
        hashes(i) = new Sha3Hash(sha3_512( hashes((i-1+n) % n).xor(hashes(v)) ))
      }
    }
   
    hashes.map { x => x.bytes.toSeq }.toSeq.flatten.toArray
  }
}

object Utilities {
 
  def isPrime(x:Long):Boolean =
    !2L.to(Math.sqrt(x).toLong).exists{factor => x%factor == 0}
 
  def sha3_512(x:Array[Byte]):Array[Byte] = new SHA3.Digest512().digest(x)
 
}

class Sha3Hash(val bytes:Array[Byte]) {
  if (bytes.size != 64) throw new Exception(s"Byte array for a Sha3Hash must be 64 bytes")

  def xor(other:Sha3Hash):Array[Byte] = bytes.zip(other.bytes).map(pr => (pr._1 ^ pr._2).toByte).toArray
 
  override def toString = Hex.toHexString(bytes)
 
}
2  Bitcoin / Bitcoin Technical Support / 32-bit Timestamp in Block Header? on: October 26, 2017, 04:05:04 AM
I'm reading Mastering Bitcoin by Andreas Antonopoulos and it says that a 32-bit timestamp is used in the header (4 bytes), but by my calculation, that means that the timestamp will max out in 2106.  What happens after that?  Isn't the Unix epoch time usually represented by 64 bits?

Groovy Code:
println Instant.ofEpochSecond(Math.pow(256,4).toLong())
//Gives 2106-02-07T06:28:16Z
3  Bitcoin / Development & Technical Discussion / Re: "No such mempool transaction" When Trying to Get a Raw Transaction on: October 24, 2017, 04:43:53 AM
I added txindex=1 to bitcoin.conf and restarted bitcoind and that did it Smiley  Thanks!
4  Bitcoin / Development & Technical Discussion / "No such mempool transaction" When Trying to Get a Raw Transaction on: October 24, 2017, 01:52:07 AM
I'm using Bitcoin core and trying to get a raw transaction using the command:

bitcoin-cli getrawtransaction d5ada064c6417ca25c4308bd158c34b77e1c0eca2a73cda16c737e7424afba2f

It's a transaction in the block at height 277316.  I'm getting the message "No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions."  It sounds like I'm supposed to use a -txindex option but when I type "bitcoin-cli help getrawtransaction" it doesn't say anything about this option and it doesn't work when I try it.  What does this message mean and how do I resolve it?  The other weird thing is that it works with some transactions in the block, but not all.  There are 419 transactions in that block and for 34 of them, the getrawtransaction command works the way I'm trying to use it.  All the rest fail. 

I've seen another post where it says that this message can sometimes mean that it's a transaction that was never accepted by the network, but I just started my full node and downloaded a fresh copy of the blockchain a few days ago and the transactions that are giving me errors show up on https://blockexplorer.com/blocks.  Thanks!
5  Alternate cryptocurrencies / Mining (Altcoins) / Re: Claymore Miner Remote Management on: January 23, 2017, 11:51:46 PM
Why not?  Is there a rule saying we need one 400-page long thread per mining software version?
6  Alternate cryptocurrencies / Mining (Altcoins) / Claymore Miner Remote Management on: January 21, 2017, 10:00:27 PM
The readme for the Claymore Miner says remote management is possible over TCPIP but when it explains where to find details, it talks about the Windows version.  Is there some other way to find out the details of how the protocol works for us Linux users?

I'm writing some code that uses my GPU for a non-mining purpose and I'm hoping it's possible to connect to the claymore instance that's running using TCPIP, tell it to use only one GPU (I have two), run its own computation using the GPU, then send another message telling claymore to go back to full speed on both GPUs.  I know it's possible to just close the current claymore instance and start it again with new command line arguments, but I'd like to be able to avoid that.  Thanks.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!