mirror of
https://github.com/XRPLF/rippled.git
synced 2026-03-15 01:02:23 +00:00
Modularization fixes (#6488)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <xrpl/basics/SHAMapHash.h>
|
||||
#include <xrpl/basics/TaggedCache.h>
|
||||
#include <xrpl/ledger/CachedSLEs.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
@@ -225,6 +226,9 @@ public:
|
||||
virtual DatabaseCon&
|
||||
getWalletDB() = 0;
|
||||
|
||||
virtual Fees
|
||||
getFees() const = 0;
|
||||
|
||||
// Temporary: Get the underlying Application for functions that haven't
|
||||
// been migrated yet. This should be removed once all code is migrated.
|
||||
virtual Application&
|
||||
|
||||
@@ -198,15 +198,15 @@ EscrowCreate::preflight(PreflightContext const& ctx)
|
||||
|
||||
if (ctx.tx.isFieldPresent(sfFinishFunction))
|
||||
{
|
||||
if (ctx.registry.config().FEES.extension_size_limit == 0 ||
|
||||
ctx.registry.config().FEES.extension_compute_limit == 0)
|
||||
auto const fees(ctx.registry.getFees());
|
||||
if (fees.extensionSizeLimit == 0 || fees.extensionComputeLimit == 0)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "WASM runtime deactivated by fee voting";
|
||||
return temTEMP_DISABLED;
|
||||
}
|
||||
|
||||
auto const code = ctx.tx.getFieldVL(sfFinishFunction);
|
||||
if (code.size() == 0 || code.size() > ctx.registry.config().FEES.extension_size_limit)
|
||||
if (code.size() == 0 || code.size() > fees.extensionSizeLimit)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "EscrowCreate.FinishFunction bad size " << code.size();
|
||||
return temMALFORMED;
|
||||
@@ -654,7 +654,8 @@ EscrowFinish::preflight(PreflightContext const& ctx)
|
||||
|
||||
if (auto const allowance = ctx.tx[~sfComputationAllowance]; allowance)
|
||||
{
|
||||
if (ctx.registry.config().FEES.extension_compute_limit == 0)
|
||||
auto const fees(ctx.registry.getFees());
|
||||
if (fees.extensionComputeLimit == 0)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "WASM runtime deactivated by fee voting";
|
||||
return temTEMP_DISABLED;
|
||||
@@ -663,7 +664,7 @@ EscrowFinish::preflight(PreflightContext const& ctx)
|
||||
{
|
||||
return temBAD_LIMIT;
|
||||
}
|
||||
if (*allowance > ctx.registry.config().FEES.extension_compute_limit)
|
||||
if (*allowance > fees.extensionComputeLimit)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "ComputationAllowance too large: " << *allowance;
|
||||
return temBAD_LIMIT;
|
||||
@@ -1178,8 +1179,8 @@ EscrowFinish::doApply()
|
||||
// already checked above, this check is just in case
|
||||
return tecINTERNAL;
|
||||
}
|
||||
std::uint32_t allowance = ctx_.tx[sfComputationAllowance];
|
||||
auto re = runEscrowWasm(wasm, ledgerDataProvider, allowance, ESCROW_FUNCTION_NAME, {});
|
||||
std::uint32_t const allowance = ctx_.tx[sfComputationAllowance];
|
||||
auto re = runEscrowWasm(wasm, ledgerDataProvider, allowance, ESCROW_FUNCTION_NAME);
|
||||
JLOG(j_.trace()) << "Escrow WASM ran";
|
||||
|
||||
if (auto const& data = ledgerDataProvider.getData(); data.has_value())
|
||||
@@ -1195,8 +1196,8 @@ EscrowFinish::doApply()
|
||||
|
||||
if (re.has_value())
|
||||
{
|
||||
auto reValue = re.value().result;
|
||||
auto reCost = re.value().cost;
|
||||
auto const reValue = re.value().result;
|
||||
auto const reCost = re.value().cost;
|
||||
JLOG(j_.debug()) << "WASM Success: " + std::to_string(reValue) << ", cost: " << reCost;
|
||||
|
||||
ctx_.setWasmReturnCode(reValue);
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#include <test/app/wasm_fixtures/fixtures.h>
|
||||
#include <test/jtx.h>
|
||||
|
||||
#include <xrpld/app/tx/applySteps.h>
|
||||
#include <xrpld/app/wasm/WasmVM.h>
|
||||
|
||||
#include <xrpl/ledger/Dir.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
#include <xrpl/tx/applySteps.h>
|
||||
#include <xrpl/tx/wasm/WasmVM.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
@@ -177,7 +176,7 @@ struct EscrowSmart_test : public beast::unit_test::suite
|
||||
Env env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->START_UP = Config::FRESH;
|
||||
cfg->START_UP = StartUpType::FRESH;
|
||||
return cfg;
|
||||
}),
|
||||
features);
|
||||
|
||||
@@ -292,7 +292,7 @@ struct Wasm_test : public beast::unit_test::suite
|
||||
{
|
||||
TestHostFunctions hfs(env, 0);
|
||||
auto re = runEscrowWasm(allHFWasm, hfs, 100'000, ESCROW_FUNCTION_NAME, {});
|
||||
checkResult(re, 1, 66'340);
|
||||
checkResult(re, 1, 65'840);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -316,7 +316,7 @@ struct Wasm_test : public beast::unit_test::suite
|
||||
TestHostFunctions hfs(env, 0);
|
||||
auto re = runEscrowWasm(
|
||||
allHFWasm, hfs, std::numeric_limits<int64_t>::max(), ESCROW_FUNCTION_NAME, {});
|
||||
checkResult(re, 1, 66'340);
|
||||
checkResult(re, 1, 65'840);
|
||||
}
|
||||
|
||||
{ // fail because trying to access nonexistent field
|
||||
@@ -482,7 +482,7 @@ struct Wasm_test : public beast::unit_test::suite
|
||||
auto const codecovWasm = hexToBytes(codecovTestsWasmHex);
|
||||
TestHostFunctions hfs(env, 0);
|
||||
|
||||
auto const allowance = 339'303;
|
||||
auto const allowance = 340'524;
|
||||
auto re = runEscrowWasm(codecovWasm, hfs, allowance, ESCROW_FUNCTION_NAME, {});
|
||||
|
||||
checkResult(re, 1, allowance);
|
||||
|
||||
@@ -787,6 +787,24 @@ public:
|
||||
return *mWalletDB;
|
||||
}
|
||||
|
||||
virtual Fees
|
||||
getFees() const override
|
||||
{
|
||||
XRPL_ASSERT(config_, "xrpl::ApplicationImp::getFees : non-null config");
|
||||
|
||||
auto const& f1(config_->FEES);
|
||||
|
||||
Fees f2;
|
||||
f2.base = f1.reference_fee;
|
||||
f2.reserve = f1.account_reserve;
|
||||
f2.increment = f1.owner_reserve;
|
||||
f2.extensionComputeLimit = f1.extension_compute_limit;
|
||||
f2.extensionSizeLimit = f1.extension_size_limit;
|
||||
f2.gasPrice = f1.gas_price;
|
||||
|
||||
return f2;
|
||||
}
|
||||
|
||||
bool
|
||||
serverOkay(std::string& reason) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user