Skip to content

Commit

Permalink
core,eth,params/types/coregeth,params/types/ctypes,params/types/genes…
Browse files Browse the repository at this point in the history
…isT,params/types/goethereum: s/ECBP1100DisableTransition/ECBP1100DeactivateTransition/g

The word Disable conflicts with the existing
ECBP1100NoDisable flag and feature.
That feature prevents the toggling of the ECBP1100
feature per the safety mechanisms of low peer count
and stale head.

Renaming to Deactivate is intended to clarify
the code usages.

Based on feedback provided here #592 (comment)

Date: 2023-12-06 07:21:58-07:00
Signed-off-by: meows <b5c6@protonmail.com>

cmd/geth,cmd/utils,core,eth,eth/ethconfig,params/types/coregeth: ECBP1100: s/enable/activate/g,s/disable/deactivate/g

rename all references besides the method name

Date: 2023-12-06 07:50:14-07:00
Signed-off-by: meows <b5c6@protonmail.com>
  • Loading branch information
meowsbits committed Dec 6, 2023
1 parent 0b1b8e1 commit cf3fbd3
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 39 deletions.
6 changes: 3 additions & 3 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
cfg.Eth.ECBP1100 = new(big.Int).SetUint64(n)
}
}
if ctx.IsSet(utils.ECBP1100DisableFlag.Name) {
if n := ctx.Uint64(utils.ECBP1100DisableFlag.Name); n != math.MaxUint64 {
cfg.Eth.ECBP1100Disable = new(big.Int).SetUint64(n)
if ctx.IsSet(utils.ECBP1100DeactivateFlag.Name) {
if n := ctx.Uint64(utils.ECBP1100DeactivateFlag.Name); n != math.MaxUint64 {
cfg.Eth.ECBP1100Deactivate = new(big.Int).SetUint64(n)
}
}
if ctx.IsSet(utils.ECBP1100NoDisableFlag.Name) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ var (
utils.MinerNotifyFullFlag,
utils.ECBP1100Flag,
utils.ECBP1100NoDisableFlag,
utils.ECBP1100DisableFlag,
utils.ECBP1100DeactivateFlag,
configFileFlag,
}, utils.NetworkFlags, utils.DatabasePathFlags)

Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Usage: "Configure ECBP-1100 (MESS) block activation number",
Value: math.MaxUint64,
}
ECBP1100DisableFlag = &cli.Uint64Flag{
ECBP1100DeactivateFlag = &cli.Uint64Flag{
Name: "ecbp1100.disable",
Usage: "Disable ECBP-1100 (MESS) block activation number",
Value: math.MaxUint64,
Expand Down
24 changes: 20 additions & 4 deletions core/blockchain_af.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,30 @@ var errReorgFinality = errors.New("finality-enforced invalid new chain")
// n = 1 : ON
// n != 1 : OFF
func (bc *BlockChain) ArtificialFinalityNoDisable(n int32) {
log.Warn("Deactivating ECBP1100 (MESS) disablers", "always on", true)
log.Warn("Deactivating ECBP1100 (MESS) safety mechanisms", "always on", true)
bc.artificialFinalityNoDisable = new(int32)
atomic.StoreInt32(bc.artificialFinalityNoDisable, n)

if n == 1 {
disabledTransition := bc.chainConfig.GetECBP1100DisableTransition()
if disabledTransition != nil && big.NewInt(int64(*disabledTransition)).Cmp(big.NewInt(0)) > 0 {
log.Warn("Disable ECBP1100 (MESS) block activation number is set together with '--ecbp1100.nodisable'.", "disable transition block", *disabledTransition)
deactivateTransition := bc.chainConfig.GetECBP1100DeactivateTransition()
if deactivateTransition != nil && big.NewInt(int64(*deactivateTransition)).Cmp(big.NewInt(0)) > 0 {

// Log the activation block as well as the deactivation block.
// Context is nice to have for the user.
var logActivationBlock uint64
logActivationBlockRaw := bc.chainConfig.GetECBP1100Transition()
if logActivationBlockRaw == nil {
// panic("impossible")
logActivationBlock = *deactivateTransition
} else {
logActivationBlock = *logActivationBlockRaw
}

log.Warn(`Deactivate-ECBP1100 (MESS) block activation number is set together with '--ecbp1100.nodisable'.
The --ecbp1100.nodisable feature prevents the toggling of ECBP1100 (MESS) artificial finality with its safety mechanisms of low peer count and stale head.
ECBP1100 (MESS) is scheduled for network-wide deactivation, rendering the --ecbp1100.nodisable feature anachronistic.
`, "ECBP1100 activation block", logActivationBlock,
"ECBP1100 deactivation block", *deactivateTransition)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}
}
}
if config.ECBP1100Disable != nil {
if n := config.ECBP1100Disable.Uint64(); n != math.MaxUint64 {
if err := eth.blockchain.Config().SetECBP1100DisableTransition(&n); err != nil {
if config.ECBP1100Deactivate != nil {
if n := config.ECBP1100Deactivate.Uint64(); n != math.MaxUint64 {
if err := eth.blockchain.Config().SetECBP1100DeactivateTransition(&n); err != nil {
return nil, err
}
}
Expand Down
2 changes: 1 addition & 1 deletion eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ type Config struct {
// Manual configuration field for ECBP1100 activation number. Used for modifying genesis config via CLI flag.
ECBP1100 *big.Int
// Manual configuration field for ECBP1100's disablement block number. Used for modifying genesis config via CLI flag.
ECBP1100Disable *big.Int
ECBP1100Deactivate *big.Int

// ECBP1100NoDisable overrides
// When this value is *true, ECBP100 will not (ever) be disabled; when *false, it will never be enabled.
Expand Down
4 changes: 2 additions & 2 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions params/types/coregeth/chain_config_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ func (c *CoreGethChainConfig) SetECBP1100Transition(n *uint64) error {
return nil
}

func (c *CoreGethChainConfig) GetECBP1100DisableTransition() *uint64 {
func (c *CoreGethChainConfig) GetECBP1100DeactivateTransition() *uint64 {
return bigNewU64(c.ECBP1100DisableFBlock)
}

func (c *CoreGethChainConfig) SetECBP1100DisableTransition(n *uint64) error {
func (c *CoreGethChainConfig) SetECBP1100DeactivateTransition(n *uint64) error {
c.ECBP1100DisableFBlock = setBig(c.ECBP1100DisableFBlock, n)
return nil
}
Expand Down Expand Up @@ -683,9 +683,9 @@ func (c *CoreGethChainConfig) IsEnabled(fn func() *uint64, n *big.Int) bool {
}
fnName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
if strings.Contains(fnName, "ECBP1100Transition") {
disabledTransition := c.GetECBP1100DisableTransition()
if disabledTransition != nil {
return big.NewInt(int64(*disabledTransition)).Cmp(n) > 0 && big.NewInt(int64(*f)).Cmp(n) <= 0
deactivateTransition := c.GetECBP1100DeactivateTransition()
if deactivateTransition != nil {
return big.NewInt(int64(*deactivateTransition)).Cmp(n) > 0 && big.NewInt(int64(*f)).Cmp(n) <= 0
}
}
return big.NewInt(int64(*f)).Cmp(n) <= 0
Expand Down
20 changes: 10 additions & 10 deletions params/types/coregeth/chain_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,42 @@ func TestCoreGethChainConfig_String(t *testing.T) {
t.Log(testConfig.String())
}

func TestCoreGethChainConfig_ECBP1100Disable(t *testing.T) {
func TestCoreGethChainConfig_ECBP1100Deactivate(t *testing.T) {
var _testConfig = &CoreGethChainConfig{}
*_testConfig = *testConfig

enable := uint64(100)
disable := uint64(200)
_testConfig.SetECBP1100Transition(&enable)
_testConfig.SetECBP1100DisableTransition(&disable)
activate := uint64(100)
deactivate := uint64(200)
_testConfig.SetECBP1100Transition(&activate)
_testConfig.SetECBP1100DeactivateTransition(&deactivate)

n := uint64(10)
bigN := new(big.Int).SetUint64(n)
if _testConfig.IsEnabled(_testConfig.GetECBP1100Transition, bigN) {
t.Errorf("ECBP1100 should be not yet be enabled at block %d", n)
t.Errorf("ECBP1100 should be not yet be activated at block %d", n)
}

n = uint64(100)
bigN = new(big.Int).SetUint64(n)
if !_testConfig.IsEnabled(_testConfig.GetECBP1100Transition, bigN) {
t.Errorf("ECBP1100 should be enabled at block %d", n)
t.Errorf("ECBP1100 should be activated at block %d", n)
}

n = uint64(110)
bigN = new(big.Int).SetUint64(n)
if !_testConfig.IsEnabled(_testConfig.GetECBP1100Transition, bigN) {
t.Errorf("ECBP1100 should be enabled at block %d", n)
t.Errorf("ECBP1100 should be activated at block %d", n)
}

n = uint64(200)
bigN = new(big.Int).SetUint64(n)
if _testConfig.IsEnabled(_testConfig.GetECBP1100Transition, bigN) {
t.Errorf("ECBP1100 should be disabled at block %d", n)
t.Errorf("ECBP1100 should be deactivated at block %d", n)
}

n = uint64(210)
bigN = new(big.Int).SetUint64(n)
if _testConfig.IsEnabled(_testConfig.GetECBP1100Transition, bigN) {
t.Errorf("ECBP1100 should be disabled at block %d", n)
t.Errorf("ECBP1100 should be deactivated at block %d", n)
}
}
4 changes: 2 additions & 2 deletions params/types/ctypes/configurator_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ type ProtocolSpecifier interface {

GetECBP1100Transition() *uint64
SetECBP1100Transition(n *uint64) error
GetECBP1100DisableTransition() *uint64
SetECBP1100DisableTransition(n *uint64) error
GetECBP1100DeactivateTransition() *uint64
SetECBP1100DeactivateTransition(n *uint64) error

GetEIP2315Transition() *uint64
SetEIP2315Transition(n *uint64) error
Expand Down
8 changes: 4 additions & 4 deletions params/types/genesisT/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,12 +789,12 @@ func (g *Genesis) SetECBP1100Transition(n *uint64) error {
return g.Config.SetECBP1100Transition(n)
}

func (g *Genesis) GetECBP1100DisableTransition() *uint64 {
return g.Config.GetECBP1100DisableTransition()
func (g *Genesis) GetECBP1100DeactivateTransition() *uint64 {
return g.Config.GetECBP1100DeactivateTransition()
}

func (g *Genesis) SetECBP1100DisableTransition(n *uint64) error {
return g.Config.SetECBP1100DisableTransition(n)
func (g *Genesis) SetECBP1100DeactivateTransition(n *uint64) error {
return g.Config.SetECBP1100DeactivateTransition(n)
}

func (g *Genesis) IsEnabled(fn func() *uint64, n *big.Int) bool {
Expand Down
6 changes: 3 additions & 3 deletions params/types/goethereum/goethereum_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ func (c *ChainConfig) SetECBP1100Transition(n *uint64) error {
return nil
}

func (c *ChainConfig) GetECBP1100DisableTransition() *uint64 {
func (c *ChainConfig) GetECBP1100DeactivateTransition() *uint64 {
return bigNewU64(c.ecbp1100DisableTransition)
}

func (c *ChainConfig) SetECBP1100DisableTransition(n *uint64) error {
func (c *ChainConfig) SetECBP1100DeactivateTransition(n *uint64) error {
c.ecbp1100DisableTransition = setBig(c.ecbp1100DisableTransition, n)
return nil
}
Expand Down Expand Up @@ -705,7 +705,7 @@ func (c *ChainConfig) IsEnabled(fn func() *uint64, n *big.Int) bool {
}
fnName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
if strings.Contains(fnName, "ECBP1100Transition") {
disabledTransition := c.GetECBP1100DisableTransition()
disabledTransition := c.GetECBP1100DeactivateTransition()
if disabledTransition != nil {
return big.NewInt(int64(*disabledTransition)).Cmp(n) > 0 && big.NewInt(int64(*f)).Cmp(n) <= 0
}
Expand Down

0 comments on commit cf3fbd3

Please sign in to comment.