Sfoglia il codice sorgente

validator/pow: Use RandomXFactory for PoW verification

parazyd 1 anno fa
parent
commit
ad36ed0eb6
2 ha cambiato i file con 5 aggiunte e 2 eliminazioni
  1. 2 0
      Makefile
  2. 3 2
      src/validator/pow.rs

+ 2 - 0
Makefile

@@ -10,6 +10,8 @@ CARGO = cargo
 RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
 # Uncomment when doing musl static builds
 #RUSTFLAGS = -C target-feature=+crt-static -C link-self-contained=yes
+# If building natively, this might give you more speed
+#RUSTFLAGS = -C target_cpu=native
 
 # List of zkas circuits to compile, used for tests
 PROOFS_SRC = \

+ 3 - 2
src/validator/pow.rs

@@ -283,9 +283,10 @@ impl PoWModule {
         let target = self.next_mine_target()?;
 
         // Setup verifier
+        let randomx_key = block.header.previous.inner();
         let flags = RandomXFlags::get_recommended_flags();
-        let cache = RandomXCache::new(flags, block.header.previous.inner())?;
-        let vm = RandomXVM::new(flags, Some(cache), None)?;
+        let cache = RandomXCache::new(flags, &randomx_key[..])?;
+        let vm = self.darkfi_rx_factory.create(&randomx_key[..], Some(cache), None)?;
         debug!(target: "validator::pow::verify_block", "[VERIFIER] Setup time: {:?}", verifier_setup.elapsed());
 
         // Compute the output hash