Skip to content

Conversation

@fmoletta
Copy link
Contributor

@fmoletta fmoletta commented Jul 12, 2024

Motivation

Being able to store and fetch blocks from the db via Store api

Description

  • Replace Transaction::encode with Transaction::encode_with_type logic (Reasoning: We cannot decode the transactions without knowing their type with the current behaviour, making it impossible to implement RLPDecode for Transaction)
  • Implement RLPDecode for Transaction (Using the logic that was previoulsy used in EncodedTransaction::decode (payload module))
  • Implement RLPDecode for Withdrawal, BlockHeader and BlockBody
  • Add the folloewng methods to Store and StoreEngine: add_block_header, add_block_body, get_block_header, get_block_body, and implement them for InMemory and Libmdbx engine types

Closes None, but is needed for #145

@fmoletta fmoletta marked this pull request as ready for review July 12, 2024 18:46
@fmoletta fmoletta requested a review from a team as a code owner July 12, 2024 18:46
Copy link
Contributor

@ElFantasma ElFantasma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

}

#[test]
fn store_and_fetch_block() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to move tests to crate/storage/src/lib just as test_store_account?
That way we'll have tests for all Engine implementations right away

@fmoletta fmoletta merged commit 27378a9 into main Jul 16, 2024
@fmoletta fmoletta deleted the add-block-api-to-db branch July 16, 2024 13:32
MegaRedHand pushed a commit that referenced this pull request Jul 17, 2024
…m libmdx impl of store (#150)

Based on #146, please merge it first

**Motivation**

Add a way to fetch blocks from their hashes (as blocks are stored by
number this translates to adding a block_hash -> block_number mapping)

<!-- Why does this pull request exist? What are its goals? -->

**Description**

* Add `get_block_number` & `add_block_number` methods to `Store` (both
using block_hash as key)
* Remove unwraps from libmdx impl of `Store` 

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

Closes None, but is needed in order to implement #31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants