Skip to content

Conversation

@randy-cro
Copy link

@randy-cro randy-cro commented Nov 6, 2025

Description

This PR fixes inconsistencies in the staking cache (originally implemented in PR #1725) across different nodes.
Previously, simulation or optimistic execution contexts did not properly handle discarded changes, which could lead to duplicate or incorrect cache data, eventually causing apphash mismatches and halting the chain.

The primary change refactors the cache to use an in-memory KV store.
With this approach, when a context is discarded, the cache is automatically rolled back, just like any other store in the system.

This ensures that cache state remains consistent with the underlying store, even during simulations or optimistic execution scenarios.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@randy-cro randy-cro changed the title Fix/staking optimization fix:staking endblocker optimization Nov 6, 2025
@randy-cro randy-cro changed the title fix:staking endblocker optimization fix: staking endblocker optimization Nov 6, 2025
@randy-cro randy-cro changed the title fix: staking endblocker optimization fix: staking cache to in-memory KV store Nov 6, 2025
@randy-cro randy-cro force-pushed the fix/staking-optimization branch from 9bc6b87 to 294f89e Compare November 7, 2025 08:40
Copy link

@JayT106 JayT106 left a comment

Choose a reason for hiding this comment

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

LGTM, but the log info and level should be refined and simplified, more of it should put it into debug level. Some logs are using error level which the code section doesn't handle the error case.

@songgaoye songgaoye self-requested a review November 10, 2025 02:49
@randy-cro randy-cro force-pushed the fix/staking-optimization branch from 294f89e to 266b797 Compare November 10, 2025 03:24
@randy-cro randy-cro force-pushed the fix/staking-optimization branch 3 times, most recently from 4cc9190 to 1d656b1 Compare November 10, 2025 04:29
@songgaoye

This comment was marked as resolved.

@github-actions github-actions bot removed the C:Store label Nov 10, 2025
@randy-cro
Copy link
Author

Member

image image

@songgaoye it is here, did u miss it?

@randy-cro randy-cro force-pushed the fix/staking-optimization branch 2 times, most recently from a93f620 to b2f35a8 Compare November 11, 2025 11:29
@randy-cro randy-cro force-pushed the fix/staking-optimization branch from 2f4f4e7 to 4071f13 Compare November 20, 2025 10:27
@randy-cro randy-cro force-pushed the fix/staking-optimization branch 2 times, most recently from 7f16a31 to a233eac Compare November 21, 2025 05:32
…e and returns error when another new entry is added after the cache is full + cache error should be dirty not full
@randy-cro randy-cro force-pushed the fix/staking-optimization branch from a233eac to 2cc54ab Compare November 21, 2025 05:43
@randy-cro randy-cro merged commit d5e74b9 into crypto-org-chain:release/v0.50-cronosv1.6.x Nov 21, 2025
45 of 48 checks passed
@randy-cro randy-cro deleted the fix/staking-optimization branch November 21, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants