Skip to content

Commit c3f9a7a

Browse files
committed
add new fuzz targets for scp, bucketlist and parallel-exec
1 parent 19c31dc commit c3f9a7a

11 files changed

Lines changed: 3000 additions & 17 deletions

‎Cargo.lock‎

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/Makefile.am‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,10 @@ FUZZ_LINKER_FLAGS = -Wl,--whole-archive,libfuzz_common.a,--no-whole-archive $(if
575575
# - Create regression test target
576576

577577
# List of fuzz targets (lowercase names)
578-
FUZZ_TARGETS = tx overlay soroban_expr soroban_wasmi
578+
FUZZ_TARGETS = tx overlay scp parallel_tx bucketlist soroban_expr soroban_wasmi
579579

580580
# Fuzz binaries are noinst because they're development tools
581-
noinst_PROGRAMS = fuzz_tx fuzz_overlay fuzz_soroban_expr fuzz_soroban_wasmi
581+
noinst_PROGRAMS = fuzz_tx fuzz_overlay fuzz_scp fuzz_parallel_tx fuzz_bucketlist fuzz_soroban_expr fuzz_soroban_wasmi
582582

583583
# Each fuzz target only compiles FuzzMain.cpp (with its specific -DFUZZ_TARGET_NAME)
584584
# and links against the shared libfuzz_common.a library.
@@ -592,6 +592,21 @@ fuzz_overlay_CXXFLAGS = $(FUZZ_CXXFLAGS) -DFUZZ_TARGET_NAME=\"overlay\"
592592
fuzz_overlay_LDADD = $(FUZZ_LIBS)
593593
fuzz_overlay_LDFLAGS = $(FUZZ_LINKER_FLAGS)
594594

595+
fuzz_scp_SOURCES = $(FUZZ_MAIN)
596+
fuzz_scp_CXXFLAGS = $(FUZZ_CXXFLAGS) -DFUZZ_TARGET_NAME=\"scp\"
597+
fuzz_scp_LDADD = $(FUZZ_LIBS)
598+
fuzz_scp_LDFLAGS = $(FUZZ_LINKER_FLAGS)
599+
600+
fuzz_parallel_tx_SOURCES = $(FUZZ_MAIN)
601+
fuzz_parallel_tx_CXXFLAGS = $(FUZZ_CXXFLAGS) -DFUZZ_TARGET_NAME=\"parallel_tx\"
602+
fuzz_parallel_tx_LDADD = $(FUZZ_LIBS)
603+
fuzz_parallel_tx_LDFLAGS = $(FUZZ_LINKER_FLAGS)
604+
605+
fuzz_bucketlist_SOURCES = $(FUZZ_MAIN)
606+
fuzz_bucketlist_CXXFLAGS = $(FUZZ_CXXFLAGS) -DFUZZ_TARGET_NAME=\"bucketlist\"
607+
fuzz_bucketlist_LDADD = $(FUZZ_LIBS)
608+
fuzz_bucketlist_LDFLAGS = $(FUZZ_LINKER_FLAGS)
609+
595610
# Soroban fuzz targets (require --features fuzz in Rust build)
596611
fuzz_soroban_expr_SOURCES = $(FUZZ_MAIN)
597612
fuzz_soroban_expr_CXXFLAGS = $(FUZZ_CXXFLAGS) -DFUZZ_TARGET_NAME=\"soroban_expr\"

‎src/main/CommandLine.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "simulation/ApplyLoad.h"
5050
#include "test/TestUtils.h"
5151
#include "test/fuzz/FuzzTargetRegistry.h"
52+
#include "test/fuzz/ScopedCatchResultCapture.h"
5253
#include "test/test.h"
5354
#endif
5455

@@ -1793,6 +1794,7 @@ runFuzz(CommandLineArgs const& args)
17931794
if (actual > 0)
17941795
{
17951796
data.resize(actual);
1797+
ScopedCatchResultCapture catchCapture;
17961798
target->run(data.data(), data.size());
17971799
}
17981800

‎src/rust/src/soroban_proto_all.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ pub(crate) mod p27 {
220220
}
221221
}
222222

223+
#[cfg(not(feature = "fastdev"))]
223224
#[path = "."]
224225
pub(crate) mod p26 {
225226
pub(crate) extern crate soroban_env_host_p26;
@@ -1477,6 +1478,7 @@ const HOST_MODULES: &'static [HostModule] = &[
14771478
proto_versioned_functions_for_module!(p24),
14781479
#[cfg(not(feature = "fastdev"))]
14791480
proto_versioned_functions_for_module!(p25),
1481+
#[cfg(not(feature = "fastdev"))]
14801482
proto_versioned_functions_for_module!(p26),
14811483
proto_versioned_functions_for_module!(p27),
14821484
];
@@ -1518,8 +1520,8 @@ fn protocol_dispatches_as_expected() {
15181520

15191521
#[cfg(feature = "fastdev")]
15201522
{
1521-
assert_eq!(get_host_module_for_protocol(20, 20).unwrap().max_proto, 26);
1522-
assert_eq!(get_host_module_for_protocol(26, 26).unwrap().max_proto, 26);
1523+
assert_eq!(get_host_module_for_protocol(20, 20).unwrap().max_proto, 27);
1524+
assert_eq!(get_host_module_for_protocol(27, 27).unwrap().max_proto, 27);
15231525
}
15241526

15251527
#[cfg(all(feature = "fastdev", feature = "next"))]

‎src/test/TxTests.cpp‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ closeLedgerOn(Application& app, int day, int month, int year,
552552

553553
TransactionResultSet
554554
closeLedger(Application& app, std::vector<TransactionFrameBasePtr> const& txs,
555-
ParallelSorobanOrder const& parallelSorobanOrder)
555+
ParallelSorobanOrder const& parallelSorobanOrder,
556+
ApplyOrderTxCallback const& applyOrderTxCallback)
556557
{
557558
auto lastCloseTime = app.getLedgerManager()
558559
.getLastClosedLedgerHeader()
@@ -561,12 +562,14 @@ closeLedger(Application& app, std::vector<TransactionFrameBasePtr> const& txs,
561562
auto nextLedgerSeq = app.getLedgerManager().getLastClosedLedgerNum() + 1;
562563

563564
return closeLedgerOn(app, nextLedgerSeq, lastCloseTime, txs, true,
564-
emptyUpgradeSteps, parallelSorobanOrder);
565+
emptyUpgradeSteps, parallelSorobanOrder,
566+
applyOrderTxCallback);
565567
}
566568

567569
TransactionResultSet
568570
closeLedger(Application& app, std::vector<TransactionFrameBasePtr> const& txs,
569-
bool strictOrder, xdr::xvector<UpgradeType, 6> const& upgrades)
571+
bool strictOrder, xdr::xvector<UpgradeType, 6> const& upgrades,
572+
ApplyOrderTxCallback const& applyOrderTxCallback)
570573
{
571574
auto lastCloseTime = app.getLedgerManager()
572575
.getLastClosedLedgerHeader()
@@ -575,14 +578,15 @@ closeLedger(Application& app, std::vector<TransactionFrameBasePtr> const& txs,
575578
auto nextLedgerSeq = app.getLedgerManager().getLastClosedLedgerNum() + 1;
576579

577580
return closeLedgerOn(app, nextLedgerSeq, lastCloseTime, txs, strictOrder,
578-
upgrades);
581+
upgrades, {}, applyOrderTxCallback);
579582
}
580583

581584
TransactionResultSet
582585
closeLedgerOn(Application& app, uint32 ledgerSeq, TimePoint closeTime,
583586
std::vector<TransactionFrameBasePtr> const& txs, bool strictOrder,
584587
xdr::xvector<UpgradeType, 6> const& upgrades,
585-
ParallelSorobanOrder const& parallelSorobanOrder)
588+
ParallelSorobanOrder const& parallelSorobanOrder,
589+
ApplyOrderTxCallback const& applyOrderTxCallback)
586590
{
587591
// Ensure that parallelSorobanOrder is only used with strictOrder
588592
releaseAssert((parallelSorobanOrder.empty() || strictOrder));
@@ -636,6 +640,18 @@ closeLedgerOn(Application& app, uint32 ledgerSeq, TimePoint closeTime,
636640
// themselves maybe intentionally invalid for testing purpose.
637641
releaseAssert(txSet.second->checkValid(app, 0, 0));
638642
}
643+
if (applyOrderTxCallback)
644+
{
645+
size_t txIndex = 0;
646+
for (auto const& phase : txSet.second->getPhasesInApplyOrder())
647+
{
648+
for (auto const& tx : phase)
649+
{
650+
applyOrderTxCallback(txIndex, tx);
651+
++txIndex;
652+
}
653+
}
654+
}
639655
app.getHerder().externalizeValue(txSet.first, ledgerSeq, closeTime,
640656
upgrades);
641657
while (app.getLedgerManager().getLastClosedLedgerNum() < ledgerSeq)

‎src/test/TxTests.h‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include "herder/LedgerCloseData.h"
99
#include "herder/Upgrades.h"
1010
#include "overlay/StellarXDR.h"
11+
#include "transactions/TransactionFrameBase.h"
1112
#include "transactions/test/TransactionTestFrame.h"
13+
#include <functional>
1214
#include <optional>
1315

1416
namespace stellar
@@ -23,6 +25,9 @@ class TestAccount;
2325
namespace txtest
2426
{
2527

28+
using ApplyOrderTxCallback =
29+
std::function<void(size_t, stellar::TransactionFrameBaseConstPtr const&)>;
30+
2631
struct ExpectedOpResult
2732
{
2833
OperationResult mOperationResult;
@@ -88,11 +93,13 @@ TransactionResultSet
8893
closeLedger(Application& app,
8994
std::vector<TransactionFrameBasePtr> const& txs = {},
9095
bool strictOrder = false,
91-
xdr::xvector<UpgradeType, 6> const& upgrades = emptyUpgradeSteps);
96+
xdr::xvector<UpgradeType, 6> const& upgrades = emptyUpgradeSteps,
97+
ApplyOrderTxCallback const& applyOrderTxCallback = {});
9298

9399
TransactionResultSet
94100
closeLedger(Application& app, std::vector<TransactionFrameBasePtr> const& txs,
95-
ParallelSorobanOrder const& parallelSorobanOrder);
101+
ParallelSorobanOrder const& parallelSorobanOrder,
102+
ApplyOrderTxCallback const& applyOrderTxCallback = {});
96103

97104
TransactionResultSet
98105
closeLedgerOn(Application& app, int day, int month, int year,
@@ -104,7 +111,8 @@ closeLedgerOn(Application& app, uint32 ledgerSeq, TimePoint closeTime,
104111
std::vector<TransactionFrameBasePtr> const& txs = {},
105112
bool strictOrder = false,
106113
xdr::xvector<UpgradeType, 6> const& upgrades = emptyUpgradeSteps,
107-
ParallelSorobanOrder const& parallelSorobanOrder = {});
114+
ParallelSorobanOrder const& parallelSorobanOrder = {},
115+
ApplyOrderTxCallback const& applyOrderTxCallback = {});
108116

109117
TransactionResultSet closeLedger(Application& app, TxSetXDRFrameConstPtr txSet);
110118

‎src/test/fuzz/FuzzMain.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#endif
3434

3535
#include "test/fuzz/FuzzTargetRegistry.h"
36+
#include "test/fuzz/ScopedCatchResultCapture.h"
3637
#include "util/Logging.h"
3738
#include "util/Math.h"
3839

@@ -95,6 +96,7 @@ LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
9596
}
9697

9798
// Run the target once
99+
stellar::ScopedCatchResultCapture catchCapture;
98100
switch (gFuzzTarget->run(data, size))
99101
{
100102
case stellar::FuzzResultCode::FUZZ_SUCCESS:

0 commit comments

Comments
 (0)