Skip to content

Commit

Permalink
chore(core): disable 4844 support by default
Browse files Browse the repository at this point in the history
  • Loading branch information
leeren committed Oct 8, 2024
1 parent 3e70840 commit d4991ee
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 4 deletions.
5 changes: 5 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {
cfg.Eth.OverrideStoryNostoi = &v
}

if ctx.IsSet(utils.Override4844Flag.Name) {
override4844 := ctx.Bool(utils.Override4844Flag.Name)
cfg.Eth.Enable4844 = override4844
}

backend, eth := utils.RegisterEthService(stack, &cfg.Eth)

// Create gauge with geth system and build information
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ var (
utils.BeaconGenesisTimeFlag,
utils.BeaconCheckpointFlag,
utils.CollectWitnessFlag,
utils.Override4844Flag,
}, utils.NetworkFlags, utils.DatabaseFlags)

rpcFlags = []cli.Flag{
Expand Down
6 changes: 6 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,12 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Value: metrics.DefaultConfig.InfluxDBOrganization,
Category: flags.MetricsCategory,
}

Override4844Flag = &cli.BoolFlag{
Name: "override.4844",
Usage: "Enable 4844 blob transactions",
Category: flags.EthCategory,
}
)

var (
Expand Down
5 changes: 5 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ func (e *GenesisMismatchError) Error() string {
type ChainOverrides struct {
OverrideCancun *uint64
OverrideVerkle *uint64

// Story iliad
OverrideStoryNostoi *uint64
Override4844 bool
}

// SetupGenesisBlock writes or updates the genesis block in db.
Expand Down Expand Up @@ -284,6 +286,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
if overrides != nil && overrides.OverrideStoryNostoi != nil {
config.NostoiBlock = new(big.Int).SetUint64(*overrides.OverrideStoryNostoi)
}
if overrides != nil && overrides.Override4844 {
config.Enable4844 = overrides.Override4844
}
}
}
// Just commit the new block if there is no stored genesis block.
Expand Down
3 changes: 3 additions & 0 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type ValidationOptions struct {
// This check is public to allow different transaction pools to check the basic
// rules without duplicating code and running the risk of missed updates.
func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types.Signer, opts *ValidationOptions) error {
if !opts.Config.Is4844Enabled() && tx.Type() == types.BlobTxType {
return core.ErrTxTypeNotSupported
}
// Ensure transactions not implemented by the calling pool are rejected
if opts.Accept&(1<<tx.Type()) == 0 {
return fmt.Errorf("%w: tx type %v not supported by this pool", core.ErrTxTypeNotSupported, tx.Type())
Expand Down
4 changes: 2 additions & 2 deletions core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type sigCache struct {
func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint64) Signer {
var signer Signer
switch {
case config.IsCancun(blockNumber, blockTime):
case config.IsCancun(blockNumber, blockTime) && config.Is4844Enabled():
signer = NewCancunSigner(config.ChainID)
case config.IsLondon(blockNumber):
signer = NewLondonSigner(config.ChainID)
Expand All @@ -65,7 +65,7 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint
// have the current block number available, use MakeSigner instead.
func LatestSigner(config *params.ChainConfig) Signer {
if config.ChainID != nil {
if config.CancunTime != nil {
if config.CancunTime != nil && config.Is4844Enabled() {
return NewCancunSigner(config.ChainID)
}
if config.LondonBlock != nil {
Expand Down
3 changes: 3 additions & 0 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ func (b *EthAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscri
}

func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error {
if !b.ChainConfig().Is4844Enabled() && signedTx.Type() == types.BlobTxType {
return types.ErrTxTypeNotSupported
}
return b.eth.txPool.Add([]*types.Transaction{signedTx}, true, false)[0]
}

Expand Down
13 changes: 11 additions & 2 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.OverrideStoryNostoi != nil {
overrides.OverrideStoryNostoi = config.OverrideStoryNostoi
}
if config.Enable4844 {
overrides.Override4844 = config.Enable4844
}
// TODO (MariusVanDerWijden) get rid of shouldPreserve in a follow-up PR
shouldPreserve := func(header *types.Header) bool {
return false
Expand All @@ -233,14 +236,20 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.BlobPool.Datadir != "" {
config.BlobPool.Datadir = stack.ResolvePath(config.BlobPool.Datadir)
}
blobPool := blobpool.New(config.BlobPool, eth.blockchain)

if config.TxPool.Journal != "" {
config.TxPool.Journal = stack.ResolvePath(config.TxPool.Journal)
}
legacyPool := legacypool.New(config.TxPool, eth.blockchain)

eth.txPool, err = txpool.New(config.TxPool.PriceLimit, eth.blockchain, []txpool.SubPool{legacyPool, blobPool})
txPools := []txpool.SubPool{legacyPool}
if eth.BlockChain().Config().Is4844Enabled() {
blobPool := blobpool.New(config.BlobPool, eth.blockchain)
txPools = append(txPools, blobPool)
}
priceLimit := uint64(config.TxPool.PriceLimit)
eth.txPool, err = txpool.New(priceLimit, eth.blockchain, txPools)

if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ type Config struct {

// OverrideNostoi
OverrideStoryNostoi *uint64 `toml:",omitempty"`

// Enables EIP-4844 blob transaction support
Enable4844 bool
}

// CreateConsensusEngine creates a consensus engine for the given chain config.
Expand Down
8 changes: 8 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ type ChainConfig struct {
// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`

// 4844 Overrides
Enable4844 bool `json:"enable4844,omitempty"`
}

// EthashConfig is the consensus engine configs for proof-of-work based sealing.
Expand Down Expand Up @@ -820,6 +823,11 @@ func (c *ChainConfig) ElasticityMultiplier() uint64 {
return DefaultElasticityMultiplier
}

// Is4844Enabled checks whether blob transactions are supported.
func (c *ChainConfig) Is4844Enabled() bool {
return c.Enable4844
}

// LatestFork returns the latest time-based fork that would be active for the given time.
func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
// Assume last non-time-based fork has passed.
Expand Down

0 comments on commit d4991ee

Please sign in to comment.