Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block: use trie.batch #3317

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft

Block: use trie.batch #3317

wants to merge 22 commits into from

Conversation

ScottyPoi
Copy link
Contributor

Follow-up to #3313
Continuing work towards optimizations in #3293

block.genTransactionsTrie()

Returns the txs trie root for array of TypedTransaction

This method is used during block building and block validation

An empty trie is contructed from a list of serialized transactions (with the tx index as key)

The root of this trie is the TransactionsTrieRoot of a block.

trie.batch()

The refactored trie.batch method in #3313 demonstrated up to 33% efficiency improvements over the naive for (tx of txs) {...} approach.

Changes:

block.genTransactionsTrieRoot() will now construct a trie from a batch input of serialized transactions.

    const batchOp: BatchDBOp[] = txs.map((tx, i) => {
      return {
        type: 'put',
        key: RLP.encode(i),
        value: tx.serialize(),
      }
    })
    await trie.batch(batchOp)

This should improve performance during block building and validation

TODO:

@ScottyPoi ScottyPoi marked this pull request as draft March 13, 2024 05:46
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 95.87629% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 86.93%. Comparing base (a70312d) to head (9609f1e).

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 88.46% <100.00%> (+0.02%) ⬆️
blockchain 91.61% <ø> (ø)
client 84.85% <ø> (ø)
common 98.43% <ø> (ø)
devp2p 82.12% <ø> (ø)
ethash ∅ <ø> (∅)
evm 74.16% <ø> (ø)
genesis 99.98% <ø> (ø)
rlp ∅ <ø> (∅)
statemanager 77.00% <ø> (ø)
trie 89.72% <95.45%> (+0.40%) ⬆️
tx 95.08% <ø> (ø)
util 89.34% <ø> (ø)
vm 79.87% <ø> (ø)
wallet 88.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@holgerd77
Copy link
Member

Cool that you even already started on this one 👍, also cool that this is separated into two PRs! 💯

Is this already "so ready" that I could test this in the client setup I had and see how it goes? Or does this need more work before?

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.

None yet

2 participants