lambdaclass / ethereum_rust

Lambda Ethereum Rust Execution client
Apache License 2.0
126 stars 12 forks source link

Get blocks by their hash from Store #280

Open vicentevieytes opened 1 month ago

vicentevieytes commented 1 month ago

We should be able to fetch blocks by their hash, like we do with transactions in get_transactions_by_hash.

The hash can be computed with the compute_block_hash method of BlockHeader:

impl BlockHeader {
    pub fn compute_block_hash(&self) -> H256 {
        let mut buf = vec![];
        self.encode(&mut buf);
        keccak(buf)
    }
mpaulucci commented 1 month ago

We should have 3 tables:

Headers: height|hash => rpl(block) CanonicalHeaders: height => hash HeaderNumber hash => height