Skip to content
Merged
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
14 changes: 12 additions & 2 deletions src/chasers/chaser_transaction_compact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,17 @@ void chaser_transaction::do_submit_compact(const transactions_cptr& txs,
}

const auto strong = is_under_checkpoint(ctx.height);
if (const auto ec = query.set_code(link, filled, strong))
const auto ec = query.set_code(link, filled, strong);

// Block size that is not storable is above weight limit.
if (ec == database::error::txs_size)
{
constexpr auto limit = system::error::block_weight_limit;
handler(unconfirmable(link, ctx.height, limit), {});
return;
}

if (ec)
{
handler(fault(ec), {});
return;
Expand Down Expand Up @@ -271,7 +281,7 @@ bool chaser_transaction::set_pooled(const database::tx_link& link,
return pooled;
}

// An identified block with an invalid tx is invalid.
// An identified block with an invalid tx or size is invalid.
code chaser_transaction::unconfirmable(const database::header_link& link,
size_t height, const code& ec) NOEXCEPT
{
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_header_in_70014.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ void protocol_header_in_70014::do_submit_compact(const code& ec,
return;
}

// The tx chaser marks an identified block with an invalid tx unconfirmable.
// The tx chaser marks an identified invalid block unconfirmable.
if (ec)
{
LOGR("Compact block [" << encode_hash(hash) << ":" << height
Expand Down
13 changes: 13 additions & 0 deletions test/chasers/chaser_transaction_compact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ BC_FIXTURE_TEST_CASE(chaser_transaction__submit_compact__invalid_tx_link__integr
BC_REQUIRE(!query_.is_associated(link));
}

BC_FIXTURE_TEST_CASE(chaser_transaction__submit_compact__unstorable_size__block_weight_limit, chaser_transaction_header_setup_fixture)
{
const auto link = query_.to_header(p2p_compact_setup_fixture::block1().hash());
BC_REQUIRE(query_.set(large_transaction()));

const auto stored = query_.to_tx(large_transaction().hash(false));
const auto result = submit_compact(package({}), { stored, stored }, link);
BC_REQUIRE_EQUAL(result.first, system::error::block_weight_limit);
BC_REQUIRE(!node_.suspended());
BC_REQUIRE(query_.is_unconfirmable(link));
BC_REQUIRE(!query_.is_associated(link));
}

BC_FIXTURE_TEST_CASE(chaser_transaction__submit_compact__stored_unpooled_tx__pooled, chaser_transaction_child_header_setup_fixture)
{
const auto link = query_.to_header(child_header().hash());
Expand Down
16 changes: 16 additions & 0 deletions test/chasers/chaser_transaction_setup_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ inline chain::transaction::cptr spend_relative(const hash_digest& hash,
});
}

// A tx with an output of one push, two of which are not storable as a block.
inline const chain::transaction& large_transaction() NOEXCEPT
{
const chain::point point{ one_hash, 1u };
const chain::operations push{ { data_chunk(4'194'304), false } };
static const chain::transaction instance
{
1u,
chain::inputs{ { point, chain::script{}, max_uint32 } },
chain::outputs{ { 42u, chain::script{ push } } },
0u
};

return instance;
}

inline chain::transactions_cptr package(
const chain::transaction_cptrs& txs) NOEXCEPT
{
Expand Down
Loading