-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
core: copy genesis before modifying #31097
base: master
Are you sure you want to change the base?
core: copy genesis before modifying #31097
Conversation
Hmm, I checked this in genesis, and it looks like the recent PR makes it modify the passed-in |
@fjl Yes you're right. I think the correct thing would be to copy the genesis struct. WDYT? |
core/genesis.go
Outdated
@@ -550,6 +551,19 @@ func (g *Genesis) MustCommit(db ethdb.Database, triedb *triedb.Database) *types. | |||
return block | |||
} | |||
|
|||
// Copy copies the genesis. | |||
func (g *Genesis) Copy() *Genesis { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be unexported.
core/genesis.go
Outdated
func (g *Genesis) copy() *Genesis { | ||
if g != nil { | ||
cpy := *g | ||
if g.Config != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In overrides.apply
, it also deep-copies the chain config before modification, maybe you can remove the logic there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its true, but I wanted to make copy a correct deep copy. I can remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry what I meant is to remove the copy logic in the overrides.apply
. I think it's good to have a correct deep-copy function
This PR fixes the following data race:
The issue was that SetupGenesisWithOverride would overwrite the passed chain config