Skip to content

Conversation

joshua-kim
Copy link
Contributor

Why this should be merged

When we merkle-ize the P and X Chains, it's likely that we're going to use similar merkledb configurations so this PR exposes defaults to avoid some boilerplate setup code.

How this works

Exposes NewConfig that contains a Config with default values

How this was tested

CI

Need to be documented in RELEASES.md?

No

@joshua-kim joshua-kim requested a review from rrazvan1 February 26, 2025 23:07
@joshua-kim joshua-kim self-assigned this Feb 26, 2025
@joshua-kim joshua-kim marked this pull request as ready for review February 26, 2025 23:08
@joshua-kim joshua-kim force-pushed the merkle-db-config branch 2 times, most recently from 9545412 to daab96b Compare March 6, 2025 16:26
Prefetcher
}

func NewConfig() Config {
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels a bit odd to default to populating mockMetrics - I'm wondering if the newDefaultConfig needs to exist at all or if we should just use this. (and populate the metrics reg here)..

Although that feels a bit odd as well... so 🤷 maybe the issue is with the mockMetrics as a whole...

It feels like whoever made mockMetrics didn't know that "github.com/prometheus/client_golang/prometheus/testutil" existed.

@joshua-kim joshua-kim force-pushed the merkle-db-config branch 3 times, most recently from 8955b58 to a4d93f3 Compare March 25, 2025 02:30
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
@joshua-kim joshua-kim enabled auto-merge March 25, 2025 15:38
numKeyValues,
deletePortion,
config.HistoryLength/2,
0.25,
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Maybe continue to use a named var for this magic number so that it can be self-documenting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved it into the function signature because the function signature self-documents what these variables mean

maxProofLen = 100
maxPastRoots = defaultHistoryLength
)
maxProofLen := 100
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Are you sure you wouldn't rather satisfy the gods of var()? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know when we're supposed to use var blocks... it seems to make sense for package-level vars, when you want a short-hand for the zero value, or where you want to choose the type of something, but when those criteria aren't met I usually don't use them (and for zero values I usually explicitly assign to the zero value...).

@joshua-kim joshua-kim added this pull request to the merge queue Mar 25, 2025
Merged via the queue into master with commit 291d1d7 Mar 25, 2025
23 checks passed
@joshua-kim joshua-kim deleted the merkle-db-config branch March 25, 2025 16:16
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