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

SmartContract: restrict the number of allowed notifications #3548

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bcc5fd0
add hardofork HF_Echidna
Jim8y Aug 7, 2024
e63f10b
Add entries to `Designation` event (#3397)
shargon Aug 8, 2024
9d16c53
[Neo Core StdLib] Add Base64url (#3453)
Jim8y Aug 8, 2024
f746f8d
add hardofork HF_Echidna
Jim8y Aug 7, 2024
8d7f9e8
Add entries to `Designation` event (#3397)
shargon Aug 8, 2024
3fc8077
[Neo Core StdLib] Add Base64url (#3453)
Jim8y Aug 8, 2024
620d938
Merge branch 'HF_Echidna' of github.com:neo-project/neo into HF_Echidna
Jim8y Oct 2, 2024
b31d95e
SmartContract: restrict the number of allowed notifications
AnnaShaleva Oct 23, 2024
0c72e57
SmartContract: fix format
AnnaShaleva Oct 23, 2024
ee21427
Update src/Neo/SmartContract/ApplicationEngine.Runtime.cs
shargon Oct 23, 2024
4a6f36a
Avoid notification creation
shargon Oct 23, 2024
7e31d0c
add hardofork HF_Echidna
Jim8y Aug 7, 2024
993e3fe
Add entries to `Designation` event (#3397)
shargon Aug 8, 2024
37bf0cb
[Neo Core StdLib] Add Base64url (#3453)
Jim8y Aug 8, 2024
7dba130
format
Jim8y Nov 6, 2024
0457ccd
Merge branch 'HF_Echidna' of github.com:neo-project/neo into HF_Echidna
Jim8y Nov 6, 2024
d7a291e
Merge Master
cschuchardt88 Nov 17, 2024
6e780c0
Fixed typo
cschuchardt88 Nov 17, 2024
6fff362
Merge branch 'HF_Echidna' into restrict-notifications-count
cschuchardt88 Nov 17, 2024
02d6ab9
Added back #3397
cschuchardt88 Nov 17, 2024
4814339
Merge branch 'HF_Echidna' into restrict-notifications-count
cschuchardt88 Nov 17, 2024
9a657a5
fix format
cschuchardt88 Nov 17, 2024
e5e3b08
Merge branch 'master' into restrict-notifications-count
shargon Jan 24, 2025
f43f296
Update src/Neo/SmartContract/Native/RoleManagement.cs
shargon Jan 24, 2025
c309f63
Neo.CLI: revert configuration changes
AnnaShaleva Mar 3, 2025
f5a0482
Merge branch 'master' into restrict-notifications-count
shargon Mar 3, 2025
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
14 changes: 13 additions & 1 deletion src/Neo/SmartContract/ApplicationEngine.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ partial class ApplicationEngine
/// </summary>
public const int MaxNotificationSize = 1024;

/// <summary>
/// The maximum number of notifications per application execution.
/// </summary>
public const int MaxNotificationCount = 512;

private uint random_times = 0;

/// <summary>
Expand Down Expand Up @@ -393,9 +398,16 @@ protected internal void RuntimeNotifyV1(byte[] eventName, Array state)
/// <param name="state">The arguments of the event.</param>
protected internal void SendNotification(UInt160 hash, string eventName, Array state)
{
notifications ??= new List<NotifyEventArgs>();
// Restrict the number of notifications for Application executions. Do not check
// persisting triggers to avoid native persist failure. Do not check verification
// trigger since verification context is loaded with ReadOnly flag.
if (IsHardforkEnabled(Hardfork.HF_Echidna) && Trigger == TriggerType.Application && notifications.Count >= MaxNotificationCount)
{
throw new InvalidOperationException($"Maximum number of notifications `{MaxNotificationCount}` is reached.");
}
NotifyEventArgs notification = new(ScriptContainer, hash, eventName, (Array)state.DeepCopy(asImmutable: true));
Notify?.Invoke(this, notification);
notifications ??= new List<NotifyEventArgs>();
notifications.Add(notification);
CurrentContext.GetState<ExecutionContextState>().NotificationCount++;
}
Expand Down