mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-11 05:03:16 +01:00
Merge bitcoin/bitcoin#30857: cluster mempool: extend DepGraph functionality
0b3ec8c59bclusterlin: remove Cluster type (Pieter Wuille)1c24c62510clusterlin: merge two DepGraph fuzz tests into simulation test (Pieter Wuille)0606e66fdbclusterlin: add DepGraph::RemoveTransactions and support for holes in DepGraph (Pieter Wuille)75b5d42419clusterlin: make DepGraph::AddDependency support multiple dependencies at once (Pieter Wuille)abf50649d1clusterlin: simplify DepGraphFormatter::Ser (Pieter Wuille)eaab55ffc8clusterlin: rework DepGraphFormatter::Unser (Pieter Wuille)5901cf7100clusterlin: abstract out DepGraph::GetReduced{Parents,Children} (Pieter Wuille) Pull request description: Part of cluster mempool: #30289 This adds: * `DepGraph::AddDependencies` to add 0 or more dependencies to a single transaction at once (identical to calling `DepGraph::AddDependency` once for each, but more efficient). * `DepGraph::RemoveTransactions` to remove 0 or more transactions from a depgraph. * `DepGraph::GetReducedParents` (and `DepGraph::GetReducedChildren`) to get the (reduced) direct parents and children of a transaction in a depgraph. After which, the `Cluster` type is removed. This is the result of fleshing out the design for the "intermediate layer" ("TxGraph", no PR yet) between the cluster linearization layer and the mempool layer. My earlier thinking was that TxGraph would store `Cluster` objects (vectors of pairs of `FeeFrac`s and sets of parents), and convert them to `DepGraph` on the fly whenever needed. However, after more consideration, it seems better to have TxGraph store `DepGraph` objects, and manipulate them directly without constantly re-creating them. This requires `DepGraph` to have some additional functionality. The bulk of the complexity here is the addition of `DepGraph::RemoveTransactions`, which leaves the remaining transactions' positions within the `DepGraph` untouched (we want existing identifiers to remain valid), so this implies that graphs can now have "holes" (positions that are unused, but followed by positions that are used). To enable that, an extension of the fuzz/test serialization format `DepGraphFormatter` is included to deal with such holes. ACKs for top commit: sdaftuar: reACK0b3ec8c59binstagibbs: reACK0b3ec8c59bismaelsadeeq: reACK0b3ec8c59bglozow: ACK0b3ec8c59b, reviewed range-diff from aab53ddcd8fcbc3c0be0da9383f8e06abe5badda and `clusterlin_depgraph_sim` Tree-SHA512: a804b7f26d544c5cb0847322e235c810525cb0607737be6116c3156d582da3ba3352af8ea48e74eed5268f9c3eca63b30181d01b23a6dd0be1b99191f81cceb0
This commit is contained in:
@@ -28,7 +28,7 @@ DepGraph<SetType> MakeLinearGraph(ClusterIndex ntx)
|
||||
DepGraph<SetType> depgraph;
|
||||
for (ClusterIndex i = 0; i < ntx; ++i) {
|
||||
depgraph.AddTransaction({-int32_t(i), 1});
|
||||
if (i > 0) depgraph.AddDependency(i - 1, i);
|
||||
if (i > 0) depgraph.AddDependencies(SetType::Singleton(i - 1), i);
|
||||
}
|
||||
return depgraph;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ DepGraph<SetType> MakeWideGraph(ClusterIndex ntx)
|
||||
DepGraph<SetType> depgraph;
|
||||
for (ClusterIndex i = 0; i < ntx; ++i) {
|
||||
depgraph.AddTransaction({int32_t(i) + 1, 1});
|
||||
if (i > 0) depgraph.AddDependency(0, i);
|
||||
if (i > 0) depgraph.AddDependencies(SetType::Singleton(0), i);
|
||||
}
|
||||
return depgraph;
|
||||
}
|
||||
@@ -70,19 +70,19 @@ DepGraph<SetType> MakeHardGraph(ClusterIndex ntx)
|
||||
depgraph.AddTransaction({1, 2});
|
||||
} else if (i == 1) {
|
||||
depgraph.AddTransaction({14, 2});
|
||||
depgraph.AddDependency(0, 1);
|
||||
depgraph.AddDependencies(SetType::Singleton(0), 1);
|
||||
} else if (i == 2) {
|
||||
depgraph.AddTransaction({6, 1});
|
||||
depgraph.AddDependency(2, 1);
|
||||
depgraph.AddDependencies(SetType::Singleton(2), 1);
|
||||
} else if (i == 3) {
|
||||
depgraph.AddTransaction({5, 1});
|
||||
depgraph.AddDependency(2, 3);
|
||||
depgraph.AddDependencies(SetType::Singleton(2), 3);
|
||||
} else if ((i & 1) == 0) {
|
||||
depgraph.AddTransaction({7, 1});
|
||||
depgraph.AddDependency(i - 1, i);
|
||||
depgraph.AddDependencies(SetType::Singleton(i - 1), i);
|
||||
} else {
|
||||
depgraph.AddTransaction({5, 1});
|
||||
depgraph.AddDependency(i, 4);
|
||||
depgraph.AddDependencies(SetType::Singleton(i), 4);
|
||||
}
|
||||
} else {
|
||||
// Even cluster size.
|
||||
@@ -98,16 +98,16 @@ DepGraph<SetType> MakeHardGraph(ClusterIndex ntx)
|
||||
depgraph.AddTransaction({1, 1});
|
||||
} else if (i == 1) {
|
||||
depgraph.AddTransaction({3, 1});
|
||||
depgraph.AddDependency(0, 1);
|
||||
depgraph.AddDependencies(SetType::Singleton(0), 1);
|
||||
} else if (i == 2) {
|
||||
depgraph.AddTransaction({1, 1});
|
||||
depgraph.AddDependency(0, 2);
|
||||
depgraph.AddDependencies(SetType::Singleton(0), 2);
|
||||
} else if (i & 1) {
|
||||
depgraph.AddTransaction({4, 1});
|
||||
depgraph.AddDependency(i - 1, i);
|
||||
depgraph.AddDependencies(SetType::Singleton(i - 1), i);
|
||||
} else {
|
||||
depgraph.AddTransaction({0, 1});
|
||||
depgraph.AddDependency(i, 3);
|
||||
depgraph.AddDependencies(SetType::Singleton(i), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void BenchMergeLinearizationsWorstCase(ClusterIndex ntx, benchmark::Bench& bench
|
||||
DepGraph<SetType> depgraph;
|
||||
for (ClusterIndex i = 0; i < ntx; ++i) {
|
||||
depgraph.AddTransaction({i, 1});
|
||||
if (i) depgraph.AddDependency(0, i);
|
||||
if (i) depgraph.AddDependencies(SetType::Singleton(0), i);
|
||||
}
|
||||
std::vector<ClusterIndex> lin1;
|
||||
std::vector<ClusterIndex> lin2;
|
||||
|
||||
Reference in New Issue
Block a user