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

TrieLogFactory plugin support #5440

Merged
merged 30 commits into from
May 15, 2023

Conversation

garyschulte
Copy link
Contributor

@garyschulte garyschulte commented May 6, 2023

PR description

PR does some plumbing to get TrieLogs and TrieLogFactory into the plugin-api, such that we can have a pluggable TrieLog serializer/deserializer and event observer. Having trielogs in plugin-api also facilitates trielog push and pull to remote services.

notable changes/rearrangement:

  • in plugin-api/services

    • adds TrieLogService
    • adds plugin-api/services/trielog package:
      • TrieLog, now plugin interface for TrieLogLayer
      • TrieLog.LogTuple, now plugin interface for BonsaiValue
      • TrieLogEvent
      • TrieLogObserver
      • TrieLogAccumulator, now plugin interface for BonsaiWorldStateUpdateAccumulator
  • in data types:

    • moves StorageSlotKey, into data-types
    • adds AccountValue, in data-types, now interface for StateTrieAccountValue and BonsaiAccount
  • writeRlp and writeInnerRlp moved from BonsaiValue into TrieLogFactory

  • TrieLog now exposes the account, code, and storage maps directly rather than only via stream

Fixed Issue(s)

fixes protocol-misc # 756

@github-actions
Copy link

github-actions bot commented May 6, 2023

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.
  • I have considered running ./gradlew acceptanceTestNonMainnet locally if my PR affects non-mainnet modules.
  • I thought about the changelog and included a changelog update if required.
  • If my PR includes database changes (e.g. KeyValueSegmentIdentifier) I have thought about compatibility and performed forwards and backwards compatibility tests

@garyschulte garyschulte force-pushed the zkbesu-756-plugin-version branch 2 times, most recently from 521c1ca to 3587329 Compare May 9, 2023 22:52
@garyschulte garyschulte marked this pull request as ready for review May 10, 2023 15:14
/**
* Block and TrieLog layer composition, used for returning a range of TrieLog layers.
*
* @param blockNumber the block number

Check notice

Code scanning / CodeQL

Spurious Javadoc @param tags

@param tag "blockNumber" does not match any actual type parameter of type "TrieLogRangeTuple".
* Block and TrieLog layer composition, used for returning a range of TrieLog layers.
*
* @param blockNumber the block number
* @param trieLog the associated TrieLog layer

Check notice

Code scanning / CodeQL

Spurious Javadoc @param tags

@param tag "trieLog" does not match any actual type parameter of type "TrieLogRangeTuple".
garyschulte added a commit to Consensys/linea-besu that referenced this pull request May 10, 2023
…inea until merge of hyperledger#5440)

Signed-off-by: garyschulte <garyschulte@gmail.com>
/**
* Block and TrieLog layer composition, used for returning a range of TrieLog layers.
*
* @param blockHash the block hash

Check notice

Code scanning / CodeQL

Spurious Javadoc @param tags

@param tag "blockHash" does not match any actual type parameter of type "TrieLogRangeTuple".
Copy link
Contributor

Choose a reason for hiding this comment

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

is this alert because it's a record? javadoc not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it is not clear what the linter wants here.

Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

so many tiny changes! a few comments

@@ -43,11 +43,13 @@
* <p>In this particular formulation only the "Leaves" are tracked" Future layers may track patrica
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* <p>In this particular formulation only the "Leaves" are tracked" Future layers may track patrica
* <p>In this particular formulation only the "Leaves" are tracked Future layers may track patricia

/**
* Block and TrieLog layer composition, used for returning a range of TrieLog layers.
*
* @param blockHash the block hash
Copy link
Contributor

Choose a reason for hiding this comment

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

is this alert because it's a record? javadoc not needed?

@garyschulte garyschulte force-pushed the zkbesu-756-plugin-version branch 3 times, most recently from 71cf24e to bfe7876 Compare May 12, 2023 08:00
Copy link
Contributor

@gfukushima gfukushima left a comment

Choose a reason for hiding this comment

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

lgtm few minor questions

import dagger.Provides;

/**
* A dagger module that know how to create the BesuCommand, which collects all configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

think this was copied over the BesuCommand module, if so could we adjust the description to keep docs coherent.

}

Stream<Long> rangeAsStream(final long fromBlockNumber, final long toBlockNumber) {
if (Math.abs(toBlockNumber - fromBlockNumber) > 1000L) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this limit number coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there isn't a use for this feature other than the shomei plugin currently, 1k is a compromise between shomei batch sync sizes and a reasonable upper bound on an corresponding rpc payload size. The payload size can vary based on the chain's gas limit and operations performed during the range. Using linea as a guidepost, an rpc request for blocks 0-1k weighs in at 510kb, whereas blocks 600k->601k are ~60mb.

I will add a class level constant for this rather than a 'magic number' however. 👍

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
…Observer to AbstractTrieLogManager

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
…ees fit

Signed-off-by: garyschulte <garyschulte@gmail.com>
…ll slot key

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
…og, add blockHeader to trielogaddedevent

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
… TrieLog Plugin Service

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
… for getTrieLogByRange return

Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
@garyschulte garyschulte enabled auto-merge (squash) May 15, 2023 17:37
@garyschulte garyschulte merged commit c85841d into hyperledger:main May 15, 2023
@garyschulte garyschulte deleted the zkbesu-756-plugin-version branch May 15, 2023 18:40
elenduuche pushed a commit to elenduuche/besu that referenced this pull request Aug 16, 2023
* TrieLogs in plugin data
* adds dagger-wired plugincontext and TrieLogService
* add getTrieLogByRange, TrieLogRangeTuple composition
---------

Signed-off-by: garyschulte <garyschulte@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
* TrieLogs in plugin data
* adds dagger-wired plugincontext and TrieLogService
* add getTrieLogByRange, TrieLogRangeTuple composition
---------

Signed-off-by: garyschulte <garyschulte@gmail.com>
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