Skip to content

Native: properly activate native methods/events#4524

Merged
shargon merged 1 commit intoneo-project:master-n3from
AnnaShaleva:fix-ActiveIn
Apr 7, 2026
Merged

Native: properly activate native methods/events#4524
shargon merged 1 commit intoneo-project:master-n3from
AnnaShaleva:fix-ActiveIn

Conversation

@AnnaShaleva
Copy link
Copy Markdown
Member

Description

#4520 fixes false-positive activation in case if DeprecatedIn hardfork is passed. However, it's not enough for proper ActiveIn work because there's a case of false-positive activation in case if both DeprecatedIn and ActiveIn hardforks are not yet passed.

This commit rewrites ActiveIn condition: the method/event IS active if and only if ActiveIn hardfork IS active AND DeprecatedIn hardfork IS NOT active. ActiveIn hardfork IS active if it's null OR it's already passed. DeprecatedIn hardfork IS NOT active if it's null OR it's not yet passed.

For reference, here's the same condition (but in reversed form) in NeoGo:
https://github.com/nspcc-dev/neo-go/blob/60b8cd32a74d033e77b0fa9034f0fa3a999a34c1/pkg/core/interop/context.go#L332-L335

Change Log

  • Rewrite ActiveIn to cover all combinations of ActiveIn/DeprecatedIn

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit Testing
  • Run Application
  • Local Computer Tests
  • No Testing

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

neo-project#4520 fixes false-positive
activation in case if DeprecatedIn hardfork is passed. However,
it's not enough for proper ActiveIn work because there's a case of
false-positive activation in case if both DeprecatedIn and ActiveIn
hardforks are not yet passed.

This commit rewrites ActiveIn condition: the method/event IS active if
and only if ActiveIn hardfork IS active AND DeprecatedIn hardfork IS NOT
active. ActiveIn hardfork IS active if it's null OR it's already passed.
DeprecatedIn hardfork IS NOT active if it's null OR it's not yet passed.

Signed-off-by: Anna Shaleva <[email protected]>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.84%. Comparing base (f7bc967) to head (c0edb37).
⚠️ Report is 1 commits behind head on master-n3.

Additional details and impacted files
@@              Coverage Diff              @@
##           master-n3    #4524      +/-   ##
=============================================
+ Coverage      78.76%   78.84%   +0.08%     
=============================================
  Files            236      236              
  Lines          16283    16278       -5     
  Branches        2361     2361              
=============================================
+ Hits           12825    12835      +10     
+ Misses          2708     2688      -20     
- Partials         750      755       +5     

☔ 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.

Copy link
Copy Markdown
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

Lgtm

Comment on lines +79 to +80
Assert.IsFalse(NativeContract.IsActive(new active() { ActiveIn = Hardfork.HF_Basilisk, DeprecatedIn = Hardfork.HF_Cockatrice }, settings.IsHardforkEnabled, 9));
Assert.IsTrue(NativeContract.IsActive(new active() { ActiveIn = Hardfork.HF_Basilisk, DeprecatedIn = Hardfork.HF_Cockatrice }, settings.IsHardforkEnabled, 10));
Copy link
Copy Markdown
Member Author

@AnnaShaleva AnnaShaleva Apr 7, 2026

Choose a reason for hiding this comment

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

Just for the record: this test is failing on the current master-n3. It passes with this fix.

@shargon shargon merged commit 38d91fc into neo-project:master-n3 Apr 7, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Used to tag confirmed bugs N3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants