Skip to content

feat(nano): remove support for using __blueprint__ in OCB code#1397

Merged
jansegre merged 1 commit intomasterfrom
feat/nano/remove-blueprint-dunder-support
Sep 24, 2025
Merged

feat(nano): remove support for using __blueprint__ in OCB code#1397
jansegre merged 1 commit intomasterfrom
feat/nano/remove-blueprint-dunder-support

Conversation

@jansegre
Copy link
Member

@jansegre jansegre commented Sep 8, 2025

Motivation

#1395 introduced the use of @export to set the main blueprint class of a module, but leaves the old method (__blueprint__ = MyBlueprint) as acceptable.

Acceptance Criteria

  • Remove support for __blueprint__
  • Refactor all remaining cases to use @export
  • Adjust tests accordingly

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@jansegre jansegre requested review from glevco and msbrogli September 8, 2025 16:53
@jansegre jansegre self-assigned this Sep 8, 2025
@jansegre jansegre moved this from Todo to In Progress (WIP) in Hathor Network Sep 8, 2025
@github-actions
Copy link

github-actions bot commented Sep 8, 2025

🐰 Bencher Report

Branchfeat/nano/remove-blueprint-dunder-support
Testbedubuntu-22.04
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
minutes (m)
(Result Δ%)
Lower Boundary
minutes (m)
(Limit %)
Upper Boundary
minutes (m)
(Limit %)
sync-v2 (up to 20000 blocks)📈 view plot
🚷 view threshold
1.97 m
(+16.06%)Baseline: 1.70 m
1.53 m
(77.54%)
2.04 m
(96.72%)
🐰 View full continuous benchmarking report in Bencher

@jansegre jansegre force-pushed the feat/nano/remove-blueprint-dunder-support branch 2 times, most recently from e7f5897 to 0c45086 Compare September 10, 2025 18:08
@jansegre jansegre moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Sep 10, 2025
@codecov
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.79%. Comparing base (4d047ca) to head (bfbc318).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
hathor/verification/on_chain_blueprint_verifier.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1397      +/-   ##
==========================================
+ Coverage   85.77%   85.79%   +0.02%     
==========================================
  Files         430      430              
  Lines       33070    33054      -16     
  Branches     5173     5172       -1     
==========================================
- Hits        28365    28360       -5     
+ Misses       3666     3657       -9     
+ Partials     1039     1037       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

"""Verify that the script defines a __blueprint__ attribute."""
"""Verify that the script seemingly exports a blueprint."""
blueprint_ast = self._get_python_code_ast(tx)
search_name = _SearchName(BLUEPRINT_EXPORT_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the _SearchName class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.


def _verify_has_blueprint_attr(self, tx: OnChainBlueprint) -> None:
"""Verify that the script defines a __blueprint__ attribute."""
"""Verify that the script seemingly exports a blueprint."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seemingly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, "seemingly", because @export could have been used in a class defined inside a function, or with an invalid class that is not a Blueprint. So at most we can say that it seemingly exports a blueprint, but we won't be sure until we execute the code.

self.manager.vertex_handler.on_new_relayed_vertex(blueprint)
assert isinstance(cm.exception.__cause__, OCBInvalidScript)
assert cm.exception.args[0] == 'full validation failed: __blueprint__ is not a class'
assert cm.exception.args[0] == 'full validation failed: Could not find a main Blueprint definition'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error should keep the previous, correct message

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this message could bubble up to blueprint devs, I wanted to avoid using __blueprint__ because now it's only an internal detail.

@glevco glevco moved this from In Progress (Done) to In Review (WIP) in Hathor Network Sep 11, 2025
@jansegre jansegre force-pushed the feat/nano/remove-blueprint-dunder-support branch 2 times, most recently from afe1de8 to f68f2e7 Compare September 19, 2025 14:54
@jansegre jansegre moved this from In Review (WIP) to In Review (Done) in Hathor Network Sep 19, 2025
@jansegre jansegre moved this from In Review (Done) to In Review (WIP) in Hathor Network Sep 19, 2025
msbrogli
msbrogli previously approved these changes Sep 23, 2025
@jansegre jansegre force-pushed the feat/nano/remove-blueprint-dunder-support branch from f68f2e7 to bfbc318 Compare September 24, 2025 14:29
@jansegre jansegre merged commit a9a0fb7 into master Sep 24, 2025
2 checks passed
@jansegre jansegre deleted the feat/nano/remove-blueprint-dunder-support branch September 24, 2025 14:30
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Sep 24, 2025
@jansegre jansegre mentioned this pull request Sep 26, 2025
2 tasks
@jansegre jansegre moved this from Waiting to be deployed to Done in Hathor Network Sep 26, 2025
@jansegre jansegre mentioned this pull request Oct 16, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants