Skip to content

Commit 489e5aa

Browse files
committed
Merge bitcoin#30857: cluster mempool: extend DepGraph functionality
0b3ec8c clusterlin: remove Cluster type (Pieter Wuille) 1c24c62 clusterlin: merge two DepGraph fuzz tests into simulation test (Pieter Wuille) 0606e66 clusterlin: add DepGraph::RemoveTransactions and support for holes in DepGraph (Pieter Wuille) 75b5d42 clusterlin: make DepGraph::AddDependency support multiple dependencies at once (Pieter Wuille) abf5064 clusterlin: simplify DepGraphFormatter::Ser (Pieter Wuille) eaab55f clusterlin: rework DepGraphFormatter::Unser (Pieter Wuille) 5901cf7 clusterlin: abstract out DepGraph::GetReduced{Parents,Children} (Pieter Wuille) Pull request description: Part of cluster mempool: bitcoin#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: reACK 0b3ec8c instagibbs: reACK 0b3ec8c ismaelsadeeq: reACK 0b3ec8c glozow: ACK 0b3ec8c, reviewed range-diff from aab53dd and `clusterlin_depgraph_sim` Tree-SHA512: a804b7f26d544c5cb0847322e235c810525cb0607737be6116c3156d582da3ba3352af8ea48e74eed5268f9c3eca63b30181d01b23a6dd0be1b99191f81cceb0
2 parents 9f45062 + 0b3ec8c commit 489e5aa

8 files changed

+543
-280
lines changed

src/bench/cluster_linearize.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DepGraph<SetType> MakeLinearGraph(ClusterIndex ntx)
2828
DepGraph<SetType> depgraph;
2929
for (ClusterIndex i = 0; i < ntx; ++i) {
3030
depgraph.AddTransaction({-int32_t(i), 1});
31-
if (i > 0) depgraph.AddDependency(i - 1, i);
31+
if (i > 0) depgraph.AddDependencies(SetType::Singleton(i - 1), i);
3232
}
3333
return depgraph;
3434
}
@@ -43,7 +43,7 @@ DepGraph<SetType> MakeWideGraph(ClusterIndex ntx)
4343
DepGraph<SetType> depgraph;
4444
for (ClusterIndex i = 0; i < ntx; ++i) {
4545
depgraph.AddTransaction({int32_t(i) + 1, 1});
46-
if (i > 0) depgraph.AddDependency(0, i);
46+
if (i > 0) depgraph.AddDependencies(SetType::Singleton(0), i);
4747
}
4848
return depgraph;
4949
}
@@ -70,19 +70,19 @@ DepGraph<SetType> MakeHardGraph(ClusterIndex ntx)
7070
depgraph.AddTransaction({1, 2});
7171
} else if (i == 1) {
7272
depgraph.AddTransaction({14, 2});
73-
depgraph.AddDependency(0, 1);
73+
depgraph.AddDependencies(SetType::Singleton(0), 1);
7474
} else if (i == 2) {
7575
depgraph.AddTransaction({6, 1});
76-
depgraph.AddDependency(2, 1);
76+
depgraph.AddDependencies(SetType::Singleton(2), 1);
7777
} else if (i == 3) {
7878
depgraph.AddTransaction({5, 1});
79-
depgraph.AddDependency(2, 3);
79+
depgraph.AddDependencies(SetType::Singleton(2), 3);
8080
} else if ((i & 1) == 0) {
8181
depgraph.AddTransaction({7, 1});
82-
depgraph.AddDependency(i - 1, i);
82+
depgraph.AddDependencies(SetType::Singleton(i - 1), i);
8383
} else {
8484
depgraph.AddTransaction({5, 1});
85-
depgraph.AddDependency(i, 4);
85+
depgraph.AddDependencies(SetType::Singleton(i), 4);
8686
}
8787
} else {
8888
// Even cluster size.
@@ -98,16 +98,16 @@ DepGraph<SetType> MakeHardGraph(ClusterIndex ntx)
9898
depgraph.AddTransaction({1, 1});
9999
} else if (i == 1) {
100100
depgraph.AddTransaction({3, 1});
101-
depgraph.AddDependency(0, 1);
101+
depgraph.AddDependencies(SetType::Singleton(0), 1);
102102
} else if (i == 2) {
103103
depgraph.AddTransaction({1, 1});
104-
depgraph.AddDependency(0, 2);
104+
depgraph.AddDependencies(SetType::Singleton(0), 2);
105105
} else if (i & 1) {
106106
depgraph.AddTransaction({4, 1});
107-
depgraph.AddDependency(i - 1, i);
107+
depgraph.AddDependencies(SetType::Singleton(i - 1), i);
108108
} else {
109109
depgraph.AddTransaction({0, 1});
110-
depgraph.AddDependency(i, 3);
110+
depgraph.AddDependencies(SetType::Singleton(i), 3);
111111
}
112112
}
113113
}
@@ -195,7 +195,7 @@ void BenchMergeLinearizationsWorstCase(ClusterIndex ntx, benchmark::Bench& bench
195195
DepGraph<SetType> depgraph;
196196
for (ClusterIndex i = 0; i < ntx; ++i) {
197197
depgraph.AddTransaction({i, 1});
198-
if (i) depgraph.AddDependency(0, i);
198+
if (i) depgraph.AddDependencies(SetType::Singleton(0), i);
199199
}
200200
std::vector<ClusterIndex> lin1;
201201
std::vector<ClusterIndex> lin2;

0 commit comments

Comments
 (0)