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

fixTrustLinesToSelf: Introduce amendment to handle trustlines to self #4105

Closed
wants to merge 1 commit into from

Conversation

a-noni-mousse
Copy link
Contributor

@a-noni-mousse a-noni-mousse commented Feb 20, 2022

Trust lines to self are impossible but because of the old bug there are two such trust lines which exist:
2F8F21EFCAFD7ACFB07D5BB04F0D2E18587820C7611305BB674A64EAB0FA71E1 and 326035D5C0560A9DA8636545DD5A1B0DFCFF63E68D491B5522B767BB00564B1A. The fixTrustLinesToSelf fix amendment will remove them when it activates. I do not know how to test this change.

High Level Overview of Change

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Trust lines must be between two different accounts but two trust lines exist where an account extends trust to itself. They were created in the early days, likely because of bugs that have been fixed. The fixTrustLinesToSelf amendment will remove those trust lines when it activates.

@manojsdoshi
Copy link
Contributor

@cryptobrad can you please rebase your PR to 1.9 it is giving us merge conflicts while adding this to the next beta. Thanks 🙏

Trustlines must be between two different accounts but two trustlines exist
where an account extends trust to itself. They were created in the early
days, likely because of bugs that have been fixed. The new fixTrustLinesToSelf
amendment will remove those trustlines when it activates.
@a-noni-mousse
Copy link
Contributor Author

I have finished the rebase. Will this be merged?

This was referenced Aug 4, 2022
@intelliot intelliot added Tech Debt Non-urgent improvements Amendment Testable labels Feb 14, 2023
removeTrustLineToSelf(
sb,
uint256{
"326035D5C0560A9DA8636545DD5A1B0DFCFF63E68D491B5522B767BB00564B1A"sv}))
Copy link
Contributor

Choose a reason for hiding this comment

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

If the first call to removeTrustLineToSelf fails, the second call to removeTrustLineToSelf will not be executed. This is due to short-circuit evaluation.

I am not sure if this is intended but just want to point it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did on purpose so if deletion fails amendment activation fails and does a roll back, but deletion would not fail.

// two on 19-02-2022. This code was here to allow those trust lines to be
// deleted. The fixTrustLinesToSelf fix amendment will remove them when it
// enables so this code will no longer be needed.
if (!view().rules().enabled(fixTrustLinesToSelf) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I would drop !view().rules().enabled(fixTrustLinesToSelf) because I don't know if all trust lines to self have been deleted. I feel that this is less defensive as it could be.

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Can't drop that because there are currently two trustlines to self. Without the check, servers with and without this PR would behave differently.

Copy link
Contributor

@drlongle drlongle Feb 27, 2023

Choose a reason for hiding this comment

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

The code says that if fixTrustLinesToSelf is disabled and account_ == uDstAccountID, we can delete a trustline. Once fixTrustLinesToSelf is enabled, no other self-issued trustlines will be deleted because the first operand of the && operator will be false.

This is fine as long as we know that there are only two self-issued trustlines on the ledger.

@intelliot
Copy link
Collaborator

Because this PR was originally merged with only 1 approval (and we generally require 2 from core ledger engineers), I asked @drlongle to review. @a-noni-mousse @nbougalis could you respond to the thoughts above?

We see that there are two trust lines hard-coded to be deleted. Can someone share how they verified that these trust lines are actually to self? Also, can you share how you confirmed that there are no other trust lines to self?

@intelliot intelliot reopened this Feb 16, 2023
@intelliot intelliot added this to the 1.10.0 milestone Feb 16, 2023
@intelliot
Copy link
Collaborator

@a-noni-mousse @nbougalis if either of you would like to make the changes suggested by drlongle above, please open a new PR with your changes. Thank you!

@intelliot
Copy link
Collaborator

intelliot commented Feb 27, 2023

  • Take current ledger; iterate all trustline (RippleState) objects, and list any trustlines where the two sides of the trustline are equal to each other, i.e. if A and B are the same.

We know of these:

Test Plan:

  • Bring up a network that starts from current network state. (Copy database files from existing Mainnet server. No need for [full] history.) Use --ledger <ledger hash> (and maybe --load?)
  • Accelerate amendment activation (change timeout from 2 weeks to a short period of time, e.g. 1 hour). [feature] won't do the right thing as it won't activate the amendment in the normal way. Maybe amendment_majority?
  • Verify that the amendment worked correctly.

@a-noni-mousse
Copy link
Contributor Author

  • Take current ledger; iterate all trustline (RippleState) objects, and list any trustlines where the two sides of the trustline are equal to each other, i.e. if A and B are the same.

We know of these:

* [2F8F21EFCAFD7ACFB07D5BB04F0D2E18587820C7611305BB674A64EAB0FA71E1](https://xrpl.org/websocket-api-tool.html?server=wss%3A%2F%2Fs1.ripple.com%2F&req=%7B%22command%22%3A%22ledger_entry%22%2C%22index%22%3A%222F8F21EFCAFD7ACFB07D5BB04F0D2E18587820C7611305BB674A64EAB0FA71E1%22%2C%22ledger_index%22%3A%22validated%22%7D)

* [326035D5C0560A9DA8636545DD5A1B0DFCFF63E68D491B5522B767BB00564B1A](https://xrpl.org/websocket-api-tool.html?server=wss%3A%2F%2Fs1.ripple.com%2F&req=%7B%22command%22%3A%22ledger_entry%22%2C%22index%22%3A%22326035D5C0560A9DA8636545DD5A1B0DFCFF63E68D491B5522B767BB00564B1A%22%2C%22ledger_index%22%3A%22validated%22%7D)

Test Plan:

* Bring up a network that starts from current network state. (Copy database files from existing Mainnet server. No need for [full] history.) Use `--ledger <ledger hash>` (and maybe `--load`?)

* Accelerate amendment activation (change timeout from 2 weeks to a short period of time, e.g. 1 hour). `[feature]` won't do the right thing as it won't activate the amendment in the normal way. Maybe `amendment_majority`?

* Verify that the amendment worked correctly.

I wrote code to parse the SHA Map with objects and find all the trustline where high and low accounts are same and only two you show exist in the recent ledger and no more can be created, but did not put it into this pr because it's not appropriate.

let me know what u need

@intelliot
Copy link
Collaborator

I wrote code to parse the SHA Map with objects and find all the trustline where high and low accounts are same and only two you show exist in the recent ledger and no more can be created, but did not put it into this pr because it's not appropriate.

For transparency and reproducibility, we would appreciate if you could share that code. If it's not much code, you can paste it here. If it's larger, you can put it in a public GitHub gist or repository.

@intelliot
Copy link
Collaborator

@sgramkumar At your convenience, please write up the results of your testing here.

@sgramkumar
Copy link
Collaborator

@sgramkumar At your convenience, please write up the results of your testing here.

This was tested with mainnet db dump, and accelerated amendment activation (fixTrustLinesToSelf) on 1.10.0-rc3
After the amendment was activated, the following 2 trustlines were removed

   "result" : {
      "error" : "entryNotFound",
      "ledger_hash" : "A7C9310D455DF826C01B41659C646D17CA796556D7E4BF392AF6A7A7F4872AAD",
      "ledger_index" : 78112941,
      "request" : {
         "api_version" : 1,
         "command" : "ledger_entry",
         "index" : "2F8F21EFCAFD7ACFB07D5BB04F0D2E18587820C7611305BB674A64EAB0FA71E1",
         "ledger_index" : "validated",
         "method" : "ledger_entry"
      },
      "status" : "error",
      "validated" : true
   }

(and for the other hash too)

@intelliot intelliot closed this Mar 15, 2023
@intelliot intelliot changed the title Trustlines to self are impossible but because of the old bug there ar… fixTrustLinesToSelf: Introduce amendment to handle trustlines to self May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Amendment Tech Debt Non-urgent improvements Testable
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants