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
feat(feature-activation): implement closest_block metadata and Feature Activation for Transactions #933
base: master
Are you sure you want to change the base?
Conversation
…e Activation for Transactions
cfe1640
to
d3d069c
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## fix/feature-activation/add-missing-migration #933 +/- ##
================================================================================
+ Coverage 85.30% 85.32% +0.02%
================================================================================
Files 289 290 +1
Lines 22411 22465 +54
Branches 3373 3381 +8
================================================================================
+ Hits 19117 19168 +51
- Misses 2620 2623 +3
Partials 674 674 ☔ View full report in Codecov by Sentry. |
"""Returns whether a Feature is active at a certain block.""" | ||
def is_feature_active_for_transaction(self, *, tx: 'Transaction', feature: Feature) -> bool: | ||
"""Return whether a Feature is active for a certain Transaction.""" | ||
metadata = tx.get_metadata() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert that isinstance(tx, Transaction)
to prevent bugs if mypy fails to detect wrong call types.
this_closest_block = vertex | ||
elif isinstance(vertex, Transaction): | ||
this_closest_block_id = ( | ||
self._settings.GENESIS_BLOCK_HASH if vertex.is_genesis else not_none(vertex_meta.closest_block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you can safely do not_none(vertex_meta.closest_block)
.
return | ||
assert isinstance(self, Transaction) | ||
assert self.storage is not None | ||
metadata = self.get_metadata() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if metadata.closest_block is not None
and returns if true.
|
||
if isinstance(vertex, Block): | ||
assert vertex_meta.closest_block is None | ||
this_closest_block = vertex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd name it candidate_block
.
# For Blocks, this is None. For Transactions, this is the Block with the greatest height that is a direct or | ||
# indirect dependency (ancestor) of the transaction, including both funds and confirmation DAGs. | ||
# It's used by Feature Activation for Transactions. | ||
closest_block: VertexId | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd name it closest_ancestor_block
.
d5306f4
to
bbcd88a
Compare
Depends on #927
Motivation
Implement the new
closest_block
metadata that will enable Feature Activation for Transactions.Acceptance Criteria
FeatureService.is_feature_active()
tois_feature_active_for_block()
.FeatureService.is_feature_active_for_transaction()
.closest_block
metadata, with a migration for it.BaseTransaction._update_closest_block_metadata()
.Checklist
master
, confirm this code is production-ready and can be included in future releases as soon as it gets merged