Skip to content

Commit 3550837

Browse files
author
Vlad
committed
RSKIP 559: fix pegouts ordering
1 parent 5736b2c commit 3550837

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

IPs/RSKIP559.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
rskip: 559
3+
title: Deterministic next pegout selection fix
4+
description: Intorduce clear solution to select next pegout with enough confirmations
5+
status: Draft
6+
purpose: Sec
7+
author: VZ
8+
layer: Core
9+
complexity: 2
10+
created: 2026-04-16
11+
---
12+
13+
## Abstract
14+
15+
It was determined that we have almost non deterministic behaviour for output of the function `getNextPegoutWithEnoughConfirmations`.
16+
We are returning first valid match from collection which ordering is depends on JDK internal implementation.
17+
This is why we were having issues switching to Java 21.
18+
19+
Such behaviour is very hard to predict and it bins nodes to exact set of JDKs.
20+
Replicating such behaviour in any other programming language is extremely hard.
21+
22+
Elements ordering algorithm must be clear and easy to understand.
23+
24+
25+
## Specification & Rationale
26+
27+
Old ordering rule is barely describable becuase it depends on ordering in 2 HashSets where one is feeded into another.
28+
29+
New ordering just reuse existing `BTC_TX_COMPARATOR` that just use lexicographical bytes ordering of serialized transactions.
30+
This approach is easy, clean and understandable.
31+
32+
33+
## Backwards compatibility
34+
35+
Changes reqires a hardfork that will turn on valid elements ordering.
36+
After hardfork it will be possible to extract all conflicting outputs of `getNextPegoutWithEnoughConfirmations` and hardcode them in mainnet node configuration.
37+
After that old ordering code will be removed.
38+
39+
For other types of networks like future testnet v4 etc it will be required to activate this RSKIP from the block one. Testnet 3 will be morelikely dismissed till that time so no need to hardcode any outputs for it.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ You can find an easily browseable version of this information [here](https://ips
255255
| 551 |[Deprecate RSKIP459](IPs/RSKIP551.md)| 18-MAR-26 | MI | Usa | Core | 1 | Draft |
256256
| 552 |[Improve Blake2F Input Validation](IPs/RSKIP552.md)| 16-MAR-2026 | FML | Sec | Core | 1 | Draft |
257257
| 553 |[Network Upgrade: Vetiver](IPs/RSKIP553.md)| 23-MAR-2026 | AE | Usa, Sca, Sec | Core | 2 | Draft |
258+
| 559 |[Fix waiting pegouts ordering](IPs/RSKIP559.md)| 16-APR-2026 | VZ | Sec | Core | 2 | Draft |
258259

259260
# Author Index
260261

@@ -293,6 +294,7 @@ You can find an easily browseable version of this information [here](https://ips
293294
| SM | Shreemoy Mishra | shreemoy@rootstocklabs.com |
294295
| SMS | Sebastian Matias Sicardi | |
295296
| VK | Volodymyr Kravets | |
297+
| VZ | Vladislav Zablotsky | |
296298

297299

298300
## Build locally

0 commit comments

Comments
 (0)