Revert --experimental-disable-boundary-checks (#11160)

* Revert --experimental-disable-boundary-checks

* add deprecation

* gaz

* spectests

* spectests fix

* fix previous justified checkpoint

* copy previous jcp

* Revert "copy previous jcp"

This reverts commit 6e2b865c23e356e24b1f801ad3670acb0714ade7.

* update previous jcp on on_tick

Co-authored-by: terencechain <terence@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Potuz 2022-08-04 10:26:41 -03:00 committed by GitHub
parent a82325615b
commit cef95dd5b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 67 additions and 46 deletions

View File

@ -3037,15 +3037,16 @@ func TestStore_NoViableHead_Reboot_DoublyLinkedTree(t *testing.T) {
require.Equal(t, true, service.ForkChoicer().AllTipsAreInvalid())
st, err = service.cfg.StateGen.StateByRoot(ctx, root)
require.NoError(t, err)
// Import blocks 21--30 (Epoch 3 was not enough to justify 2)
for i := 21; i < 30; i++ {
// Import blocks 21--23
for i := 21; i < 24; i++ {
driftGenesisTime(service, int64(i), 0)
require.NoError(t, err)
b, err := util.GenerateFullBlockBellatrix(st, keys, util.DefaultBlockGenConfig(), types.Slot(i))
require.NoError(t, err)
wsb, err := consensusblocks.NewSignedBeaconBlock(b)
require.NoError(t, err)
root, err := b.Block.HashTreeRoot()
root, err = b.Block.HashTreeRoot()
require.NoError(t, err)
err = service.onBlock(ctx, wsb, root)
require.NoError(t, err)
@ -3063,10 +3064,10 @@ func TestStore_NoViableHead_Reboot_DoublyLinkedTree(t *testing.T) {
require.Equal(t, true, optimistic)
require.Equal(t, true, service.ForkChoicer().AllTipsAreInvalid())
// Import block 30, it should justify Epoch 4 and become HEAD, the node
// Import block 24, it should justify Epoch 3 and become HEAD, the node
// recovers
driftGenesisTime(service, 30, 0)
b, err = util.GenerateFullBlockBellatrix(st, keys, util.DefaultBlockGenConfig(), 30)
driftGenesisTime(service, 24, 0)
b, err = util.GenerateFullBlockBellatrix(st, keys, util.DefaultBlockGenConfig(), 24)
require.NoError(t, err)
wsb, err = consensusblocks.NewSignedBeaconBlock(b)
require.NoError(t, err)
@ -3080,7 +3081,7 @@ func TestStore_NoViableHead_Reboot_DoublyLinkedTree(t *testing.T) {
require.Equal(t, root, bytesutil.ToBytes32(headRoot))
sjc = service.CurrentJustifiedCheckpt()
require.Equal(t, types.Epoch(4), sjc.Epoch)
require.Equal(t, types.Epoch(3), sjc.Epoch)
optimistic, err = service.IsOptimistic(ctx)
require.NoError(t, err)
require.Equal(t, false, optimistic)
@ -3262,8 +3263,8 @@ func TestStore_NoViableHead_Reboot_Protoarray(t *testing.T) {
require.Equal(t, true, service.ForkChoicer().AllTipsAreInvalid())
st, err = service.cfg.StateGen.StateByRoot(ctx, root)
require.NoError(t, err)
// Import blocks 21--30 (Epoch 3 was not enough to justify 2)
for i := 21; i < 30; i++ {
// Import blocks 21--23
for i := 21; i < 24; i++ {
driftGenesisTime(service, int64(i), 0)
require.NoError(t, err)
b, err := util.GenerateFullBlockBellatrix(st, keys, util.DefaultBlockGenConfig(), types.Slot(i))
@ -3288,10 +3289,10 @@ func TestStore_NoViableHead_Reboot_Protoarray(t *testing.T) {
require.Equal(t, true, optimistic)
require.Equal(t, true, service.ForkChoicer().AllTipsAreInvalid())
// Import block 30, it should justify Epoch 4 and become HEAD, the node
// Import block 24, it should justify Epoch 3 and become HEAD, the node
// recovers
driftGenesisTime(service, 30, 0)
b, err = util.GenerateFullBlockBellatrix(st, keys, util.DefaultBlockGenConfig(), 30)
driftGenesisTime(service, 24, 0)
b, err = util.GenerateFullBlockBellatrix(st, keys, util.DefaultBlockGenConfig(), 24)
require.NoError(t, err)
wsb, err = consensusblocks.NewSignedBeaconBlock(b)
require.NoError(t, err)
@ -3305,7 +3306,7 @@ func TestStore_NoViableHead_Reboot_Protoarray(t *testing.T) {
require.Equal(t, root, bytesutil.ToBytes32(headRoot))
sjc = service.CurrentJustifiedCheckpt()
require.Equal(t, types.Epoch(4), sjc.Epoch)
require.Equal(t, types.Epoch(3), sjc.Epoch)
optimistic, err = service.IsOptimistic(ctx)
require.NoError(t, err)
require.Equal(t, false, optimistic)

View File

@ -62,7 +62,6 @@ go_test(
"//beacon-chain/forkchoice/types:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/v3:go_default_library",
"//config/features:go_default_library",
"//config/params:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/primitives:go_default_library",

View File

@ -150,7 +150,7 @@ func (f *ForkChoice) InsertNode(ctx context.Context, state state.BeaconState, ro
return err
}
if features.Get().EnablePullTips {
if !features.Get().DisablePullTips {
jc, fc = f.store.pullTips(state, node, jc, fc)
}
return f.updateCheckpoints(ctx, jc, fc)

View File

@ -62,10 +62,11 @@ func (f *ForkChoice) NewSlot(ctx context.Context, slot types.Slot) error {
return err
}
if r == fcp.Root {
f.store.prevJustifiedCheckpoint = jcp
f.store.justifiedCheckpoint = bjcp
}
}
if features.Get().EnablePullTips {
if !features.Get().DisablePullTips {
f.updateUnrealizedCheckpoints()
}
return nil

View File

@ -51,6 +51,7 @@ func (f *ForkChoice) updateUnrealizedCheckpoints() {
node.justifiedEpoch = node.unrealizedJustifiedEpoch
node.finalizedEpoch = node.unrealizedFinalizedEpoch
if node.justifiedEpoch > f.store.justifiedCheckpoint.Epoch {
f.store.prevJustifiedCheckpoint = f.store.justifiedCheckpoint
f.store.justifiedCheckpoint = f.store.unrealizedJustifiedCheckpoint
if node.justifiedEpoch > f.store.bestJustifiedCheckpoint.Epoch {
f.store.bestJustifiedCheckpoint = f.store.unrealizedJustifiedCheckpoint

View File

@ -5,7 +5,6 @@ import (
"testing"
forkchoicetypes "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/types"
"github.com/prysmaticlabs/prysm/config/features"
"github.com/prysmaticlabs/prysm/config/params"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/testing/require"
@ -250,10 +249,6 @@ func TestStore_ForkNextEpoch(t *testing.T) {
}
func TestStore_PullTips_Heuristics(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
EnablePullTips: true,
})
defer resetCfg()
ctx := context.Background()
t.Run("Current epoch is justified", func(tt *testing.T) {
f := setup(1, 1)

View File

@ -63,7 +63,6 @@ go_test(
"//beacon-chain/forkchoice/types:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/v3:go_default_library",
"//config/features:go_default_library",
"//config/params:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/primitives:go_default_library",

View File

@ -62,10 +62,11 @@ func (f *ForkChoice) NewSlot(ctx context.Context, slot types.Slot) error {
return err
}
if r == fcp.Root {
f.store.prevJustifiedCheckpoint = jcp
f.store.justifiedCheckpoint = bjcp
}
}
if features.Get().EnablePullTips {
if !features.Get().DisablePullTips {
f.UpdateUnrealizedCheckpoints()
}
return nil

View File

@ -155,7 +155,7 @@ func (f *ForkChoice) InsertNode(ctx context.Context, state state.BeaconState, ro
return err
}
if features.Get().EnablePullTips {
if !features.Get().DisablePullTips {
jc, fc = f.store.pullTips(state, node, jc, fc)
}
return f.updateCheckpoints(ctx, jc, fc)

View File

@ -66,6 +66,7 @@ func (f *ForkChoice) UpdateUnrealizedCheckpoints() {
if node.justifiedEpoch > f.store.bestJustifiedCheckpoint.Epoch {
f.store.bestJustifiedCheckpoint = f.store.unrealizedJustifiedCheckpoint
}
f.store.prevJustifiedCheckpoint = f.store.justifiedCheckpoint
f.store.justifiedCheckpoint = f.store.unrealizedJustifiedCheckpoint
}
if node.finalizedEpoch > f.store.finalizedCheckpoint.Epoch {

View File

@ -5,7 +5,6 @@ import (
"testing"
forkchoicetypes "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/types"
"github.com/prysmaticlabs/prysm/config/features"
"github.com/prysmaticlabs/prysm/config/params"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/testing/require"
@ -251,10 +250,6 @@ func TestStore_ForkNextEpoch(t *testing.T) {
}
func TestStore_PullTips_Heuristics(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
EnablePullTips: true,
})
defer resetCfg()
ctx := context.Background()
t.Run("Current epoch is justified", func(tt *testing.T) {
f := setup(1, 1)

View File

@ -61,7 +61,7 @@ type Flags struct {
EnableSlashingProtectionPruning bool
EnableNativeState bool // EnableNativeState defines whether the beacon state will be represented as a pure Go struct or a Go struct that wraps a proto struct.
EnablePullTips bool // EnablePullTips enables experimental disabling of boundary checks.
DisablePullTips bool // DisablePullTips enables experimental disabling of boundary checks.
EnableVectorizedHTR bool // EnableVectorizedHTR specifies whether the beacon state will use the optimized sha256 routines.
EnableForkChoiceDoublyLinkedTree bool // EnableForkChoiceDoublyLinkedTree specifies whether fork choice store will use a doubly linked tree.
EnableBatchGossipAggregation bool // EnableBatchGossipAggregation specifies whether to further aggregate our gossip batches before verifying them.
@ -150,9 +150,6 @@ func applyPraterFeatureFlags(ctx *cli.Context) {
if err := ctx.Set(enableVecHTR.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling disable p flag")
}
if err := ctx.Set(enablePullTips.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling disable of boundary checks flag")
}
if err := ctx.Set(enableForkChoiceDoublyLinkedTree.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling doubly linked tree forkchoice flag")
}
@ -166,9 +163,6 @@ func applyRopstenFeatureFlags(ctx *cli.Context) {
if err := ctx.Set(enableVecHTR.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling vectorized HTR flag")
}
if err := ctx.Set(enablePullTips.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling disable of boundary checks flag")
}
if err := ctx.Set(enableForkChoiceDoublyLinkedTree.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling doubly linked tree forkchoice flag")
}
@ -179,9 +173,6 @@ func applySepoliaFeatureFlags(ctx *cli.Context) {
if err := ctx.Set(enableVecHTR.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling vectorized HTR flag")
}
if err := ctx.Set(enablePullTips.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling disable of boundary checks flag")
}
if err := ctx.Set(enableForkChoiceDoublyLinkedTree.Names()[0], "true"); err != nil {
log.WithError(err).Debug("error enabling doubly linked tree forkchoice flag")
}
@ -237,9 +228,10 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
logDisabled(disableNativeState)
cfg.EnableNativeState = false
}
if ctx.Bool(enablePullTips.Name) {
logEnabled(enablePullTips)
cfg.EnablePullTips = true
if ctx.Bool(disablePullTips.Name) {
logEnabled(disablePullTips)
cfg.DisablePullTips = true
}
if ctx.Bool(enableVecHTR.Name) {
logEnabled(enableVecHTR)

View File

@ -130,6 +130,11 @@ var (
Usage: deprecatedUsage,
Hidden: true,
}
deprecatedEnablePullTips = &cli.BoolFlag{
Name: "experimental-disable-boundary-checks",
Usage: deprecatedUsage,
Hidden: true,
}
)
var deprecatedFlags = []cli.Flag{
@ -156,4 +161,5 @@ var deprecatedFlags = []cli.Flag{
deprecatedEnableNativeState,
deprecatedEnablePeerScorer,
deprecatedEnableGossipBatchAggregation,
deprecatedEnablePullTips,
}

View File

@ -106,9 +106,9 @@ var (
Name: "disable-native-state",
Usage: "Disables representing the beacon state as a pure Go struct.",
}
enablePullTips = &cli.BoolFlag{
Name: "experimental-disable-boundary-checks",
Usage: "Experimental disable of boundary checks, useful for debugging, may cause bad votes.",
disablePullTips = &cli.BoolFlag{
Name: "experimental-enable-boundary-checks",
Usage: "Experimental enable of boundary checks, useful for debugging, may cause bad votes.",
}
enableVecHTR = &cli.BoolFlag{
Name: "enable-vectorized-htr",
@ -170,7 +170,7 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
enableSlasherFlag,
enableHistoricalSpaceRepresentation,
disableNativeState,
enablePullTips,
disablePullTips,
enableVecHTR,
enableForkChoiceDoublyLinkedTree,
disableGossipBatchAggregation,

View File

@ -9,11 +9,16 @@ import (
)
func TestMainnet_Altair_Forkchoice(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
})
defer resetCfg()
forkchoice.Run(t, "mainnet", version.Altair)
}
func TestMainnet_Altair_Forkchoice_DoublyLinkTree(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
EnableForkChoiceDoublyLinkedTree: true,
})
defer resetCfg()

View File

@ -9,11 +9,16 @@ import (
)
func TestMainnet_Bellatrix_Forkchoice(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
})
defer resetCfg()
forkchoice.Run(t, "mainnet", version.Bellatrix)
}
func TestMainnet_Bellatrix_Forkchoice_DoublyLinkTree(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
EnableForkChoiceDoublyLinkedTree: true,
})
defer resetCfg()

View File

@ -9,11 +9,16 @@ import (
)
func TestMainnet_Altair_Forkchoice(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
})
defer resetCfg()
forkchoice.Run(t, "mainnet", version.Phase0)
}
func TestMainnet_Altair_Forkchoice_DoublyLinkTree(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
EnableForkChoiceDoublyLinkedTree: true,
})
defer resetCfg()

View File

@ -9,12 +9,17 @@ import (
)
func TestMinimal_Altair_Forkchoice(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
})
defer resetCfg()
forkchoice.Run(t, "minimal", version.Altair)
}
func TestMinimal_Altair_Forkchoice_DoublyLinkTre(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
EnableForkChoiceDoublyLinkedTree: true,
DisablePullTips: true,
})
defer resetCfg()
forkchoice.Run(t, "minimal", version.Altair)

View File

@ -9,11 +9,16 @@ import (
)
func TestMinimal_Bellatrix_Forkchoice(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
})
defer resetCfg()
forkchoice.Run(t, "minimal", version.Bellatrix)
}
func TestMinimal_Bellatrix_Forkchoice_DoublyLinkTree(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
EnableForkChoiceDoublyLinkedTree: true,
})
defer resetCfg()

View File

@ -9,11 +9,16 @@ import (
)
func TestMinimal_Altair_Forkchoice(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
})
defer resetCfg()
forkchoice.Run(t, "minimal", version.Phase0)
}
func TestMinimal_Altair_Forkchoice_DoublyLinkTre(t *testing.T) {
resetCfg := features.InitWithReset(&features.Flags{
DisablePullTips: true,
EnableForkChoiceDoublyLinkedTree: true,
})
defer resetCfg()