Skip to content

fixXahauGenesisOwnerCount#666

Merged
RichardAH merged 4 commits intodevfrom
fixXahauGenesisOwnerCount
Feb 18, 2026
Merged

fixXahauGenesisOwnerCount#666
RichardAH merged 4 commits intodevfrom
fixXahauGenesisOwnerCount

Conversation

@tequdev
Copy link
Member

@tequdev tequdev commented Jan 13, 2026

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 update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

@tequdev tequdev force-pushed the fixXahauGenesisOwnerCount branch from 86f22a7 to ac93b24 Compare January 13, 2026 06:42
reserve += hookObj.getFieldArray(sfHookParameters).size();

if (hookObj.isFieldPresent(sfHookGrants))
reserve += hookObj.getFieldArray(sfHookGrants).size();
Copy link
Contributor

Choose a reason for hiding this comment

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

would be nice to have a way to ensure hookSetObj is never accidentally passed into here, even just via a comment at the top

@RichardAH RichardAH merged commit c3e8039 into dev Feb 18, 2026
21 of 22 checks passed
Comment on lines 139 to 2333
@@ -247,7 +249,10 @@ struct XahauGenesis_test : public beast::unit_test::suite
BEAST_EXPECT(
genesisAccRoot->getFieldAmount(sfBalance) ==
XahauGenesis::GenesisAmount);
BEAST_EXPECT(genesisAccRoot->getFieldU32(sfOwnerCount) == 2);
BEAST_EXPECT(
genesisAccRoot->getFieldU32(sfOwnerCount) == !testFlag
? expectedOwnerCount
: 14);

// ensure the definitions are correctly set
{
@@ -583,7 +588,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
toBase58(t), membersStr);
}

activate(__LINE__, env, true, false, true);
activate(
__LINE__,
env,
true,
false,
true,
{},
3 /* IRR,IRD,IMC */ + members.size() + tables.size());

env.close();
env.close();
@@ -2235,13 +2247,18 @@ struct XahauGenesis_test : public beast::unit_test::suite
BEAST_EXPECT(!!hookLE);
uint256 const ns = beast::zero;
uint8_t mc = 0;
uint8_t paramsCount = 0;

if (hookLE)
{
auto const hooksArray = hookLE->getFieldArray(sfHooks);
BEAST_EXPECT(
hooksArray.size() == 1 &&
hooksArray[0].getFieldH256(sfHookHash) == governHookHash);

paramsCount =
hooksArray[0].getFieldArray(sfHookParameters).size();

for (Account const* m : members)
{
auto const mVec = vecFromAcc(*m);
@@ -2308,7 +2325,9 @@ struct XahauGenesis_test : public beast::unit_test::suite
BEAST_EXPECT(!!root);
if (root)
{
BEAST_EXPECT(root->getFieldU32(sfOwnerCount) == mc * 2 + 2);
BEAST_EXPECT(
root->getFieldU32(sfOwnerCount) ==
mc * 2 + 2 + paramsCount);
BEAST_EXPECT(root->getFieldU32(sfFlags) & lsfDisableMaster);
BEAST_EXPECT(root->getAccountID(sfRegularKey) == noAccount());
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assertion currently has a precedence bug and is not checking what it appears to check. As written, ownerCount == !testFlag ? expectedOwnerCount : 14 is parsed as (ownerCount == !testFlag) ? expectedOwnerCount : 14, so BEAST_EXPECT(...) receives either expectedOwnerCount or 14 (both non-zero), which can pass even when ownerCount is wrong. The intended check is that owner count
equals expectedOwnerCount when testFlag == false, otherwise equals 14. We need to parenthesize the ternary on the right-hand side: ownerCount == (!testFlag ? expectedOwnerCount : 14).

XahauGenesis::GenesisAmount);
BEAST_EXPECT(genesisAccRoot->getFieldU32(sfOwnerCount) == 2);
BEAST_EXPECT(
genesisAccRoot->getFieldU32(sfOwnerCount) == !testFlag
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assertion currently has a precedence bug and is not checking what it appears to check. As written, \ownerCount == !testFlag ? expectedOwnerCount : 14is parsed as(ownerCount == !testFlag) ?
expectedOwnerCount : 14, so BEAST_EXPECT(...)receives eitherexpectedOwnerCountor14(both non-zero), which can pass even whenownerCountis wrong. The intended check is that owner count equalsexpectedOwnerCountwhentestFlag == false, otherwise equals 14. Please parenthesize the ternary on the right-hand side: ownerCount == (!testFlag ? expectedOwnerCount : 14).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants