Skip to content

Native: include DeprecatedIn hardfork into usedHardforks#3245

Merged
shargon merged 2 commits intomasterfrom
fix-deprecated-methods
May 21, 2024
Merged

Native: include DeprecatedIn hardfork into usedHardforks#3245
shargon merged 2 commits intomasterfrom
fix-deprecated-methods

Conversation

@AnnaShaleva
Copy link
Member

Description

DeprecatedIn hardfork of every native method (if not null) should be included into the set of used hardforks, otherwise no contract update will be performed during this hardfork activation:

internal bool IsInitializeBlock(ProtocolSettings settings, uint index, out Hardfork[] hardforks)
{
var hfs = new List<Hardfork>();
// If is in the hardfork height, add them to return array
foreach (var hf in usedHardforks)

internal override async ContractTask OnPersistAsync(ApplicationEngine engine)
{
foreach (NativeContract contract in Contracts)
{
if (contract.IsInitializeBlock(engine.ProtocolSettings, engine.PersistingBlock.Index, out var hfs))

This commit should be a part of #3234 and a part of 3.7.4. Luckily, this new DeprecatedIn functionality is used only for the old native CryptoLib's verifyWithECDsa method with Cockatrice hardfork. And luckily, there are other CryptoLib's methods with ActiveIn set to Cockatrice hardfork. Due to these two facts this bug does not affect mainnet/testnet, and thus we don't need 3.7.5 with this fix included. So this fix may safely be postponed to 3.8.0.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

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

DeprecatedIn hardfork of every native method (if not null) should be
included into the set of used hardforks, otherwise no contract update
will be performed on this hardfork activation:

https://github.com/neo-project/neo/blob/08f2dfc56762bb43be33e873bc3659bad368d4d6/src/Neo/SmartContract/Native/NativeContract.cs#L279-L284

https://github.com/neo-project/neo/blob/08f2dfc56762bb43be33e873bc3659bad368d4d6/src/Neo/SmartContract/Native/ContractManagement.cs#L69-L73

This commit should be a part of #3234 and a part of 3.7.4. Luckily, this new
DeprecatedIn functionality is used only for the old native CryptoLib's
verifyWithECDsa method with Cockatrice hardfork. And luckily, there are other
CryptoLib's methods with ActiveIn set to Cockatrice hardfork. Due to
these two facts this bug does not affect mainnet/testnet, and thus we don't
need 3.7.5 with this fix included. So this fix may safely be postponed to 3.8.0.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva AnnaShaleva added the Bug Used to tag confirmed bugs label May 20, 2024
@AnnaShaleva AnnaShaleva added this to the v3.8.0 milestone May 20, 2024
@Jim8y
Copy link
Contributor

Jim8y commented May 20, 2024

I thought about this, but will there be a case where the hf only has deprecated?

@AnnaShaleva
Copy link
Member Author

will there be a case where the hf only has deprecated?

There might be this case if we decide to remove some method from native contract. I think it's better to have it properly handled, just in case.

@shargon shargon merged commit f8c43cf into master May 21, 2024
@shargon shargon deleted the fix-deprecated-methods branch May 21, 2024 08:14
Jim8y added a commit to Jim8y/neo that referenced this pull request May 25, 2024
…gins

* 'latest-plugins' of github.com:Jim8y/neo: (21 commits)
  fix: custom plugins won't shown by command `plugins` (neo-project#3269)
  COVERALL: Improve maintenance and readbility of some variables (neo-project#3248)
  Update nuget (neo-project#3262)
  [**Part-2**] Neo module/master fixes (neo-project#3244)
  Fix `dotnet pack` error (neo-project#3266)
  Fix and Update devcontainer.json to use Dockerfile  (neo-project#3259)
  Add optimization to template (neo-project#3247)
  Optimize plugin's models (neo-project#3246)
  fix CancelTransaction !signers.Any() (neo-project#3263)
  COVERALL: fix broken by changing report from lcov to cobertura (neo-project#3252)
  fix TraverseIterator count (neo-project#3261)
  Native: include DeprecatedIn hardfork into usedHardforks (neo-project#3245)
  [**Part-1**] `neo-module/master` (neo-project#3232)
  Make `ApplicationEngine.LoadContext` protection level `public` (neo-project#3243)
  improve parse method in neo-cli (neo-project#3204)
  Fix neo-project#3239 (neo-project#3242)
  Neo.CLI: enable hardforks for NeoFS mainnet (neo-project#3240)
  v3.7.4 (neo-project#3237)
  fix hardfork issues (neo-project#3234)
  Update src/Neo.CLI/CLI/MainService.Plugins.cs
  ...

# Conflicts:
#	src/Neo.CLI/CLI/MainService.Plugins.cs
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants