#block-header #arweave #validation #pow #hash #merkle #difficulty

arweave_rs_validator

Methods for doing PoW pre-validation on Arweave block headers to verify their integrity

1 unstable release

0.1.0 Feb 14, 2024

#5 in #arweave

Download history 54/week @ 2024-07-28

54 downloads per month

MIT/Apache

125KB
2K SLoC

Validator

This libary package cointains the components neccessary to validate that an Arweave block was produced by Proof-of-work consensus and met or exceeded the difficulty setting of the network at the time it was produce.

Because Arweave uses a "Proof-of-useful-work" mechanisim where the hashes computed to produce a block are calcuated from Arweaves historical data, thes steps for validaing consensus are more elaborate then simply comparing a hash.

Validation Tests

To validate an Arweave block header you need the block header currently being validated, and the previous block header.

The steps are as follows

https://github.com/ThePeopleOfTheNetwork/arweave_rs/blob/ee2fa244de829b78a02517784abb161247790cb5/validator/src/lib.rs#L18-L157

Huge thanks to janekolszak for his go work on computing the block_hash for validation. Also to CalebEverett for the merkle tree building blocks which I borrowed from arloader. Both were insturmental in completing the validation steps.

Merkle Proofs

There are two merkle proofs in a block header. The tx_path and the data_path. The tx_path is the path though a merkle tree composed of all the data_roots of all the transactions in the block. It proves that the transaction the chunk belongs to was part of the block. The data_path is the path though the merkle tree composed of all the chunks in the transaction. It maps the path from the transactions data_root to a specific chunk. In thise case, the chunk provided as part of the poa or poa2 data.

Dependencies

~15–32MB
~523K SLoC