Skip to content

Commit

Permalink
*: remove remnants of ConflictsFee in native Policy
Browse files Browse the repository at this point in the history
ConflictsFee logic was replaced by the generic attribute fee mechanism
implemented in neo-project#2916.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Oct 10, 2023
1 parent fff3129 commit 330cbea
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
19 changes: 0 additions & 19 deletions src/Neo/SmartContract/Native/PolicyContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public sealed class PolicyContract : NativeContract
/// </summary>
public const uint DefaultStoragePrice = 100000;

/// <summary>
/// The default fee for Conflicts attribute per signer.
/// </summary>
public const uint DefaultConflictsFee = 0;

/// <summary>
/// The default network fee per byte of transactions.
/// </summary>
Expand All @@ -62,11 +57,6 @@ public sealed class PolicyContract : NativeContract
/// </summary>
public const uint MaxStoragePrice = 10000000;

/// <summary>
/// The maximum fee for Conflicts attribute per signer that the committee can set.
/// </summary>
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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand Down
57 changes: 0 additions & 57 deletions tests/Neo.UnitTests/SmartContract/Native/UT_PolicyContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<InvalidOperationException>(() =>
{
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<VM.Types.Integer>();
ret.GetInteger().Should().Be(0);

// With signature, wrong value
UInt160 committeeMultiSigAddr = NativeContract.NEO.GetCommitteeAddress(snapshot);
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
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<VM.Types.Integer>();
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<VM.Types.Integer>();
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<VM.Types.Integer>();
ret.GetInteger().Should().Be(0);
}

[TestMethod]
public void Check_BlockAccount()
{
Expand Down

0 comments on commit 330cbea

Please sign in to comment.