Skip to content

fix: remove unused NOP features #901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions hathor/conf/testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 0 additions & 29 deletions hathor/conf/testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions hathor/transaction/storage/transaction_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down