8000 Revive chainConfig in Governance by ian0371 · Pull Request #1749 · klaytn/klaytn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

Revive chainConfig in Governance #1749

Merged
merged 3 commits into from
Jan 4, 2023
Merged

Revive chainConfig in Governance #1749

merged 3 commits into from
Jan 4, 2023

Conversation

ian0371
Copy link
Contributor
@ian0371 ian0371 commented Jan 4, 2023

Proposed changes

This commit removes chainConfig from struct Governance.
This resulted in a panic when downgrading node from v1.10.0 to v1.9.1.

How to reproduce the bug

  1. Start a chain with v1.10.0.
  2. Wait until it passes block 1024 (checkpointInterval)
  3. Stop the chain
  4. Restart the chain with v1.9.1
  5. Below panic appears.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x12877e5]

goroutine 1 [running]:
github.com/klaytn/klaytn/governance.(*Governance).ReadGovernance(0xc0297b4120, 0x6998604)
	/klaytn/governance/default.go:814 +0x25
github.com/klaytn/klaytn/governance.(*Governance).initializeCache(0xc0297b4120)
	/klaytn/governance/default.go:717 +0x3c5
github.com/klaytn/klaytn/governance.NewGovernanceInitialize(0x290b100, {0x1d39250, 0xc00013da40})
	/klaytn/governance/default.go:450 +0x5d
github.com/klaytn/klaytn/governance.newMixedEngine(0x290b100, {0x1d39250, 0xc00013da40}, 0x1)
	/klaytn/governance/mixed.go:45 +0x1a8
github.com/klaytn/klaytn/governance.NewMixedEngine(...)
	/klaytn/governance/mixed.go:58
github.com/klaytn/klaytn/node/cn.New(0xc00039ec80, 0xc0004c9800)
	/klaytn/node/cn/backend.go:218 +0x15c
github.com/klaytn/klaytn/cmd/utils.RegisterCNService.func1(0x203000)
	/klaytn/cmd/utils/flags.go:1988 +0x54
github.com/klaytn/klaytn/node.(*Node).initService(0xc00030a000, {0xc00020a460, 0x1, 0xc00039ec60}, 0x0)
	/klaytn/node/node.go:298 +0x183
github.com/klaytn/klaytn/node.(*Node).Start(0xc00030a000)
	/klaytn/node/node.go:199 +0x6d8
github.com/klaytn/klaytn/cmd/utils.StartNode(0xc00030a000)
	/klaytn/cmd/utils/cmd.go:46 +0x25
github.com/klaytn/klaytn/cmd/utils/nodecmd.startNode(0x0, 0xc00030a000)
	/klaytn/cmd/utils/nodecmd/defaultcmd.go:65 +0x65
github.com/klaytn/klaytn/cmd/utils/nodecmd.RunKlaytnNode(0x0)
	/klaytn/cmd/utils/nodecmd/defaultcmd.go:53 +0x30
gopkg.in/urfave/cli%2ev1.HandleAction({0x16e45e0, 0x1a56f48}, 0xc0001b8c00)
	/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:490 +0x5a
gopkg.in/urfave/cli%2ev1.(*App).Run(0xc0000b69c0, {0xc00003c300, 0x30, 0x30})
	/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:264 +0x5e6
main.main()
	/klaytn/cmd/ken/main.go:91 +0x70

FYI, the panic line in v1.9.1:

if g.ChainConfig.Istanbul == nil {

The fix

This panic attributes to the discrepancy of miscDB's governanceState.chainConfig field between v1.9.1 and v1.10.0.

Therefore, this PR revives chainConfig in struct Governance to make "governanceState" in miscDB backward-compatible.

Before this PR:

// miscDB lookup with key=governanceState
{
  blockNumber: 8,
  chainConfig: null,
  ...
}

After this PR:

// miscDB lookup with key=governanceState
{
  blockNumber: 8,
  chainConfig: {
    chainId: 10000,
    istanbulCompatibleBlock: 0,
    londonCompatibleBlock: 0,
    ...
}

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@aidan-kwon aidan-kwon mentioned this pull request Jan 4, 2023
Copy link
Member
@aidan-kwon aidan-kwon left a comment

Choose a reason for hiding this comment

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

It seems that upgrading v1.9.1 -> v1.10.0 -> v1.10.1 can cause a problem for the same reason, right?
-> My mistake. It looks fine

@ian0371 ian0371 merged commit 13f13db into klaytn:dev Jan 4, 2023
blukat29 pushed a commit that referenced this pull request Jan 6, 2023
Revive chainConfig in Governance
@blukat29 blukat29 added this to the v1.10.1 milestone Jan 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0