Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: Ximinez/lending xls 66 #5270

Draft
wants to merge 62 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
1a032f0
Integrate STNumber with STParsedJSON
thejohnfreeman Nov 7, 2024
ff8c649
Start vault implementation
thejohnfreeman Oct 17, 2024
a8ec8e7
wip
thejohnfreeman Nov 12, 2024
d09e74e
format
thejohnfreeman Nov 12, 2024
1680477
progress
thejohnfreeman Nov 12, 2024
ebc97ae
progress
thejohnfreeman Nov 12, 2024
286612c
progress
thejohnfreeman Nov 12, 2024
6046fa2
progress
thejohnfreeman Nov 13, 2024
1255216
progress
thejohnfreeman Nov 13, 2024
1ff1274
AND_THEN
thejohnfreeman Nov 14, 2024
ea6c040
wip
thejohnfreeman Nov 14, 2024
ea30f44
fix
thejohnfreeman Nov 22, 2024
12646cb
revise tests
thejohnfreeman Dec 3, 2024
54d511b
remove blob constants
thejohnfreeman Dec 6, 2024
b5619fb
bless sfAsset to carry MPT
thejohnfreeman Dec 6, 2024
ad58166
wip clawback
thejohnfreeman Dec 6, 2024
ecec6e5
Fix failing MPToken payment test
Bronek Dec 17, 2024
eae2cd3
Fix compilation errors
Bronek Dec 18, 2024
526f715
Comment out failing test
Bronek Dec 18, 2024
b9f1200
Fix formatting
Bronek Dec 18, 2024
241429b
Simplify conversions to Json::Value
Bronek Dec 18, 2024
8d5cfb9
Merge branch 'develop' into vault
Bronek Jan 13, 2025
bf8bbff
Merge branch 'develop' into vault
Bronek Jan 15, 2025
375614d
Merge branch 'develop' into vault
Bronek Jan 17, 2025
c325b6c
Fix Vault unit tests
Bronek Jan 17, 2025
dbaa12a
WIP permissioned domain support
Bronek Jan 17, 2025
580a85f
WIP support adding domainID in VaultSet
Bronek Jan 20, 2025
c08f86d
Remove temSTRING_TOO_LARGE, fix authorizedDomain, refactor Vault_test
Bronek Jan 21, 2025
25a20ad
Add VaultID to account
Bronek Jan 23, 2025
2c4a224
Verify credentials in VaultDeposit
Bronek Jan 23, 2025
9bf9a1e
Merge branch 'develop' into vault
Bronek Jan 24, 2025
86d249a
Fix checo of expired credential
Bronek Jan 24, 2025
65d6c48
Unit tests naming fix
Bronek Jan 24, 2025
02dec4f
Merge branch 'develop' into vault
Bronek Jan 27, 2025
3eebdae
Implement MPT domain checks
Bronek Jan 27, 2025
ad68074
MPT permissioned domain checks
Bronek Jan 30, 2025
06a8a61
WIP trying to fix MSVC compilation error
Bronek Jan 31, 2025
a98e59a
Revert "WIP trying to fix MSVC compilation error"
ximinez Jan 31, 2025
21e0e7e
Fix ICE errors by reusing a global static const object
ximinez Jan 31, 2025
eed18d1
Remove unnecessary ValueProxy friend operator !=
ximinez Jan 31, 2025
c3f9a4c
Fix MSVC build: Get the intended const& for some fields
ximinez Jan 31, 2025
d1c7d1a
Merge branch 'develop' into vault
Bronek Feb 3, 2025
8baadd5
Fix clang build error
Bronek Feb 3, 2025
9decc05
Rename getSequence to getSeqValue
Bronek Feb 3, 2025
6765c10
Check permissioned domain enabled if DomainID is used
Bronek Feb 4, 2025
1884ec5
Check for frozen assets in preclaim
Bronek Feb 4, 2025
acaed58
Prevent deposit when asset is frozen for depositor
Bronek Feb 4, 2025
ffaa8bd
Improve checks in Vault
Bronek Feb 6, 2025
b7c9577
Remove unnecessary check
Bronek Feb 6, 2025
87d8881
Merge branch 'develop' into vault
Bronek Feb 7, 2025
c1d8bc4
Enforce freeze of pseudo-account
Bronek Feb 7, 2025
e9ed800
Optimise isFrozen check for pair of accounts
Bronek Feb 7, 2025
9d619b9
Merge branch 'develop' into vault
Bronek Feb 7, 2025
3f5df80
Merge branch 'develop' into vault
Bronek Feb 24, 2025
a0632a0
Add WithdrawalPolicy
Bronek Feb 25, 2025
04503c9
Enforce non-negative amounts
Bronek Feb 25, 2025
48e0d20
fix: Remove 'new parent hash' assert (#5313)
Bronek Feb 25, 2025
9fb1cba
Fix Replace `assert` with `XRPL_ASSERT` (#5312)
Bronek Feb 25, 2025
d4a619c
fix: Acquire previously failed transaction set from network as new pr…
mtrippled Feb 26, 2025
8b2c516
Set version to 2.4.0-rc3
legleux Feb 26, 2025
a273b39
Calculate numFeatures automatically
ximinez Jan 31, 2025
a697138
Add the LendingProtocol amendment
ximinez Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/xrpl/json/json_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
#ifndef RIPPLE_JSON_JSON_VALUE_H_INCLUDED
#define RIPPLE_JSON_JSON_VALUE_H_INCLUDED

#include <xrpl/basics/Number.h>
#include <xrpl/json/json_forwards.h>
#include <cstring>
#include <map>
#include <string>
#include <utility>
#include <vector>

/** \brief JSON (JavaScript Object Notation).
Expand Down Expand Up @@ -215,6 +217,7 @@ class Value
Value(UInt value);
Value(double value);
Value(const char* value);
Value(ripple::Number const& value);
/** \brief Constructs a value from a static string.

* Like other value string constructor but do not duplicate the string for
Expand All @@ -237,6 +240,17 @@ class Value
Value&
operator=(Value&& other);

template <typename T>
Value&
operator=(T const& rhs)
requires(
!std::is_convertible_v<T, Value> &&
std::is_convertible_v<decltype(to_json(std::declval<T>())), Value>)
{
*this = to_json(rhs);
return *this;
}

Value(Value&& other) noexcept;

/// Swap values.
Expand Down Expand Up @@ -364,6 +378,8 @@ class Value
*/
Value&
operator[](const StaticString& key);
Value const&
operator[](const StaticString& key) const;

/// Return the member named key if it exist, defaultValue otherwise.
Value
Expand Down Expand Up @@ -435,6 +451,12 @@ class Value
int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
};

inline Value
to_json(ripple::Number const& number)
{
return to_string(number);
}

bool
operator==(const Value&, const Value&);

Expand Down
8 changes: 0 additions & 8 deletions include/xrpl/protocol/AMMCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ class STObject;
class STAmount;
class Rules;

/** Calculate AMM account ID.
*/
AccountID
ammAccountID(
std::uint16_t prefix,
uint256 const& parentHash,
uint256 const& ammID);

/** Calculate Liquidity Provider Token (LPT) Currency.
*/
Currency
Expand Down
16 changes: 13 additions & 3 deletions include/xrpl/protocol/Asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
#ifndef RIPPLE_PROTOCOL_ASSET_H_INCLUDED
#define RIPPLE_PROTOCOL_ASSET_H_INCLUDED

#include <xrpl/basics/Number.h>
#include <xrpl/basics/base_uint.h>
#include <xrpl/protocol/Issue.h>
#include <xrpl/protocol/MPTIssue.h>

namespace ripple {

class Asset;
class STAmount;

template <typename TIss>
concept ValidIssueType =
Expand Down Expand Up @@ -92,6 +94,9 @@ class Asset
void
setJson(Json::Value& jv) const;

STAmount
operator()(Number const&) const;

bool
native() const
{
Expand All @@ -114,6 +119,14 @@ class Asset
equalTokens(Asset const& lhs, Asset const& rhs);
};

inline Json::Value
to_json(Asset const& asset)
{
Json::Value jv;
asset.setJson(jv);
return jv;
}

template <ValidIssueType TIss>
constexpr bool
Asset::holds() const
Expand Down Expand Up @@ -219,9 +232,6 @@ validJSONAsset(Json::Value const& jv);
Asset
assetFromJson(Json::Value const& jv);

Json::Value
to_json(Asset const& asset);

} // namespace ripple

#endif // RIPPLE_PROTOCOL_ASSET_H_INCLUDED
69 changes: 47 additions & 22 deletions include/xrpl/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@
*
* Steps required to add new features to the code:
*
* 1) In this file, increment `numFeatures` and add a uint256 declaration
* for the feature at the bottom
* 2) Add a uint256 definition for the feature to the corresponding source
* file (Feature.cpp). Use `registerFeature` to create the feature with
* the feature's name, `Supported::no`, and `VoteBehavior::DefaultNo`. This
* should be the only place the feature's name appears in code as a string.
* 3) Use the uint256 as the parameter to `view.rules.enabled()` to
* control flow into new code that this feature limits.
* 4) If the feature development is COMPLETE, and the feature is ready to be
* SUPPORTED, change the `registerFeature` parameter to Supported::yes.
* 5) When the feature is ready to be ENABLED, change the `registerFeature`
* parameter to `VoteBehavior::DefaultYes`.
* 1) Add a the appropriate XRPL_FEATURE or XRPL_FIX macro definition for the
* feature to features.macro with the feature's name, `Supported::no`, and
* `VoteBehavior::DefaultNo`.
*
* 2) Use the generated variable name as the parameter to `view.rules.enabled()`
* to control flow into new code that this feature limits. (featureName or
* fixName)
*
* 3) If the feature development is COMPLETE, and the feature is ready to be
* SUPPORTED, change the macro parameter in features.macro to Supported::yes.
*
* 4) When the feature is ready to be ENABLED, change the macro parameter in
* features.macro parameter to `VoteBehavior::DefaultYes`.
*
* In general, any newly supported amendments (`Supported::yes`) should have
* a `VoteBehavior::DefaultNo` for at least one full release cycle. High
* priority bug fixes can be an exception to this rule of thumb.
*
* When a feature has been enabled for several years, the conditional code
* may be removed, and the feature "retired". To retire a feature:
* 1) Remove the uint256 declaration from this file.
* 2) MOVE the uint256 definition in Feature.cpp to the "retired features"
* section at the end of the file.
* 3) CHANGE the name of the variable to start with "retired".
* 4) CHANGE the parameters of the `registerFeature` call to `Supported::yes`
* and `VoteBehavior::DefaultNo`.
*
* 1) MOVE the macro definition in features.macro to the "retired features"
* section at the end of the file, and change the macro to XRPL_RETIRE.
*
* The feature must remain registered and supported indefinitely because it
* still exists in the ledger, but there is no need to vote for it because
* there's nothing to vote for. If it is removed completely from the code, any
* instances running that code will get amendment blocked. Removing the
* feature from the ledger is beyond the scope of these instructions.
* there's nothing to vote for. If the definition is removed completely from the
* code, any instances running that code will get amendment blocked. Removing
* the feature from the ledger is beyond the scope of these instructions.
*
*/

Expand All @@ -80,7 +80,27 @@ 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 = 88;
static constexpr std::size_t numFeatures = 0
#pragma push_macro("XRPL_FEATURE")
#undef XRPL_FEATURE
#pragma push_macro("XRPL_FIX")
#undef XRPL_FIX
#pragma push_macro("XRPL_RETIRE")
#undef XRPL_RETIRE

#define XRPL_FEATURE(name, supported, vote) +1
#define XRPL_FIX(name, supported, vote) +1
#define XRPL_RETIRE(name) +1

#include <xrpl/protocol/detail/features.macro>

#undef XRPL_RETIRE
#pragma pop_macro("XRPL_RETIRE")
#undef XRPL_FIX
#pragma pop_macro("XRPL_FIX")
#undef XRPL_FEATURE
#pragma pop_macro("XRPL_FEATURE")
;

/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
Expand Down Expand Up @@ -320,12 +340,17 @@ foreachFeature(FeatureBitset bs, F&& f)
#undef XRPL_FEATURE
#pragma push_macro("XRPL_FIX")
#undef XRPL_FIX
#pragma push_macro("XRPL_RETIRE")
#undef XRPL_RETIRE

#define XRPL_FEATURE(name, supported, vote) extern uint256 const feature##name;
#define XRPL_FIX(name, supported, vote) extern uint256 const fix##name;
#define XRPL_RETIRE(name)

#include <xrpl/protocol/detail/features.macro>

#undef XRPL_RETIRE
#pragma pop_macro("XRPL_RETIRE")
#undef XRPL_FIX
#pragma pop_macro("XRPL_FIX")
#undef XRPL_FEATURE
Expand Down
1 change: 0 additions & 1 deletion include/xrpl/protocol/IOUAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <boost/operators.hpp>
#include <cstdint>
#include <string>
#include <utility>

namespace ripple {

Expand Down
9 changes: 9 additions & 0 deletions include/xrpl/protocol/Indexes.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ mptoken(uint256 const& mptokenKey)
Keylet
mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;

Keylet
vault(AccountID const& owner, std::uint32_t seq) noexcept;

inline Keylet
vault(uint256 const& vaultKey)
{
return {ltVAULT, vaultKey};
}

Keylet
permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept;

Expand Down
4 changes: 4 additions & 0 deletions include/xrpl/protocol/LedgerFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ enum LedgerSpecificFlags {

// ltMPTOKEN
lsfMPTAuthorized = 0x00000002,
lsfMPTDomainCheck = 0x00000004,

// ltCREDENTIAL
lsfAccepted = 0x00010000,

// ltVAULT
lsfVaultPrivate = 0x00010000,
};

//------------------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions include/xrpl/protocol/MPTAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@
#include <xrpl/basics/contract.h>
#include <xrpl/basics/safe_cast.h>
#include <xrpl/beast/utility/Zero.h>
#include <xrpl/json/json_value.h>

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/operators.hpp>

#include <cstdint>
#include <optional>
#include <string>
#include <type_traits>

namespace ripple {

Expand Down
7 changes: 5 additions & 2 deletions include/xrpl/protocol/MPTIssue.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ class MPTIssue
AccountID const&
getIssuer() const;

MPTID const&
getMptID() const;
constexpr MPTID const&
getMptID() const
{
return mptID_;
}

std::string
getText() const;
Expand Down
6 changes: 6 additions & 0 deletions include/xrpl/protocol/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ std::size_t constexpr maxMPTokenMetadataLength = 1024;
/** The maximum amount of MPTokenIssuance */
std::uint64_t constexpr maxMPTokenAmount = 0x7FFF'FFFF'FFFF'FFFFull;

/** The maximum length of MPTokenMetadata */
std::size_t constexpr maxVaultDataLength = 256;

/** Vault withdrawal policies */
std::uint8_t constexpr vaultStrategyFirstComeFirstServe = 1;

/** A ledger index. */
using LedgerIndex = std::uint32_t;

Expand Down
1 change: 0 additions & 1 deletion include/xrpl/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <cstdint>
#include <map>
#include <utility>

namespace ripple {

Expand Down
23 changes: 21 additions & 2 deletions include/xrpl/protocol/STAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ class STAmount final : public STBase, public CountedObject<STAmount>
template <AssetType A>
STAmount(A const& asset, int mantissa, int exponent = 0);

template <AssetType A>
STAmount(A const& asset, Number const& number)
: STAmount(asset, number.mantissa(), number.exponent())
{
}

// Legacy support for new-style amounts
STAmount(IOUAmount const& amount, Issue const& issue);
STAmount(XRPAmount const& amount);
Expand Down Expand Up @@ -230,6 +236,9 @@ class STAmount final : public STBase, public CountedObject<STAmount>
STAmount&
operator=(XRPAmount const& amount);

STAmount&
operator=(Number const&);

//--------------------------------------------------------------------------
//
// Modification
Expand Down Expand Up @@ -268,7 +277,7 @@ class STAmount final : public STBase, public CountedObject<STAmount>
std::string
getText() const override;

Json::Value getJson(JsonOptions) const override;
Json::Value getJson(JsonOptions = JsonOptions::none) const override;

void
add(Serializer& s) const override;
Expand Down Expand Up @@ -417,7 +426,7 @@ STAmount
amountFromQuality(std::uint64_t rate);

STAmount
amountFromString(Asset const& issue, std::string const& amount);
amountFromString(Asset const& asset, std::string const& amount);

STAmount
amountFromJson(SField const& name, Json::Value const& v);
Expand Down Expand Up @@ -541,6 +550,16 @@ STAmount::operator=(XRPAmount const& amount)
return *this;
}

inline STAmount&
STAmount::operator=(Number const& number)
{
mIsNegative = number.mantissa() < 0;
mValue = mIsNegative ? -number.mantissa() : number.mantissa();
mOffset = number.exponent();
canonicalize();
return *this;
}

inline void
STAmount::negate()
{
Expand Down
Loading
Loading