Building your Score
<<
epoch::32-little,
segment_vr_hash::32-binary,
node_pk::48-binary,
node_pop::96-binary,
solver_pk::48-binary, # (optional) hint who solved the sol
nonce::12-binary
>>
seed = <<
Consensus.chain_epoch()::32-little,
Consensus.chain_segment_vr_hash()::32-binary,
Application.fetch_env!(:ama, :trainer_pk)::48-binary,
Application.fetch_env!(:ama, :trainer_pop)::96-binary,
Application.fetch_env!(:ama, :trainer_pk)::48-binary,
:crypto.strong_rand_bytes(12)::12-binary
>>
b = Blake3.new()
Blake3.update(b, seed)
<<
matrix_a::binary-size(16*50240),
matrix_b::binary-size(50240*16)
>> = Blake3.finalize_xof(b, 16*50240 + 50240*16)
c = MatrixMul.multiply(matrix_a, matrix_b) |> MatrixMul.map_to_binary()
solution = seed <> c
diff_bits = Consensus.chain_diff_bits()
<<leading_zeros::size(diff_bits), _::bitstring>> = hash = Blake3.hash(solution)
if leading_zeros == 0 do
IO.puts "congratulations, broadcast this now to the network to increase score"
tx_packed = TX.build(Application.fetch_env!(:ama, :trainer_sk),
"Epoch", "submit_sol", [solution])
TXPool.insert_and_broadcast(tx_packed)
endLast updated