mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
add validation and logs around prague1 checks
This commit is contained in:
parent
365217f04d
commit
88db0d12fa
2 changed files with 18 additions and 5 deletions
|
|
@ -21,10 +21,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
)
|
)
|
||||||
|
|
@ -90,7 +91,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
||||||
|
|
||||||
// Berachain: Pre-compute expected PoL tx hash when in Prague1.
|
// Berachain: Pre-compute expected PoL tx hash when in Prague1.
|
||||||
isPrague1 := v.config.IsPrague1(block.Number(), block.Time())
|
isPrague1 := v.config.IsPrague1(block.Number(), block.Time())
|
||||||
var expectedPoLHash common.Hash
|
var expectedPoLTx *types.Transaction
|
||||||
if isPrague1 {
|
if isPrague1 {
|
||||||
if block.ProposerPubkey() == nil {
|
if block.ProposerPubkey() == nil {
|
||||||
return errors.New("post-prague1 block missing parent proposer pubkey")
|
return errors.New("post-prague1 block missing parent proposer pubkey")
|
||||||
|
|
@ -107,7 +108,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create expected PoL tx: %w", err)
|
return fmt.Errorf("failed to create expected PoL tx: %w", err)
|
||||||
}
|
}
|
||||||
expectedPoLHash = polTx.Hash()
|
expectedPoLTx = polTx
|
||||||
|
|
||||||
// Validate that the block has at least one tx.
|
// Validate that the block has at least one tx.
|
||||||
if len(txs) == 0 {
|
if len(txs) == 0 {
|
||||||
|
|
@ -121,8 +122,10 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
||||||
// Berachain: validate the PoL tx is only the first tx in the block.
|
// Berachain: validate the PoL tx is only the first tx in the block.
|
||||||
switch {
|
switch {
|
||||||
case isPrague1 && i == 0:
|
case isPrague1 && i == 0:
|
||||||
if tx.Hash() != expectedPoLHash {
|
if tx.Hash() != expectedPoLTx.Hash() {
|
||||||
return fmt.Errorf("PoL tx hash mismatch: have %v, want %v", tx.Hash(), expectedPoLHash)
|
log.Debug("PoL tx hash mismatch", "have", tx.Hash(), "expected", expectedPoLTx.Hash())
|
||||||
|
log.Debug("PoL tx contents", "have", spew.Sdump(tx), "expected", spew.Sdump(expectedPoLTx))
|
||||||
|
return fmt.Errorf("PoL tx hash mismatch: have %v, want %v", tx.Hash(), expectedPoLTx.Hash())
|
||||||
}
|
}
|
||||||
case tx.Type() == types.PoLTxType:
|
case tx.Type() == types.PoLTxType:
|
||||||
return fmt.Errorf("invalid block: tx at index %d is a PoL tx", i)
|
return fmt.Errorf("invalid block: tx at index %d is a PoL tx", i)
|
||||||
|
|
|
||||||
|
|
@ -994,6 +994,16 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Berachain: Check that Prague1 is configured correctly if it is enabled.
|
||||||
|
if c.Berachain.Prague1.Time != nil {
|
||||||
|
if c.Berachain.Prague1.PoLDistributorAddress == (common.Address{}) {
|
||||||
|
return fmt.Errorf("invalid chain configuration: missing PoL distributor address for Prague1 fork")
|
||||||
|
}
|
||||||
|
if c.Berachain.Prague1.BaseFeeChangeDenominator == 0 {
|
||||||
|
return fmt.Errorf("invalid chain configuration: base fee change denominator must be > 0 for Prague1 fork")
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue