Skip to content

Commit

Permalink
Fix HookResult(ExitType) when accept() is not called (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
tequdev authored Jan 22, 2025
1 parent 4466175 commit d17f715
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/ripple/app/hook/impl/applyHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,10 @@ hook::apply(
.hookParamOverrides = hookParamOverrides,
.hookParams = hookParams,
.hookSkips = {},
.exitType =
hook_api::ExitType::ROLLBACK, // default is to rollback unless
// hook calls accept()
.exitType = applyCtx.view().rules().enabled(fixXahauV3)
? hook_api::ExitType::UNSET
: hook_api::ExitType::ROLLBACK, // default is to rollback
// unless hook calls accept()
.exitReason = std::string(""),
.exitCode = -1,
.hasCallback = hasCallback,
Expand Down
24 changes: 16 additions & 8 deletions src/ripple/app/tx/impl/Transactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,10 +1270,18 @@ Transactor::executeHookChain(
if (results.back().exitType == hook_api::ExitType::WASM_ERROR)
{
JLOG(j_.warn()) << "HookError[" << account << "-"
<< ctx_.tx.getAccountID(sfAccount) << "]: "
<< ctx_.tx.getAccountID(sfAccount)
<< "]: Execution failure (graceful) "
<< "HookHash: " << hookHash;
}
if (results.back().exitType == hook_api::ExitType::UNSET)
{
JLOG(j_.warn())
<< "HookError[" << account << "-"
<< ctx_.tx.getAccountID(sfAccount)
<< "]: Execution failure (no exit type specified) "
<< "HookHash: " << hookHash;
}
return tecHOOK_REJECTED;
}

Expand All @@ -1298,7 +1306,7 @@ Transactor::executeHookChain(
{
JLOG(j_.warn())
<< "HookError[" << account << "-"
<< ctx_.tx.getAccountID(sfAccount) << "]: "
<< ctx_.tx.getAccountID(sfAccount)
<< "]: Execution failure (exceptional) "
<< "Exception: " << e.what() << " HookHash: " << hookHash;

Expand Down Expand Up @@ -1426,13 +1434,13 @@ Transactor::doHookCallback(
finalizeHookResult(callbackResult, ctx_, success);

JLOG(j_.trace()) << "HookInfo[" << callbackAccountID << "-"
<< ctx_.tx.getAccountID(sfAccount) << "]: "
<< "Callback finalizeHookResult = " << result;
<< ctx_.tx.getAccountID(sfAccount)
<< "]: Callback finalizeHookResult = " << result;
}
catch (std::exception& e)
{
JLOG(j_.fatal()) << "HookError[" << callbackAccountID << "-"
<< ctx_.tx.getAccountID(sfAccount) << "]: "
<< ctx_.tx.getAccountID(sfAccount)
<< "]: Callback failure " << e.what();
}
}
Expand Down Expand Up @@ -1678,13 +1686,13 @@ Transactor::doAgainAsWeak(
results.push_back(aawResult);

JLOG(j_.trace()) << "HookInfo[" << hookAccountID << "-"
<< ctx_.tx.getAccountID(sfAccount) << "]: "
<< " aaw Hook ExitCode = " << aawResult.exitCode;
<< ctx_.tx.getAccountID(sfAccount)
<< "]: aaw Hook ExitCode = " << aawResult.exitCode;
}
catch (std::exception& e)
{
JLOG(j_.fatal()) << "HookError[" << hookAccountID << "-"
<< ctx_.tx.getAccountID(sfAccount) << "]: "
<< ctx_.tx.getAccountID(sfAccount)
<< "]: aaw failure " << e.what();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 75;
static constexpr std::size_t numFeatures = 76;

/** 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 @@ -363,6 +363,7 @@ extern uint256 const fixPageCap;
extern uint256 const fix240911;
extern uint256 const fixFloatDivide;
extern uint256 const fixReduceImport;
extern uint256 const fixXahauV3;

} // namespace ripple

Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/impl/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ REGISTER_FIX (fixPageCap, Supported::yes, VoteBehavior::De
REGISTER_FIX (fix240911, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixFloatDivide, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixReduceImport, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixXahauV3, Supported::yes, VoteBehavior::DefaultNo);

// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.
Expand Down

0 comments on commit d17f715

Please sign in to comment.