diff --git a/hathor/conf/testnet.py b/hathor/conf/testnet.py index e59a2daa2..792d95ce5 100644 --- a/hathor/conf/testnet.py +++ b/hathor/conf/testnet.py @@ -58,33 +58,6 @@ enable_usage=True, default_threshold=30240, features={ - Feature.NOP_FEATURE_1: Criteria( - bit=0, - start_height=3_144_960, # N (right now the best block is 3093551 on testnet) - timeout_height=3_225_600, # N + 2 * 40320 (4 weeks after the start) - minimum_activation_height=3_265_920, # N + 3 * 40320 (6 weeks after the start) - lock_in_on_timeout=False, - version='0.56.0', - signal_support_by_default=True - ), - Feature.NOP_FEATURE_2: Criteria( - bit=1, - start_height=3_144_960, # N (right now the best block is 3093551 on testnet) - timeout_height=3_225_600, # N + 2 * 40320 (4 weeks after the start) - minimum_activation_height=0, - lock_in_on_timeout=True, - version='0.56.0', - signal_support_by_default=False - ), - Feature.NOP_FEATURE_3: Criteria( - bit=2, - start_height=3_144_960, # N (right now the best block is 3093551 on testnet) - timeout_height=3_225_600, # N + 2 * 40320 (4 weeks after the start) - minimum_activation_height=0, - lock_in_on_timeout=False, - version='0.56.0', - signal_support_by_default=False - ), Feature.NOP_FEATURE_4: Criteria( bit=0, start_height=3_386_880, # N (right now the best block is 3_346_600 on testnet) diff --git a/hathor/conf/testnet.yml b/hathor/conf/testnet.yml index 0696ee70b..ca799c299 100644 --- a/hathor/conf/testnet.yml +++ b/hathor/conf/testnet.yml @@ -40,35 +40,6 @@ FEATURE_ACTIVATION: enable_usage: true default_threshold: 30_240 # 30240 = 75% of evaluation_interval (40320) features: - #### First Phased Testing features #### - - NOP_FEATURE_1: - bit: 0 - start_height: 3_144_960 # N (right now the best block is 3093551 on testnet) - timeout_height: 3_225_600 # N + 2 * 40320 (4 weeks after the start) - minimum_activation_height: 3_265_920 # N + 3 * 40320 (6 weeks after the start) - lock_in_on_timeout: false - version: 0.56.0 - signal_support_by_default: true - - NOP_FEATURE_2: - bit: 1 - start_height: 3_144_960 # N (right now the best block is 3093551 on testnet) - timeout_height: 3_225_600 # N + 2 * 40320 (4 weeks after the start) - minimum_activation_height: 0 - lock_in_on_timeout: true - version: 0.56.0 - signal_support_by_default: false - - NOP_FEATURE_3: - bit: 2 - start_height: 3_144_960 # N (right now the best block is 3093551 on testnet) - timeout_height: 3_225_600 # N + 2 * 40320 (4 weeks after the start) - minimum_activation_height: 0 - lock_in_on_timeout: false - version: 0.56.0 - signal_support_by_default: false - #### Second Phased Testing features #### NOP_FEATURE_4: diff --git a/hathor/transaction/storage/migrations/remove_first_nop_features.py b/hathor/transaction/storage/migrations/remove_first_nop_features.py new file mode 100644 index 000000000..c245e8d22 --- /dev/null +++ b/hathor/transaction/storage/migrations/remove_first_nop_features.py @@ -0,0 +1,58 @@ +# Copyright 2023 Hathor Labs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import TYPE_CHECKING + +from structlog import get_logger + +from hathor.conf.get_settings import get_settings +from hathor.transaction.storage.migrations import BaseMigration +from hathor.util import progress + +if TYPE_CHECKING: + from hathor.transaction.storage import TransactionStorage + +logger = get_logger() + + +class Migration(BaseMigration): + def skip_empty_db(self) -> bool: + return True + + def get_db_name(self) -> str: + return 'remove_first_nop_features' + + def run(self, storage: 'TransactionStorage') -> None: + """ + This migration clears the Feature Activation metadata related to the first Phased Testing on testnet. + """ + settings = get_settings() + log = logger.new() + + if settings.NETWORK_NAME != 'testnet-golf': + # If it's not testnet, we don't have to clear anything. + log.info('Skipping testnet-only migration.') + return + + topological_iterator = storage.topological_iterator() + + for vertex in progress(topological_iterator, log=log, total=None): + if vertex.is_block: + meta = vertex.get_metadata() + assert meta.height is not None + # This is the start_height of the **second** Phased Testing, so we clear anything before it. + if meta.height < 3_386_880: + meta.feature_states = None + + storage.save_transaction(vertex, only_metadata=True) diff --git a/hathor/transaction/storage/transaction_storage.py b/hathor/transaction/storage/transaction_storage.py index 3a9df6be7..a4358c6c4 100644 --- a/hathor/transaction/storage/transaction_storage.py +++ b/hathor/transaction/storage/transaction_storage.py @@ -40,6 +40,7 @@ MigrationState, add_feature_activation_bit_counts_metadata, add_min_height_metadata, + remove_first_nop_features, ) from hathor.transaction.storage.tx_allow_scope import TxAllowScope, tx_allow_context from hathor.transaction.transaction import Transaction @@ -87,6 +88,7 @@ class TransactionStorage(ABC): _migration_factories: list[type[BaseMigration]] = [ add_min_height_metadata.Migration, add_feature_activation_bit_counts_metadata.Migration, + remove_first_nop_features.Migration ] _migrations: list[BaseMigration]