Skip to content

Commit

Permalink
chore(feature-activation): phased testing adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
glevco committed Jan 23, 2024
1 parent 9ef629f commit 5029a38
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 67 deletions.
34 changes: 1 addition & 33 deletions hathor/conf/testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

from hathor.checkpoint import Checkpoint as cp
from hathor.conf.settings import HathorSettings
from hathor.feature_activation.feature import Feature
from hathor.feature_activation.model.criteria import Criteria
from hathor.feature_activation.settings import Settings as FeatureActivationSettings

SETTINGS = HathorSettings(
Expand Down Expand Up @@ -55,36 +53,6 @@
cp(1_600_000, bytes.fromhex('00000000060adfdfd7d488d4d510b5779cf35a3c50df7bcff941fbb6957be4d2')),
],
FEATURE_ACTIVATION=FeatureActivationSettings(
evaluation_interval=40_320,
default_threshold=30240,
features={
Feature.NOP_FEATURE_4: Criteria(
bit=0,
start_height=3_386_880, # N (right now the best block is 3_346_600 on testnet)
timeout_height=3_467_520, # N + 2 * 40320 (4 weeks after the start)
minimum_activation_height=3_507_840, # N + 3 * 40320 (6 weeks after the start)
lock_in_on_timeout=False,
version='0.57.0',
signal_support_by_default=True
),
Feature.NOP_FEATURE_5: Criteria(
bit=1,
start_height=3_386_880, # N (right now the best block is 3_346_600 on testnet)
timeout_height=3_467_520, # N + 2 * 40320 (4 weeks after the start)
minimum_activation_height=0,
lock_in_on_timeout=True,
version='0.57.0',
signal_support_by_default=False
),
Feature.NOP_FEATURE_6: Criteria(
bit=2,
start_height=3_386_880, # N (right now the best block is 3_346_600 on testnet)
timeout_height=3_467_520, # N + 2 * 40320 (4 weeks after the start)
minimum_activation_height=0,
lock_in_on_timeout=False,
version='0.57.0',
signal_support_by_default=False
)
}
default_threshold=15_120, # 15120 = 75% of evaluation_interval (20160)
)
)
32 changes: 1 addition & 31 deletions hathor/conf/testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,4 @@ CHECKPOINTS:
1_600_000: 00000000060adfdfd7d488d4d510b5779cf35a3c50df7bcff941fbb6957be4d2

FEATURE_ACTIVATION:
evaluation_interval: 40_320
default_threshold: 30_240 # 30240 = 75% of evaluation_interval (40320)
features:
#### Second Phased Testing features ####

NOP_FEATURE_4:
bit: 0
start_height: 3_386_880 # N (right now the best block is 3_346_600 on testnet)
timeout_height: 3_467_520 # N + 2 * 40320 (4 weeks after the start)
minimum_activation_height: 3_507_840 # N + 3 * 40320 (6 weeks after the start)
lock_in_on_timeout: false
version: 0.57.0
signal_support_by_default: true

NOP_FEATURE_5:
bit: 1
start_height: 3_386_880 # N (right now the best block is 3_346_600 on testnet)
timeout_height: 3_467_520 # N + 2 * 40320 (4 weeks after the start)
minimum_activation_height: 0
lock_in_on_timeout: true
version: 0.57.0
signal_support_by_default: false

NOP_FEATURE_6:
bit: 2
start_height: 3_386_880 # N (right now the best block is 3_346_600 on testnet)
timeout_height: 3_467_520 # N + 2 * 40320 (4 weeks after the start)
minimum_activation_height: 0
lock_in_on_timeout: false
version: 0.57.0
signal_support_by_default: false
default_threshold: 15_120 # 15120 = 75% of evaluation_interval (20160)
5 changes: 3 additions & 2 deletions hathor/feature_activation/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ class Feature(Enum):
should NOT be changed either, as configuration uses them for setting feature activation criteria.
"""

# First Phased Testing features
# Mainnet Phased Testing features
NOP_FEATURE_1 = 'NOP_FEATURE_1'
NOP_FEATURE_2 = 'NOP_FEATURE_2'
NOP_FEATURE_3 = 'NOP_FEATURE_3'

# Second Phased Testing features
# TODO: Those can be removed in a future PR
# Testnet Phased Testing features
NOP_FEATURE_4 = 'NOP_FEATURE_4'
NOP_FEATURE_5 = 'NOP_FEATURE_5'
NOP_FEATURE_6 = 'NOP_FEATURE_6'
2 changes: 1 addition & 1 deletion hathor/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def _log_feature_states(self, vertex: BaseTransaction) -> None:
features_states=state_by_feature
)

features = [Feature.NOP_FEATURE_4, Feature.NOP_FEATURE_5, Feature.NOP_FEATURE_6]
features = [Feature.NOP_FEATURE_1, Feature.NOP_FEATURE_2]
for feature in features:
self._log_if_feature_is_active(vertex, feature)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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_global_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_second_nop_features'

def run(self, storage: 'TransactionStorage') -> None:
"""
This migration clears the Feature Activation metadata related to the second Phased Testing on testnet.
"""
settings = get_global_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()
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 @@ -42,6 +42,7 @@
add_feature_activation_bit_counts_metadata2,
add_min_height_metadata,
remove_first_nop_features,
remove_second_nop_features,
)
from hathor.transaction.storage.tx_allow_scope import TxAllowScope, tx_allow_context
from hathor.transaction.transaction import Transaction
Expand Down Expand Up @@ -92,6 +93,7 @@ class TransactionStorage(ABC):
add_feature_activation_bit_counts_metadata.Migration,
remove_first_nop_features.Migration,
add_feature_activation_bit_counts_metadata2.Migration,
remove_second_nop_features.Migration,
]

_migrations: list[BaseMigration]
Expand Down

0 comments on commit 5029a38

Please sign in to comment.