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

Add ledgerstatefix transaction reference #102

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ To learn more about the consensus process and the workflow for features to go fr

- [XLS-56d Batch Transactions](xls-56d-batch-transactions/index.md)
- [Reference](xls-56d-batch-transactions/reference/reference.md)

### LedgerStateFix
- [LedgerStateFix](ledger-state-fix/index.md)
68 changes: 68 additions & 0 deletions docs/ledger-state-fix/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
seo:
description: Repair corruptions to the XRP ledger.
labels:
- Utilities, troubleshooting
---
# LedgerStateFix
[[Source]](https://github.com/XRPLF/rippled/blob/develop/src/xrpld/app/tx/detail/LedgerStateFix.cpp "Source")

{% partial file="/snippets/_ledgerstatefix-disclaimer.md" /%}

`LedgerStateFix` is a general purpose transaction used to fix specific issues affecting the XRP ledger. You submit the transaction with the `LedgerFixType` value set to indicate the particular error state to correct.

_(Added by the [NonFungibleTokensV1_1](https://xrpl.org/resources/known-amendments#nonfungibletokensv1_1) amendment.

## Example LedgerStateFix JSON

```json
{
"Account" : "<Signer and fee payer>",
"Fee" : "2000000",
"LedgerFixType" : 1,
"Owner" : "<Account with corrupted NFTokenPage directory",
"Sequence" : <n>,
"SigningPubKey" : "<Account's public key>",
"TransactionType" : "LedgerStateFix",
"TxnSignature" : "<Signature>",
}
```


| Field | Data Type | Required? | Description |
|:------|:-----------|:----------|:------------|
| `TransactionType` | uint16 | Required | Identifies this as a `LedgerStateFix` transaction. |
| `Account` | STAccount | Required | Identifies the account signing and submitting the transaction as well as paying the Fee. |
| `Fee` | STAmount | Required | This transaction is rare and potentially compute intensive. The minimum fee is the same as the fee for an AccountDelete transaction. If the transaction fails with a tec code, the fee is still charged. |
| `Flags` | uint32 | Optional | Not needed for `LedgerFixType` == _1_. Reserved for a future type of ledger fix. |
| `LedgerFixType` | uint16 | Required | Currently the only type is _1_, which fixes the NFToken directory for a single account. |
| `Owner` | STAccount | Optional | Required if `LedgerFixType` == _1_, the account ID that owns the NFToken directory that needs fixing. Need not have any relationship to Account. |

## LedgerStateFix Flags

Transactions of the LedgerStateFix type can support additional values in the `Flags` field. Currently, there are no flags defined. A future `LedgerFixType` might require flag settings.

## Error Cases

Potential errors are those that can occur for all transactions. {% $frontmatter.seo.title %}.

## LedgerStateFix Types

`LedgerStateFix` might sound like a general panacea for all your ledger's ills, but in practice it is a targeted solution for very rare, known, and specific issues.

### Type 1

There are two different transactions that introduced corruptions to NFT directories. In both cases, the following conditions were met:

- There were at least two NFToken pages in the directory.
- The next-to-last page was completely full, holding 32 NFTokens.
- The very last page of the directory contained only one NFToken.
- The transaction removed the last remaining token from the last page.

When these conditions were met, the last NFToken page was removed and the next-to-last page was left as the final page in the directory.

That would be fine, except the NFToken directory has an expectation that the last page has a specific index. The page with that index was just deleted. When an NFToken is added to the directory, and that token has a high enough value that it doesn't belong on the current last page, then a new last page is created that has no links to the previous page, creating a hole in the middle of the list.

The `fixNFTokenPageLinks` amendment modifies the NFToken page, coalescing code to notice when the very last page of the directory would be removed. In that case, it moves all of the contents of the next lower page into the last page and deletes the next-to-last page. It then fixes up the links.

New invariant checks also validate aspects of the links on pages, so a similar corruption returns a tecINVARIANT_FAILED transaction result. That will prevent this specific type of corruption going forward.
35 changes: 35 additions & 0 deletions index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,41 @@ export default function Page() {
</WideTile>
</Box>
</Box>
<Box p={{ _: "8px", sm: "12px", md: "16px", lg: "24px" }}>
<Box
display="flex"
justifyContent="center"
flexWrap="wrap"
maxWidth="1200px"
margin="0 auto"
>
<WideTile
style={{ height: "284px", margin: "16px" }}
to="docs/ledger-state-fix/"
header="LedgerStateFix"
color="#141A1F"
textAlign="left"
disableArrow
>
<TileText>
A general purpose transaction used to fix specific
issues affecting the XRP ledger.
</TileText>
<div style={{ bottom: "36px", position: "absolute"}}>
<Button style={{
padding: "8px 16px",
borderRadius: "20px",
fontSize: "14px",
lineHeight: "20px",
color: "#FFFFFF",
background: "#005BCC",
}}>
Go to Docs
</Button>
</div>
</WideTile>
</Box>
</Box>
</LandingLayout>
);
}
3 changes: 3 additions & 0 deletions sidebars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@
items:
- page: docs/xls-56d-batch-transactions/reference/batch.md
- page: docs/xls-56d-batch-transactions/reference/common-fields.md
- group: LedgerStateFix
page: docs/ledger-state-fix/index.md
expanded: false
4 changes: 4 additions & 0 deletions snippets/_ledgerstatefix-disclaimer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% admonition type="info" name="Attention" %}

_LedgerStateFix is part of the proposed [fixNFTokenPageLinks](https://github.com/XRPLF/rippled/pull/4945) extension to the XRP Ledger protocol. You can test the transaction on test networks for now, but there isn't an official amendment and the feature is not available on the production Mainnet yet. Until there is an amendment in a stable release, the details documented on these pages are subject to change frequently._ <!-- SPELLING_IGNORE: 33d -->
{% /admonition %}