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

params: clarify consensus engine config Strings #29643

Merged
merged 1 commit into from Apr 28, 2024

Conversation

roysc
Copy link
Contributor

@roysc roysc commented Apr 25, 2024

  • Defines the String() methods on a value receiever so that nil is shown differently.
  • Adds the parameters to the representation for CliqueConfig.

Currently these config objects will display the same whether they're nil or present. For example, this chain config:

{
  "chainId": 1212,
  "homesteadBlock": 0,
  "eip150Block": 0,
  "eip155Block": 0,
  "eip158Block": 0,
  "byzantiumBlock": 0,
  "constantinopleBlock": 0,
  "petersburgBlock": 0,
  "istanbulBlock": 0,
  "berlinBlock": 0,
  "londonBlock": 0,
  "mergeNetsplitBlock": 0,
  "terminalTotalDifficulty": 0,
  "shanghaiTime": 0,
  "cancunTime": 0
}

when printed with %+v, shows as (note Ethash:ethash Clique:clique at the end):

&{ChainID:+1212 HomesteadBlock:+0 DAOForkBlock:<nil> DAOForkSupport:false EIP150Block:+0 EIP155Block:+0 EIP158Block:+0 ByzantiumBlock:+0 ConstantinopleBlock:+0 PetersburgBlock:+0 IstanbulBlock:+0 MuirGlacierBlock:<nil> BerlinBlock:+0 LondonBlock:+0 ArrowGlacierBlock:<nil> GrayGlacierBlock:<nil> MergeNetsplitBlock:+0 ShanghaiTime:0x14000312da0 CancunTime:0x14000312da8 PragueTime:<nil> VerkleTime:<nil> TerminalTotalDifficulty:+0 Ethash:ethash Clique:clique}

With this change, we see Ethash:<nil> Clique:<nil>.

If we add a clique key to the config:

{
  "chainId": 1212,
  "homesteadBlock": 0,
  "eip150Block": 0,
  "eip155Block": 0,
  "eip158Block": 0,
  "byzantiumBlock": 0,
  "constantinopleBlock": 0,
  "petersburgBlock": 0,
  "istanbulBlock": 0,
  "berlinBlock": 0,
  "londonBlock": 0,
  "mergeNetsplitBlock": 0,
  "terminalTotalDifficulty": 0,
  "shanghaiTime": 0,
  "cancunTime": 0,
  "clique": {
    "period": 5,
    "epoch": 30000
  }
}

and print it, it currently shows identically to the first one (Ethash:ethash Clique:clique).

With this change we see Ethash:<nil> Clique:clique(period: 5, epoch: 30000).
This makes it more clear which engines are and are not active.

This is revised from #29635.

Define these on a value receiever so that nil is shown differently.
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

That was a pretty neat way to solve it, actually!

@fjl fjl merged commit 4bdbaab into ethereum:master Apr 28, 2024
2 of 3 checks passed
@roysc roysc deleted the fix-consensus-config-strings branch April 28, 2024 13:20
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.

None yet

3 participants