From 8cbbc1e83dd3bdaed2357d916c36b7af4eb2e27f Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sat, 15 Nov 2025 00:23:05 +0800 Subject: [PATCH] consensus, params: remove `SkipV2Validation`, close XFN-151 (#1730) --- cicd/devnet/genesis.json | 3 +-- consensus/XDPoS/engines/engine_v2/verifyHeader.go | 5 ----- .../tests/engine_v2_tests/verify_header_test.go | 14 -------------- genesis/devnet.json | 3 +-- params/config.go | 5 +---- 5 files changed, 3 insertions(+), 27 deletions(-) diff --git a/cicd/devnet/genesis.json b/cicd/devnet/genesis.json index ee67134682..792b58c951 100644 --- a/cicd/devnet/genesis.json +++ b/cicd/devnet/genesis.json @@ -35,8 +35,7 @@ "timeoutPeriod": 10, "certificateThreshold": 0.667 } - }, - "SkipV2Validation": false + } } } }, diff --git a/consensus/XDPoS/engines/engine_v2/verifyHeader.go b/consensus/XDPoS/engines/engine_v2/verifyHeader.go index 1efca9248f..adbefd3b28 100644 --- a/consensus/XDPoS/engines/engine_v2/verifyHeader.go +++ b/consensus/XDPoS/engines/engine_v2/verifyHeader.go @@ -18,11 +18,6 @@ import ( // Verify individual header func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Header, parents []*types.Header, fullVerify bool) error { - // If we're running a engine faking, accept any block as valid - if x.config.V2.SkipV2Validation { - return nil - } - if !x.isInitilised { if err := x.initial(chain, header); err != nil { return err diff --git a/consensus/tests/engine_v2_tests/verify_header_test.go b/consensus/tests/engine_v2_tests/verify_header_test.go index 844a0ec645..68f9617a44 100644 --- a/consensus/tests/engine_v2_tests/verify_header_test.go +++ b/consensus/tests/engine_v2_tests/verify_header_test.go @@ -25,8 +25,6 @@ func TestShouldVerifyBlock(t *testing.T) { var config params.ChainConfig err = json.Unmarshal([]byte(configString), &config) assert.Nil(t, err) - // Enable verify - config.XDPoS.V2.SkipV2Validation = false // Block 901 is the first v2 block with round of 1 blockchain, _, _, signer, signFn, _ := PrepareXDCTestBlockChainForV2Engine(t, 910, &config, nil) adaptor := blockchain.Engine().(*XDPoS.XDPoS) @@ -176,8 +174,6 @@ func TestConfigSwitchOnDifferentCertThreshold(t *testing.T) { var config params.ChainConfig err = json.Unmarshal([]byte(configString), &config) assert.Nil(t, err) - // Enable verify - config.XDPoS.V2.SkipV2Validation = false // Block 901 is the first v2 block with round of 1 blockchain, _, _, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 915, &config, nil) @@ -274,8 +270,6 @@ func TestConfigSwitchOnDifferentMasternodeCount(t *testing.T) { var config params.ChainConfig err = json.Unmarshal([]byte(configString), &config) assert.Nil(t, err) - // Enable verify - config.XDPoS.V2.SkipV2Validation = false // Block 901 is the first v2 block with round of 1 blockchain, _, currentBlock, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, int(config.XDPoS.Epoch)*2, &config, nil) adaptor := blockchain.Engine().(*XDPoS.XDPoS) @@ -312,8 +306,6 @@ func TestConfigSwitchOnDifferentMindPeriod(t *testing.T) { var config params.ChainConfig err = json.Unmarshal([]byte(configString), &config) assert.Nil(t, err) - // Enable verify - config.XDPoS.V2.SkipV2Validation = false // Block 901 is the first v2 block with round of 1 blockchain, _, _, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 915, &config, nil) @@ -365,8 +357,6 @@ func TestShouldFailIfNotEnoughQCSignatures(t *testing.T) { var config params.ChainConfig err = json.Unmarshal([]byte(configString), &config) assert.Nil(t, err) - // Enable verify - config.XDPoS.V2.SkipV2Validation = false // Block 901 is the first v2 block with round of 1 blockchain, _, currentBlock, signer, signFn, _ := PrepareXDCTestBlockChainForV2Engine(t, 902, &config, nil) adaptor := blockchain.Engine().(*XDPoS.XDPoS) @@ -416,8 +406,6 @@ func TestShouldVerifyHeaders(t *testing.T) { var config params.ChainConfig err = json.Unmarshal([]byte(configString), &config) assert.Nil(t, err) - // Enable verify - config.XDPoS.V2.SkipV2Validation = false // Block 901 is the first v2 block with round of 1 blockchain, _, _, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 910, &config, nil) adaptor := blockchain.Engine().(*XDPoS.XDPoS) @@ -455,8 +443,6 @@ func TestShouldVerifyHeadersEvenIfParentsNotYetWrittenIntoDB(t *testing.T) { var config params.ChainConfig err = json.Unmarshal([]byte(configString), &config) assert.Nil(t, err) - // Enable verify - config.XDPoS.V2.SkipV2Validation = false // Block 901 is the first v2 block with round of 1 blockchain, _, block910, signer, signFn, _ := PrepareXDCTestBlockChainForV2Engine(t, 910, &config, nil) adaptor := blockchain.Engine().(*XDPoS.XDPoS) diff --git a/genesis/devnet.json b/genesis/devnet.json index ee67134682..792b58c951 100644 --- a/genesis/devnet.json +++ b/genesis/devnet.json @@ -35,8 +35,7 @@ "timeoutPeriod": 10, "certificateThreshold": 0.667 } - }, - "SkipV2Validation": false + } } } }, diff --git a/params/config.go b/params/config.go index 861b8b7852..556ac46478 100644 --- a/params/config.go +++ b/params/config.go @@ -488,8 +488,6 @@ type V2 struct { CurrentConfig *V2Config `json:"config"` AllConfigs map[uint64]*V2Config `json:"allConfigs"` configIndex []uint64 //list of switch block of configs - - SkipV2Validation bool //Skip Block Validation for testing purpose, V2 consensus only } type V2Config struct { @@ -574,7 +572,7 @@ func (v2 *V2) String() string { return "V2: " } - return fmt.Sprintf("V2{SwitchEpoch: %v, SwitchBlock: %v, SkipV2Validation: %v, %s}", v2.SwitchEpoch, v2.SwitchBlock, v2.SkipV2Validation, v2.CurrentConfig.String()) + return fmt.Sprintf("V2{SwitchEpoch: %v, SwitchBlock: %v, %s}", v2.SwitchEpoch, v2.SwitchBlock, v2.CurrentConfig.String()) } func (v2 *V2) Description(indent int) string { @@ -586,7 +584,6 @@ func (v2 *V2) Description(indent int) string { prefix := strings.Repeat(" ", indent) banner += fmt.Sprintf("%s- SwitchEpoch: %v\n", prefix, v2.SwitchEpoch) banner += fmt.Sprintf("%s- SwitchBlock: %v\n", prefix, v2.SwitchBlock) - banner += fmt.Sprintf("%s- SkipV2Validation: %v\n", prefix, v2.SkipV2Validation) banner += fmt.Sprintf("%s- %s", prefix, v2.GetCurrentConfig().Description("CurrentConfig", indent+2)) return banner }