mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 05:55:51 +00:00
Compare commits
83 Commits
ripple/was
...
ximinez/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10f9c18dd3 | ||
|
|
856470203a | ||
|
|
13ab98fb4c | ||
|
|
b124c9f7e3 | ||
|
|
fec2f60697 | ||
|
|
b550dc00ed | ||
|
|
528ede7864 | ||
|
|
4dac87a1b8 | ||
|
|
7c933e06a0 | ||
|
|
d94722e4d0 | ||
|
|
059092d773 | ||
|
|
1cb0887436 | ||
|
|
b9e289df55 | ||
|
|
fff08cb2b1 | ||
|
|
d3842b3908 | ||
|
|
759bd4d199 | ||
|
|
4c88dfc384 | ||
|
|
f241378e6e | ||
|
|
c8ff090d8e | ||
|
|
945c362559 | ||
|
|
9546c52013 | ||
|
|
3a099aeb64 | ||
|
|
8567bd0d12 | ||
|
|
3cb1851537 | ||
|
|
55feea308e | ||
|
|
a6692af17a | ||
|
|
1d058a5d78 | ||
|
|
a70821adc5 | ||
|
|
bfeb60d3f5 | ||
|
|
c86bfa32f7 | ||
|
|
0f44d619b6 | ||
|
|
2add6a7917 | ||
|
|
d21c4f3218 | ||
|
|
265a504301 | ||
|
|
b1e576d3d1 | ||
|
|
d2d3039ce6 | ||
|
|
16e85a7b79 | ||
|
|
4ae1c01e13 | ||
|
|
8807afc074 | ||
|
|
a4e13e07d5 | ||
|
|
6067d59336 | ||
|
|
e14aecee66 | ||
|
|
0e4c3e3427 | ||
|
|
da5c563426 | ||
|
|
b9f5d8b1c5 | ||
|
|
5ea7b562a2 | ||
|
|
8450970b80 | ||
|
|
14d4cff530 | ||
|
|
88ac659d86 | ||
|
|
43fdbf27b9 | ||
|
|
1e33f8e868 | ||
|
|
a6e30857df | ||
|
|
563f24edb0 | ||
|
|
a89f6d5da2 | ||
|
|
5b2e91986a | ||
|
|
fbc5056817 | ||
|
|
b7cafed040 | ||
|
|
b6ebd34b30 | ||
|
|
74c2765159 | ||
|
|
62c7fdadba | ||
|
|
372c66e684 | ||
|
|
a2fab5bcaf | ||
|
|
2e4f41571c | ||
|
|
8799a6dbfd | ||
|
|
e655087027 | ||
|
|
46bd2a4090 | ||
|
|
f3b8a8aef3 | ||
|
|
ee0c917e95 | ||
|
|
375aedd340 | ||
|
|
95397a7710 | ||
|
|
7af8a52d27 | ||
|
|
326a8093c9 | ||
|
|
9f0e159205 | ||
|
|
2fda101b44 | ||
|
|
e6e1e4f9dd | ||
|
|
70591265e5 | ||
|
|
ed1d477a45 | ||
|
|
cd58f636d3 | ||
|
|
3152f2233f | ||
|
|
0c147a895c | ||
|
|
cf80710ef1 | ||
|
|
fc929ab984 | ||
|
|
145a8817dc |
2
.github/workflows/on-pr.yml
vendored
2
.github/workflows/on-pr.yml
vendored
@@ -122,7 +122,7 @@ jobs:
|
|||||||
needs:
|
needs:
|
||||||
- should-run
|
- should-run
|
||||||
- build-test
|
- build-test
|
||||||
if: ${{ needs.should-run.outputs.go == 'true' && contains(fromJSON('["release", "master"]'), github.ref_name) }}
|
if: ${{ needs.should-run.outputs.go == 'true' && (startsWith(github.base_ref, 'release') || github.base_ref == 'master') }}
|
||||||
uses: ./.github/workflows/reusable-notify-clio.yml
|
uses: ./.github/workflows/reusable-notify-clio.yml
|
||||||
secrets:
|
secrets:
|
||||||
clio_notify_token: ${{ secrets.CLIO_NOTIFY_TOKEN }}
|
clio_notify_token: ${{ secrets.CLIO_NOTIFY_TOKEN }}
|
||||||
|
|||||||
6
.github/workflows/on-trigger.yml
vendored
6
.github/workflows/on-trigger.yml
vendored
@@ -14,9 +14,7 @@ on:
|
|||||||
- "master"
|
- "master"
|
||||||
paths:
|
paths:
|
||||||
# These paths are unique to `on-trigger.yml`.
|
# These paths are unique to `on-trigger.yml`.
|
||||||
- ".github/workflows/reusable-check-missing-commits.yml"
|
|
||||||
- ".github/workflows/on-trigger.yml"
|
- ".github/workflows/on-trigger.yml"
|
||||||
- ".github/workflows/publish-docs.yml"
|
|
||||||
|
|
||||||
# Keep the paths below in sync with those in `on-pr.yml`.
|
# Keep the paths below in sync with those in `on-pr.yml`.
|
||||||
- ".github/actions/build-deps/**"
|
- ".github/actions/build-deps/**"
|
||||||
@@ -63,10 +61,6 @@ defaults:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-missing-commits:
|
|
||||||
if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && contains(fromJSON('["develop", "release"]'), github.ref_name) }}
|
|
||||||
uses: ./.github/workflows/reusable-check-missing-commits.yml
|
|
||||||
|
|
||||||
build-test:
|
build-test:
|
||||||
uses: ./.github/workflows/reusable-build-test.yml
|
uses: ./.github/workflows/reusable-build-test.yml
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
# This workflow checks that all commits in the "master" branch are also in the
|
|
||||||
# "release" and "develop" branches, and that all commits in the "release" branch
|
|
||||||
# are also in the "develop" branch.
|
|
||||||
name: Check for missing commits
|
|
||||||
|
|
||||||
# This workflow can only be triggered by other workflows.
|
|
||||||
on: workflow_call
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}-missing-commits
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Check for missing commits
|
|
||||||
env:
|
|
||||||
MESSAGE: |
|
|
||||||
|
|
||||||
If you are reading this, then the commits indicated above are missing
|
|
||||||
from the "develop" and/or "release" branch. Do a reverse-merge as soon
|
|
||||||
as possible. See CONTRIBUTING.md for instructions.
|
|
||||||
run: |
|
|
||||||
set -o pipefail
|
|
||||||
# Branches are ordered by how "canonical" they are. Every commit in one
|
|
||||||
# branch should be in all the branches behind it.
|
|
||||||
order=(master release develop)
|
|
||||||
branches=()
|
|
||||||
for branch in "${order[@]}"; do
|
|
||||||
# Check that the branches exist so that this job will work on forked
|
|
||||||
# repos, which don't necessarily have master and release branches.
|
|
||||||
echo "Checking if ${branch} exists."
|
|
||||||
if git ls-remote --exit-code --heads origin \
|
|
||||||
refs/heads/${branch} > /dev/null; then
|
|
||||||
branches+=(origin/${branch})
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
prior=()
|
|
||||||
for branch in "${branches[@]}"; do
|
|
||||||
if [[ ${#prior[@]} -ne 0 ]]; then
|
|
||||||
echo "Checking ${prior[@]} for commits missing from ${branch}."
|
|
||||||
git log --oneline --no-merges "${prior[@]}" \
|
|
||||||
^$branch | tee -a "missing-commits.txt"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
prior+=("${branch}")
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $(cat missing-commits.txt | wc -l) -ne 0 ]]; then
|
|
||||||
echo "${MESSAGE}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -64,8 +64,6 @@ XRPL_FEATURE(Clawback, Supported::yes, VoteBehavior::DefaultNo
|
|||||||
XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo)
|
XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo)
|
||||||
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
|
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
|
||||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
|
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
|
||||||
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
|
|
||||||
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
|
|
||||||
|
|
||||||
// The following amendments are obsolete, but must remain supported
|
// The following amendments are obsolete, but must remain supported
|
||||||
// because they could potentially get enabled.
|
// because they could potentially get enabled.
|
||||||
@@ -124,7 +122,9 @@ XRPL_RETIRE_FEATURE(Escrow)
|
|||||||
XRPL_RETIRE_FEATURE(EnforceInvariants)
|
XRPL_RETIRE_FEATURE(EnforceInvariants)
|
||||||
XRPL_RETIRE_FEATURE(ExpandedSignerList)
|
XRPL_RETIRE_FEATURE(ExpandedSignerList)
|
||||||
XRPL_RETIRE_FEATURE(FeeEscalation)
|
XRPL_RETIRE_FEATURE(FeeEscalation)
|
||||||
|
XRPL_RETIRE_FEATURE(Flow)
|
||||||
XRPL_RETIRE_FEATURE(FlowCross)
|
XRPL_RETIRE_FEATURE(FlowCross)
|
||||||
|
XRPL_RETIRE_FEATURE(FlowSortStrands)
|
||||||
XRPL_RETIRE_FEATURE(HardenedValidations)
|
XRPL_RETIRE_FEATURE(HardenedValidations)
|
||||||
XRPL_RETIRE_FEATURE(ImmediateOfferKilled)
|
XRPL_RETIRE_FEATURE(ImmediateOfferKilled)
|
||||||
XRPL_RETIRE_FEATURE(MultiSign)
|
XRPL_RETIRE_FEATURE(MultiSign)
|
||||||
|
|||||||
@@ -267,9 +267,8 @@ public:
|
|||||||
// strand dry until the liquidity is actually used)
|
// strand dry until the liquidity is actually used)
|
||||||
|
|
||||||
// The implementation allows any single step to consume at most 1000
|
// The implementation allows any single step to consume at most 1000
|
||||||
// offers. With the `FlowSortStrands` feature enabled, if the total
|
// offers.If the total number of offers consumed by all the steps
|
||||||
// number of offers consumed by all the steps combined exceeds 1500, the
|
// combined exceeds 1500, the payment stops.
|
||||||
// payment stops.
|
|
||||||
{
|
{
|
||||||
Env env(*this, features);
|
Env env(*this, features);
|
||||||
|
|
||||||
@@ -457,16 +456,12 @@ public:
|
|||||||
// below the limit. However, if all the offers are consumed it would
|
// below the limit. However, if all the offers are consumed it would
|
||||||
// create a tecOVERSIZE error.
|
// create a tecOVERSIZE error.
|
||||||
|
|
||||||
// The featureFlowSortStrands introduces a way of tracking the total
|
|
||||||
// number of consumed offers; with this feature the transaction no
|
|
||||||
// longer fails with a tecOVERSIZE error.
|
|
||||||
// The implementation allows any single step to consume at most 1000
|
// The implementation allows any single step to consume at most 1000
|
||||||
// offers. With the `FlowSortStrands` feature enabled, if the total
|
// offers. If the total number of offers consumed by all the steps
|
||||||
// number of offers consumed by all the steps combined exceeds 1500, the
|
// combined exceeds 1500, the payment stops. Since the first set of
|
||||||
// payment stops. Since the first set of offers consumes 998 offers, the
|
// offers consumes 998 offers, the second set will consume 998, which is
|
||||||
// second set will consume 998, which is not over the limit and the
|
// not over the limit and the payment stops. So 2*998, or 1996 is the
|
||||||
// payment stops. So 2*998, or 1996 is the expected value when
|
// expected value.
|
||||||
// `FlowSortStrands` is enabled.
|
|
||||||
n_offers(env, 998, alice, XRP(1.00), USD(1));
|
n_offers(env, 998, alice, XRP(1.00), USD(1));
|
||||||
n_offers(env, 998, alice, XRP(0.99), USD(1));
|
n_offers(env, 998, alice, XRP(0.99), USD(1));
|
||||||
n_offers(env, 998, alice, XRP(0.98), USD(1));
|
n_offers(env, 998, alice, XRP(0.98), USD(1));
|
||||||
@@ -474,24 +469,10 @@ public:
|
|||||||
n_offers(env, 998, alice, XRP(0.96), USD(1));
|
n_offers(env, 998, alice, XRP(0.96), USD(1));
|
||||||
n_offers(env, 998, alice, XRP(0.95), USD(1));
|
n_offers(env, 998, alice, XRP(0.95), USD(1));
|
||||||
|
|
||||||
bool const withSortStrands = features[featureFlowSortStrands];
|
env(offer(bob, USD(8000), XRP(8000)), ter(tesSUCCESS));
|
||||||
|
|
||||||
auto const expectedTER = [&]() -> TER {
|
|
||||||
if (!withSortStrands)
|
|
||||||
return TER{tecOVERSIZE};
|
|
||||||
return tesSUCCESS;
|
|
||||||
}();
|
|
||||||
|
|
||||||
env(offer(bob, USD(8000), XRP(8000)), ter(expectedTER));
|
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
auto const expectedUSD = [&] {
|
env.require(balance(bob, USD(1996)));
|
||||||
if (!withSortStrands)
|
|
||||||
return USD(0);
|
|
||||||
return USD(1996);
|
|
||||||
}();
|
|
||||||
|
|
||||||
env.require(balance(bob, expectedUSD));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -507,9 +488,7 @@ public:
|
|||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
auto const sa = testable_amendments();
|
auto const sa = testable_amendments();
|
||||||
testAll(sa);
|
testAll(sa);
|
||||||
testAll(sa - featureFlowSortStrands);
|
|
||||||
testAll(sa - featurePermissionedDEX);
|
testAll(sa - featurePermissionedDEX);
|
||||||
testAll(sa - featureFlowSortStrands - featurePermissionedDEX);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1054,7 +1054,7 @@ public:
|
|||||||
// Charlie - queue a transaction, with a higher fee
|
// Charlie - queue a transaction, with a higher fee
|
||||||
// than default
|
// than default
|
||||||
env(noop(charlie), fee(15), queued);
|
env(noop(charlie), fee(15), queued);
|
||||||
checkMetrics(*this, env, 6, initQueueMax, 4, 3);
|
checkMetrics(*this, env, 6, initQueueMax, 4, 3, 257);
|
||||||
|
|
||||||
BEAST_EXPECT(env.seq(alice) == aliceSeq);
|
BEAST_EXPECT(env.seq(alice) == aliceSeq);
|
||||||
BEAST_EXPECT(env.seq(bob) == bobSeq);
|
BEAST_EXPECT(env.seq(bob) == bobSeq);
|
||||||
@@ -4330,7 +4330,7 @@ public:
|
|||||||
Account const ellie("ellie");
|
Account const ellie("ellie");
|
||||||
Account const fiona("fiona");
|
Account const fiona("fiona");
|
||||||
|
|
||||||
constexpr int ledgersInQueue = 20;
|
constexpr int ledgersInQueue = 30;
|
||||||
auto cfg = makeConfig(
|
auto cfg = makeConfig(
|
||||||
{{"minimum_txn_in_ledger_standalone", "1"},
|
{{"minimum_txn_in_ledger_standalone", "1"},
|
||||||
{"ledgers_in_queue", std::to_string(ledgersInQueue)},
|
{"ledgers_in_queue", std::to_string(ledgersInQueue)},
|
||||||
|
|||||||
@@ -798,16 +798,18 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
// a Env FeatureBitset has *only* those features
|
// a Env FeatureBitset has *only* those features
|
||||||
Env env{*this, FeatureBitset{featureDynamicMPT | featureFlow}};
|
Env env{
|
||||||
|
*this, FeatureBitset{featureDynamicMPT | featureTokenEscrow}};
|
||||||
BEAST_EXPECT(env.app().config().features.size() == 2);
|
BEAST_EXPECT(env.app().config().features.size() == 2);
|
||||||
foreachFeature(supported, [&](uint256 const& f) {
|
foreachFeature(supported, [&](uint256 const& f) {
|
||||||
bool const has = (f == featureDynamicMPT || f == featureFlow);
|
bool const has =
|
||||||
|
(f == featureDynamicMPT || f == featureTokenEscrow);
|
||||||
this->BEAST_EXPECT(has == hasFeature(env, f));
|
this->BEAST_EXPECT(has == hasFeature(env, f));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const missingSomeFeatures =
|
auto const missingSomeFeatures =
|
||||||
testable_amendments() - featureDynamicMPT - featureFlow;
|
testable_amendments() - featureDynamicMPT - featureTokenEscrow;
|
||||||
BEAST_EXPECT(missingSomeFeatures.count() == (supported.count() - 2));
|
BEAST_EXPECT(missingSomeFeatures.count() == (supported.count() - 2));
|
||||||
{
|
{
|
||||||
// a Env supported_features_except is missing *only* those features
|
// a Env supported_features_except is missing *only* those features
|
||||||
@@ -815,7 +817,8 @@ public:
|
|||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
env.app().config().features.size() == (supported.count() - 2));
|
env.app().config().features.size() == (supported.count() - 2));
|
||||||
foreachFeature(supported, [&](uint256 const& f) {
|
foreachFeature(supported, [&](uint256 const& f) {
|
||||||
bool hasnot = (f == featureDynamicMPT || f == featureFlow);
|
bool hasnot =
|
||||||
|
(f == featureDynamicMPT || f == featureTokenEscrow);
|
||||||
this->BEAST_EXPECT(hasnot != hasFeature(env, f));
|
this->BEAST_EXPECT(hasnot != hasFeature(env, f));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -828,7 +831,9 @@ public:
|
|||||||
Env env{
|
Env env{
|
||||||
*this,
|
*this,
|
||||||
FeatureBitset{
|
FeatureBitset{
|
||||||
featureDynamicMPT, featureFlow, *neverSupportedFeat}};
|
featureDynamicMPT,
|
||||||
|
featureTokenEscrow,
|
||||||
|
*neverSupportedFeat}};
|
||||||
|
|
||||||
// this app will have just 2 supported amendments and
|
// this app will have just 2 supported amendments and
|
||||||
// one additional never supported feature flag
|
// one additional never supported feature flag
|
||||||
@@ -836,7 +841,7 @@ public:
|
|||||||
BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
|
BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
|
||||||
|
|
||||||
foreachFeature(supported, [&](uint256 const& f) {
|
foreachFeature(supported, [&](uint256 const& f) {
|
||||||
bool has = (f == featureDynamicMPT || f == featureFlow);
|
bool has = (f == featureDynamicMPT || f == featureTokenEscrow);
|
||||||
this->BEAST_EXPECT(has == hasFeature(env, f));
|
this->BEAST_EXPECT(has == hasFeature(env, f));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -856,7 +861,8 @@ public:
|
|||||||
(supported.count() - 2 + 1));
|
(supported.count() - 2 + 1));
|
||||||
BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
|
BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
|
||||||
foreachFeature(supported, [&](uint256 const& f) {
|
foreachFeature(supported, [&](uint256 const& f) {
|
||||||
bool hasnot = (f == featureDynamicMPT || f == featureFlow);
|
bool hasnot =
|
||||||
|
(f == featureDynamicMPT || f == featureTokenEscrow);
|
||||||
this->BEAST_EXPECT(hasnot != hasFeature(env, f));
|
this->BEAST_EXPECT(hasnot != hasFeature(env, f));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1117,7 +1117,7 @@ class GetAmendments_test : public beast::unit_test::suite
|
|||||||
// There should be at least 3 amendments. Don't do exact comparison
|
// There should be at least 3 amendments. Don't do exact comparison
|
||||||
// to avoid maintenance as more amendments are added in the future.
|
// to avoid maintenance as more amendments are added in the future.
|
||||||
BEAST_EXPECT(i == 254);
|
BEAST_EXPECT(i == 254);
|
||||||
BEAST_EXPECT(majorities.size() >= 3);
|
BEAST_EXPECT(majorities.size() >= 2);
|
||||||
|
|
||||||
// None of the amendments should be enabled yet.
|
// None of the amendments should be enabled yet.
|
||||||
auto enableds = getEnabledAmendments(*env.closed());
|
auto enableds = getEnabledAmendments(*env.closed());
|
||||||
@@ -1135,7 +1135,7 @@ class GetAmendments_test : public beast::unit_test::suite
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BEAST_EXPECT(i == 255);
|
BEAST_EXPECT(i == 255);
|
||||||
BEAST_EXPECT(enableds.size() >= 3);
|
BEAST_EXPECT(enableds.size() >= 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class Feature_test : public beast::unit_test::suite
|
|||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
featureToName(fixRemoveNFTokenAutoTrustLine) ==
|
featureToName(fixRemoveNFTokenAutoTrustLine) ==
|
||||||
"fixRemoveNFTokenAutoTrustLine");
|
"fixRemoveNFTokenAutoTrustLine");
|
||||||
BEAST_EXPECT(featureToName(featureFlow) == "Flow");
|
BEAST_EXPECT(featureToName(featureBatch) == "Batch");
|
||||||
BEAST_EXPECT(featureToName(featureDID) == "DID");
|
BEAST_EXPECT(featureToName(featureDID) == "DID");
|
||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
featureToName(fixIncludeKeyletFields) == "fixIncludeKeyletFields");
|
featureToName(fixIncludeKeyletFields) == "fixIncludeKeyletFields");
|
||||||
@@ -183,16 +183,16 @@ class Feature_test : public beast::unit_test::suite
|
|||||||
using namespace test::jtx;
|
using namespace test::jtx;
|
||||||
Env env{*this};
|
Env env{*this};
|
||||||
|
|
||||||
auto jrr = env.rpc("feature", "Flow")[jss::result];
|
auto jrr = env.rpc("feature", "fixAMMOverflowOffer")[jss::result];
|
||||||
BEAST_EXPECTS(jrr[jss::status] == jss::success, "status");
|
BEAST_EXPECTS(jrr[jss::status] == jss::success, "status");
|
||||||
jrr.removeMember(jss::status);
|
jrr.removeMember(jss::status);
|
||||||
BEAST_EXPECT(jrr.size() == 1);
|
BEAST_EXPECT(jrr.size() == 1);
|
||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
jrr.isMember("740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D6"
|
jrr.isMember("12523DF04B553A0B1AD74F42DDB741DE8DC06A03FC089A0EF197E"
|
||||||
"28A06927F11"));
|
"2A87F1D8107"));
|
||||||
auto feature = *(jrr.begin());
|
auto feature = *(jrr.begin());
|
||||||
|
|
||||||
BEAST_EXPECTS(feature[jss::name] == "Flow", "name");
|
BEAST_EXPECTS(feature[jss::name] == "fixAMMOverflowOffer", "name");
|
||||||
BEAST_EXPECTS(!feature[jss::enabled].asBool(), "enabled");
|
BEAST_EXPECTS(!feature[jss::enabled].asBool(), "enabled");
|
||||||
BEAST_EXPECTS(
|
BEAST_EXPECTS(
|
||||||
feature[jss::vetoed].isBool() && !feature[jss::vetoed].asBool(),
|
feature[jss::vetoed].isBool() && !feature[jss::vetoed].asBool(),
|
||||||
@@ -200,7 +200,7 @@ class Feature_test : public beast::unit_test::suite
|
|||||||
BEAST_EXPECTS(feature[jss::supported].asBool(), "supported");
|
BEAST_EXPECTS(feature[jss::supported].asBool(), "supported");
|
||||||
|
|
||||||
// feature names are case-sensitive - expect error here
|
// feature names are case-sensitive - expect error here
|
||||||
jrr = env.rpc("feature", "flow")[jss::result];
|
jrr = env.rpc("feature", "fMM")[jss::result];
|
||||||
BEAST_EXPECT(jrr[jss::error] == "badFeature");
|
BEAST_EXPECT(jrr[jss::error] == "badFeature");
|
||||||
BEAST_EXPECT(jrr[jss::error_message] == "Feature unknown or invalid.");
|
BEAST_EXPECT(jrr[jss::error_message] == "Feature unknown or invalid.");
|
||||||
}
|
}
|
||||||
@@ -419,9 +419,9 @@ class Feature_test : public beast::unit_test::suite
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There should be at least 3 amendments. Don't do exact comparison
|
// There should be at least 2 amendments. Don't do exact comparison
|
||||||
// to avoid maintenance as more amendments are added in the future.
|
// to avoid maintenance as more amendments are added in the future.
|
||||||
BEAST_EXPECT(majorities.size() >= 3);
|
BEAST_EXPECT(majorities.size() >= 2);
|
||||||
std::map<std::string, VoteBehavior> const& votes =
|
std::map<std::string, VoteBehavior> const& votes =
|
||||||
ripple::detail::supportedAmendments();
|
ripple::detail::supportedAmendments();
|
||||||
|
|
||||||
@@ -476,8 +476,8 @@ class Feature_test : public beast::unit_test::suite
|
|||||||
testcase("Veto");
|
testcase("Veto");
|
||||||
|
|
||||||
using namespace test::jtx;
|
using namespace test::jtx;
|
||||||
Env env{*this, FeatureBitset{featureFlow}};
|
Env env{*this, FeatureBitset{featurePriceOracle}};
|
||||||
constexpr char const* featureName = "Flow";
|
constexpr char const* featureName = "fixAMMOverflowOffer";
|
||||||
|
|
||||||
auto jrr = env.rpc("feature", featureName)[jss::result];
|
auto jrr = env.rpc("feature", featureName)[jss::result];
|
||||||
if (!BEAST_EXPECTS(jrr[jss::status] == jss::success, "status"))
|
if (!BEAST_EXPECTS(jrr[jss::status] == jss::success, "status"))
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <test/jtx/multisign.h>
|
#include <test/jtx/multisign.h>
|
||||||
#include <test/jtx/xchain_bridge.h>
|
#include <test/jtx/xchain_bridge.h>
|
||||||
|
|
||||||
|
#include <xrpld/app/tx/apply.h>
|
||||||
|
|
||||||
#include <xrpl/beast/unit_test.h>
|
#include <xrpl/beast/unit_test.h>
|
||||||
#include <xrpl/json/json_value.h>
|
#include <xrpl/json/json_value.h>
|
||||||
#include <xrpl/protocol/AccountID.h>
|
#include <xrpl/protocol/AccountID.h>
|
||||||
@@ -2008,6 +2010,370 @@ class LedgerEntry_test : public beast::unit_test::suite
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test the ledger entry types that don't take parameters
|
||||||
|
void
|
||||||
|
testLedgerEntryFixed()
|
||||||
|
{
|
||||||
|
using namespace test::jtx;
|
||||||
|
|
||||||
|
Account const alice{"alice"};
|
||||||
|
Account const bob{"bob"};
|
||||||
|
|
||||||
|
Env env{*this, envconfig([](auto cfg) {
|
||||||
|
cfg->START_UP = Config::FRESH;
|
||||||
|
return cfg;
|
||||||
|
})};
|
||||||
|
|
||||||
|
env.close();
|
||||||
|
|
||||||
|
/** Verifies that the RPC result has the expected data
|
||||||
|
*
|
||||||
|
* @param good: Indicates that the request should have succeeded
|
||||||
|
* and returned a ledger object of `expectedType` type.
|
||||||
|
* @param jv: The RPC result Json value
|
||||||
|
* @param expectedType: The type that the ledger object should
|
||||||
|
* have if "good".
|
||||||
|
* @param expectedError: Optional. The expected error if not
|
||||||
|
* good. Defaults to "entryNotFound".
|
||||||
|
*/
|
||||||
|
auto checkResult =
|
||||||
|
[&](bool good,
|
||||||
|
Json::Value const& jv,
|
||||||
|
Json::StaticString const& expectedType,
|
||||||
|
std::optional<std::string> const& expectedError = {}) {
|
||||||
|
if (good)
|
||||||
|
{
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
jv.isObject() && jv.isMember(jss::result) &&
|
||||||
|
!jv[jss::result].isMember(jss::error) &&
|
||||||
|
jv[jss::result].isMember(jss::node) &&
|
||||||
|
jv[jss::result][jss::node].isMember(
|
||||||
|
sfLedgerEntryType.jsonName) &&
|
||||||
|
jv[jss::result][jss::node]
|
||||||
|
[sfLedgerEntryType.jsonName] == expectedType,
|
||||||
|
to_string(jv));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
jv.isObject() && jv.isMember(jss::result) &&
|
||||||
|
jv[jss::result].isMember(jss::error) &&
|
||||||
|
!jv[jss::result].isMember(jss::node) &&
|
||||||
|
jv[jss::result][jss::error] ==
|
||||||
|
expectedError.value_or("entryNotFound"),
|
||||||
|
to_string(jv));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Runs a series of tests for a given fixed-position ledger
|
||||||
|
* entry.
|
||||||
|
*
|
||||||
|
* @param field: The Json request field to use.
|
||||||
|
* @param expectedType: The type that the ledger object should
|
||||||
|
* have if "good".
|
||||||
|
* @param expectedKey: The keylet of the fixed object.
|
||||||
|
* @param good: Indicates whether the object is expected to
|
||||||
|
* exist.
|
||||||
|
*/
|
||||||
|
auto test = [&](Json::StaticString const& field,
|
||||||
|
Json::StaticString const& expectedType,
|
||||||
|
Keylet const& expectedKey,
|
||||||
|
bool good) {
|
||||||
|
testcase << "ledger_entry " << expectedType.c_str()
|
||||||
|
<< (good ? "" : " not") << " found";
|
||||||
|
|
||||||
|
auto const hexKey = strHex(expectedKey.key);
|
||||||
|
|
||||||
|
// Test bad values
|
||||||
|
// "field":null
|
||||||
|
Json::Value params;
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[field] = Json::nullValue;
|
||||||
|
auto jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, expectedType, "malformedRequest");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// "field":"string"
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[field] = "arbitrary string";
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, expectedType, "malformedRequest");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// "field":false
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[field] = false;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, expectedType, "invalidParams");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
{
|
||||||
|
// "field":[incorrect index hash]
|
||||||
|
auto const badKey = strHex(expectedKey.key + uint256{1});
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[field] = badKey;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, expectedType, "entryNotFound");
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
jv[jss::result][jss::index] == badKey, to_string(jv));
|
||||||
|
}
|
||||||
|
|
||||||
|
// "index":"field" using API 2
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::index] = field;
|
||||||
|
params[jss::api_version] = 2;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, expectedType, "malformedRequest");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// Test good values
|
||||||
|
// Use the "field":true notation
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[field] = true;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
// Index will always be returned for valid parameters.
|
||||||
|
std::string const pdIdx = jv[jss::result][jss::index].asString();
|
||||||
|
BEAST_EXPECTS(hexKey == pdIdx, to_string(jv));
|
||||||
|
checkResult(good, jv, expectedType);
|
||||||
|
|
||||||
|
// "field":"[index hash]"
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[field] = hexKey;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(good, jv, expectedType);
|
||||||
|
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
||||||
|
|
||||||
|
// Use the "index":"field" notation with API 3
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::index] = field;
|
||||||
|
params[jss::api_version] = 3;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
// Index is correct either way
|
||||||
|
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
||||||
|
checkResult(good, jv, expectedType);
|
||||||
|
|
||||||
|
// Use the "index":"[index hash]" notation
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::index] = pdIdx;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
// Index is correct either way
|
||||||
|
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
||||||
|
checkResult(good, jv, expectedType);
|
||||||
|
};
|
||||||
|
|
||||||
|
test(jss::amendments, jss::Amendments, keylet::amendments(), true);
|
||||||
|
test(jss::fee, jss::FeeSettings, keylet::fees(), true);
|
||||||
|
// There won't be an nunl
|
||||||
|
test(jss::nunl, jss::NegativeUNL, keylet::negativeUNL(), false);
|
||||||
|
// Can only get the short skip list this way
|
||||||
|
test(jss::hashes, jss::LedgerHashes, keylet::skip(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
testLedgerEntryHashes()
|
||||||
|
{
|
||||||
|
using namespace test::jtx;
|
||||||
|
|
||||||
|
Account const alice{"alice"};
|
||||||
|
Account const bob{"bob"};
|
||||||
|
|
||||||
|
Env env{*this, envconfig([](auto cfg) {
|
||||||
|
cfg->START_UP = Config::FRESH;
|
||||||
|
return cfg;
|
||||||
|
})};
|
||||||
|
|
||||||
|
env.close();
|
||||||
|
|
||||||
|
/** Verifies that the RPC result has the expected data
|
||||||
|
*
|
||||||
|
* @param good: Indicates that the request should have succeeded
|
||||||
|
* and returned a ledger object of `expectedType` type.
|
||||||
|
* @param jv: The RPC result Json value
|
||||||
|
* @param expectedCount: The number of Hashes expected in the
|
||||||
|
* object if "good".
|
||||||
|
* @param expectedError: Optional. The expected error if not
|
||||||
|
* good. Defaults to "entryNotFound".
|
||||||
|
*/
|
||||||
|
auto checkResult =
|
||||||
|
[&](bool good,
|
||||||
|
Json::Value const& jv,
|
||||||
|
int expectedCount,
|
||||||
|
std::optional<std::string> const& expectedError = {}) {
|
||||||
|
if (good)
|
||||||
|
{
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
jv.isObject() && jv.isMember(jss::result) &&
|
||||||
|
!jv[jss::result].isMember(jss::error) &&
|
||||||
|
jv[jss::result].isMember(jss::node) &&
|
||||||
|
jv[jss::result][jss::node].isMember(
|
||||||
|
sfLedgerEntryType.jsonName) &&
|
||||||
|
jv[jss::result][jss::node]
|
||||||
|
[sfLedgerEntryType.jsonName] == jss::LedgerHashes,
|
||||||
|
to_string(jv));
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
jv[jss::result].isMember(jss::node) &&
|
||||||
|
jv[jss::result][jss::node].isMember("Hashes") &&
|
||||||
|
jv[jss::result][jss::node]["Hashes"].size() ==
|
||||||
|
expectedCount,
|
||||||
|
to_string(jv[jss::result][jss::node]["Hashes"].size()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
jv.isObject() && jv.isMember(jss::result) &&
|
||||||
|
jv[jss::result].isMember(jss::error) &&
|
||||||
|
!jv[jss::result].isMember(jss::node) &&
|
||||||
|
jv[jss::result][jss::error] ==
|
||||||
|
expectedError.value_or("entryNotFound"),
|
||||||
|
to_string(jv));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Runs a series of tests for a given ledger index.
|
||||||
|
*
|
||||||
|
* @param ledger: The ledger index value of the "hashes" request
|
||||||
|
* parameter. May not necessarily be a number.
|
||||||
|
* @param expectedKey: The expected keylet of the object.
|
||||||
|
* @param good: Indicates whether the object is expected to
|
||||||
|
* exist.
|
||||||
|
* @param expectedCount: The number of Hashes expected in the
|
||||||
|
* object if "good".
|
||||||
|
*/
|
||||||
|
auto test = [&](Json::Value ledger,
|
||||||
|
Keylet const& expectedKey,
|
||||||
|
bool good,
|
||||||
|
int expectedCount = 0) {
|
||||||
|
testcase << "ledger_entry LedgerHashes: seq: "
|
||||||
|
<< env.current()->info().seq
|
||||||
|
<< " \"hashes\":" << to_string(ledger)
|
||||||
|
<< (good ? "" : " not") << " found";
|
||||||
|
|
||||||
|
auto const hexKey = strHex(expectedKey.key);
|
||||||
|
|
||||||
|
// Test bad values
|
||||||
|
// "hashes":null
|
||||||
|
Json::Value params;
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = Json::nullValue;
|
||||||
|
auto jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, 0, "malformedRequest");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// "hashes":"non-uint string"
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = "arbitrary string";
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, 0, "malformedRequest");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// "hashes":"uint string" is invalid, too
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = "10";
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, 0, "malformedRequest");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// "hashes":false
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = false;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, 0, "invalidParams");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// "hashes":-1
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = -1;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, 0, "internal");
|
||||||
|
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||||
|
|
||||||
|
// "hashes":[incorrect index hash]
|
||||||
|
{
|
||||||
|
auto const badKey = strHex(expectedKey.key + uint256{1});
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = badKey;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(false, jv, 0, "entryNotFound");
|
||||||
|
BEAST_EXPECT(jv[jss::result][jss::index] == badKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test good values
|
||||||
|
// Use the "hashes":ledger notation
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = ledger;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(good, jv, expectedCount);
|
||||||
|
// Index will always be returned for valid parameters.
|
||||||
|
std::string const pdIdx = jv[jss::result][jss::index].asString();
|
||||||
|
BEAST_EXPECTS(hexKey == pdIdx, strHex(pdIdx));
|
||||||
|
|
||||||
|
// "hashes":"[index hash]"
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::hashes] = hexKey;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(good, jv, expectedCount);
|
||||||
|
// Index is correct either way
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
hexKey == jv[jss::result][jss::index].asString(),
|
||||||
|
strHex(jv[jss::result][jss::index].asString()));
|
||||||
|
|
||||||
|
// Use the "index":"[index hash]" notation
|
||||||
|
params.clear();
|
||||||
|
params[jss::ledger_index] = jss::validated;
|
||||||
|
params[jss::index] = hexKey;
|
||||||
|
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||||
|
checkResult(good, jv, expectedCount);
|
||||||
|
// Index is correct either way
|
||||||
|
BEAST_EXPECTS(
|
||||||
|
hexKey == jv[jss::result][jss::index].asString(),
|
||||||
|
strHex(jv[jss::result][jss::index].asString()));
|
||||||
|
};
|
||||||
|
|
||||||
|
// short skip list
|
||||||
|
test(true, keylet::skip(), true, 2);
|
||||||
|
// long skip list at index 0
|
||||||
|
test(1, keylet::skip(1), false);
|
||||||
|
// long skip list at index 1
|
||||||
|
test(1 << 17, keylet::skip(1 << 17), false);
|
||||||
|
|
||||||
|
// Close more ledgers, but stop short of the flag ledger
|
||||||
|
for (auto i = env.current()->seq(); i <= 250; ++i)
|
||||||
|
env.close();
|
||||||
|
|
||||||
|
// short skip list
|
||||||
|
test(true, keylet::skip(), true, 249);
|
||||||
|
// long skip list at index 0
|
||||||
|
test(1, keylet::skip(1), false);
|
||||||
|
// long skip list at index 1
|
||||||
|
test(1 << 17, keylet::skip(1 << 17), false);
|
||||||
|
|
||||||
|
// Close a flag ledger so the first "long" skip list is created
|
||||||
|
for (auto i = env.current()->seq(); i <= 260; ++i)
|
||||||
|
env.close();
|
||||||
|
|
||||||
|
// short skip list
|
||||||
|
test(true, keylet::skip(), true, 256);
|
||||||
|
// long skip list at index 0
|
||||||
|
test(1, keylet::skip(1), true, 1);
|
||||||
|
// long skip list at index 1
|
||||||
|
test(1 << 17, keylet::skip(1 << 17), false);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
testLedgerEntryCLI()
|
testLedgerEntryCLI()
|
||||||
{
|
{
|
||||||
@@ -2057,6 +2423,8 @@ public:
|
|||||||
testOracleLedgerEntry();
|
testOracleLedgerEntry();
|
||||||
testLedgerEntryMPT();
|
testLedgerEntryMPT();
|
||||||
testLedgerEntryPermissionedDomain();
|
testLedgerEntryPermissionedDomain();
|
||||||
|
testLedgerEntryFixed();
|
||||||
|
testLedgerEntryHashes();
|
||||||
testLedgerEntryCLI();
|
testLedgerEntryCLI();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,15 +43,6 @@ RippleCalc::rippleCalculate(
|
|||||||
PaymentSandbox flowSB(&view);
|
PaymentSandbox flowSB(&view);
|
||||||
auto j = l.journal("Flow");
|
auto j = l.journal("Flow");
|
||||||
|
|
||||||
if (!view.rules().enabled(featureFlow))
|
|
||||||
{
|
|
||||||
// The new payment engine was enabled several years ago. New transaction
|
|
||||||
// should never use the old rules. Assume this is a replay
|
|
||||||
j.fatal()
|
|
||||||
<< "Old payment rules are required for this transaction. Assuming "
|
|
||||||
"this is a replay and running with the new rules.";
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
bool const defaultPaths =
|
bool const defaultPaths =
|
||||||
!pInputs ? true : pInputs->defaultPathsAllowed;
|
!pInputs ? true : pInputs->defaultPathsAllowed;
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ public:
|
|||||||
// add the strands in `next_` to `cur_`, sorted by theoretical quality.
|
// add the strands in `next_` to `cur_`, sorted by theoretical quality.
|
||||||
// Best quality first.
|
// Best quality first.
|
||||||
cur_.clear();
|
cur_.clear();
|
||||||
if (v.rules().enabled(featureFlowSortStrands) && !next_.empty())
|
if (!next_.empty())
|
||||||
{
|
{
|
||||||
std::vector<std::pair<Quality, Strand const*>> strandQuals;
|
std::vector<std::pair<Quality, Strand const*>> strandQuals;
|
||||||
strandQuals.reserve(next_.size());
|
strandQuals.reserve(next_.size());
|
||||||
@@ -719,8 +719,6 @@ flow(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseView.rules().enabled(featureFlowSortStrands))
|
|
||||||
{
|
|
||||||
XRPL_ASSERT(!best, "ripple::flow : best is unset");
|
XRPL_ASSERT(!best, "ripple::flow : best is unset");
|
||||||
if (!f.inactive)
|
if (!f.inactive)
|
||||||
activeStrands.push(strand);
|
activeStrands.push(strand);
|
||||||
@@ -729,36 +727,8 @@ flow(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
activeStrands.push(strand);
|
bool const shouldBreak =
|
||||||
|
!best || offersConsidered >= maxOffersToConsider;
|
||||||
if (!best || best->quality < q ||
|
|
||||||
(best->quality == q && best->out < f.out))
|
|
||||||
{
|
|
||||||
// If this strand is inactive (because it consumed too many
|
|
||||||
// offers) and ends up having the best quality, remove it
|
|
||||||
// from the activeStrands. If it doesn't end up having the
|
|
||||||
// best quality, keep it active.
|
|
||||||
|
|
||||||
if (f.inactive)
|
|
||||||
{
|
|
||||||
// This should be `nextSize`, not `size`. This issue is
|
|
||||||
// fixed in featureFlowSortStrands.
|
|
||||||
markInactiveOnUse = activeStrands.size() - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
markInactiveOnUse.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
best.emplace(f.in, f.out, std::move(*f.sandbox), *strand, q);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool const shouldBreak = [&] {
|
|
||||||
if (baseView.rules().enabled(featureFlowSortStrands))
|
|
||||||
return !best || offersConsidered >= maxOffersToConsider;
|
|
||||||
return !best;
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (best)
|
if (best)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,32 @@
|
|||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
|
using FunctionType = std::function<Expected<uint256, Json::Value>(
|
||||||
|
Json::Value const&,
|
||||||
|
Json::StaticString const,
|
||||||
|
unsigned apiVersion)>;
|
||||||
|
|
||||||
|
static Expected<uint256, Json::Value>
|
||||||
|
parseFixed(
|
||||||
|
Keylet const& keylet,
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const& fieldName,
|
||||||
|
unsigned apiVersion);
|
||||||
|
|
||||||
|
// Helper function to return FunctionType for objects that have a fixed
|
||||||
|
// location. That is, they don't take parameters to compute the index.
|
||||||
|
// e.g. amendments, fees, negative UNL, etc.
|
||||||
|
static FunctionType
|
||||||
|
fixed(Keylet const& keylet)
|
||||||
|
{
|
||||||
|
return [&keylet](
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion) -> Expected<uint256, Json::Value> {
|
||||||
|
return parseFixed(keylet, params, fieldName, apiVersion);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseObjectID(
|
parseObjectID(
|
||||||
Json::Value const& params,
|
Json::Value const& params,
|
||||||
@@ -33,13 +59,33 @@ parseObjectID(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseIndex(Json::Value const& params, Json::StaticString const fieldName)
|
parseIndex(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
|
if (apiVersion > 2u && params.isString())
|
||||||
|
{
|
||||||
|
std::string const index = params.asString();
|
||||||
|
if (index == jss::amendments.c_str())
|
||||||
|
return keylet::amendments().key;
|
||||||
|
if (index == jss::fee.c_str())
|
||||||
|
return keylet::fees().key;
|
||||||
|
if (index == jss::nunl)
|
||||||
|
return keylet::negativeUNL().key;
|
||||||
|
if (index == jss::hashes)
|
||||||
|
// Note this only finds the "short" skip list. Use "hashes":index to
|
||||||
|
// get the long list.
|
||||||
|
return keylet::skip().key;
|
||||||
|
}
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseAccountRoot(Json::Value const& params, Json::StaticString const fieldName)
|
parseAccountRoot(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (auto const account = LedgerEntryHelpers::parse<AccountID>(params))
|
if (auto const account = LedgerEntryHelpers::parse<AccountID>(params))
|
||||||
{
|
{
|
||||||
@@ -50,14 +96,13 @@ parseAccountRoot(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
"malformedAddress", fieldName, "AccountID");
|
"malformedAddress", fieldName, "AccountID");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
auto const parseAmendments = fixed(keylet::amendments());
|
||||||
parseAmendments(Json::Value const& params, Json::StaticString const fieldName)
|
|
||||||
{
|
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
|
||||||
}
|
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseAMM(Json::Value const& params, Json::StaticString const fieldName)
|
parseAMM(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -84,7 +129,10 @@ parseAMM(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseBridge(Json::Value const& params, Json::StaticString const fieldName)
|
parseBridge(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isMember(jss::bridge))
|
if (!params.isMember(jss::bridge))
|
||||||
{
|
{
|
||||||
@@ -115,13 +163,19 @@ parseBridge(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseCheck(Json::Value const& params, Json::StaticString const fieldName)
|
parseCheck(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseCredential(Json::Value const& cred, Json::StaticString const fieldName)
|
parseCredential(
|
||||||
|
Json::Value const& cred,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!cred.isObject())
|
if (!cred.isObject())
|
||||||
{
|
{
|
||||||
@@ -152,7 +206,10 @@ parseCredential(Json::Value const& cred, Json::StaticString const fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDelegate(Json::Value const& params, Json::StaticString const fieldName)
|
parseDelegate(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -243,7 +300,10 @@ parseAuthorizeCredentials(Json::Value const& jv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
|
parseDepositPreauth(
|
||||||
|
Json::Value const& dp,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!dp.isObject())
|
if (!dp.isObject())
|
||||||
{
|
{
|
||||||
@@ -296,7 +356,10 @@ parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDID(Json::Value const& params, Json::StaticString const fieldName)
|
parseDID(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
auto const account = LedgerEntryHelpers::parse<AccountID>(params);
|
auto const account = LedgerEntryHelpers::parse<AccountID>(params);
|
||||||
if (!account)
|
if (!account)
|
||||||
@@ -311,7 +374,8 @@ parseDID(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDirectoryNode(
|
parseDirectoryNode(
|
||||||
Json::Value const& params,
|
Json::Value const& params,
|
||||||
Json::StaticString const fieldName)
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -364,7 +428,10 @@ parseDirectoryNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseEscrow(Json::Value const& params, Json::StaticString const fieldName)
|
parseEscrow(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -383,20 +450,53 @@ parseEscrow(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
return keylet::escrow(*id, *seq).key;
|
return keylet::escrow(*id, *seq).key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto const parseFeeSettings = fixed(keylet::fees());
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseFeeSettings(Json::Value const& params, Json::StaticString const fieldName)
|
parseFixed(
|
||||||
|
Keylet const& keylet,
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const& fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
|
{
|
||||||
|
if (!params.isBool())
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
if (!params.asBool())
|
||||||
static Expected<uint256, Json::Value>
|
|
||||||
parseLedgerHashes(Json::Value const& params, Json::StaticString const fieldName)
|
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return LedgerEntryHelpers::invalidFieldError(
|
||||||
|
"invalidParams", fieldName, "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
return keylet.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseMPToken(Json::Value const& params, Json::StaticString const fieldName)
|
parseLedgerHashes(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
|
{
|
||||||
|
if (params.isUInt() || params.isInt())
|
||||||
|
{
|
||||||
|
// If the index doesn't parse as a UInt, throw
|
||||||
|
auto const index = params.asUInt();
|
||||||
|
|
||||||
|
// Return the "long" skip list for the given ledger index.
|
||||||
|
auto const keylet = keylet::skip(index);
|
||||||
|
return keylet.key;
|
||||||
|
}
|
||||||
|
// Return the key in `params` or the "short" skip list, which contains
|
||||||
|
// hashes since the last flag ledger.
|
||||||
|
return parseFixed(keylet::skip(), params, fieldName, apiVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Expected<uint256, Json::Value>
|
||||||
|
parseMPToken(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -419,7 +519,8 @@ parseMPToken(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseMPTokenIssuance(
|
parseMPTokenIssuance(
|
||||||
Json::Value const& params,
|
Json::Value const& params,
|
||||||
Json::StaticString const fieldName)
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
auto const mptIssuanceID = LedgerEntryHelpers::parse<uint192>(params);
|
auto const mptIssuanceID = LedgerEntryHelpers::parse<uint192>(params);
|
||||||
if (!mptIssuanceID)
|
if (!mptIssuanceID)
|
||||||
@@ -430,25 +531,30 @@ parseMPTokenIssuance(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseNFTokenOffer(Json::Value const& params, Json::StaticString const fieldName)
|
parseNFTokenOffer(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseNFTokenPage(Json::Value const& params, Json::StaticString const fieldName)
|
parseNFTokenPage(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
auto const parseNegativeUNL = fixed(keylet::negativeUNL());
|
||||||
parseNegativeUNL(Json::Value const& params, Json::StaticString const fieldName)
|
|
||||||
{
|
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
|
||||||
}
|
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseOffer(Json::Value const& params, Json::StaticString const fieldName)
|
parseOffer(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -469,7 +575,10 @@ parseOffer(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseOracle(Json::Value const& params, Json::StaticString const fieldName)
|
parseOracle(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -490,7 +599,10 @@ parseOracle(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parsePayChannel(Json::Value const& params, Json::StaticString const fieldName)
|
parsePayChannel(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
@@ -498,7 +610,8 @@ parsePayChannel(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parsePermissionedDomain(
|
parsePermissionedDomain(
|
||||||
Json::Value const& pd,
|
Json::Value const& pd,
|
||||||
Json::StaticString const fieldName)
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (pd.isString())
|
if (pd.isString())
|
||||||
{
|
{
|
||||||
@@ -527,7 +640,8 @@ parsePermissionedDomain(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseRippleState(
|
parseRippleState(
|
||||||
Json::Value const& jvRippleState,
|
Json::Value const& jvRippleState,
|
||||||
Json::StaticString const fieldName)
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
Currency uCurrency;
|
Currency uCurrency;
|
||||||
|
|
||||||
@@ -577,13 +691,19 @@ parseRippleState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseSignerList(Json::Value const& params, Json::StaticString const fieldName)
|
parseSignerList(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseTicket(Json::Value const& params, Json::StaticString const fieldName)
|
parseTicket(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -604,7 +724,10 @@ parseTicket(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseVault(Json::Value const& params, Json::StaticString const fieldName)
|
parseVault(
|
||||||
|
Json::Value const& params,
|
||||||
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -627,7 +750,8 @@ parseVault(Json::Value const& params, Json::StaticString const fieldName)
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseXChainOwnedClaimID(
|
parseXChainOwnedClaimID(
|
||||||
Json::Value const& claim_id,
|
Json::Value const& claim_id,
|
||||||
Json::StaticString const fieldName)
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!claim_id.isObject())
|
if (!claim_id.isObject())
|
||||||
{
|
{
|
||||||
@@ -652,7 +776,8 @@ parseXChainOwnedClaimID(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseXChainOwnedCreateAccountClaimID(
|
parseXChainOwnedCreateAccountClaimID(
|
||||||
Json::Value const& claim_id,
|
Json::Value const& claim_id,
|
||||||
Json::StaticString const fieldName)
|
Json::StaticString const fieldName,
|
||||||
|
unsigned apiVersion)
|
||||||
{
|
{
|
||||||
if (!claim_id.isObject())
|
if (!claim_id.isObject())
|
||||||
{
|
{
|
||||||
@@ -676,10 +801,6 @@ parseXChainOwnedCreateAccountClaimID(
|
|||||||
return keylet.key;
|
return keylet.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
using FunctionType = Expected<uint256, Json::Value> (*)(
|
|
||||||
Json::Value const&,
|
|
||||||
Json::StaticString const);
|
|
||||||
|
|
||||||
struct LedgerEntry
|
struct LedgerEntry
|
||||||
{
|
{
|
||||||
Json::StaticString fieldName;
|
Json::StaticString fieldName;
|
||||||
@@ -712,7 +833,7 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
{jss::ripple_state, parseRippleState, ltRIPPLE_STATE},
|
{jss::ripple_state, parseRippleState, ltRIPPLE_STATE},
|
||||||
});
|
});
|
||||||
|
|
||||||
auto hasMoreThanOneMember = [&]() {
|
auto const hasMoreThanOneMember = [&]() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (auto const& ledgerEntry : ledgerEntryParsers)
|
for (auto const& ledgerEntry : ledgerEntryParsers)
|
||||||
@@ -756,8 +877,8 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
Json::Value const& params = ledgerEntry.fieldName == jss::bridge
|
Json::Value const& params = ledgerEntry.fieldName == jss::bridge
|
||||||
? context.params
|
? context.params
|
||||||
: context.params[ledgerEntry.fieldName];
|
: context.params[ledgerEntry.fieldName];
|
||||||
auto const result =
|
auto const result = ledgerEntry.parseFunction(
|
||||||
ledgerEntry.parseFunction(params, ledgerEntry.fieldName);
|
params, ledgerEntry.fieldName, context.apiVersion);
|
||||||
if (!result)
|
if (!result)
|
||||||
return result.error();
|
return result.error();
|
||||||
|
|
||||||
@@ -788,9 +909,13 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the computed index regardless of whether the node exists.
|
||||||
|
jvResult[jss::index] = to_string(uNodeIndex);
|
||||||
|
|
||||||
if (uNodeIndex.isZero())
|
if (uNodeIndex.isZero())
|
||||||
{
|
{
|
||||||
return RPC::make_error(rpcENTRY_NOT_FOUND);
|
RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
|
||||||
|
return jvResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const sleNode = lpLedger->read(keylet::unchecked(uNodeIndex));
|
auto const sleNode = lpLedger->read(keylet::unchecked(uNodeIndex));
|
||||||
@@ -802,12 +927,14 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
if (!sleNode)
|
if (!sleNode)
|
||||||
{
|
{
|
||||||
// Not found.
|
// Not found.
|
||||||
return RPC::make_error(rpcENTRY_NOT_FOUND);
|
RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
|
||||||
|
return jvResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((expectedType != ltANY) && (expectedType != sleNode->getType()))
|
if ((expectedType != ltANY) && (expectedType != sleNode->getType()))
|
||||||
{
|
{
|
||||||
return RPC::make_error(rpcUNEXPECTED_LEDGER_TYPE);
|
RPC::inject_error(rpcUNEXPECTED_LEDGER_TYPE, jvResult);
|
||||||
|
return jvResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bNodeBinary)
|
if (bNodeBinary)
|
||||||
@@ -817,12 +944,10 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
sleNode->add(s);
|
sleNode->add(s);
|
||||||
|
|
||||||
jvResult[jss::node_binary] = strHex(s.peekData());
|
jvResult[jss::node_binary] = strHex(s.peekData());
|
||||||
jvResult[jss::index] = to_string(uNodeIndex);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jvResult[jss::node] = sleNode->getJson(JsonOptions::none);
|
jvResult[jss::node] = sleNode->getJson(JsonOptions::none);
|
||||||
jvResult[jss::index] = to_string(uNodeIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return jvResult;
|
return jvResult;
|
||||||
|
|||||||
Reference in New Issue
Block a user