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

common: allow specifying eip-7840 blobSchedule via geth genesis #3835

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented Jan 16, 2025

allow gethgenesis to specify eip 7840 blobschedule + optional update fraction: ethereum/EIPs#9240

Closes #3822

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 77.14286% with 8 lines in your changes missing coverage. Please review.

Project coverage is 75.36%. Comparing base (be2b63a) to head (4754cc7).

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 73.33% <ø> (ø)
blockchain 82.92% <ø> (ø)
client 73.19% <ø> (ø)
common 89.89% <77.14%> (+0.06%) ⬆️
devp2p 71.18% <ø> (+0.10%) ⬆️
evm 64.59% <ø> (ø)
genesis 100.00% <ø> (ø)
mpt 51.77% <ø> (+0.03%) ⬆️
rlp 95.11% <ø> (ø)
statemanager 67.05% <ø> (ø)
tx 75.32% <ø> (ø)
util 72.41% <ø> (ø)
vm 57.19% <ø> (ø)
wallet 78.97% <ø> (ø)

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

Comment on lines +69 to +71
// Allow to even override an existing hardfork specification
(this._chainParams.customHardforks && this._chainParams.customHardforks[hf.name]) ??
hardforksDict[hf.name],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

important change here cc @jochem-brouwer @acolytec3 @holgerd77

(please see comment)

Copy link
Member

Choose a reason for hiding this comment

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

Ok, this works, but the problem is that if you want to correctly override it, you first have to import all the params from the original hardfork and then set that as custom hardfork

Copy link
Member

Choose a reason for hiding this comment

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

My initial thoughts here are: load the original hardforksDict[hf.name] and then merge the overridden changes in it? (via copy so via JSON.stringify / JSON.parse)

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

Ok rather lengthy review 😅

This change:

      // Allow to even override an existing hardfork specification
      (this._chainParams.customHardforks && this._chainParams.customHardforks[hf.name]) ?? 
      hardforksDict[hf.name],

Is rather big, and I think we should test this more, because I think currently "wrong" inputs can throw away all hardfork params (for that common)?

Comment on lines +69 to +71
// Allow to even override an existing hardfork specification
(this._chainParams.customHardforks && this._chainParams.customHardforks[hf.name]) ??
hardforksDict[hf.name],
Copy link
Member

Choose a reason for hiding this comment

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

Ok, this works, but the problem is that if you want to correctly override it, you first have to import all the params from the original hardfork and then set that as custom hardfork

Comment on lines +69 to +71
// Allow to even override an existing hardfork specification
(this._chainParams.customHardforks && this._chainParams.customHardforks[hf.name]) ??
hardforksDict[hf.name],
Copy link
Member

Choose a reason for hiding this comment

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

My initial thoughts here are: load the original hardforksDict[hf.name] and then merge the overridden changes in it? (via copy so via JSON.stringify / JSON.parse)

let customHardforks: HardforksDict | undefined = undefined;
if (config.blobSchedule !== undefined) {
customHardforks = {};
const blobGasPerBlob = 131072;
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we do not hard-code this constant and read it from blobGasPerBlob (= 2**17 / 131072)

for (const [hfKey, hfSchedule] of Object.entries(config.blobSchedule)) {
const hfConfig = hardforksDict[hfKey];
if (hfConfig === undefined) {
throw new Error(`unknown hardfork=${hfKey} specified in blobSchedule`);
Copy link
Member

Choose a reason for hiding this comment

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

Could you add this case to tests?

throw new Error(`unknown hardfork=${hfKey} specified in blobSchedule`);
}
const { target, max, baseFeeUpdateFraction: blobGasPriceUpdateFraction } = hfSchedule as { target?: number, max?: number, baseFeeUpdateFraction?: undefined };
if (target === undefined || max === undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is blobGasPriceUpdateFraction not mandatory?

Copy link
Member

Choose a reason for hiding this comment

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

The "fallback" logic now works different from target/max and blobGasPriceUpdateFraction, for blobGasPriceUpdateFraction it will do the fallback, but for max/target it has to be explicitly defined.

const customHfConfig = JSON.parse(JSON.stringify(hfConfig));
customHfConfig.params = {
...customHardforks.params,
// removes blobGasPriceUpdateFraction key to prevent undefined overriding if undefined
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this works, if blobGasPriceUpdateFraction is undefined then it will set the param to undefined also.

bootstrapNodes: [],
consensus:
config.clique !== undefined
? {
type: 'poa',
Copy link
Member

Choose a reason for hiding this comment

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

Why is this code block moved?

"prague": {
"target": 61,
"max": 91,
"baseFeeUpdateFraction": 13338477
Copy link
Member

Choose a reason for hiding this comment

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

Could you also add a test where baseFeeUpdateFraction is not set (also not explicitly to undefined)? I think this will override and set the param in the fork to undefined instead of leaving that key alone.

@@ -321,6 +321,7 @@
"beaconroot",
"Grandine",
"EVMBN",
"kaust"
"kaust",
"blobschedule"
Copy link
Member

Choose a reason for hiding this comment

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

This should be in cspell-ts.json

@jochem-brouwer
Copy link
Member

I have updated this PR description to mark this issue #3822 to be closed if it gets merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update fromGethGenesis to include blob schedule (and related changes)
2 participants