From d17f7151ab35e4c7b7fbb18371a427f62b416d74 Mon Sep 17 00:00:00 2001 From: tequ Date: Wed, 22 Jan 2025 12:33:59 +0900 Subject: [PATCH] Fix HookResult(ExitType) when accept() is not called (#415) --- src/ripple/app/hook/impl/applyHook.cpp | 7 ++++--- src/ripple/app/tx/impl/Transactor.cpp | 24 ++++++++++++++++-------- src/ripple/protocol/Feature.h | 3 ++- src/ripple/protocol/impl/Feature.cpp | 1 + 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/ripple/app/hook/impl/applyHook.cpp b/src/ripple/app/hook/impl/applyHook.cpp index 0507aca97..aeb9f3f50 100644 --- a/src/ripple/app/hook/impl/applyHook.cpp +++ b/src/ripple/app/hook/impl/applyHook.cpp @@ -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, diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 7c2734f20..180bf64a8 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -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; } @@ -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; @@ -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(); } } @@ -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(); } } diff --git a/src/ripple/protocol/Feature.h b/src/ripple/protocol/Feature.h index 715f5dac6..f479ecba7 100644 --- a/src/ripple/protocol/Feature.h +++ b/src/ripple/protocol/Feature.h @@ -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 @@ -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 diff --git a/src/ripple/protocol/impl/Feature.cpp b/src/ripple/protocol/impl/Feature.cpp index 1c7fc931b..12c7b66c8 100644 --- a/src/ripple/protocol/impl/Feature.cpp +++ b/src/ripple/protocol/impl/Feature.cpp @@ -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.