Skip to content

Commit d3beff7

Browse files
karalabefjl
authored andcommitted
consensus/clique: add fork hash enforcement (#15236)
1 parent 40a3856 commit d3beff7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

consensus/clique/clique.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/ethereum/go-ethereum/common"
3030
"github.com/ethereum/go-ethereum/common/hexutil"
3131
"github.com/ethereum/go-ethereum/consensus"
32+
"github.com/ethereum/go-ethereum/consensus/misc"
3233
"github.com/ethereum/go-ethereum/core/state"
3334
"github.com/ethereum/go-ethereum/core/types"
3435
"github.com/ethereum/go-ethereum/crypto"
@@ -313,6 +314,10 @@ func (c *Clique) verifyHeader(chain consensus.ChainReader, header *types.Header,
313314
return errInvalidDifficulty
314315
}
315316
}
317+
// If all checks passed, validate any special fields for hard forks
318+
if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil {
319+
return err
320+
}
316321
// All basic checks passed, verify cascading fields
317322
return c.verifyCascadingFields(chain, header, parents)
318323
}

consensus/clique/snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type testerChainReader struct {
7474
db ethdb.Database
7575
}
7676

77-
func (r *testerChainReader) Config() *params.ChainConfig { panic("not supported") }
77+
func (r *testerChainReader) Config() *params.ChainConfig { return params.AllProtocolChanges }
7878
func (r *testerChainReader) CurrentHeader() *types.Header { panic("not supported") }
7979
func (r *testerChainReader) GetHeader(common.Hash, uint64) *types.Header { panic("not supported") }
8080
func (r *testerChainReader) GetBlock(common.Hash, uint64) *types.Block { panic("not supported") }

0 commit comments

Comments
 (0)