mirror of
https://github.com/Xahau/xahaud.git
synced 2026-07-02 03:52:00 +00:00
Compare commits
1 Commits
server-def
...
SecureUI
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51f8a9c9ac |
@@ -34,6 +34,7 @@
|
||||
// If you add an amendment here, then do not forget to increment `numFeatures`
|
||||
// in include/xrpl/protocol/Feature.h.
|
||||
|
||||
XRPL_FEATURE(SecureUI, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (HookMap, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (GuardDepth32, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(NamedHooks, Supported::yes, VoteBehavior::DefaultNo)
|
||||
|
||||
@@ -262,6 +262,7 @@ LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, account, ({
|
||||
{sfHookStateScale, soeOPTIONAL},
|
||||
{sfCron, soeOPTIONAL},
|
||||
{sfAMMID, soeOPTIONAL},
|
||||
{sfSecureUI, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** A ledger object which contains a list of object identifiers.
|
||||
|
||||
@@ -293,6 +293,7 @@ TYPED_SFIELD(sfAssetClass, VL, 29)
|
||||
TYPED_SFIELD(sfProvider, VL, 30)
|
||||
TYPED_SFIELD(sfMPTokenMetadata, VL, 31)
|
||||
TYPED_SFIELD(sfCredentialType, VL, 32)
|
||||
TYPED_SFIELD(sfSecureUI, VL, 96)
|
||||
TYPED_SFIELD(sfHookName, VL, 97)
|
||||
TYPED_SFIELD(sfRemarkValue, VL, 98)
|
||||
TYPED_SFIELD(sfRemarkName, VL, 99)
|
||||
|
||||
@@ -74,6 +74,7 @@ TRANSACTION(ttACCOUNT_SET, 3, AccountSet, ({
|
||||
{sfTickSize, soeOPTIONAL},
|
||||
{sfNFTokenMinter, soeOPTIONAL},
|
||||
{sfHookStateScale, soeOPTIONAL},
|
||||
{sfSecureUI, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** This transaction type cancels an existing escrow. */
|
||||
|
||||
@@ -293,8 +293,6 @@ JSS(effective); // out: ValidatorList
|
||||
// in: UNL
|
||||
JSS(elapsed_seconds);
|
||||
JSS(enabled); // out: AmendmentTable
|
||||
JSS(ledger_enabled); // out: ServerDefinitions (amendment on-ledger)
|
||||
JSS(cfg_forced); // out: ServerDefinitions ([features] config stanza)
|
||||
JSS(engine_result); // out: NetworkOPs, TransactionSign, Submit
|
||||
JSS(engine_result_code); // out: NetworkOPs, TransactionSign, Submit
|
||||
JSS(engine_result_message); // out: NetworkOPs, TransactionSign, Submit
|
||||
|
||||
@@ -186,13 +186,10 @@ public:
|
||||
bool expectObsolete =
|
||||
(votes.at(feature[jss::name].asString()) ==
|
||||
VoteBehavior::Obsolete);
|
||||
// "enabled" is now the effective value (ledger_voted || forced);
|
||||
// this default env votes nothing onto the ledger, so assert on the
|
||||
// canonical on-ledger flag.
|
||||
BEAST_EXPECTS(
|
||||
feature.isMember(jss::ledger_enabled) &&
|
||||
!feature[jss::ledger_enabled].asBool(),
|
||||
feature[jss::name].asString() + " ledger_enabled");
|
||||
feature.isMember(jss::enabled) &&
|
||||
!feature[jss::enabled].asBool(),
|
||||
feature[jss::name].asString() + " enabled");
|
||||
BEAST_EXPECTS(
|
||||
feature.isMember(jss::vetoed) &&
|
||||
feature[jss::vetoed].isBool() == !expectObsolete &&
|
||||
@@ -240,12 +237,10 @@ public:
|
||||
bool expectObsolete =
|
||||
(votes.at((*it)[jss::name].asString()) ==
|
||||
VoteBehavior::Obsolete);
|
||||
// expectEnabled reflects the on-ledger amendment table, so compare
|
||||
// against ledger_enabled (enabled is now ledger_voted || forced).
|
||||
BEAST_EXPECTS(
|
||||
(*it).isMember(jss::ledger_enabled) &&
|
||||
(*it)[jss::ledger_enabled].asBool() == expectEnabled,
|
||||
(*it)[jss::name].asString() + " ledger_enabled");
|
||||
(*it).isMember(jss::enabled) &&
|
||||
(*it)[jss::enabled].asBool() == expectEnabled,
|
||||
(*it)[jss::name].asString() + " enabled");
|
||||
if (expectEnabled)
|
||||
BEAST_EXPECTS(
|
||||
!(*it).isMember(jss::vetoed),
|
||||
@@ -365,78 +360,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testConfigForced(FeatureBitset features)
|
||||
{
|
||||
testcase("Config-forced features ([features] stanza)");
|
||||
|
||||
using namespace test::jtx;
|
||||
|
||||
// jtx enables amendments by inserting them into config.features (the
|
||||
// same presets mechanism as the [features] config stanza), so passing
|
||||
// a single-feature bitset gives us exactly one config-forced amendment
|
||||
// and votes nothing onto the ledger. server_definitions must then
|
||||
// report that one as effectively enabled, distinguishing the source:
|
||||
// enabled = ledger_enabled || cfg_forced
|
||||
// ledger_enabled = false (never voted onto the ledger)
|
||||
// cfg_forced = true (forced via config) for the one feature only
|
||||
auto const forced = featurePriceOracle;
|
||||
auto const forcedHex = to_string(forced);
|
||||
|
||||
Env env{*this, FeatureBitset(forced)};
|
||||
|
||||
auto jrr = env.rpc("server_definitions")[jss::result];
|
||||
if (!BEAST_EXPECT(jrr.isMember(jss::features)))
|
||||
return;
|
||||
|
||||
bool sawForced = false;
|
||||
for (auto it = jrr[jss::features].begin();
|
||||
it != jrr[jss::features].end();
|
||||
++it)
|
||||
{
|
||||
auto const& f = *it;
|
||||
auto const name = f[jss::name].asString();
|
||||
|
||||
// every entry now carries the split flags
|
||||
if (!BEAST_EXPECTS(
|
||||
f.isMember(jss::enabled) &&
|
||||
f.isMember(jss::ledger_enabled) &&
|
||||
f.isMember(jss::cfg_forced),
|
||||
name + " split flags"))
|
||||
return;
|
||||
|
||||
// nothing is enabled on-ledger in a fresh env
|
||||
BEAST_EXPECTS(
|
||||
!f[jss::ledger_enabled].asBool(), name + " ledger_enabled");
|
||||
|
||||
if (it.key().asString() == forcedHex)
|
||||
{
|
||||
sawForced = true;
|
||||
BEAST_EXPECTS(
|
||||
f[jss::cfg_forced].asBool(), name + " cfg_forced");
|
||||
// ledger_enabled(false) || cfg_forced(true) == true
|
||||
BEAST_EXPECTS(f[jss::enabled].asBool(), name + " enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
!f[jss::cfg_forced].asBool(), name + " cfg_forced");
|
||||
// not forced and not on-ledger => not effectively enabled
|
||||
BEAST_EXPECTS(
|
||||
f[jss::enabled].asBool() == f[jss::ledger_enabled].asBool(),
|
||||
name + " enabled==ledger_enabled");
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(sawForced);
|
||||
}
|
||||
|
||||
void
|
||||
testServerFeatures(FeatureBitset features)
|
||||
{
|
||||
testNoParams(features);
|
||||
testSomeEnabled(features);
|
||||
testWithMajorities(features);
|
||||
testConfigForced(features);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -197,6 +197,31 @@ SetAccount::preflight(PreflightContext const& ctx)
|
||||
return temMALFORMED;
|
||||
}
|
||||
|
||||
if (tx.isFieldPresent(sfSecureUI))
|
||||
{
|
||||
if (!ctx.rules.enabled(featureSecureUI))
|
||||
return temMALFORMED;
|
||||
|
||||
Blob ui = tx.getFieldVL(sfSecureUI);
|
||||
|
||||
if (ui.size() == 0)
|
||||
{
|
||||
// this is an unset operation, pass
|
||||
}
|
||||
else if (ui.size() > 4096)
|
||||
{
|
||||
JLOG(j.trace()) << "SecureUI: Too long > 4096 bytes";
|
||||
return temMALFORMED;
|
||||
}
|
||||
else if (!URIToken::validateUTF8(ui))
|
||||
{
|
||||
JLOG(j.trace()) << "SecureUI: Not UTF-8";
|
||||
return temMALFORMED;
|
||||
}
|
||||
|
||||
// valid
|
||||
}
|
||||
|
||||
return preflight2(ctx);
|
||||
}
|
||||
|
||||
@@ -699,6 +724,23 @@ SetAccount::doApply()
|
||||
sle->setFieldU16(sfHookStateScale, newScale);
|
||||
}
|
||||
}
|
||||
|
||||
if (tx.isFieldPresent(sfSecureUI))
|
||||
{
|
||||
Blob ui = tx.getFieldVL(sfSecureUI);
|
||||
if (ui.size() == 0)
|
||||
{
|
||||
// unset operation
|
||||
if (sle->isFieldPresent(sfSecureUI))
|
||||
sle->makeFieldAbsent(sfSecureUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set operation
|
||||
sle->setFieldVL(sfSecureUI, std::move(ui));
|
||||
}
|
||||
}
|
||||
|
||||
ctx_.view().update(sle);
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <xrpld/app/main/Application.h>
|
||||
#include <xrpld/app/misc/AmendmentTable.h>
|
||||
#include <xrpld/app/misc/NetworkOPs.h>
|
||||
#include <xrpld/core/Config.h>
|
||||
#include <xrpld/rpc/detail/TransactionSign.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/json_writer.h>
|
||||
@@ -546,39 +545,6 @@ doServerDefinitions(RPC::JsonContext& context)
|
||||
features[to_string(h)][jss::majority] =
|
||||
t.time_since_epoch().count();
|
||||
|
||||
// Amendment activation has two independent sources; surface both so a
|
||||
// consumer isn't misled by a node that force-enables amendments:
|
||||
// ledger_enabled : recorded in the on-ledger Amendments object
|
||||
// (network-canonical; what the table reports as
|
||||
// "enabled")
|
||||
// cfg_forced : force-activated via the [features] config stanza
|
||||
// (node-local; active in the Rules regardless of the
|
||||
// ledger, casts no votes, never written on-ledger)
|
||||
// enabled : effective for transaction processing on this
|
||||
// server, i.e. ledger_enabled || cfg_forced
|
||||
for (auto const& name : features.getMemberNames())
|
||||
{
|
||||
Json::Value& entry = features[name];
|
||||
bool const ledgerEnabled = entry[jss::enabled].asBool();
|
||||
entry[jss::ledger_enabled] = ledgerEnabled;
|
||||
entry[jss::cfg_forced] = false;
|
||||
// entry[jss::enabled] is left == ledgerEnabled here; only
|
||||
// cfg_forced amendments below flip it.
|
||||
}
|
||||
for (auto const& h : context.app.config().features)
|
||||
{
|
||||
Json::Value& entry = features[to_string(h)];
|
||||
if (!entry.isMember(jss::name))
|
||||
{
|
||||
if (auto const fname = featureToName(h); !fname.empty())
|
||||
entry[jss::name] = fname;
|
||||
}
|
||||
if (!entry.isMember(jss::ledger_enabled))
|
||||
entry[jss::ledger_enabled] = false;
|
||||
entry[jss::cfg_forced] = true;
|
||||
entry[jss::enabled] = true; // ledger_enabled || cfg_forced
|
||||
}
|
||||
|
||||
lastFeatures = features;
|
||||
{
|
||||
const std::string out = Json::FastWriter().write(features);
|
||||
|
||||
Reference in New Issue
Block a user