collect call logic bug

This commit is contained in:
Richard Holland
2022-05-17 12:35:23 +00:00
parent f1a8b086b5
commit 5f4f2baa58
3 changed files with 15 additions and 15 deletions

View File

@@ -242,8 +242,8 @@ namespace hook
uint32_t maxHookChainLength(void); uint32_t maxHookChainLength(void);
uint32_t computeExecutionFee(uint64_t instructionCount); int64_t computeExecutionFee(uint64_t instructionCount);
uint32_t computeCreationFee(uint64_t byteCount); int64_t computeCreationFee(uint64_t byteCount);
struct HookResult struct HookResult
{ {

View File

@@ -418,20 +418,22 @@ bool hook::isEmittedTxn(ripple::STTx const& tx)
#define U32MAX ((uint32_t)(-1)) #define U32MAX ((uint32_t)(-1))
uint32_t hook::computeExecutionFee(uint64_t instructionCount) int64_t hook::computeExecutionFee(uint64_t instructionCount)
{ {
// RH TODO: fee multiplier, validator votable int64_t fee = (int64_t)instructionCount;
if (instructionCount > U32MAX) if (fee < instructionCount)
return U32MAX; return 0x7FFFFFFFFFFFFFFFLL;
return instructionCount;
return fee;
} }
uint32_t hook::computeCreationFee(uint64_t byteCount) int64_t hook::computeCreationFee(uint64_t byteCount)
{ {
// RH TODO: fee multiplier, validator votable int64_t fee = ((int64_t)byteCount) * 10000ULL;
if (byteCount > U32MAX) if (fee < byteCount)
return U32MAX; return 0x7FFFFFFFFFFFFFFFLL;
return byteCount;
return fee;
} }
uint32_t hook::maxHookChainLength(void) uint32_t hook::maxHookChainLength(void)

View File

@@ -200,9 +200,7 @@ calculateHookChainFee(
flags = hookDef->getFieldU32(sfFlags); flags = hookDef->getFieldU32(sfFlags);
if (hook::canHook(tx.getTxnType(), hookOn) && if (hook::canHook(tx.getTxnType(), hookOn) &&
((collectCallsOnly && (flags & hook::hsfCOLLECT)) || (!collectCallsOnly || (flags & hook::hsfCOLLECT)))
(!collectCallsOnly && !(flags & hook::hsfCOLLECT)))
)
{ {
fee += FeeUnit64{ fee += FeeUnit64{
(uint32_t)(hookDef->getFieldAmount(sfFee).xrp().drops()) (uint32_t)(hookDef->getFieldAmount(sfFee).xrp().drops())