#crypto #solana #mars #marsh #miraland

marsh-drillx

Drillx is a proof-of-work algorithm for Marsh mining mission. Fork of regolith-labs/drillx

8 releases (4 stable)

2.1.0 Aug 23, 2024
2.0.1 Aug 21, 2024
2.0.0-rc3 Jul 16, 2024
1.0.0 Jul 31, 2024
0.2.0 Jul 2, 2024

#1 in #marsh

Download history 64/week @ 2024-08-24 15/week @ 2024-08-31 20/week @ 2024-09-07 28/week @ 2024-09-14 38/week @ 2024-09-21 38/week @ 2024-09-28 12/week @ 2024-10-05 10/week @ 2024-10-12 4/week @ 2024-10-19 2/week @ 2024-10-26 8/week @ 2024-11-02 1/week @ 2024-11-09 4/week @ 2024-11-16 7/week @ 2024-11-23 3/week @ 2024-11-30 107/week @ 2024-12-07

121 downloads per month
Used in 4 crates

Apache-2.0 and LGPL-3.0-only

12KB
191 lines

Drillx

Drillx is a proof-of-work algorithm for smart contract or program based crypto asset mining.

Summary

Drillx builds upon Equix, the CPU-friendly client puzzle designed to protect Tor from DOS attacks. Equix itself is a variation of Equihash, an asymmetric proof-of-work function with cheap verifications. Drillx adds a Blake3 hashing step on top of Equix to guarantee a difficulty distribution of p(Z) = 2^-Z where Z is the number of leading zeros on the hash. A challenge C is assumed to be a securely generated 256-bit hash, seeded by a recent Solana blockhash. Miners compete to find a 64-bit nonce N that produces a hash of their target difficulty. Solutions must be presented in the form (E, N) where E = Equix(C, N). The difficulty is calculated from Blake3(E', N) where E' is the Equix proof, sorted lexographically to prevent malleability. Since E can be efficiently verified on-chain and Blake3 is available as a Solana syscall, Drillx solutions can easily fit into a single Solana transaction.

Usage

Miners can iterate through nonces to find a hash that satisfies their target difficulty.

use drillx::{equix::SolverMemory, Solution};

fn main() {
    let challenge = [255; 32]; // Should be provided by a program
    let target = 8;
    let mut memory = SolverMemory::new();
    for nonce in 0..u64::MAX {
        let hx = drillx::hash_with_memory(&mut memory, &challenge, &nonce.to_le_bytes());
        if hx.difficuty() >= target {
            println!("Solution: {:?}", Solution::new(hx.d, nonce));
            return
        }
    }
}

Smart contracts can verify the solution and use the difficulty to issue token rewards.

use drillx::Solution;

fn verify(solution: Solution) {
    let challenge = [255; 32]; // Fetch from state
    let target = 8;
    assert!(solution.is_valid(&challenge));
    assert!(solution.to_hash().difficulty() >= target);
}

Dependencies

~2–11MB
~121K SLoC