Skip to content

Ignore duplicate future state roots - #1045

Merged
Jim8y merged 4 commits into
master-n3from
fix/state-service-root-cache
May 12, 2026
Merged

Jim8y merged 4 commits into
master-n3from
fix/state-service-root-cache

Conversation

@Jim8y

@Jim8y Jim8y commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • ignore duplicate future state roots instead of throwing from the pending cache
  • add a StateService regression test for repeated future state root handling

Tests

  • dotnet test tests/Neo.Plugins.StateService.Tests/Neo.Plugins.StateService.Tests.csproj -c Release --no-restore --logger "console;verbosity=normal"
  • dotnet format --no-restore --verify-no-changes --include plugins/StateService/Storage/StateStore.cs tests/Neo.Plugins.StateService.Tests/UT_StatePlugin.cs
  • git diff --check

@github-actions github-actions Bot added the N3 label May 8, 2026
@Jim8y
Jim8y marked this pull request as ready for review May 8, 2026 15:49
@codecov

codecov Bot commented May 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.66%. Comparing base (95e6880) to head (1a037eb).
⚠️ Report is 1 commits behind head on master-n3.

Additional details and impacted files
@@              Coverage Diff              @@
##           master-n3    #1045      +/-   ##
=============================================
+ Coverage      48.39%   48.66%   +0.26%     
=============================================
  Files            274      274              
  Lines          15796    15799       +3     
  Branches        2015     2016       +1     
=============================================
+ Hits            7645     7688      +43     
+ Misses          7677     7633      -44     
- Partials         474      478       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Wi1l-B0t

Wi1l-B0t commented May 9, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this modification?

@Jim8y

Jim8y commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

The purpose is to make future state root handling idempotent. A future root can be received more than once while it is still waiting in the pending cache, for example through repeated network delivery or a retry path before the local root index catches up.

Using Dictionary.Add makes that duplicate delivery throw and can interrupt StateService even though the root is already known. TryAdd keeps the first cached value and returns false for the duplicate, so the caller can ignore it without changing persisted state. The added test covers this repeated future-root case.

@shargon shargon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return of this method is always discarded, isn't it? It should be better if the ut use Akka instead of reflection, but as I see the bool result is not checked, maybe should log it when false?

@Jim8y
Jim8y merged commit 68fa085 into master-n3 May 12, 2026
7 checks passed
@Jim8y
Jim8y deleted the fix/state-service-root-cache branch May 12, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants