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

Timeboost Bulk BlockMetadata API #2754

Open
wants to merge 5 commits into
base: add-timeboosted-broadcastfeedmessage
Choose a base branch
from

Conversation

ganeshvanahalli
Copy link
Contributor

This PR introduces an RPC method to the arb namespace called arb_getRawBlockMetadata, which takes a range and returns an array of NumberAndBlockMetadata struct which contains the blockNumber and blockMetadata in hex encoding, for all the blocks in the range that the node has blockMetadata for.

To enhance performance, the api uses LRU cache to store the newly fetched blockMetadata from local DB, this can be enabled by setting --execution.block-metadata-api-cache-size to a positive value.

Resolves NIT-2837

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Oct 24, 2024
@ganeshvanahalli ganeshvanahalli changed the base branch from express-lane-timeboost to add-timeboosted-broadcastfeedmessage October 24, 2024 13:13
@ganeshvanahalli ganeshvanahalli marked this pull request as ready for review October 24, 2024 13:15
@ganeshvanahalli ganeshvanahalli changed the title Bulk blockmetadata api Timeboost Bulk BlockMetadata API Oct 24, 2024
@eljobe
Copy link
Member

eljobe commented Oct 25, 2024

I'm afraid I cannot realistically review this with everything going on with BoLD. Sorry. Removing myself as a reviewer for now.

@eljobe eljobe removed their request for review October 25, 2024 12:56
Copy link
Contributor

@magicxyyz magicxyyz left a comment

Choose a reason for hiding this comment

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

looks good, just a question about hexutil.Uint64 use instead of rpc.BlockNumber and some nitpicks

}
}

func (b *BulkBlockMetadataFetcher) Fetch(fromBlock, toBlock hexutil.Uint64) ([]NumberAndBlockMetadata, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason for using hexutil.Uint64 here instead of rpc.BlockNumber?

@@ -41,6 +43,90 @@ import (
"github.com/stretchr/testify/require"
)

func TestTimeboosBulkBlockMetadataAPI(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Timeboos typo :)

@@ -99,6 +103,9 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet) {
f.Uint64(prefix+".tx-lookup-limit", ConfigDefault.TxLookupLimit, "retain the ability to lookup transactions by hash for the past N blocks (0 = all blocks)")
f.Bool(prefix+".enable-prefetch-block", ConfigDefault.EnablePrefetchBlock, "enable prefetching of blocks")
StylusTargetConfigAddOptions(prefix+".stylus-target", f)
f.Int(prefix+".block-metadata-api-cache-size", ConfigDefault.BlockMetadataApiCacheSize, "size of lru cache storing the blockMetadata to service arb_getRawBlockMetadata.\n"+
"Note: setting a non-zero value would mean the blockMetadata might be outdated (if the block was reorged out).\n"+
Copy link
Contributor

Choose a reason for hiding this comment

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

can we somehow trigger clearing the cache on reorg?

}

func (a *ArbAPI) CheckPublisherHealth(ctx context.Context) error {
return a.txPublisher.CheckHealth(ctx)
}

func (a *ArbAPI) GetRawBlockMetadata(ctx context.Context, fromBlock, toBlock hexutil.Uint64) ([]NumberAndBlockMetadata, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

similarly to (b *BulkBlockMetadataFetcher) Fetch, is there a reason to not use rpc.BlockNumber here?

defer cleanup()

arbDb := builder.L2.ConsensusNode.ArbDB
dbKey := func(prefix []byte, pos uint64) []byte {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: looks like dbKey is only used here []byte("t") prefix - can we rename it to something like blockMetadataInputFeedKey and take only block number as argument?
or alternatively we might define a const blockMetadataInputFeedPrefix = []byte("t") in the test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants