Skip to content

Commit f6dd5c9

Browse files
committed
fix: remove unused NOP features
1 parent 8261720 commit f6dd5c9

File tree

4 files changed

+60
-56
lines changed

4 files changed

+60
-56
lines changed

hathor/conf/testnet.py

-27
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,6 @@
5858
enable_usage=True,
5959
default_threshold=30240,
6060
features={
61-
Feature.NOP_FEATURE_1: Criteria(
62-
bit=0,
63-
start_height=3_144_960, # N (right now the best block is 3093551 on testnet)
64-
timeout_height=3_225_600, # N + 2 * 40320 (4 weeks after the start)
65-
minimum_activation_height=3_265_920, # N + 3 * 40320 (6 weeks after the start)
66-
lock_in_on_timeout=False,
67-
version='0.56.0',
68-
signal_support_by_default=True
69-
),
70-
Feature.NOP_FEATURE_2: Criteria(
71-
bit=1,
72-
start_height=3_144_960, # N (right now the best block is 3093551 on testnet)
73-
timeout_height=3_225_600, # N + 2 * 40320 (4 weeks after the start)
74-
minimum_activation_height=0,
75-
lock_in_on_timeout=True,
76-
version='0.56.0',
77-
signal_support_by_default=False
78-
),
79-
Feature.NOP_FEATURE_3: Criteria(
80-
bit=2,
81-
start_height=3_144_960, # N (right now the best block is 3093551 on testnet)
82-
timeout_height=3_225_600, # N + 2 * 40320 (4 weeks after the start)
83-
minimum_activation_height=0,
84-
lock_in_on_timeout=False,
85-
version='0.56.0',
86-
signal_support_by_default=False
87-
),
8861
Feature.NOP_FEATURE_4: Criteria(
8962
bit=0,
9063
start_height=3_386_880, # N (right now the best block is 3_346_600 on testnet)

hathor/conf/testnet.yml

-29
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,6 @@ FEATURE_ACTIVATION:
4040
enable_usage: true
4141
default_threshold: 30_240 # 30240 = 75% of evaluation_interval (40320)
4242
features:
43-
#### First Phased Testing features ####
44-
45-
NOP_FEATURE_1:
46-
bit: 0
47-
start_height: 3_144_960 # N (right now the best block is 3093551 on testnet)
48-
timeout_height: 3_225_600 # N + 2 * 40320 (4 weeks after the start)
49-
minimum_activation_height: 3_265_920 # N + 3 * 40320 (6 weeks after the start)
50-
lock_in_on_timeout: false
51-
version: 0.56.0
52-
signal_support_by_default: true
53-
54-
NOP_FEATURE_2:
55-
bit: 1
56-
start_height: 3_144_960 # N (right now the best block is 3093551 on testnet)
57-
timeout_height: 3_225_600 # N + 2 * 40320 (4 weeks after the start)
58-
minimum_activation_height: 0
59-
lock_in_on_timeout: true
60-
version: 0.56.0
61-
signal_support_by_default: false
62-
63-
NOP_FEATURE_3:
64-
bit: 2
65-
start_height: 3_144_960 # N (right now the best block is 3093551 on testnet)
66-
timeout_height: 3_225_600 # N + 2 * 40320 (4 weeks after the start)
67-
minimum_activation_height: 0
68-
lock_in_on_timeout: false
69-
version: 0.56.0
70-
signal_support_by_default: false
71-
7243
#### Second Phased Testing features ####
7344

7445
NOP_FEATURE_4:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2023 Hathor Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import TYPE_CHECKING
16+
17+
from structlog import get_logger
18+
19+
from hathor.conf.get_settings import get_settings
20+
from hathor.transaction.storage.migrations import BaseMigration
21+
from hathor.util import progress
22+
23+
if TYPE_CHECKING:
24+
from hathor.transaction.storage import TransactionStorage
25+
26+
logger = get_logger()
27+
28+
29+
class Migration(BaseMigration):
30+
def skip_empty_db(self) -> bool:
31+
return True
32+
33+
def get_db_name(self) -> str:
34+
return 'remove_first_nop_features'
35+
36+
def run(self, storage: 'TransactionStorage') -> None:
37+
"""
38+
This migration clears the Feature Activation metadata related to the first Phased Testing on testnet.
39+
"""
40+
settings = get_settings()
41+
log = logger.new()
42+
43+
if settings.NETWORK_NAME != 'testnet-golf':
44+
# If it's not testnet, we don't have to clear anything.
45+
log.info('Skipping testnet-only migration.')
46+
return
47+
48+
topological_iterator = storage.topological_iterator()
49+
50+
for vertex in progress(topological_iterator, log=log, total=None):
51+
if vertex.is_block:
52+
meta = vertex.get_metadata()
53+
assert meta.height is not None
54+
# This is the start_height of the **second** Phased Testing, so we clear anything before it.
55+
if meta.height < 3_386_880:
56+
meta.feature_states = None
57+
58+
storage.save_transaction(vertex, only_metadata=True)

hathor/transaction/storage/transaction_storage.py

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
MigrationState,
4141
add_feature_activation_bit_counts_metadata,
4242
add_min_height_metadata,
43+
remove_first_nop_features,
4344
)
4445
from hathor.transaction.storage.tx_allow_scope import TxAllowScope, tx_allow_context
4546
from hathor.transaction.transaction import Transaction
@@ -87,6 +88,7 @@ class TransactionStorage(ABC):
8788
_migration_factories: list[type[BaseMigration]] = [
8889
add_min_height_metadata.Migration,
8990
add_feature_activation_bit_counts_metadata.Migration,
91+
remove_first_nop_features.Migration
9092
]
9193

9294
_migrations: list[BaseMigration]

0 commit comments

Comments
 (0)