Skip to content

Commit

Permalink
chore(core): disable 4844 support by default (#42)
Browse files Browse the repository at this point in the history
* chore(core): disable 4844 support by default

* fix blob trace tests
  • Loading branch information
leeren authored Oct 17, 2024
1 parent 8070676 commit da87b58
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 9 deletions.
5 changes: 3 additions & 2 deletions cmd/devp2p/internal/ethtest/testdata/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"cancunTime": 840,
"terminalTotalDifficulty": 9454784,
"terminalTotalDifficultyPassed": true,
"ethash": {}
"ethash": {},
"enable4844": true
},
"nonce": "0x0",
"timestamp": "0x0",
Expand Down Expand Up @@ -109,4 +110,4 @@
"baseFeePerGas": null,
"excessBlobGas": null,
"blobGasUsed": null
}
}
5 changes: 5 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {
cfg.Eth.OverrideVerkle = &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 @@ -157,6 +157,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 @@ -969,6 +969,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,6 +248,8 @@ func (e *GenesisMismatchError) Error() string {
type ChainOverrides struct {
OverrideCancun *uint64
OverrideVerkle *uint64

Override4844 bool
}

// SetupGenesisBlock writes or updates the genesis block in db.
Expand Down Expand Up @@ -279,6 +281,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
if overrides != nil && overrides.OverrideVerkle != nil {
config.VerkleTime = overrides.OverrideVerkle
}
if overrides != nil && overrides.Override4844 {
config.Enable4844 = overrides.Override4844
}
}
}
// Just commit the new block if there is no stored genesis block.
Expand Down
1 change: 1 addition & 0 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestStateProcessorErrors(t *testing.T) {
TerminalTotalDifficultyPassed: true,
ShanghaiTime: new(uint64),
CancunTime: new(uint64),
Enable4844: true,
}
signer = types.LatestSigner(config)
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
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 @@ -217,6 +217,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.OverrideVerkle != nil {
overrides.OverrideVerkle = config.OverrideVerkle
}
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 @@ -230,14 +233,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 @@ -166,6 +166,9 @@ type Config struct {

// OverrideVerkle (TODO: remove after the fork)
OverrideVerkle *uint64 `toml:",omitempty"`

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

// CreateConsensusEngine creates a consensus engine for the given chain config.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"shanghaiTime": 0,
"cancunTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true
"terminalTotalDifficultyPassed": true,
"enable4844": true
}
},
"context": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"shanghaiTime": 0,
"cancunTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true
"terminalTotalDifficultyPassed": true,
"enable4844": true
}
},
"context": {
Expand Down
20 changes: 20 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var (
ShanghaiTime: newUint64(1681338455),
CancunTime: newUint64(1710338135),
Ethash: new(EthashConfig),
Enable4844: true,
}
// HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network.
HoleskyChainConfig = &ChainConfig{
Expand All @@ -87,6 +88,7 @@ var (
ShanghaiTime: newUint64(1696000704),
CancunTime: newUint64(1707305664),
Ethash: new(EthashConfig),
Enable4844: true,
}
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
SepoliaChainConfig = &ChainConfig{
Expand All @@ -112,6 +114,7 @@ var (
ShanghaiTime: newUint64(1677557088),
CancunTime: newUint64(1706655072),
Ethash: new(EthashConfig),
Enable4844: true,
}
// GoerliChainConfig contains the chain parameters to run a node on the Görli test network.
GoerliChainConfig = &ChainConfig{
Expand All @@ -138,6 +141,7 @@ var (
Period: 15,
Epoch: 30000,
},
Enable4844: true,
}

IliadChainConfig = &ChainConfig{
Expand All @@ -158,6 +162,7 @@ var (
TerminalTotalDifficultyPassed: true,
ShanghaiTime: newUint64(0),
CancunTime: newUint64(0),
Enable4844: false,
}

LocalChainConfig = &ChainConfig{
Expand All @@ -178,6 +183,7 @@ var (
TerminalTotalDifficultyPassed: true,
ShanghaiTime: newUint64(0),
CancunTime: newUint64(0),
Enable4844: false,
}

// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
Expand Down Expand Up @@ -208,6 +214,7 @@ var (
TerminalTotalDifficultyPassed: true,
Ethash: new(EthashConfig),
Clique: nil,
Enable4844: true,
}

AllDevChainProtocolChanges = &ChainConfig{
Expand All @@ -229,6 +236,7 @@ var (
CancunTime: newUint64(0),
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
Enable4844: true,
}

// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
Expand Down Expand Up @@ -259,6 +267,7 @@ var (
TerminalTotalDifficultyPassed: false,
Ethash: nil,
Clique: &CliqueConfig{Period: 0, Epoch: 30000},
Enable4844: true,
}

// TestChainConfig contains every protocol change (EIPs) introduced
Expand Down Expand Up @@ -289,6 +298,7 @@ var (
TerminalTotalDifficultyPassed: false,
Ethash: new(EthashConfig),
Clique: nil,
Enable4844: true,
}

// MergedTestChainConfig contains every protocol change (EIPs) introduced
Expand Down Expand Up @@ -319,6 +329,7 @@ var (
TerminalTotalDifficultyPassed: true,
Ethash: new(EthashConfig),
Clique: nil,
Enable4844: true,
}

// NonActivatedConfig defines the chain configuration without activating
Expand Down Expand Up @@ -349,6 +360,7 @@ var (
TerminalTotalDifficultyPassed: false,
Ethash: new(EthashConfig),
Clique: nil,
Enable4844: true,
}
TestRules = TestChainConfig.Rules(new(big.Int), false, 0)
)
Expand Down Expand Up @@ -413,6 +425,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 @@ -805,6 +820,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
Loading

0 comments on commit da87b58

Please sign in to comment.