Merge branch 'HookFeeV2' into HookFeeV3

This commit is contained in:
tequ
2026-09-25 16:33:45 +09:00
59 changed files with 2188 additions and 1964 deletions

View File

@@ -280,8 +280,7 @@ compute_wce(
// expr under analysis begins and end_offset is where it ends returns {worst
// case instruction count} if valid or {} if invalid may throw overflow_error,
// length_error
inline std::optional<
std::pair<uint64_t, uint64_t>> // {instruction count, execution cost}
inline std::optional<uint64_t> // count or cost depending on returnCost
check_guard(
std::vector<uint8_t> const& wasm,
int codesec,
@@ -293,6 +292,7 @@ check_guard(
int last_import_idx,
GuardLog guardLog,
std::string guardLogAccStr,
bool returnCost,
/* RH NOTE:
* rules version is a bit field, so rule update 1 is 0x01, update 2 is 0x02
* and update 3 is 0x04 ideally at rule version 3 all bits so far are set
@@ -828,10 +828,6 @@ check_guard(
return {};
}
GUARDLOG(hook::log::INSTRUCTION_COUNT)
<< "GuardCheck "
<< "Total worse-case execution count: " << instruction_count << "\n";
if (instruction_count >= 0xFFFFU)
{
GUARDLOG(hook::log::INSTRUCTION_EXCESS)
@@ -842,7 +838,10 @@ check_guard(
<< "\n";
return {};
}
return std::pair<uint64_t, uint64_t>{instruction_count, execution_cost};
if (returnCost)
return execution_cost;
else
return instruction_count;
}
// RH TODO: reprogram this function to use REQUIRE/ADVANCE
@@ -1535,21 +1534,30 @@ validateGuards(
last_import_number,
guardLog,
guardLogAccStr,
returnCost,
rulesVersion);
if (!valid)
return {};
if (hook_func_idx && *hook_func_idx == j)
if (!returnCost)
maxInstrCountHook = valid->first;
else
maxInstrCountHook = valid->second;
{
GUARDLOG(hook::log::INSTRUCTION_COUNT)
<< "GuardCheck "
<< "Total hook worse-case execution "
<< (returnCost ? "cost: " : "count: ") << *valid
<< "\n";
maxInstrCountHook = *valid;
}
else if (cbak_func_idx && *cbak_func_idx == j)
if (!returnCost)
maxInstrCountCbak = valid->first;
else
maxInstrCountCbak = valid->second;
{
GUARDLOG(hook::log::INSTRUCTION_COUNT)
<< "GuardCheck "
<< "Total cbak worse-case execution "
<< (returnCost ? "cost: " : "count: ") << *valid
<< "\n";
maxInstrCountCbak = *valid;
}
else
{
if (DEBUG_GUARD)

View File

@@ -88,7 +88,7 @@ main(int argc, char** argv)
hook,
std::cout,
"",
false,
true,
hook_api::getImportWhitelist(rules),
hook_api::getGuardRulesVersion(rules));

View File

@@ -36,6 +36,7 @@
XRPL_FEATURE(HookFeeV3, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(HookFeeV2, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(HookOnV2_1, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(OnChainManifests, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (HookMap, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FIX (GuardDepth32, Supported::yes, VoteBehavior::DefaultNo)
@@ -47,7 +48,7 @@ XRPL_FEATURE(HookAPISerializedType240, Supported::yes, VoteBehavior::DefaultNo
XRPL_FEATURE(PermissionedDomains, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(DynamicNFT, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(Credentials, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(AMMClawback, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(MPTokensV1, Supported::no, VoteBehavior::DefaultNo)
// InvariantsV1_1 will be changes to Supported::yes when all the
// invariants expected to be included under it are complete.
@@ -67,7 +68,8 @@ XRPL_FEATURE(XChainBridge, Supported::no, VoteBehavior::DefaultNo
XRPL_FEATURE(AMM, Supported::no, VoteBehavior::DefaultNo)
XRPL_FIX (ReducedOffersV1, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(HooksUpdate2, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(HookOnV2, Supported::yes, VoteBehavior::DefaultNo)
// replaced to HookOnV2_1
XRPL_FEATURE(HookOnV2, Supported::no, VoteBehavior::DefaultNo)
XRPL_FIX (HookAPI20251128, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FIX (CronStacking, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(ExtendedHookState, Supported::yes, VoteBehavior::DefaultNo)
@@ -91,8 +93,6 @@ XRPL_FIX (240819, Supported::yes, VoteBehavior::DefaultYe
XRPL_FIX (NSDelete, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(ZeroB2M, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(Remit, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (XahauV2, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (XahauV1, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(HooksUpdate1, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(XahauGenesis, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(Import, Supported::yes, VoteBehavior::DefaultYes)
@@ -163,6 +163,8 @@ XRPL_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete)
// pre-amendment code has been removed and the identifiers are deprecated.
// All known amendments and amendments that may appear in a validated
// ledger must be registered either here or above with the "active" amendments
XRPL_RETIRE(fixXahauV2)
XRPL_RETIRE(fixXahauV1)
XRPL_RETIRE(MultiSign)
XRPL_RETIRE(TrustSetAuth)
XRPL_RETIRE(FeeEscalation)

View File

@@ -292,7 +292,9 @@ JSS(duration_us); // out: NetworkOPs
JSS(effective); // out: ValidatorList
// in: UNL
JSS(elapsed_seconds);
JSS(enabled); // out: AmendmentTable
JSS(enabled); // out: AmendmentTable (on-ledger);
// ServerDefinitions (this server)
JSS(ledger_enabled); // out: ServerDefinitions (on-ledger)
JSS(engine_result); // out: NetworkOPs, TransactionSign, Submit
JSS(engine_result_code); // out: NetworkOPs, TransactionSign, Submit
JSS(engine_result_message); // out: NetworkOPs, TransactionSign, Submit