forked from cerc-io/plugeth
Added IsEIP1559() hook
Modifications to genesis injection and datadir injections
This commit is contained in:
parent
cb62de132c
commit
d9de580d74
@ -990,7 +990,7 @@ func init() {
|
||||
// then a subdirectory of the specified datadir will be used.
|
||||
func MakeDataDir(ctx *cli.Context) string {
|
||||
// begin PluGeth injection
|
||||
if path := ctx.String(DataDirFlag.Name); path != "" {
|
||||
if path := ctx.String(DataDirFlag.Name); path == "" {
|
||||
if pluginPath := pluginDefaultDataDir(path); pluginPath != "" {
|
||||
return pluginPath
|
||||
}
|
||||
@ -1935,7 +1935,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||
|
||||
//begin plugeth injection
|
||||
if genesis := pluginGenesisBlock(); genesis != nil {
|
||||
chaindb := MakeChainDatabase(ctx, stack, false)
|
||||
cfg.Genesis = genesis
|
||||
rawdb.WriteChainConfig(chaindb, genesis.ToBlock().Hash(), genesis.Config)
|
||||
chaindb.Close()
|
||||
}
|
||||
//end plugeth injection
|
||||
|
||||
|
@ -34,7 +34,9 @@ import (
|
||||
func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Header) error {
|
||||
// Verify that the gas limit remains within allowed bounds
|
||||
parentGasLimit := parent.GasLimit
|
||||
if !config.IsLondon(parent.Number) {
|
||||
// begin PluGeth injection
|
||||
if !config.Is1559(parent.Number) {
|
||||
// end PluGeth injection
|
||||
parentGasLimit = parent.GasLimit * config.ElasticityMultiplier()
|
||||
}
|
||||
if err := misc.VerifyGaslimit(parentGasLimit, header.GasLimit); err != nil {
|
||||
@ -56,7 +58,9 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
|
||||
// CalcBaseFee calculates the basefee of the header.
|
||||
func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
|
||||
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
||||
if !config.IsLondon(parent.Number) {
|
||||
// begin PluGeth injection
|
||||
if !config.Is1559(parent.Number) {
|
||||
// end PluGeth injection
|
||||
return new(big.Int).SetUint64(params.InitialBaseFee)
|
||||
}
|
||||
|
||||
|
29
params/plugin_hooks.go
Normal file
29
params/plugin_hooks.go
Normal file
@ -0,0 +1,29 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
)
|
||||
|
||||
// IsLondon returns whether num is either equal to the London fork block or greater.
|
||||
func (c *ChainConfig) Is1559(num *big.Int) bool {
|
||||
if plugins.DefaultPluginLoader == nil {
|
||||
log.Warn("Attempting is1559, but default PluginLoader has not been initialized")
|
||||
return c.IsLondon(num)
|
||||
}
|
||||
if active, ok := PluginIs1559(plugins.DefaultPluginLoader, num); ok {
|
||||
return active
|
||||
}
|
||||
return c.IsLondon(num)
|
||||
}
|
||||
|
||||
|
||||
func PluginIs1559(pl *plugins.PluginLoader, num *big.Int) (bool, bool) {
|
||||
fn, ok := plugins.LookupOne[func(*big.Int) bool](pl, "Is1559")
|
||||
if !ok {
|
||||
return false, false
|
||||
}
|
||||
return fn(num), ok
|
||||
}
|
Loading…
Reference in New Issue
Block a user