Skip to content

RSKIP559: Fix pegouts ordering#559

Open
wlaclaw wants to merge 1 commit into
masterfrom
fix-pegouts
Open

RSKIP559: Fix pegouts ordering#559
wlaclaw wants to merge 1 commit into
masterfrom
fix-pegouts

Conversation

@wlaclaw

@wlaclaw wlaclaw commented Apr 16, 2026

Copy link
Copy Markdown

Related PR to RSKJ is here: rsksmart/rskj#3507

@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@wlaclaw wlaclaw changed the title New RSKIP RSKIP559: Fix pegouts ordering Apr 16, 2026
@wlaclaw wlaclaw marked this pull request as ready for review May 1, 2026 17:44
@marcos-iov marcos-iov requested a review from Copilot June 4, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new RSKIP document (RSKIP-559) describing a deterministic pegout-selection ordering fix, and registers it in the repository index and author list.

Changes:

  • Added IPs/RSKIP559.md (Draft) describing the proposed deterministic ordering rule for getNextPegoutWithEnoughConfirmations.
  • Updated README.md to list RSKIP-559 and add author initials VZ to the Author Index.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
README.md Registers RSKIP-559 in the main RSKIP list and adds the new author initials entry.
IPs/RSKIP559.md Introduces the Draft RSKIP text and metadata for the pegouts ordering determinism change.
Comments suppressed due to low confidence (1)

IPs/RSKIP559.md:52

  • The document currently ends without the standard ## References and ### Copyright sections present in the RSKIP template (IPs/RSKIP0_TEMPLATE.md) and recent RSKIPs (e.g. IPs/RSKIP551.md). This is needed for completeness and licensing clarity.
Considering that testnet 3 is near EOL it is unreasonable to introduce additional complexity
with state mutation for historical pegouts while it is not required for the mainnet.
I suggest to do not harcode conflicting pegouts and leave old sorting code until testnet 3 will be dismissed.



💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread IPs/RSKIP559.md Outdated
Comment thread IPs/RSKIP559.md Outdated
Comment thread IPs/RSKIP559.md
Comment thread IPs/RSKIP559.md Outdated
Comment thread IPs/RSKIP559.md Outdated
Comment thread IPs/RSKIP559.md Outdated
Copilot AI review requested due to automatic review settings June 8, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread README.md
Comment thread IPs/RSKIP559.md
Comment thread IPs/RSKIP559.md Outdated
Copilot AI review requested due to automatic review settings June 18, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread README.md
| 551 |[Deprecate RSKIP459](IPs/RSKIP551.md)| 18-MAR-26 | MI | Usa | Core | 1 | Adopted |
| 552 |[Improve Blake2F Input Validation](IPs/RSKIP552.md)| 16-MAR-2026 | FML | Sec | Core | 1 | Adopted |
| 553 |[Network Upgrade: Vetiver](IPs/RSKIP553.md)| 23-MAR-2026 | AE | Usa, Sca, Sec | Core | 2 | Adopted |
| 559 |[Fix waiting pegouts ordering](IPs/RSKIP559.md)| 16-APR-2026 | VZ | Sec | Core | 2 | Draft |
Comment thread IPs/RSKIP559.md
Comment on lines +2 to +10
rskip: 559
title: Deterministic next pegout selection fix
description: Introduce a clear solution for selecting the next pegout with enough confirmations
status: Draft
purpose: Sec
author: VZ
layer: Core
complexity: 2
created: 16-APR-26
Comment thread IPs/RSKIP559.md
Comment on lines +58 to +66
## Testnet v3 additional logic

`PegoutsWaitingForConfirmation` storage is mutable,
it updates after processing of the output taken from `getNextPegoutWithEnoughConfirmations` is finished.
On the testnet there are several blocks where the next pegout is requested multiple times per block.

Considering this additional logic is required to search for the hardcoded pegout.
Also, for historical blocks, a sequence of pegouts should be saved for such cases.

Comment thread IPs/RSKIP559.md
Comment on lines +53 to +54
No logic branching is required - hardcoded pegouts exist only before the hard fork,
this covers all cases where the new selection logic differs from the historical one.
Comment thread IPs/RSKIP559.md
Comment on lines +17 to +24
It was determined that the output of `getNextPegoutWithEnoughConfirmations` is almost non-deterministic.
We return the first valid match from a collection whose iteration order depends on the JDK's internal implementation.
This is why we had issues when switching to Java 21.

Such behavior is very hard to predict and it effectively binds nodes to a specific set of JDK versions.
Replicating this behavior in any other programming language is extremely hard.

Elements ordering algorithm must be clear and easy to understand.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants