-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix hardfork issues #3234
fix hardfork issues #3234
Conversation
is the manifests of native contracts fixed? |
@@ -43,6 +43,9 @@ public ECPoint[] GetDesignatedByRole(DataCache snapshot, Role role, uint index) | |||
throw new ArgumentOutOfRangeException(nameof(role)); | |||
if (Ledger.CurrentIndex(snapshot) + 1 < index) | |||
throw new ArgumentOutOfRangeException(nameof(index)); | |||
// Fix hardfork for https://github.com/neo-project/neo/pull/3172 | |||
if (role == Role.P2PNotary && !ProtocolSettings.Custom.IsHardforkEnabled(Hardfork.HF_Cockatrice, Ledger.CurrentIndex(snapshot))) |
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.
Breaks NeoFS chains immediately. I've tried to explain why we're doing it this way numerous times, but looks like no one cares about NeoFS and compatibility.
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.
breaks neofs or break the mainnet, this is a problem. We will have it but can not make it take effect untill we have the fork.
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.
Please, revert #3172 then. It causes more problems than it solves with this HF logic.
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.
BTW, it can only be exploited by committee. Nasty committee.
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.
BTW, it can only be exploited by committee. Nasty committee.
Hardly ever committee will designate this role before Notary subsystem implementation is finished. Thus, I'd vote for keeping P2PNotary role without binding to hardfork.
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.
BTW, it can only be exploited by committee
Sorry, not exactly. getDesignatedByRole
will return empty array instead of failing.
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.
This reverts commit c1af443.
@@ -23,12 +23,19 @@ internal class ContractMethodAttribute : Attribute | |||
public long CpuFee { get; init; } | |||
public long StorageFee { get; init; } | |||
public Hardfork? ActiveIn { get; init; } = null; | |||
public Hardfork? DeprecatedIn { get; init; } = null; |
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.
BTW, this is a part of #3210. Add a reference to the PR description, please.
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.
Also, we need the same functionality to be implemented for events. It's not hard to extend it, read the original issue.
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.
This pr is a hotpatch for the hf issues, i prefer to keep it as simple as possible.
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.
Ref. #3210 (comment) as TODO.
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.
Rename to ActiveTil
?
|
||
public ContractMethodAttribute() { } | ||
|
||
public ContractMethodAttribute(Hardfork activeIn) | ||
{ | ||
ActiveIn = activeIn; | ||
} | ||
|
||
public ContractMethodAttribute(bool isDeprecated, Hardfork deprecatedIn) |
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.
public ContractMethodAttribute(bool isDeprecated, Hardfork deprecatedIn) | |
public ContractMethodAttribute(Hardfork? activeIn, Hardfork deprecatedIn) |
I'd suggest to use this option, and just put null
as the first argument for those methods that were always active but need to be deprecated.
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.
Existing solution already works, i may update it after we have confirmed that this pr works fine.
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.
Ref. #3210 (comment) as TODO.
|
||
// This is for solving the hardfork issue in https://github.com/neo-project/neo/pull/3209 | ||
[ContractMethod(true, Hardfork.HF_Cockatrice, CpuFee = 1 << 15)] | ||
public static bool VerifyWithECDsa(byte[] message, byte[] pubkey, byte[] signature, NamedCurve curve) |
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.
You may safely get rid of NamedCurve
type here and use NamedCurveHash
, just check that curve
falls within the expected range (22 or 23) and throw if not. You can do this because NamedCurveHash
is compatible. If you implement this, then no 'NamedCurve' is obsolete
linter warnings will be raised.
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.
This is a hotpatch, i prefer to keep it simple and use original logic as much as possible.
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.
Every TODO is an issue, otherwise it won't be done. See #3236.
manifest of event |
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.
Tested OK. This fixed.
|
||
// This is for solving the hardfork issue in https://github.com/neo-project/neo/pull/3209 | ||
[ContractMethod(true, Hardfork.HF_Cockatrice, CpuFee = 1 << 15)] | ||
public static bool VerifyWithECDsa(byte[] message, byte[] pubkey, byte[] signature, NamedCurve curve) |
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.
Every TODO is an issue, otherwise it won't be done. See #3236.
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.
Seems good to me, only the rename to ActiveTil
, but also it's ok like this
|
||
if (!newCommittee.SequenceEqual(prevCommittee)) | ||
// Hardfork check for https://github.com/neo-project/neo/pull/3158 | ||
// New notification will case 3.7.0 and 3.6.0 have different behavior |
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.
will case?
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.
Good job @Jim8y
The deprecatedIn function was really needed for many cases and pending to be done!
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#L284 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 fixincluded, so this fix may safely be postponed to 3.8.0. Signed-off-by: Anna Shaleva <[email protected]>
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#L284 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 <[email protected]>
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 <[email protected]>
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 <[email protected]> Co-authored-by: Shargon <[email protected]>
…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
Description
This pr fixes the hardfork issue in the 3.7.
Fixes # (issue)
Type of change
Test Configuration:
Checklist: