Skip to content
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

Move MaxTraceableBlocks to protocol #2042

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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