Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix20250131 #428

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/ripple/app/hook/Guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iostream>
#include <map>
#include <memory>
#include <optional>
#include <ostream>
#include <stack>
#include <string>
Expand Down Expand Up @@ -271,7 +272,8 @@ check_guard(
int guard_func_idx,
int last_import_idx,
GuardLog guardLog,
std::string guardLogAccStr)
std::string guardLogAccStr,
uint64_t rulesVersion = 0)
{
#define MAX_GUARD_CALLS 1024
uint32_t guard_count = 0;
Expand Down Expand Up @@ -621,11 +623,17 @@ check_guard(
}
else if (fc_type == 10) // memory.copy
{
if (rulesVersion & 0x02U)
GUARD_ERROR("Memory.copy instruction is not allowed.");

REQUIRE(2);
ADVANCE(2);
}
else if (fc_type == 11) // memory.fill
{
if (rulesVersion & 0x02U)
GUARD_ERROR("Memory.fill instruction is not allowed.");

ADVANCE(1);
}
else if (fc_type <= 7) // numeric instructions
Expand Down Expand Up @@ -1477,7 +1485,8 @@ validateGuards(
guard_import_number,
last_import_number,
guardLog,
guardLogAccStr);
guardLogAccStr,
rulesVersion);

if (!valid)
return {};
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/hook/guard_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ main(int argc, char** argv)

close(fd);

auto result = validateGuards(hook, std::cout, "", 1);
auto result = validateGuards(hook, std::cout, "", 3);

if (!result)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/tx/impl/Change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ Change::activateXahauGenesis()
wasmBytes, // wasm to verify
loggerStream,
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
ctx_.view().rules().enabled(featureHooksUpdate1) ? 1 : 0);
(ctx_.view().rules().enabled(featureHooksUpdate1) ? 1 : 0) +
(ctx_.view().rules().enabled(fix20250131) ? 2 : 0));

if (!result)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/tx/impl/SetHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ SetHook::validateHookSetEntry(SetHookCtx& ctx, STObject const& hookSetObj)
hook, // wasm to verify
logger,
hsacc,
ctx.rules.enabled(featureHooksUpdate1) ? 1 : 0);
(ctx.rules.enabled(featureHooksUpdate1) ? 1 : 0) +
(ctx.rules.enabled(fix20250131) ? 2 : 0));

if (ctx.j.trace())
{
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 = 76;
static constexpr std::size_t numFeatures = 77;

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

} // namespace ripple

Expand Down
3 changes: 2 additions & 1 deletion src/ripple/protocol/impl/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ 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);
REGISTER_FIX (fixXahauV3, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fix20250131, Supported::yes, VoteBehavior::DefaultYes);

// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.
Expand Down
50 changes: 50 additions & 0 deletions src/test/app/SetHook_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,54 @@ class SetHook_test : public beast::unit_test::suite
: preHookCount + 66);
}

void
testFillCopy(FeatureBitset features)
{
testcase("Test fill/copy");

// a hook containing memory.fill instruction
std::string hookFill =
"0061736d0100000001130360027f7f017f60037f7f7e017e60017f017e02"
"170203656e76025f67000003656e76066163636570740001030201020503"
"0100020621057f01418088040b7f004180080b7f004180080b7f00418088"
"040b7f004180080b07080104686f6f6b00020aa4800001a0800001017e23"
"01412a41e400fc0b004101410110001a41004100420010011a20010b";

// a hook containing memory.copy instruction
std::string hookCopy =
"0061736d0100000001130360027f7f017f60037f7f7e017e60017f017e02"
"170203656e76025f67000003656e76066163636570740001030201020503"
"0100020621057f01418088040b7f004180080b7f004180080b7f00418088"
"040b7f004180080b07080104686f6f6b00020aa5800001a1800001017e23"
"00230141e400fc0a00004101410110001a41004100420010011a20010b";

using namespace jtx;

for (int withFix = 0; withFix < 2; ++withFix)
{
auto f = withFix ? features : features - fix20250131;
Env env{*this, f};

auto const alice = Account{"alice"};
env.fund(XRP(10000), alice);

auto const bob = Account{"bob"};
env.fund(XRP(10000), bob);

env(ripple::test::jtx::hook(alice, {{hso(hookFill)}}, 0),
M(withFix ? "hookFill - with fix" : "hookFill - zonder fix"),
HSFEE,
withFix ? ter(temMALFORMED) : ter(tesSUCCESS));

env(ripple::test::jtx::hook(bob, {{hso(hookCopy)}}, 0),
M(withFix ? "hookCopy - with fix" : "hookCopy - zonder fix"),
HSFEE,
withFix ? ter(temMALFORMED) : ter(tesSUCCESS));

env.close();
}
}

void
testCreate(FeatureBitset features)
{
Expand Down Expand Up @@ -11973,6 +12021,8 @@ class SetHook_test : public beast::unit_test::suite
testNSDeletePartial(features);
testPageCap(features);

testFillCopy(features);

testWasm(features);
test_accept(features);
test_rollback(features);
Expand Down
Loading