mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 18:45:55 +00:00
Compare commits
9 Commits
nd-experim
...
flap_fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48ed253ddb | ||
|
|
49138aa0ab | ||
|
|
2dfe1fbe89 | ||
|
|
945ad4869c | ||
|
|
d5ff8b7010 | ||
|
|
596b080a6b | ||
|
|
c101aa0920 | ||
|
|
83e231941a | ||
|
|
8c955da7cf |
@@ -94,21 +94,6 @@ Change::preflight(PreflightContext const& ctx)
|
|||||||
"of sfImportVLKey, sfActiveValidator";
|
"of sfImportVLKey, sfActiveValidator";
|
||||||
return temMALFORMED;
|
return temMALFORMED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we do specify import_vl_keys in config then we won't approve keys
|
|
||||||
// that aren't on our list
|
|
||||||
if (ctx.tx.isFieldPresent(sfImportVLKey) &&
|
|
||||||
!ctx.app.config().IMPORT_VL_KEYS.empty())
|
|
||||||
{
|
|
||||||
auto const& inner = const_cast<ripple::STTx&>(ctx.tx)
|
|
||||||
.getField(sfImportVLKey)
|
|
||||||
.downcast<STObject>();
|
|
||||||
auto const pk = inner.getFieldVL(sfPublicKey);
|
|
||||||
std::string const strPk = strHex(makeSlice(pk));
|
|
||||||
if (ctx.app.config().IMPORT_VL_KEYS.find(strPk) ==
|
|
||||||
ctx.app.config().IMPORT_VL_KEYS.end())
|
|
||||||
return telIMPORT_VL_KEY_NOT_RECOGNISED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
@@ -168,9 +153,42 @@ Change::preclaim(PreclaimContext const& ctx)
|
|||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
case ttAMENDMENT:
|
case ttAMENDMENT:
|
||||||
case ttUNL_MODIFY:
|
case ttUNL_MODIFY:
|
||||||
case ttUNL_REPORT:
|
|
||||||
case ttEMIT_FAILURE:
|
case ttEMIT_FAILURE:
|
||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
|
case ttUNL_REPORT: {
|
||||||
|
if (!ctx.tx.isFieldPresent(sfImportVLKey) ||
|
||||||
|
ctx.app.config().IMPORT_VL_KEYS.empty())
|
||||||
|
return tesSUCCESS;
|
||||||
|
|
||||||
|
// if we do specify import_vl_keys in config then we won't approve
|
||||||
|
// keys that aren't on our list and/or aren't in the ledger object
|
||||||
|
auto const& inner = const_cast<ripple::STTx&>(ctx.tx)
|
||||||
|
.getField(sfImportVLKey)
|
||||||
|
.downcast<STObject>();
|
||||||
|
auto const pkBlob = inner.getFieldVL(sfPublicKey);
|
||||||
|
std::string const strPk = strHex(makeSlice(pkBlob));
|
||||||
|
if (ctx.app.config().IMPORT_VL_KEYS.find(strPk) !=
|
||||||
|
ctx.app.config().IMPORT_VL_KEYS.end())
|
||||||
|
return tesSUCCESS;
|
||||||
|
|
||||||
|
auto const pkType = publicKeyType(makeSlice(pkBlob));
|
||||||
|
if (!pkType)
|
||||||
|
return tefINTERNAL;
|
||||||
|
|
||||||
|
PublicKey const pk(makeSlice(pkBlob));
|
||||||
|
|
||||||
|
// check on ledger
|
||||||
|
if (auto const unlRep = ctx.view.read(keylet::UNLReport());
|
||||||
|
unlRep && unlRep->isFieldPresent(sfImportVLKeys))
|
||||||
|
{
|
||||||
|
auto const& vlKeys = unlRep->getFieldArray(sfImportVLKeys);
|
||||||
|
for (auto const& k : vlKeys)
|
||||||
|
if (PublicKey(k[sfPublicKey]) == pk)
|
||||||
|
return tesSUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return telIMPORT_VL_KEY_NOT_RECOGNISED;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return temUNKNOWN;
|
return temUNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -357,6 +357,32 @@ class UNLReport_test : public beast::unit_test::suite
|
|||||||
BEAST_EXPECT(isImportVL(env, ivlKeys[0]) == true);
|
BEAST_EXPECT(isImportVL(env, ivlKeys[0]) == true);
|
||||||
BEAST_EXPECT(isImportVL(env, ivlKeys[1]) == false);
|
BEAST_EXPECT(isImportVL(env, ivlKeys[1]) == false);
|
||||||
BEAST_EXPECT(isActiveValidator(env, vlKeys[0]) == true);
|
BEAST_EXPECT(isActiveValidator(env, vlKeys[0]) == true);
|
||||||
|
|
||||||
|
// now test unrecognised keys that are already present in the ledger
|
||||||
|
// object (flap fix)
|
||||||
|
l = std::make_shared<Ledger>(
|
||||||
|
*l, env.app().timeKeeper().closeTime());
|
||||||
|
|
||||||
|
// insert a ttUNL_REPORT pseudo into the open ledger
|
||||||
|
env.app().openLedger().modify(
|
||||||
|
[&](OpenView& view, beast::Journal j) -> bool {
|
||||||
|
STTx tx = createUNLRTx(l->seq(), ivlKeys[1], vlKeys[0]);
|
||||||
|
uint256 txID = tx.getTransactionID();
|
||||||
|
auto s = std::make_shared<ripple::Serializer>();
|
||||||
|
tx.add(*s);
|
||||||
|
env.app().getHashRouter().setFlags(txID, SF_PRIVATE2);
|
||||||
|
view.rawTxInsert(txID, std::move(s), nullptr);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
BEAST_EXPECT(hasUNLReport(env) == true);
|
||||||
|
|
||||||
|
// close the ledger
|
||||||
|
env.close();
|
||||||
|
|
||||||
|
BEAST_EXPECT(isImportVL(env, ivlKeys[0]) == true);
|
||||||
|
BEAST_EXPECT(isImportVL(env, ivlKeys[1]) == false);
|
||||||
|
BEAST_EXPECT(isActiveValidator(env, vlKeys[0]) == true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1324,4 +1350,4 @@ createUNLRTx(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace ripple
|
} // namespace ripple
|
||||||
|
|||||||
Reference in New Issue
Block a user