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

Validator recording fix #2660

Merged
merged 17 commits into from
Sep 13, 2024
Merged

Validator recording fix #2660

merged 17 commits into from
Sep 13, 2024

Conversation

tsahee
Copy link
Collaborator

@tsahee tsahee commented Sep 11, 2024

Fixes batch recording.
Mostly:

  • only fetch each batch once including DA (and not once per block)
  • add a config to recorder for max supported pre-recorded

pulls-in: OffchainLabs/go-ethereum#358 (though not necessary, it just removes now-unused code from geth)

@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 Sep 11, 2024
@tsahee tsahee requested a review from PlasmaPower September 11, 2024 17:10
Copy link
Collaborator

@PlasmaPower PlasmaPower left a comment

Choose a reason for hiding this comment

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

I have a few minor comments, but generally LGTM

type BlockRecorderConfig struct {
TrieDirtyCache int `koanf:"trie-dirty-cache"`
TrieCleanCache int `koanf:"trie-clean-cache"`
MaxPrepared int `koanf:"max-prepared"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should have this extend arbitrum.RecordingDatabaseConfig (having that as an unnamed field, I forget the proper terminology in geth). Then we can call arbitrum.RecordingDatabaseConfigAddOptions inside BlockRecorderConfigAddOptions. Alternatively, I'd just drop the geth struct, or at least drop its koanf options and the AddOptions function to clarify that it's not directly part of the config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I'll remove the geth koanf and AddOptions

return true, &fullInfo, nil
}

func clonePreimagesInto(dest, source map[arbutil.PreimageType]map[common.Hash][]byte) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I'd call this copyPreimagesInto, to clarify that it won't clear out the destination and only adds new entries

func clonePreimagesInto(dest, source map[arbutil.PreimageType]map[common.Hash][]byte) {
for piType, piMap := range source {
if dest[piType] == nil {
dest[piType] = make(map[common.Hash][]byte, len(source[piType]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: len(source[piType]) -> len(piMap)

return nil, err
}
msg.Message.BatchGasCost = nil
if err := msg.Message.FillInBatchGasCost(valBatchFetcher); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

technically, we don't need the preimages list for the batch gas cost calculation, but I don't think there's much overhead in practice especially with the cache so it's probably fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point and I do want to solve it because it allows making some things actually simpler..
PTAL

if recording.Preimages != nil {
e.Preimages[arbutil.Keccak256PreimageType] = recording.Preimages
recordingPreimages := make(map[arbutil.PreimageType]map[common.Hash][]byte)
recordingPreimages[arbutil.Keccak256PreimageType] = recording.Preimages
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: map initialization syntax simplifies this slightly:

recordingPreimages := map[arbutil.PreimageType]map[common.Hash][]byte {
    arbutil.Keccak256PreimageType: recording.Preimages,
}

@tsahee tsahee requested a review from PlasmaPower September 12, 2024 03:12
Copy link
Collaborator

@PlasmaPower PlasmaPower left a comment

Choose a reason for hiding this comment

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

LGTM

@tsahee tsahee merged commit 4483e77 into master Sep 13, 2024
14 checks passed
@tsahee tsahee deleted the validator_fetch_batch_fix branch September 13, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-approved 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.

2 participants