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

Network ID logic should not be applied to pseudo-transactions #4737

Merged
merged 6 commits into from
Oct 19, 2023

Conversation

dangell7
Copy link
Collaborator

@dangell7 dangell7 commented Oct 2, 2023

This PR fixes the issue with enabling new amendments on a network with an ID > 1024.

See an example here: #4736

@intelliot
Copy link
Collaborator

Just curious - is there a reason this solution is better than adding the NetworkID field to pseudo-transactions?

@mvadari
Copy link
Collaborator

mvadari commented Oct 2, 2023

Just curious - is there a reason this solution is better than adding the NetworkID field to pseudo-transactions?

I don't fully understand how pseudo-transactions work, but is there a chance that a signed pseudo-transaction could be submitted on another network to cause unwanted changes?

@ximinez
Copy link
Collaborator

ximinez commented Oct 2, 2023

Pseudo-transactions don't get signed, nor are they submitted. I think it's possible to request one, but I'm not 100% sure of that. Point is, that's not a risk.

That said, adding the NetworkID to pseudo-transactions should be an equally viable solution. Perhaps better, because someone seeing one of these pseudo-txs would know exactly where it came from.

P.S. Either way, unit tests should be added to ensure that pseudo-transactions are generated and processed correctly with a network ID > 1024.

@RichardAH
Copy link
Collaborator

That said, adding the NetworkID to pseudo-transactions should be an equally viable solution. Perhaps better, because someone seeing one of these pseudo-txs would know exactly where it came from.

P.S. Either way, unit tests should be added to ensure that pseudo-transactions are generated and processed correctly with a network ID > 1024.

It's not obvious to me why pseudos would ever need a network ID? If you want to differentiate networks just add NetworkID to the fees (or another singleton) object?

@intelliot
Copy link
Collaborator

It would never be needed. When looking some pseudo-transaction JSON, you would be able to see which network it came from, however.

@intelliot intelliot added this to the 2.0 milestone Oct 6, 2023
std::optional<uint32_t> const txNID = ctx.tx[~sfNetworkID];

if (nodeNID <= 1024)
if (isPseudoTx(ctx.tx))
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's better not to have the empty block and check if (!isPseudoTx(ctx.tx))

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not having much luck with testing this fix. I run a local network of 5 nodes. I added this to config:

 [network_id]
 1026
 [amendment_majority_time]
 16 minutes

I ran this to every node:

         {
             "method": "feature",
             "params": [
               {
                 "feature": "AMM",
                 "vetoed": false
               }
             ]
           }

This is the response:

  {'count': 1,
    'enabled': False,
    'name': 'AMM',
    'supported': True,
    'threshold': 3,
    'validations': 5,
    'vetoed': False}

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gregtatcam did you wait for at least 2 * amendment_majority_time? I think you may also need at least 2 flag ledgers (1 for "got majority" and 1 for "enabled") which usually takes at least 30 minutes. (To be safe, maybe check after 1 hour.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll re-test with the suggested wait time to double check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I waited 45 minutes - the same result.

@intelliot
Copy link
Collaborator

Notes

  • Concern: consistency, and having all transactions follow the same rules
  • May be preferable to avoid making exceptions which may be forgotten in the future
  • Should try to minimize exceptions that apply only to pseudo-transactions

@intelliot intelliot assigned seelabs and ximinez and unassigned legleux Oct 12, 2023
@intelliot
Copy link
Collaborator

Just to close the loop on my earlier question: I'm personally fine with this solution, given these are pseudo-transactions, which are already different from normal transactions anyway. It makes sense to review (and potentially merge) this change as-is.

if (txNID)
return telNETWORK_ID_MAKES_TX_NON_CANONICAL;
// all emitted and pseudo transactions are free to pass, do not need
// network id
Copy link
Collaborator

@seelabs seelabs Oct 13, 2023

Choose a reason for hiding this comment

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

What should we do if a pseudo transaction has a network id? Right now it's ignored, which is probably fine. But some other options would be:

  1. If present, it needs to follow the same rules as other transactions (i.e. match the configured network id), fail if the network is less than 1024.
  2. Fail if present in any form.
  3. Assert if present in any form, but allow to continue processing in release mode.

I'd probably prefer (3). If someone does add a network id to a pseudo transaction, and they did it intentionally, the assert will let them know this code needs to change. But your call if you want to add it or not. I'm fine either way.

As a side note, I also prefer not to have the empty if block, but that's just a preference. I'm also fine if you want to keep it as-is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd vote for option 1. It has the advantage of being simple to add that check. Simply change the check to

if (isPseudoTx(ctx.tx) && !ctx.tx.isFieldPresent(sfNetworkID))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like option 1 because its simple.

Copy link
Collaborator

@seelabs seelabs Oct 17, 2023

Choose a reason for hiding this comment

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

@dangell7 I don't think that patch is going to work. If the network ID is required, but isn't present the new patch lets the transaction succeed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think @ximinez is right. The block should look something like:

    if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID))
    {
        uint32_t nodeNID = ctx.app.config().NETWORK_ID;
        std::optional<uint32_t> txNID = ctx.tx[~sfNetworkID];

        if (nodeNID <= 1024)
        {
            // legacy networks have ids less than 1024, these networks cannot
            // specify NetworkID in txn
            if (txNID)
                return telNETWORK_ID_MAKES_TX_NON_CANONICAL;
        }
        else
        {
            // new networks both require the field to be present and require it
            // to match
            if (!txNID)
                return telREQUIRES_NETWORK_ID;

            if (*txNID != nodeNID)
                return telWRONG_NETWORK;
        }
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed in d8b2ba4

@intelliot intelliot changed the title Network ID logic should not be applied to pseudos Network ID logic should not be applied to pseudo-transactions Oct 16, 2023
@intelliot
Copy link
Collaborator

notes:

  • could not verify in testing. an issue with environment? Michael may be trying to test. @manojsdoshi will connect with @gregtatcam to see why prior test attempts did not work.
  • once merged, Manoj and Ram will test with a real test network.
  • need to include this for sidechains.

Copy link
Collaborator

@seelabs seelabs left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@gregtatcam gregtatcam left a comment

Choose a reason for hiding this comment

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

👍

@intelliot
Copy link
Collaborator

note: needs to be brought up-to-date with develop

@sgramkumar
Copy link
Collaborator

Verified on networks with network_id 12 & 1212. Amendment is enabled in both cases.

@intelliot intelliot merged commit 8d86c5e into XRPLF:develop Oct 19, 2023
16 checks passed
@intelliot intelliot mentioned this pull request Oct 23, 2023
1 task
sophiax851 pushed a commit to sophiax851/rippled that referenced this pull request Jun 12, 2024
The Network ID logic should not be applied to pseudo-transactions.

This allows amendments to enable on a network with an ID > 1024.

Context:
- NetworkID: XRPLF#4370
- Pseudo-transactions: https://xrpl.org/pseudo-transaction-types.html

Fix XRPLF#4736

---------

Co-authored-by: RichardAH <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

10 participants