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

core: verify genesis extradata for clique #24470

Merged
merged 4 commits into from
Mar 30, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,13 @@ func (g *Genesis) Commit(db ethdb.Database) (*types.Block, error) {
if err := config.CheckConfigForkOrder(); err != nil {
return nil, err
}
if config.Clique != nil && len(block.Extra()) == 0 {
return nil, errors.New("can't start clique chain without signers")
if config.Clique != nil {
if len(block.Extra()) < 32 {
return nil, errors.New("extra-data 32 byte vanity prefix missing")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to me that we can omit this one? If someone submits an empty extradata, it's a bit silly to say

  • "no sorry you need at least 32 bytes"
  • "Ok here are 32 bytes"
  • "no sorry you need at least 32+65 bytes"

We might aswell error on the second clause from the beginning

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO the full change could have been to just change len(block.Extra()) == 0 into len(block.Extra()) < 32+crypto.SignatureLength on line 327.

if len(block.Extra()) < 32+crypto.SignatureLength {
return nil, errors.New("extra-data 65 byte signature suffix missing")
}
}
rawdb.WriteTd(db, block.Hash(), block.NumberU64(), block.Difficulty())
rawdb.WriteBlock(db, block)
Expand Down