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 topic #78

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 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
67 changes: 67 additions & 0 deletions docs/LedgerStateFix/ledgerstatefix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
seo:
description: Repair corruptions to the XRP ledger.
labels:
- Utilities, troubleshooting
---
# LedgerStateFix
[[Source]]()

`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 [fixNFTokenPageLinks 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>",
}
```

{% raw-partial file="/docs/_snippets/tx-fields-intro.md" /%}

| 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](../common-fields.md#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.
31 changes: 31 additions & 0 deletions index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,34 @@ export default LandingContainer;
</WideTile>
</FlexSection>
</Box>

<Box p={{ _: "8px", sm: "12px", md: "16px", lg: "24px" }}>
<FlexSection justifyContent="space-around" flexWrap="wrap">
<WideTile
style={{ height: "284px"}}
to="docs/LedgerStateFix/ledgerstatefix.md"
header="LedgerStateFix"
color="#141A1F"
textAlign="left"
disableArrow
>
<TileText>
`LedgerStateFix` is a general purpose transaction used to fix specific
issues affecting the XRP ledger. You submit the transaction with the
`LedgerFixType` set to indicate the particular error state to correct.
</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>
</FlexSection>
</Box>
67 changes: 67 additions & 0 deletions ledgerstatefix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
seo:
description: Repair corruptions to the XRP ledger.
labels:
- Utilities, troubleshooting
---
# LedgerStateFix
[[Source]]()

`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 [fixNFTokenPageLinks amendment][].)_

## Example {% $frontmatter.seo.title %} 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>",
}
```

{% raw-partial file="/docs/_snippets/tx-fields-intro.md" /%}

| 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](../common-fields.md#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.
8 changes: 7 additions & 1 deletion sidebars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,10 @@ opensource:
expanded: false
pages:
- page: docs/xls-47d-price-oracles/transaction-types/deleteoracle.md
- page: docs/xls-47d-price-oracles/transaction-types/setoracle.md
- page: docs/xls-47d-price-oracles/transaction-types/setoracle.md
- group: LedgerStateFix
page: docs/LedgerStateFix/ledgerstatefix.md
expanded: false
pages:
- page: docs/LedgerStateFix/ledgerstatefix.md