Skip to content

Commit

Permalink
fix hardfork for 3172
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim8y committed May 15, 2024
1 parent a3319aa commit a88ebe4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Neo/SmartContract/Native/NativeContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ private NativeContractsCache.CacheEntry GetAllowedMethods(IsHardforkEnabledDeleg
{
foreach (ContractMethodMetadata method in methodDescriptors.Where(u
=>
// no hardfork is involved
u.ActiveIn is null && u.DeprecatedIn is null ||
// deprecated method hardfork is involved
u.DeprecatedIn is not null && hfChecker(u.DeprecatedIn.Value, index) == false ||
// active method hardfork is involved
u.ActiveIn is not null && hfChecker(u.ActiveIn.Value, index))
)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Neo/SmartContract/Native/RoleManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.Default.IsHardforkEnabled(Hardfork.HF_Cockatrice, index))
throw new ArgumentOutOfRangeException(nameof(role));
byte[] key = CreateStorageKey((byte)role).AddBigEndian(index).ToArray();
byte[] boundary = CreateStorageKey((byte)role).ToArray();
return snapshot.FindRange(key, boundary, SeekDirection.Backward)
Expand All @@ -62,6 +65,9 @@ private void DesignateAsRole(ApplicationEngine engine, Role role, ECPoint[] node
if (engine.PersistingBlock is null)
throw new InvalidOperationException(nameof(DesignateAsRole));
uint index = engine.PersistingBlock.Index + 1;
// Fix hardfork for https://github.com/neo-project/neo/pull/3172
if (role == Role.P2PNotary && !ProtocolSettings.Default.IsHardforkEnabled(Hardfork.HF_Cockatrice, index))
throw new ArgumentOutOfRangeException(nameof(role));
var key = CreateStorageKey((byte)role).AddBigEndian(index);
if (engine.Snapshot.Contains(key))
throw new InvalidOperationException();
Expand Down

0 comments on commit a88ebe4

Please sign in to comment.