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

Touch amendment [DO NOT MERGE] #294

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/ripple/app/tx/impl/Transactor.cpp
Expand Up @@ -1079,6 +1079,31 @@ Transactor::checkMultiSign(PreclaimContext const& ctx)

//------------------------------------------------------------------------------

// increment the touch counter on an account
static void
touchAccount(
ApplyView& view,
AccountID const& id,
std::optional<std::shared_ptr<SLE>> sle)
{
if (!view.rules().enabled(featureTouch))
return;

if (!sle)
*sle = view.peek(keylet::account(id));

if (!(*sle))
return;

uint64_t tc = (*sle)->isFieldPresent(sfTouchCount)
? (*sle)->getFieldU64(sfTouchCount)
: 0;

(*sle)->setFieldU64(sfTouchCount, tc + 1);

view.update(*sle);
}

static void
removeUnfundedOffers(
ApplyView& view,
Expand Down Expand Up @@ -1511,6 +1536,8 @@ Transactor::doTSH(
if ((!canRollback && strong) || (canRollback && !strong))
continue;

touchAccount(view, tshAccountID, {});

auto klTshHook = keylet::hook(tshAccountID);

auto tshHook = view.read(klTshHook);
Expand Down
4 changes: 3 additions & 1 deletion src/ripple/protocol/Feature.h
Expand Up @@ -74,7 +74,8 @@ 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
Expand Down Expand Up @@ -356,6 +357,7 @@ extern uint256 const featureHooksUpdate1;
extern uint256 const fixXahauV1;
extern uint256 const fixXahauV2;
extern uint256 const featureRemit;
extern uint256 const featureTouch;
extern uint256 const featureZeroB2M;
extern uint256 const fixNSDelete;

Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/SField.h
Expand Up @@ -433,6 +433,7 @@ extern SF_UINT64 const sfReferenceCount;
extern SF_UINT64 const sfRewardAccumulator;
extern SF_UINT64 const sfAccountCount;
extern SF_UINT64 const sfAccountIndex;
extern SF_UINT64 const sfTouchCount;

// 128-bit
extern SF_UINT128 const sfEmailHash;
Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/impl/Feature.cpp
Expand Up @@ -462,6 +462,7 @@ REGISTER_FEATURE(HooksUpdate1, Supported::yes, VoteBehavior::De
REGISTER_FIX (fixXahauV1, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixXahauV2, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(Remit, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(Touch, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(ZeroB2M, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixNSDelete, Supported::yes, VoteBehavior::DefaultNo);

Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/impl/LedgerFormats.cpp
Expand Up @@ -66,6 +66,7 @@ LedgerFormats::LedgerFormats()
{sfGovernanceFlags, soeOPTIONAL},
{sfGovernanceMarks, soeOPTIONAL},
{sfAccountIndex, soeOPTIONAL},
{sfTouchCount, soeOPTIONAL},
},
commonFields);

Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/impl/SField.cpp
Expand Up @@ -183,6 +183,7 @@ CONSTRUCT_TYPED_SFIELD(sfEmitBurden, "EmitBurden", UINT64,
CONSTRUCT_TYPED_SFIELD(sfHookInstructionCount, "HookInstructionCount", UINT64, 17);
CONSTRUCT_TYPED_SFIELD(sfHookReturnCode, "HookReturnCode", UINT64, 18);
CONSTRUCT_TYPED_SFIELD(sfReferenceCount, "ReferenceCount", UINT64, 19);
CONSTRUCT_TYPED_SFIELD(sfTouchCount, "TouchCount", UINT64, 97);
CONSTRUCT_TYPED_SFIELD(sfAccountIndex, "AccountIndex", UINT64, 98);
CONSTRUCT_TYPED_SFIELD(sfAccountCount, "AccountCount", UINT64, 99);
CONSTRUCT_TYPED_SFIELD(sfRewardAccumulator, "RewardAccumulator", UINT64, 100);
Expand Down