Skip to content

Commit

Permalink
Move MaxValidUntilBlockIncrement & MaxTraceableBlocks to protocol (ne…
Browse files Browse the repository at this point in the history
…o-project#2042)

* Move MaxValidUntilBlockIncrement & MaxTraceableBlocks to protocol

* Add comments

* Revert MaxValidUntilBlockIncrement

Co-authored-by: Jin Qiao <jinqiao@neo.org>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com>
  • Loading branch information
4 people authored and cloud8little committed Jan 24, 2021
1 parent 866e885 commit 634980f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/neo/Network/P2P/Payloads/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Neo.Network.P2P.Payloads
public class Transaction : IEquatable<Transaction>, IInventory, IInteroperable
{
public const int MaxTransactionSize = 102400;
public const uint MaxValidUntilBlockIncrement = 2102400;
public const uint MaxValidUntilBlockIncrement = 5760; // 24 hour
/// <summary>
/// Maximum number of attributes that can be contained within a transaction
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/neo/ProtocolSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ProtocolSettings
public string[] SeedList { get; }
public uint MillisecondsPerBlock { get; }
public int MemoryPoolMaxTransactions { get; }
public uint MaxTraceableBlocks { get; }

static ProtocolSettings _default;

Expand Down Expand Up @@ -94,6 +95,7 @@ private ProtocolSettings(IConfigurationSection section)
};
this.MillisecondsPerBlock = section.GetValue("MillisecondsPerBlock", 15000u);
this.MemoryPoolMaxTransactions = Math.Max(1, section.GetValue("MemoryPoolMaxTransactions", 50_000));
this.MaxTraceableBlocks = section.GetValue("MaxTraceableBlocks", 2_102_400u);// 365 days
}
}
}
4 changes: 1 addition & 3 deletions src/neo/SmartContract/ApplicationEngine.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace Neo.SmartContract
{
partial class ApplicationEngine
{
public const uint MaxTraceableBlocks = Transaction.MaxValidUntilBlockIncrement;

public static readonly InteropDescriptor System_Blockchain_GetHeight = Register("System.Blockchain.GetHeight", nameof(GetBlockchainHeight), 0_00000400, CallFlags.AllowStates, true);
public static readonly InteropDescriptor System_Blockchain_GetBlock = Register("System.Blockchain.GetBlock", nameof(GetBlock), 0_02500000, CallFlags.AllowStates, true);
public static readonly InteropDescriptor System_Blockchain_GetTransaction = Register("System.Blockchain.GetTransaction", nameof(GetTransaction), 0_01000000, CallFlags.AllowStates, true);
Expand Down Expand Up @@ -97,7 +95,7 @@ protected internal ContractState GetContract(UInt160 hash)
private static bool IsTraceableBlock(StoreView snapshot, uint index)
{
if (index > snapshot.Height) return false;
return index + MaxTraceableBlocks > snapshot.Height;
return index + ProtocolSettings.Default.MaxTraceableBlocks > snapshot.Height;
}
}
}
2 changes: 1 addition & 1 deletion tests/neo.UnitTests/SmartContract/UT_Syscalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void System_Blockchain_GetBlock()
// Not traceable block

var height = snapshot.BlockHashIndex.GetAndChange();
height.Index = block.Index + Transaction.MaxValidUntilBlockIncrement;
height.Index = block.Index + ProtocolSettings.Default.MaxTraceableBlocks;

var blocks = snapshot.Blocks;
var txs = snapshot.Transactions;
Expand Down

0 comments on commit 634980f

Please sign in to comment.