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
Merged
Changes from 1 commit
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
35 changes: 21 additions & 14 deletions src/ripple/app/tx/impl/Transactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,32 @@ namespace ripple {
NotTEC
preflight0(PreflightContext const& ctx)
{
uint32_t const nodeNID = ctx.app.config().NETWORK_ID;
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.

{
// legacy networks have IDs 1024 and below. These networks cannot
// specify NetworkID in txn
if (txNID)
return telNETWORK_ID_MAKES_TX_NON_CANONICAL;
// all emitted and pseudo transactions are free to pass, do not need network id
}
else
{
// new networks both require the field to be present and require it to
// match
if (!txNID)
return telREQUIRES_NETWORK_ID;
uint32_t nodeNID = ctx.app.config().NETWORK_ID;
std::optional<uint32_t> txNID = ctx.tx[~sfNetworkID];

if (*txNID != nodeNID)
return telWRONG_NETWORK;
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;
}
}

auto const txID = ctx.tx.getTransactionID();
Expand Down
Loading