-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: Implement MPT changes #1147
Open
shawnxie999
wants to merge
78
commits into
XRPLF:develop
Choose a base branch
from
shawnxie999:mpt-holders
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
3c98a06
Refactoring currency (WIP)
shawnxie999 f8bbf0c
compile
shawnxie999 924dd72
remove static cast
shawnxie999 59bcb97
wip
shawnxie999 f182a1d
Working account_objects and Ledger_entry
shawnxie999 b908b4e
Synthetic MPT ID
shawnxie999 2e297fa
reafactor
shawnxie999 efc839c
Working ledger entry
shawnxie999 5bc4ca5
use translation
shawnxie999 5bbf673
ledger_entry tests
shawnxie999 9ac779d
account object test
shawnxie999 a97d549
initial
shawnxie999 0dae3cb
compile
shawnxie999 f9b494e
working marker
shawnxie999 0adc32e
tests
shawnxie999 1d7e49f
typo
shawnxie999 a700caa
cmake
shawnxie999 7052364
comments
shawnxie999 ac5f48e
ledgerdata
shawnxie999 2decaa8
ledgerdata test
shawnxie999 880d036
clang
shawnxie999 412fa2e
change order
shawnxie999 18a8a4a
improve condition
shawnxie999 75eddfd
tests
shawnxie999 5fa9182
Merge remote-tracking branch 'upstream/develop' into mpt-holders
shawnxie999 96288d0
add deletion blocker
shawnxie999 c453391
Merge branch 'develop' into mpt-holders
shawnxie999 e6d34fa
Merge branch 'develop' into mpt-holders
shawnxie999 b6691bd
refactor validators and add tests
shawnxie999 62b01fe
remove comment
shawnxie999 eb138d2
Merge remote-tracking branch 'upstream/develop' into mpt-holders-bk
shawnxie999 f3d7f0d
template parameter type checking
shawnxie999 203fa8d
clang
shawnxie999 b368864
clang
shawnxie999 494f56f
doxygen and end of file line
shawnxie999 9a378b0
revert issue changes
shawnxie999 38804f6
Merge remote-tracking branch 'upstream/develop' into mpt-holders
shawnxie999 4d85852
update
shawnxie999 f224555
revert
shawnxie999 d28b21f
comment
shawnxie999 66a4fe7
improvements
shawnxie999 63b4f7c
remove rvalue ref
shawnxie999 5630132
clang
shawnxie999 1d166a7
Merge remote-tracking branch 'upstream/develop' into mpt-holders
shawnxie999 d316375
use copyif
shawnxie999 b988f2d
comment
shawnxie999 aac1e0c
use getaccountid
shawnxie999 90dc297
comment
shawnxie999 19b268f
Merge branch 'develop' into mpt-holders
shawnxie999 f4852a8
update libxrpl
shawnxie999 e7c77d3
doc
shawnxie999 d9c54be
comment
shawnxie999 8d798a6
doc
shawnxie999 55386e8
change var name
shawnxie999 0087ff5
var name
shawnxie999 01453ee
use toJson
shawnxie999 87838f6
clang
shawnxie999 cee9cd5
change libxrpl
shawnxie999 26ca942
Merge remote-tracking branch 'upstream/develop' into mpt-holders
shawnxie999 d2f40a9
revert libxrpl
shawnxie999 c4dbd11
libxrpl
shawnxie999 a39c90a
Delete CMake/deps/libxrpl.cmake
shawnxie999 3defe87
add renamed libxrpl
shawnxie999 57020c2
Merge branch 'develop' into mpt-holders
shawnxie999 e75e2cf
comments
shawnxie999 5df2068
predicate const ref
shawnxie999 a464fba
Merge remote-tracking branch 'upstream/develop' into mpt-holders
shawnxie999 703500f
clang
shawnxie999 8b8cc9b
add MPT amendment
shawnxie999 ca079a5
Merge branch 'develop' into mpt-holders
godexsoft 1a03ae0
make compile
shawnxie999 1c271f4
Merge remote-tracking branch 'upstream/develop' into mpt-holders
shawnxie999 2fc2536
Merge remote-tracking branch 'upstream/develop' into mpt-holders
shawnxie999 d877e5d
update clio to compile with latest rippled
shawnxie999 cce63dc
comments
shawnxie999 a9b1430
fix API response discrepancies
shawnxie999 7bd4472
ledger entry test
shawnxie999 2ea0cb8
Merge branch 'develop' into mpt-holders
shawnxie999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
find_package(xrpl REQUIRED CONFIG) | ||
find_package(xrpl-mpt REQUIRED CONFIG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of clio: https://github.com/XRPLF/clio | ||
Copyright (c) 2024, the clio developers. | ||
|
||
Permission to use, copy, modify, and 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 "data/BackendInterface.hpp" | ||
#include "data/DBHelpers.hpp" | ||
#include "data/Types.hpp" | ||
|
||
#include <fmt/core.h> | ||
#include <ripple/protocol/STBase.h> | ||
#include <ripple/protocol/STTx.h> | ||
#include <ripple/protocol/TxMeta.h> | ||
|
||
#include <vector> | ||
|
||
namespace etl { | ||
|
||
/** | ||
* @brief Get the MPToken created from a transaction | ||
* | ||
* @param txMeta Transaction metadata | ||
* @return MPT and holder account pair | ||
*/ | ||
static std::optional<MPTHolderData> | ||
getMPTokenAuthorize(ripple::TxMeta const& txMeta) | ||
{ | ||
for (ripple::STObject const& node : txMeta.getNodes()) { | ||
if (node.getFieldU16(ripple::sfLedgerEntryType) != ripple::ltMPTOKEN) | ||
continue; | ||
|
||
if (node.getFName() == ripple::sfCreatedNode) { | ||
auto const& newMPT = node.peekAtField(ripple::sfNewFields).downcast<ripple::STObject>(); | ||
return MPTHolderData{newMPT[ripple::sfMPTokenIssuanceID], newMPT.getAccountID(ripple::sfAccount)}; | ||
} | ||
} | ||
return {}; | ||
} | ||
|
||
std::optional<MPTHolderData> | ||
getMPTHolderFromTx(ripple::TxMeta const& txMeta, ripple::STTx const& sttx) | ||
{ | ||
if (txMeta.getResultTER() != ripple::tesSUCCESS || sttx.getTxnType() != ripple::TxType::ttMPTOKEN_AUTHORIZE) | ||
cindyyan317 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return {}; | ||
|
||
return getMPTokenAuthorize(txMeta); | ||
cindyyan317 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
std::optional<MPTHolderData> | ||
getMPTHolderFromObj(std::string const& key, std::string const& blob) | ||
{ | ||
ripple::STLedgerEntry const sle = | ||
ripple::STLedgerEntry(ripple::SerialIter{blob.data(), blob.size()}, ripple::uint256::fromVoid(key.data())); | ||
|
||
if (sle.getFieldU16(ripple::sfLedgerEntryType) != ripple::ltMPTOKEN) | ||
return {}; | ||
|
||
auto const mptIssuanceID = sle[ripple::sfMPTokenIssuanceID]; | ||
auto const holder = sle.getAccountID(ripple::sfAccount); | ||
|
||
return MPTHolderData{mptIssuanceID, holder}; | ||
} | ||
|
||
} // namespace etl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of clio: https://github.com/XRPLF/clio | ||
Copyright (c) 2024, the clio developers. | ||
|
||
Permission to use, copy, modify, and 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. | ||
*/ | ||
//============================================================================== | ||
|
||
/** @file */ | ||
#pragma once | ||
|
||
#include "data/DBHelpers.hpp" | ||
|
||
#include <ripple/protocol/STTx.h> | ||
#include <ripple/protocol/TxMeta.h> | ||
|
||
namespace etl { | ||
|
||
/** | ||
* @brief Pull MPT data from TX via ETLService. | ||
* | ||
* @param txMeta Transaction metadata | ||
* @param sttx The transaction | ||
* @return The MPTIssuanceID and holder pair as a optional | ||
*/ | ||
std::optional<MPTHolderData> | ||
getMPTHolderFromTx(ripple::TxMeta const& txMeta, ripple::STTx const& sttx); | ||
|
||
/** | ||
* @brief Pull MPT data from ledger object via loadInitialLedger. | ||
* | ||
* @param key The owner key | ||
* @param blob Object data as blob | ||
* @return The MPTIssuanceID and holder pair as a optional | ||
*/ | ||
std::optional<MPTHolderData> | ||
getMPTHolderFromObj(std::string const& key, std::string const& blob); | ||
|
||
} // namespace etl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually , Only this part needs to be virtual. The filter logic is same for different DB. By reducing the scope of virtual functions, you can unittest more of the logic without real DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you clarify what you mean? inside this function, there is another call to the database
auto mptObjects = doFetchLedgerObjects(mptKeys, ledgerSequence, yield);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we create a function in CassandraBackend.hpp to just select MPT holder, then all the filter logic can move to BackendInterface. If we want to add a new database, you don't need to copy all the logic to new database implementation. How to filter the valid holder is database unrelated. Instead, new database only needs to provide how to select MPT holder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But aren't existing functions in CassandraBackend.hpp also do something similar? BTW
fetchMPTHolders
doesn't only have filter logic, it does make another call to theobjects
table on line 576:auto mptObjects = doFetchLedgerObjects(mptKeys, ledgerSequence, yield);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood the
fetchMPTHolders
does not only have filter logic. So I suggested that we can add the pure virtual functiondoFetchMPTHolders
in BackendInterface, which only obtains the data fromselectMPTHolders
table. Then the filer logic can move to BackendInterface normal function.override doFetchfetchMPTHolders in CassandraBackend.hpp
Then your
fetchMPTHolders
will be like:I admit that current CassandraBackend.hpp has similar implementation which is not correct. We will refactor them eventually. Feel free to leave it. We can refactor it in future.