From 330cbea762948e1b2c2f4c446a810a455606e2b7 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 10 Oct 2023 17:06:50 +0300 Subject: [PATCH] *: remove remnants of ConflictsFee in native Policy ConflictsFee logic was replaced by the generic attribute fee mechanism implemented in #2916. Signed-off-by: Anna Shaleva --- .../SmartContract/Native/PolicyContract.cs | 19 ------- .../SmartContract/Native/UT_PolicyContract.cs | 57 ------------------- 2 files changed, 76 deletions(-) diff --git a/src/Neo/SmartContract/Native/PolicyContract.cs b/src/Neo/SmartContract/Native/PolicyContract.cs index 9b48e9d15e..c754a15a93 100644 --- a/src/Neo/SmartContract/Native/PolicyContract.cs +++ b/src/Neo/SmartContract/Native/PolicyContract.cs @@ -32,11 +32,6 @@ public sealed class PolicyContract : NativeContract /// public const uint DefaultStoragePrice = 100000; - /// - /// The default fee for Conflicts attribute per signer. - /// - public const uint DefaultConflictsFee = 0; - /// /// The default network fee per byte of transactions. /// @@ -62,11 +57,6 @@ public sealed class PolicyContract : NativeContract /// public const uint MaxStoragePrice = 10000000; - /// - /// The maximum fee for Conflicts attribute per signer that the committee can set. - /// - public const uint MaxConflictsFee = 10_0000_0000; - private const byte Prefix_BlockedAccount = 15; private const byte Prefix_FeePerByte = 10; private const byte Prefix_ExecFeeFactor = 18; @@ -82,7 +72,6 @@ internal override ContractTask Initialize(ApplicationEngine engine) engine.Snapshot.Add(CreateStorageKey(Prefix_FeePerByte), new StorageItem(DefaultFeePerByte)); engine.Snapshot.Add(CreateStorageKey(Prefix_ExecFeeFactor), new StorageItem(DefaultExecFeeFactor)); engine.Snapshot.Add(CreateStorageKey(Prefix_StoragePrice), new StorageItem(DefaultStoragePrice)); - engine.Snapshot.Add(CreateStorageKey(Prefix_ConflictsFee), new StorageItem(DefaultConflictsFee)); return ContractTask.CompletedTask; } @@ -181,14 +170,6 @@ private void SetStoragePrice(ApplicationEngine engine, uint value) engine.Snapshot.GetAndChange(CreateStorageKey(Prefix_StoragePrice)).Set(value); } - [ContractMethod(CpuFee = 1 << 15, RequiredCallFlags = CallFlags.States)] - private void SetConflictsFee(ApplicationEngine engine, uint value) - { - if (value > MaxConflictsFee) throw new ArgumentOutOfRangeException(nameof(value)); - if (!CheckCommittee(engine)) throw new InvalidOperationException(); - engine.Snapshot.GetAndChange(CreateStorageKey(Prefix_ConflictsFee)).Set(value); - } - [ContractMethod(CpuFee = 1 << 15, RequiredCallFlags = CallFlags.States)] private bool BlockAccount(ApplicationEngine engine, UInt160 account) { diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_PolicyContract.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_PolicyContract.cs index 4f652cbeef..6793c27614 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_PolicyContract.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_PolicyContract.cs @@ -240,63 +240,6 @@ public void Check_SetStoragePrice() ret.GetInteger().Should().Be(300300); } - [TestMethod] - public void Check_SetConflictsFee() - { - var snapshot = _snapshot.CreateSnapshot(); - - // Fake blockchain - Block block = new() - { - Header = new Header - { - Index = 1000, - PrevHash = UInt256.Zero - } - }; - - // Without signature - Assert.ThrowsException(() => - { - NativeContract.Policy.Call(snapshot, new Nep17NativeContractExtensions.ManualWitness(), block, - "setConflictsFee", new ContractParameter(ContractParameterType.Integer) { Value = 100500 }); - }); - - var ret = NativeContract.Policy.Call(snapshot, "getConflictsFee"); - ret.Should().BeOfType(); - ret.GetInteger().Should().Be(0); - - // With signature, wrong value - UInt160 committeeMultiSigAddr = NativeContract.NEO.GetCommitteeAddress(snapshot); - Assert.ThrowsException(() => - { - NativeContract.Policy.Call(snapshot, new Nep17NativeContractExtensions.ManualWitness(committeeMultiSigAddr), block, - "setConflictsFee", new ContractParameter(ContractParameterType.Integer) { Value = 11_0000_0000 }); - }); - - ret = NativeContract.Policy.Call(snapshot, "getConflictsFee"); - ret.Should().BeOfType(); - ret.GetInteger().Should().Be(0); - - // Proper set - ret = NativeContract.Policy.Call(snapshot, new Nep17NativeContractExtensions.ManualWitness(committeeMultiSigAddr), block, - "setConflictsFee", new ContractParameter(ContractParameterType.Integer) { Value = 300300 }); - ret.IsNull.Should().BeTrue(); - - ret = NativeContract.Policy.Call(snapshot, "getConflictsFee"); - ret.Should().BeOfType(); - ret.GetInteger().Should().Be(300300); - - // Set to zero - ret = NativeContract.Policy.Call(snapshot, new Nep17NativeContractExtensions.ManualWitness(committeeMultiSigAddr), block, - "setConflictsFee", new ContractParameter(ContractParameterType.Integer) { Value = 0 }); - ret.IsNull.Should().BeTrue(); - - ret = NativeContract.Policy.Call(snapshot, "getConflictsFee"); - ret.Should().BeOfType(); - ret.GetInteger().Should().Be(0); - } - [TestMethod] public void Check_BlockAccount() {