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

Charge fees for use of memo #3007

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 14 additions & 1 deletion src/ripple/app/tx/impl/Transactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,20 @@ std::uint64_t Transactor::calculateBaseFee (
if (tx.isFieldPresent (sfSigners))
signerCount = tx.getFieldArray (sfSigners).size();

return baseFee + (signerCount * baseFee);
std::uint32_t memoCount = 0;

if (tx.isFieldPresent(sfMemos) && view.rules().enabled(featureMemoFee))
{
auto const& memos = tx.getFieldArray (sfMemos);

Serializer s (2048);
memos.add (s);

if (s.size() > 32)
memoCount = 2 * static_cast<std::uint32_t>(s.size());
Copy link
Contributor

@nbougalis nbougalis Jul 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. I'd probably consider making the multiplier a function of length too. For example:
memoCount = std::max(1, (s.size() / 128)) * static_cast<std::uint32_t>(s.size());

This gives it a nice stepped "curve" of increasing slope, as you can see on this WolframAlpha graph

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just s.size() * s.size() / 128 for simplicity. With a minimum s.size() of 32, this expression starts at 8 and scales to 8192.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miguelportilla makes a good point that super-linear fee scaling will just encourage splitting into multiple transactions at the point where the marginal cost of a memo byte exceeds the cost of a new transaction. That means we should just use s.size() for memoCount.

}

return baseFee + (signerCount * baseFee) + (memoCount * baseFee);
}

XRPAmount
Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ extern uint256 const fix1578;
extern uint256 const featureMultiSignReserve;
extern uint256 const fixTakerDryOfferRemoval;
extern uint256 const fixMasterKeyAsRegularKey;
extern uint256 const featureMemoFee;

} // ripple

Expand Down
2 changes: 2 additions & 0 deletions src/ripple/protocol/impl/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ detail::supportedAmendments ()
"MultiSignReserve",
"fixTakerDryOfferRemoval",
"fixMasterKeyAsRegularKey",
"MemoFee"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to also add "MemoFee" to featureNames in Feature.h.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a trailing comma to this line as well.

};
return supported;
}
Expand Down Expand Up @@ -175,5 +176,6 @@ uint256 const fix1578 = *getRegisteredFeature("fix1578");
uint256 const featureMultiSignReserve = *getRegisteredFeature("MultiSignReserve");
uint256 const fixTakerDryOfferRemoval = *getRegisteredFeature("fixTakerDryOfferRemoval");
uint256 const fixMasterKeyAsRegularKey = *getRegisteredFeature("fixMasterKeyAsRegularKey");
uint256 const featureMemoFee = *getRegisteredFeature("MemoFee");

} // ripple