Compare commits

...

25 Commits

Author SHA1 Message Date
Denis Angell
4d130bd9f7 misc 2024-07-10 20:21:15 +02:00
Denis Angell
9d4ee7cff5 fix h error 2024-07-10 13:16:47 +02:00
Denis Angell
51541cd95a add index 2024-07-10 13:16:38 +02:00
Denis Angell
b9628271a4 update template 2024-07-10 13:16:08 +02:00
Denis Angell
90405f728c update template 2024-07-10 12:35:21 +02:00
Denis Angell
2220f65cb2 new feature template 2024-07-10 12:18:53 +02:00
Denis Angell
77f9415e51 Update loops.txt 2024-07-08 11:25:36 +02:00
Denis Angell
fa7406fe1e add header includes 2024-07-08 11:22:17 +02:00
Denis Angell
84eee588d3 Merge branch 'dev' into strict-builds 2024-06-05 12:17:36 +02:00
Denis Angell
03569dbb11 add correct imports 2024-05-14 12:03:07 +02:00
Denis Angell
cb77121e20 Merge branch 'dev' into strict-builds 2024-05-06 12:14:05 +02:00
Denis Angell
c55a97c51a Update STValidation.h 2024-03-25 09:27:17 +01:00
Denis Angell
fc0be9c416 Merge branch 'dev' into strict-builds 2024-03-25 09:13:55 +01:00
Denis Angell
aaccf9b5b2 revert remove json log 2024-03-25 09:12:55 +01:00
Denis Angell
17af075665 revert remove json log 2024-03-25 09:12:33 +01:00
Denis Angell
e6b362c832 Merge branch 'dev' into strict-builds 2024-03-22 13:38:51 +01:00
Denis Angell
5b2b915955 clang-format 2024-03-18 14:57:35 +01:00
Denis Angell
e801ead39d fix more headers 2024-03-18 14:52:00 +01:00
Denis Angell
78a96dd633 add missing headers 2024-03-18 13:17:10 +01:00
Denis Angell
b3984c166d misc 2024-03-18 13:13:09 +01:00
Denis Angell
945f737706 Update ServerInfo.cpp 2024-03-18 13:09:01 +01:00
Denis Angell
8360ff8bc2 more linting 2024-03-18 13:03:05 +01:00
Denis Angell
c1274d2a12 Update ServerDefinitions_test.cpp 2024-03-18 13:02:03 +01:00
Denis Angell
4aa79b6100 Update ClaimReward_test.cpp 2024-03-18 12:59:05 +01:00
Denis Angell
6a4c563ced fix
invalid operands to binary expression ('basic_ostream<char, std::char_traits<char>>' and 'Json::Value')
2024-03-18 12:38:25 +01:00
44 changed files with 401 additions and 132 deletions

View File

@@ -3,7 +3,7 @@
"C_Cpp.clang_format_path": ".clang-format",
"C_Cpp.clang_format_fallbackStyle": "{ ColumnLimit: 0 }",
"[cpp]":{
"editor.wordBasedSuggestions": false,
"editor.wordBasedSuggestions": "off",
"editor.suggest.insertMode": "replace",
"editor.semanticHighlighting.enabled": true,
"editor.tabSize": 4,

View File

@@ -433,13 +433,17 @@ target_sources (rippled PRIVATE
src/ripple/app/tx/impl/CancelOffer.cpp
src/ripple/app/tx/impl/CashCheck.cpp
src/ripple/app/tx/impl/Change.cpp
src/ripple/app/tx/impl/ClaimReward.cpp
src/ripple/app/tx/impl/CreateCheck.cpp
src/ripple/app/tx/impl/CreateOffer.cpp
src/ripple/app/tx/impl/CreateTicket.cpp
src/ripple/app/tx/impl/DeleteAccount.cpp
src/ripple/app/tx/impl/DepositPreauth.cpp
src/ripple/app/tx/impl/Escrow.cpp
src/ripple/app/tx/impl/GenesisMint.cpp
src/ripple/app/tx/impl/Import.cpp
src/ripple/app/tx/impl/InvariantCheck.cpp
src/ripple/app/tx/impl/Invoke.cpp
src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp
src/ripple/app/tx/impl/NFTokenBurn.cpp
src/ripple/app/tx/impl/NFTokenCancelOffer.cpp
@@ -448,14 +452,11 @@ target_sources (rippled PRIVATE
src/ripple/app/tx/impl/OfferStream.cpp
src/ripple/app/tx/impl/PayChan.cpp
src/ripple/app/tx/impl/Payment.cpp
src/ripple/app/tx/impl/SetAccount.cpp
src/ripple/app/tx/impl/SetRegularKey.cpp
src/ripple/app/tx/impl/SetHook.cpp
src/ripple/app/tx/impl/ClaimReward.cpp
src/ripple/app/tx/impl/GenesisMint.cpp
src/ripple/app/tx/impl/Import.cpp
src/ripple/app/tx/impl/Invoke.cpp
src/ripple/app/tx/impl/Remit.cpp
src/ripple/app/tx/impl/SetAccount.cpp
src/ripple/app/tx/impl/SetHook.cpp
src/ripple/app/tx/impl/SetHookDefinition.cpp
src/ripple/app/tx/impl/SetRegularKey.cpp
src/ripple/app/tx/impl/SetSignerList.cpp
src/ripple/app/tx/impl/SetTrust.cpp
src/ripple/app/tx/impl/SignerEntries.cpp
@@ -757,6 +758,7 @@ if (tests)
src/test/app/ValidatorList_test.cpp
src/test/app/ValidatorSite_test.cpp
src/test/app/SetHook_test.cpp
src/test/app/SetHookDefinition_test.cpp
src/test/app/SetHookTSH_test.cpp
src/test/app/Wildcard_test.cpp
src/test/app/XahauGenesis_test.cpp

View File

@@ -53,7 +53,7 @@ Loop: test.app test.jtx
test.app > test.jtx
Loop: test.app test.rpc
test.rpc == test.app
test.rpc ~= test.app
Loop: test.jtx test.toplevel
test.toplevel > test.jtx

View File

@@ -19,6 +19,7 @@ enum HookSetFlags : uint8_t {
hsfOVERRIDE = 0b00000001U, // override or delete hook
hsfNSDELETE = 0b00000010U, // delete namespace
hsfCOLLECT = 0b00000100U, // allow collect calls on this hook
hsfMUTALBE = 0b00001000U, // allow mutable hook definition
};
enum HookEmissionFlags : uint16_t {

View File

@@ -1,12 +1,17 @@
#include <ripple/app/hook/applyHook.h>
#include <ripple/app/ledger/OpenLedger.h>
#include <ripple/app/ledger/TransactionMaster.h>
#include <ripple/app/misc/HashRouter.h>
#include <ripple/app/misc/NetworkOPs.h>
#include <ripple/app/misc/Transaction.h>
#include <ripple/app/misc/TxQ.h>
#include <ripple/app/tx/impl/Import.h>
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/Slice.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/protocol/st.h>
#include <ripple/protocol/tokens.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <any>

View File

@@ -19,7 +19,9 @@
#include <ripple/app/consensus/RCLValidations.h>
#include <ripple/app/ledger/Ledger.h>
#include <ripple/app/main/Application.h>
#include <ripple/app/misc/NegativeUNLVote.h>
#include <ripple/json/to_string.h>
namespace ripple {

View File

@@ -23,6 +23,7 @@
#include <ripple/ledger/View.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/st.h>
namespace ripple {

View File

@@ -24,12 +24,15 @@
#include <ripple/basics/base64.h>
#include <ripple/json/json_reader.h>
#include <ripple/json/json_value.h>
#include <ripple/json/to_string.h>
#include <ripple/ledger/View.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/Import.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/PublicKey.h>
#include <ripple/protocol/STTx.h>
#include <ripple/protocol/STValidation.h>
#include <ripple/protocol/st.h>
#include <algorithm>
#include <charconv>
#include <iostream>

View File

@@ -22,6 +22,7 @@
#include <ripple/ledger/View.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/st.h>
namespace ripple {

View File

@@ -23,6 +23,9 @@
#include <ripple/ledger/View.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/protocol/st.h>
namespace ripple {
TxConsequences

View File

@@ -0,0 +1,105 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/app/tx/impl/SetHookDefinition.h>
#include <ripple/basics/Log.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/TxFlags.h>
namespace ripple {
XRPAmount
SetHookDefinition::calculateBaseFee(ReadView const& view, STTx const& tx)
{
return Transactor::calculateBaseFee(view, tx);
}
NotTEC
SetHookDefinition::preflight(PreflightContext const& ctx)
{
// if (!ctx.rules.enabled(featureHooksUpdate2))
// return temDISABLED;
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
return ret;
return preflight2(ctx);
}
TER
SetHookDefinition::preclaim(PreclaimContext const& ctx)
{
// if (!ctx.view.rules().enabled(featureHooksUpdate2))
// return temDISABLED;
return tesSUCCESS;
}
TER
SetHookDefinition::doApply()
{
auto j = ctx_.app.journal("View");
Sandbox sb(&ctx_.view());
auto const sle = sb.read(keylet::account(account_));
if (!sle)
return tefINTERNAL;
ripple::Blob wasmBytes = ctx_.tx.getFieldVL(sfCreateCode);
if (wasmBytes.size() > hook::maxHookWasmSize())
{
JLOG(j.warn()) << "Malformed transaction: SetHookDefinition operation "
"would create blob larger than max";
return tecINTERNAL;
}
auto const createHookHash =
ripple::sha512Half_s(ripple::Slice(wasmBytes.data(), wasmBytes.size()));
Keylet keylet = ripple::keylet::hookDefinition(
account_, ctx_.tx.getFieldU32(sfSequence));
auto newHookDef = std::make_shared<SLE>(keylet);
newHookDef->setFieldH256(sfHookHash, createHookHash);
newHookDef->setAccountID(sfOwner, account_);
newHookDef->setFieldH256(sfHookOn, ctx_.tx.getFieldH256(sfHookOn));
newHookDef->setFieldH256(sfHookNamespace, ctx_.tx.getFieldH256(sfHookOn));
newHookDef->setFieldArray(
sfHookParameters,
ctx_.tx.isFieldPresent(sfHookParameters)
? ctx_.tx.getFieldArray(sfHookParameters)
: STArray{});
newHookDef->setFieldU16(
sfHookApiVersion, ctx_.tx.getFieldU16(sfHookApiVersion));
newHookDef->setFieldVL(sfCreateCode, wasmBytes);
newHookDef->setFieldH256(sfHookSetTxnID, ctx_.tx.getTransactionID());
newHookDef->setFieldU64(sfReferenceCount, 0);
newHookDef->setFieldU32(sfFlags, hsfMUTALBE);
if (ctx_.tx.isFieldPresent(sfHookGrants))
{
auto const& grants = ctx_.tx.getFieldArray(sfHookGrants);
if (!grants.empty())
newHookDef->setFieldArray(sfHookGrants, grants);
}
sb.update(newHookDef);
sb.apply(ctx_.rawView());
return tesSUCCESS;
}
} // namespace ripple

View File

@@ -0,0 +1,54 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_TX_SETHOOKDEFINITION_H_INCLUDED
#define RIPPLE_TX_SETHOOKDEFINITION_H_INCLUDED
#include <ripple/app/tx/impl/Transactor.h>
#include <ripple/basics/Log.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/protocol/UintTypes.h>
namespace ripple {
class SetHookDefinition : public Transactor
{
public:
static constexpr ConsequencesFactoryType ConsequencesFactory{Blocker};
explicit SetHookDefinition(ApplyContext& ctx) : Transactor(ctx)
{
}
static XRPAmount
calculateBaseFee(ReadView const& view, STTx const& tx);
static NotTEC
preflight(PreflightContext const& ctx);
static TER
preclaim(PreclaimContext const& ctx);
TER
doApply() override;
};
} // namespace ripple
#endif

View File

@@ -153,8 +153,10 @@ SetSignerList::preCompute()
// NOTE: This way of computing the OwnerCount associated with a SignerList
// is valid until the featureMultiSignReserve amendment passes. Once it
// passes then just 1 OwnerCount is associated with a SignerList.
static int
signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules)
int
SetSignerList::signerCountBasedOwnerCountDelta(
std::size_t entryCount,
Rules const& rules)
{
// We always compute the full change in OwnerCount, taking into account:
// o The fact that we're adding/removing a SignerList and
@@ -176,8 +178,8 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules)
return 2 + static_cast<int>(entryCount);
}
static TER
removeSignersFromLedger(
TER
SetSignerList::removeSignersFromLedger(
Application& app,
ApplyView& view,
Keylet const& accountKeylet,

View File

@@ -71,6 +71,18 @@ public:
AccountID const& account,
beast::Journal j);
static TER
removeSignersFromLedger(
Application& app,
ApplyView& view,
Keylet const& accountKeylet,
Keylet const& ownerDirKeylet,
Keylet const& signerListKeylet,
beast::Journal j);
static int
signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules);
private:
static void
writeSignersToSLE(

View File

@@ -23,6 +23,7 @@
#include <ripple/app/tx/impl/CancelOffer.h>
#include <ripple/app/tx/impl/CashCheck.h>
#include <ripple/app/tx/impl/Change.h>
#include <ripple/app/tx/impl/ClaimReward.h>
#include <ripple/app/tx/impl/CreateCheck.h>
#include <ripple/app/tx/impl/CreateOffer.h>
#include <ripple/app/tx/impl/CreateTicket.h>
@@ -39,12 +40,15 @@
#include <ripple/app/tx/impl/NFTokenMint.h>
#include <ripple/app/tx/impl/PayChan.h>
#include <ripple/app/tx/impl/Payment.h>
#include <ripple/app/tx/impl/Remit.h>
#include <ripple/app/tx/impl/SetAccount.h>
#include <ripple/app/tx/impl/SetHook.h>
#include <ripple/app/tx/impl/SetHookDefinition.h>
#include <ripple/app/tx/impl/SetRegularKey.h>
#include <ripple/app/tx/impl/SetSignerList.h>
#include <ripple/app/tx/impl/SetTrust.h>
#include <ripple/app/tx/impl/URIToken.h>
#include <ripple/app/tx/impl/XahauGenesis.h>
namespace ripple {
@@ -172,6 +176,8 @@ invoke_preflight(PreflightContext const& ctx)
case ttURITOKEN_CREATE_SELL_OFFER:
case ttURITOKEN_CANCEL_SELL_OFFER:
return invoke_preflight_helper<URIToken>(ctx);
case ttHOOK_SET_DEFINITION:
return invoke_preflight_helper<SetHookDefinition>(ctx);
default:
assert(false);
return {temUNKNOWN, TxConsequences{temUNKNOWN}};
@@ -293,6 +299,8 @@ invoke_preclaim(PreclaimContext const& ctx)
case ttURITOKEN_CREATE_SELL_OFFER:
case ttURITOKEN_CANCEL_SELL_OFFER:
return invoke_preclaim<URIToken>(ctx);
case ttHOOK_SET_DEFINITION:
return invoke_preclaim<SetHookDefinition>(ctx);
default:
assert(false);
return temUNKNOWN;
@@ -376,6 +384,8 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx)
case ttURITOKEN_CREATE_SELL_OFFER:
case ttURITOKEN_CANCEL_SELL_OFFER:
return URIToken::calculateBaseFee(view, tx);
case ttHOOK_SET_DEFINITION:
return SetHookDefinition::calculateBaseFee(view, tx);
default:
return XRPAmount{0};
}
@@ -561,6 +571,10 @@ invoke_apply(ApplyContext& ctx)
URIToken p(ctx);
return p();
}
case ttHOOK_SET_DEFINITION: {
SetHookDefinition p(ctx);
return p();
}
default:
assert(false);
return {temUNKNOWN, false};

View File

@@ -30,7 +30,7 @@ mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div)
{
using namespace boost::multiprecision;
uint128_t result;
boost::multiprecision::uint128_t result;
result = multiply(result, value, mul);
result /= div;

View File

@@ -145,111 +145,78 @@ private:
};
// VFALCO TODO This should only be enabled for maps.
class pair_value_compare
: public beast::detail::empty_base_optimization<Compare>
#ifdef _LIBCPP_VERSION
,
public std::binary_function<value_type, value_type, bool>
#endif
class pair_value_compare : public Compare
{
public:
#ifndef _LIBCPP_VERSION
using first_argument = value_type;
using second_argument = value_type;
using result_type = bool;
#endif
bool
operator()(value_type const& lhs, value_type const& rhs) const
{
return this->member()(lhs.first, rhs.first);
return Compare::operator()(lhs.first, rhs.first);
}
pair_value_compare()
{
}
pair_value_compare(pair_value_compare const& other)
: beast::detail::empty_base_optimization<Compare>(other)
pair_value_compare(pair_value_compare const& other) : Compare(other)
{
}
private:
friend aged_ordered_container;
pair_value_compare(Compare const& compare)
: beast::detail::empty_base_optimization<Compare>(compare)
pair_value_compare(Compare const& compare) : Compare(compare)
{
}
};
// Compares value_type against element, used in insert_check
// VFALCO TODO hoist to remove template argument dependencies
class KeyValueCompare
: public beast::detail::empty_base_optimization<Compare>
#ifdef _LIBCPP_VERSION
,
public std::binary_function<Key, element, bool>
#endif
class KeyValueCompare : public Compare
{
public:
#ifndef _LIBCPP_VERSION
using first_argument = Key;
using second_argument = element;
using result_type = bool;
#endif
KeyValueCompare() = default;
KeyValueCompare(Compare const& compare)
: beast::detail::empty_base_optimization<Compare>(compare)
KeyValueCompare(Compare const& compare) : Compare(compare)
{
}
// VFALCO NOTE WE might want only to enable these overloads
// if Compare has is_transparent
#if 0
template <class K>
bool operator() (K const& k, element const& e) const
{
return this->member() (k, extract (e.value));
}
template <class K>
bool operator() (element const& e, K const& k) const
{
return this->member() (extract (e.value), k);
}
#endif
bool
operator()(Key const& k, element const& e) const
{
return this->member()(k, extract(e.value));
return Compare::operator()(k, extract(e.value));
}
bool
operator()(element const& e, Key const& k) const
{
return this->member()(extract(e.value), k);
return Compare::operator()(extract(e.value), k);
}
bool
operator()(element const& x, element const& y) const
{
return this->member()(extract(x.value), extract(y.value));
return Compare::operator()(extract(x.value), extract(y.value));
}
Compare&
compare()
{
return beast::detail::empty_base_optimization<Compare>::member();
return *this;
}
Compare const&
compare() const
{
return beast::detail::empty_base_optimization<Compare>::member();
return *this;
}
};

View File

@@ -148,115 +148,84 @@ private:
};
// VFALCO TODO hoist to remove template argument dependencies
class ValueHash : private beast::detail::empty_base_optimization<Hash>
#ifdef _LIBCPP_VERSION
,
public std::unary_function<element, std::size_t>
#endif
class ValueHash : public Hash
{
public:
#ifndef _LIBCPP_VERSION
using argument_type = element;
using result_type = size_t;
#endif
ValueHash()
{
}
ValueHash(Hash const& h)
: beast::detail::empty_base_optimization<Hash>(h)
ValueHash(Hash const& h) : Hash(h)
{
}
std::size_t
operator()(element const& e) const
{
return this->member()(extract(e.value));
return Hash::operator()(extract(e.value));
}
Hash&
hash_function()
{
return this->member();
return *this;
}
Hash const&
hash_function() const
{
return this->member();
return *this;
}
};
// Compares value_type against element, used in find/insert_check
// VFALCO TODO hoist to remove template argument dependencies
class KeyValueEqual
: private beast::detail::empty_base_optimization<KeyEqual>
#ifdef _LIBCPP_VERSION
,
public std::binary_function<Key, element, bool>
#endif
class KeyValueEqual : public KeyEqual
{
public:
#ifndef _LIBCPP_VERSION
using first_argument_type = Key;
using second_argument_type = element;
using result_type = bool;
#endif
KeyValueEqual()
{
}
KeyValueEqual(KeyEqual const& keyEqual)
: beast::detail::empty_base_optimization<KeyEqual>(keyEqual)
KeyValueEqual(KeyEqual const& keyEqual) : KeyEqual(keyEqual)
{
}
// VFALCO NOTE WE might want only to enable these overloads
// if KeyEqual has is_transparent
#if 0
template <class K>
bool operator() (K const& k, element const& e) const
{
return this->member() (k, extract (e.value));
}
template <class K>
bool operator() (element const& e, K const& k) const
{
return this->member() (extract (e.value), k);
}
#endif
bool
operator()(Key const& k, element const& e) const
{
return this->member()(k, extract(e.value));
return KeyEqual::operator()(k, extract(e.value));
}
bool
operator()(element const& e, Key const& k) const
{
return this->member()(extract(e.value), k);
return KeyEqual::operator()(extract(e.value), k);
}
bool
operator()(element const& lhs, element const& rhs) const
{
return this->member()(extract(lhs.value), extract(rhs.value));
return KeyEqual::operator()(extract(lhs.value), extract(rhs.value));
}
KeyEqual&
key_eq()
{
return this->member();
return *this;
}
KeyEqual const&
key_eq() const
{
return this->member();
return *this;
}
};

View File

@@ -19,6 +19,7 @@
#include <ripple/basics/contract.h>
#include <ripple/ledger/detail/ApplyViewBase.h>
#include <ripple/protocol/STAccount.h>
namespace ripple {
namespace detail {

View File

@@ -91,17 +91,10 @@ private:
using value_type = map_type::value_type;
struct Transform
#ifdef _LIBCPP_VERSION
: std::unary_function<
map_type::right_map::const_iterator::value_type const&,
beast::IP::Endpoint const&>
#endif
{
#ifndef _LIBCPP_VERSION
using first_argument_type =
map_type::right_map::const_iterator::value_type const&;
using result_type = beast::IP::Endpoint const&;
#endif
explicit Transform() = default;

View File

@@ -69,14 +69,9 @@ public:
public:
// Iterator transformation to extract the endpoint from Element
struct Transform
#ifdef _LIBCPP_VERSION
: public std::unary_function<Element, Endpoint>
#endif
{
#ifndef _LIBCPP_VERSION
using first_argument = Element;
using result_type = Endpoint;
#endif
explicit Transform() = default;
@@ -239,15 +234,9 @@ public:
template <bool IsConst>
struct Transform
#ifdef _LIBCPP_VERSION
: public std::
unary_function<typename lists_type::value_type, Hop<IsConst>>
#endif
{
#ifndef _LIBCPP_VERSION
using first_argument = typename lists_type::value_type;
using result_type = Hop<IsConst>;
#endif
explicit Transform() = default;

View File

@@ -74,7 +74,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 70;
static constexpr std::size_t numFeatures = 71;
/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
@@ -358,6 +358,7 @@ extern uint256 const fixXahauV2;
extern uint256 const featureRemit;
extern uint256 const featureZeroB2M;
extern uint256 const fixNSDelete;
extern uint256 const featureHooksUpdate2;
} // namespace ripple

View File

@@ -62,6 +62,9 @@ emittedTxn(uint256 const& id) noexcept;
Keylet
hookDefinition(uint256 const& hash) noexcept;
Keylet
hookDefinition(AccountID const& account, std::uint32_t seq) noexcept;
Keylet
hook(AccountID const& id) noexcept;

View File

@@ -185,6 +185,7 @@ enum TxType : std::uint16_t
ttUNL_MODIFY = 102,
ttEMIT_FAILURE = 103,
ttUNL_REPORT = 104,
ttHOOK_SET_DEFINITION = 105,
};
// clang-format on

View File

@@ -464,6 +464,7 @@ REGISTER_FIX (fixXahauV2, Supported::yes, VoteBehavior::De
REGISTER_FEATURE(Remit, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(ZeroB2M, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixNSDelete, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (HooksUpdate2, Supported::yes, VoteBehavior::DefaultNo);
// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.

View File

@@ -171,6 +171,13 @@ hookDefinition(uint256 const& hash) noexcept
ltHOOK_DEFINITION, indexHash(LedgerNameSpace::HOOK_DEFINITION, hash)};
}
Keylet
hookDefinition(AccountID const& account, std::uint32_t seq) noexcept
{
return {
ltHOOK_DEFINITION, indexHash(LedgerNameSpace::HOOK_DEFINITION, account, seq)};
}
Keylet
hookState(AccountID const& id, uint256 const& key, uint256 const& ns) noexcept
{

View File

@@ -90,7 +90,8 @@ InnerObjectFormats::InnerObjectFormats()
{sfHookOn, soeREQUIRED},
{sfHookApiVersion, soeREQUIRED},
{sfFlags, soeREQUIRED},
{sfFee, soeREQUIRED}});
{sfFee, soeREQUIRED},
{sfOwner, soeOPTIONAL}});
add(sfHook.jsonName.c_str(),
sfHook.getCode(),

View File

@@ -456,6 +456,19 @@ TxFormats::TxFormats()
{sfTicketSequence, soeOPTIONAL},
},
commonFields);
add(jss::SetHookDefinition,
ttHOOK_SET_DEFINITION,
{
{sfCreateCode, soeREQUIRED},
{sfHookNamespace, soeREQUIRED},
{sfHookParameters, soeOPTIONAL},
{sfHookGrants, soeOPTIONAL},
{sfHookOn, soeREQUIRED},
{sfHookApiVersion, soeREQUIRED},
{sfFlags, soeREQUIRED},
},
commonFields);
}
TxFormats const&

View File

@@ -129,6 +129,7 @@ JSS(Sequence); // in/out: TransactionSign; field.
JSS(SetFlag); // field.
JSS(SetRegularKey); // transaction type.
JSS(SetHook); // transaction type.
JSS(SetHookDefinition); // transaction type.
JSS(Hook); // ledger type.
JSS(HookDefinition); // ledger type.
JSS(HookState); // ledger type.

View File

@@ -19,6 +19,7 @@
#include <ripple/app/main/Application.h>
#include <ripple/app/misc/NetworkOPs.h>
#include <ripple/app/reporting/P2pProxy.h>
#include <ripple/protocol/jss.h>
#include <ripple/rpc/Context.h>
#include <ripple/rpc/Role.h>

View File

@@ -398,7 +398,7 @@ SHAMapInnerNode::canonicalizeChild(
void
SHAMapInnerNode::invariants(bool is_root) const
{
unsigned count = 0;
[[maybe_unused]] unsigned count = 0;
auto [numAllocated, hashes, children] =
hashesAndChildren_.getHashesAndChildren();

View File

@@ -17,7 +17,9 @@
*/
//==============================================================================
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/jss.h>
#include <test/jtx.h>
namespace ripple {

View File

@@ -15,8 +15,8 @@
*/
//==============================================================================
#include <ripple/app/tx/impl/XahauGenesis.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/jss.h>
#include <optional>
#include <test/jtx.h>
@@ -94,7 +94,7 @@ struct GenesisMint_test : public beast::unit_test::suite
using namespace jtx;
using namespace std::literals::chrono_literals;
Env env{*this, envconfig(), features, nullptr};
Env env{*this, envconfig(), features};
auto const alice = Account("alice");
auto const bob = Account("bob");
auto const invoker = Account("invoker");
@@ -133,11 +133,7 @@ struct GenesisMint_test : public beast::unit_test::suite
using namespace jtx;
using namespace std::literals::chrono_literals;
Env env{*this, envconfig(), features, nullptr};
// Env env{*this, envconfig(), features, nullptr,
// // beast::severities::kWarning
// beast::severities::kTrace
// };
Env env{*this, envconfig(), features};
auto const alice = Account("alice");
auto const bob = Account("bob");
auto const invoker = Account("invoker");
@@ -639,7 +635,7 @@ struct GenesisMint_test : public beast::unit_test::suite
using namespace jtx;
using namespace std::literals::chrono_literals;
Env env{*this, envconfig(), features, nullptr};
Env env{*this, envconfig(), features};
auto const alice = Account("alice");
auto const bob = Account("bob");
env.fund(XRP(10000), alice, bob);
@@ -661,7 +657,7 @@ struct GenesisMint_test : public beast::unit_test::suite
using namespace jtx;
using namespace std::literals::chrono_literals;
Env env{*this, envconfig(), features, nullptr};
Env env{*this, envconfig(), features};
auto const alice = Account("alice");
auto const bob = Account("bob");
env.fund(XRP(10000), alice, bob);

View File

@@ -17,6 +17,7 @@
*/
//==============================================================================
#include <ripple/protocol/jss.h>
#include <test/jtx.h>
namespace ripple {

View File

@@ -2132,7 +2132,6 @@ struct Remit_test : public beast::unit_test::suite
auto const delta = USD(100);
env(remit::remit(alice, bob), remit::amts({delta}));
env.close();
auto xferRate = transferRate(*env.current(), gw);
auto const postAlice = env.balance(alice, USD.issue());
BEAST_EXPECT(env.balance(bob, USD.issue()) == preBob + delta);
BEAST_EXPECT(to_string(postAlice.value()) == tc.result);

View File

@@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2016 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/core/ConfigSections.h>
#include <ripple/ledger/Directory.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/jss.h>
#include <test/jtx.h>
namespace ripple {
namespace test {
struct SetHookDefinition_test : public beast::unit_test::suite
{
Json::Value
setDefinition(jtx::Account const& account, std::string const& hex)
{
using namespace jtx;
Json::Value jv;
jv[jss::TransactionType] = jss::SetHookDefinition;
jv[jss::Account] = account.human();
jv[jss::CreateCode] = hex;
jv[sfHookNamespace.jsonName] = "0000000000000000000000000000000000000000000000000000000000000000";
jv[sfHookOn.jsonName] = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFFFBFFFFF";
jv[sfHookApiVersion.jsonName] = 0;
jv[sfFlags.jsonName] = hsfMUTALBE;
return jv;
}
void
testEnabled()
{
using namespace test::jtx;
testcase("Enabled");
Account const alice = Account("alice");
for (bool const withFeature : {false, true})
{
// auto const amend = withFeature ? features : features - featureHooksUpdate2;
Env env{*this};
env.fund(XRP(1000), alice);
env.close();
// std::string const createCodeHex =
// "0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F"
// "017F60017F017E02250303656E76057472616365000003656E7608726F6C6C"
// "6261636B000103656E76025F670002030201030503010002062B077F0141C0"
// "88040B7F004180080B7F0041BE080B7F004180080B7F0041C088040B7F0041"
// "000B7F0041010B07080104686F6F6B00030AC3800001BF800001017F230041"
// "106B220124002001200036020C41940841154180084114410010001A41AA08"
// "4114420A10011A41012200200010021A200141106A240042000B0B44010041"
// "80080B3D526F6C6C6261636B2E633A2043616C6C65642E0022526F6C6C6261"
// "636B2E633A2043616C6C65642E2200526F6C6C6261636B3A20526F6C6C6261"
// "636B21";
// strHex(wasmBytes)
// auto const txResult = withFeature ? ter(tesSUCCESS) : ter(temDISABLED);
// env(setDefinition(alice, createCodeHex), fee(10), txResult);
// env.close();
// Json::Value jvParams;
// jvParams[jss::index] = "ledgerHash";
// Json::Value const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
}
}
// void
// testWithFeats(FeatureBitset features)
// {
// testEnabled(features);
// }
public:
void
run() override
{
using namespace test::jtx;
// auto const sa = supported_amendments();
// testWithFeats(sa);
testEnabled();
}
};
BEAST_DEFINE_TESTSUITE(SetHookDefinition, app, ripple);
} // namespace test
} // namespace ripple

View File

@@ -18,6 +18,7 @@
*/
//==============================================================================
#include <ripple/app/hook/Enum.h>
#include <ripple/app/misc/HashRouter.h>
#include <ripple/app/misc/TxQ.h>
#include <ripple/app/tx/apply.h>
@@ -31,6 +32,13 @@
namespace ripple {
namespace test {
#define BEAST_REQUIRE(x) \
{ \
BEAST_EXPECT(!!(x)); \
if (!(x)) \
return; \
}
struct SetHookTSH_test : public beast::unit_test::suite
{
private:

View File

@@ -17,6 +17,7 @@
*/
//==============================================================================
#include <ripple/protocol/jss.h>
#include <test/jtx/Env.h>
#include <test/jtx/acctdelete.h>

View File

@@ -17,6 +17,7 @@
*/
//==============================================================================
#include <ripple/protocol/TxFlags.h>
#include <ripple/protocol/jss.h>
#include <test/jtx/escrow.h>

View File

@@ -17,6 +17,7 @@
*/
//==============================================================================
#include <ripple/basics/StringUtilities.h>
#include <ripple/json/json_reader.h>
#include <ripple/json/json_writer.h>
#include <ripple/protocol/Feature.h>

View File

@@ -17,6 +17,7 @@
*/
//==============================================================================
#include <ripple/protocol/TxFlags.h>
#include <ripple/protocol/jss.h>
#include <test/jtx/paychan.h>

View File

@@ -23,6 +23,7 @@
#include <ripple/json/json_value.h>
#include <ripple/protocol/STAmount.h>
#include <test/jtx/Account.h>
#include <test/jtx/Env.h>
namespace ripple {
namespace test {

View File

@@ -24,6 +24,7 @@
#include <ripple/beast/unit_test.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/jss.h>
#include <test/app/Import_json.h>
#include <test/jtx.h>
namespace ripple {

View File

@@ -19,6 +19,7 @@
#include <ripple/app/misc/AmendmentTable.h>
#include <ripple/beast/unit_test.h>
#include <ripple/json/json_reader.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/jss.h>
#include <test/jtx.h>