chia-blockchain 2.5.5rc3__py3-none-any.whl → 2.5.5rc5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chia/_tests/core/mempool/test_mempool_manager.py +108 -0
- chia/full_node/mempool_manager.py +20 -4
- {chia_blockchain-2.5.5rc3.dist-info → chia_blockchain-2.5.5rc5.dist-info}/METADATA +1 -1
- {chia_blockchain-2.5.5rc3.dist-info → chia_blockchain-2.5.5rc5.dist-info}/RECORD +7 -7
- {chia_blockchain-2.5.5rc3.dist-info → chia_blockchain-2.5.5rc5.dist-info}/LICENSE +0 -0
- {chia_blockchain-2.5.5rc3.dist-info → chia_blockchain-2.5.5rc5.dist-info}/WHEEL +0 -0
- {chia_blockchain-2.5.5rc3.dist-info → chia_blockchain-2.5.5rc5.dist-info}/entry_points.txt +0 -0
|
@@ -3161,3 +3161,111 @@ def test_check_removals(case: CheckRemovalsCase) -> None:
|
|
|
3161
3161
|
assert err == expected_err
|
|
3162
3162
|
assert len(conflicts) == len(expected_conflicts)
|
|
3163
3163
|
assert set(conflicts) == set(expected_conflicts)
|
|
3164
|
+
|
|
3165
|
+
|
|
3166
|
+
@pytest.mark.anyio
|
|
3167
|
+
async def test_new_peak_deferred_ff_items() -> None:
|
|
3168
|
+
"""
|
|
3169
|
+
Covers the case where we update lineage info for multiple fast forward
|
|
3170
|
+
singletons at new peak.
|
|
3171
|
+
"""
|
|
3172
|
+
singleton_spend1 = make_singleton_spend(bytes32([1] * 32))
|
|
3173
|
+
singleton1_id = singleton_spend1.coin.name()
|
|
3174
|
+
singleton_spend2 = make_singleton_spend(bytes32([2] * 32))
|
|
3175
|
+
singleton2_id = singleton_spend2.coin.name()
|
|
3176
|
+
coins = TestCoins(
|
|
3177
|
+
[singleton_spend1.coin, singleton_spend2.coin, TEST_COIN, TEST_COIN2],
|
|
3178
|
+
{
|
|
3179
|
+
singleton_spend1.coin.puzzle_hash: singleton_spend1.coin,
|
|
3180
|
+
singleton_spend2.coin.puzzle_hash: singleton_spend2.coin,
|
|
3181
|
+
},
|
|
3182
|
+
)
|
|
3183
|
+
mempool_manager = await setup_mempool(coins)
|
|
3184
|
+
# Let's submit the two singletons transactions to the mempool
|
|
3185
|
+
sb_names = []
|
|
3186
|
+
for singleton_spend, regular_coin in [(singleton_spend1, TEST_COIN), (singleton_spend2, TEST_COIN2)]:
|
|
3187
|
+
sb = SpendBundle([singleton_spend, mk_coin_spend(regular_coin)], G2Element())
|
|
3188
|
+
sb_name = sb.name()
|
|
3189
|
+
await mempool_manager.add_spend_bundle(
|
|
3190
|
+
sb,
|
|
3191
|
+
make_test_conds(spend_ids=[(singleton_spend.coin, ELIGIBLE_FOR_FF), (regular_coin, 0)], cost=1337),
|
|
3192
|
+
sb_name,
|
|
3193
|
+
uint32(1),
|
|
3194
|
+
)
|
|
3195
|
+
assert mempool_manager.get_mempool_item(sb_name) is not None
|
|
3196
|
+
sb_names.append(sb_name)
|
|
3197
|
+
# Let's advance the mempool by spending these singletons into new lineages
|
|
3198
|
+
singleton1_new_latest = Coin(singleton1_id, singleton_spend1.coin.puzzle_hash, singleton_spend1.coin.amount)
|
|
3199
|
+
coins.update_lineage(singleton_spend1.coin.puzzle_hash, singleton1_new_latest)
|
|
3200
|
+
singleton2_new_latest = Coin(singleton2_id, singleton_spend2.coin.puzzle_hash, singleton_spend2.coin.amount)
|
|
3201
|
+
coins.update_lineage(singleton_spend2.coin.puzzle_hash, singleton2_new_latest)
|
|
3202
|
+
await advance_mempool(mempool_manager, [singleton1_id, singleton2_id], use_optimization=True)
|
|
3203
|
+
# Both items should get updated with their related latest lineages
|
|
3204
|
+
mi1 = mempool_manager.get_mempool_item(sb_names[0])
|
|
3205
|
+
assert mi1 is not None
|
|
3206
|
+
latest_singleton_lineage1 = mi1.bundle_coin_spends[singleton1_id].latest_singleton_lineage
|
|
3207
|
+
assert latest_singleton_lineage1 is not None
|
|
3208
|
+
assert latest_singleton_lineage1.coin_id == singleton1_new_latest.name()
|
|
3209
|
+
mi2 = mempool_manager.get_mempool_item(sb_names[1])
|
|
3210
|
+
assert mi2 is not None
|
|
3211
|
+
latest_singleton_lineage2 = mi2.bundle_coin_spends[singleton2_id].latest_singleton_lineage
|
|
3212
|
+
assert latest_singleton_lineage2 is not None
|
|
3213
|
+
assert latest_singleton_lineage2.coin_id == singleton2_new_latest.name()
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
@pytest.mark.anyio
|
|
3217
|
+
async def test_different_ff_versions() -> None:
|
|
3218
|
+
"""
|
|
3219
|
+
Covers the case where we send an item with an older ff singleton version
|
|
3220
|
+
while the mempool is aware of a newer lineage.
|
|
3221
|
+
"""
|
|
3222
|
+
launcher_id = bytes32([1] * 32)
|
|
3223
|
+
singleton_spend1 = make_singleton_spend(launcher_id, bytes32([2] * 32))
|
|
3224
|
+
version1_id = singleton_spend1.coin.name()
|
|
3225
|
+
singleton_spend2 = make_singleton_spend(launcher_id, bytes32([3] * 32))
|
|
3226
|
+
version2_id = singleton_spend2.coin.name()
|
|
3227
|
+
singleton_ph = singleton_spend2.coin.puzzle_hash
|
|
3228
|
+
coins = TestCoins(
|
|
3229
|
+
[singleton_spend1.coin, singleton_spend2.coin, TEST_COIN, TEST_COIN2], {singleton_ph: singleton_spend2.coin}
|
|
3230
|
+
)
|
|
3231
|
+
mempool_manager = await setup_mempool(coins)
|
|
3232
|
+
mempool_items: list[MempoolItem] = []
|
|
3233
|
+
for singleton_spend, regular_coin in [(singleton_spend1, TEST_COIN), (singleton_spend2, TEST_COIN2)]:
|
|
3234
|
+
sb = SpendBundle([singleton_spend, mk_coin_spend(regular_coin)], G2Element())
|
|
3235
|
+
sb_name = sb.name()
|
|
3236
|
+
await mempool_manager.add_spend_bundle(
|
|
3237
|
+
sb,
|
|
3238
|
+
make_test_conds(spend_ids=[(singleton_spend.coin, ELIGIBLE_FOR_FF), (regular_coin, 0)], cost=1337),
|
|
3239
|
+
sb_name,
|
|
3240
|
+
uint32(1),
|
|
3241
|
+
)
|
|
3242
|
+
mi = mempool_manager.get_mempool_item(sb_name)
|
|
3243
|
+
assert mi is not None
|
|
3244
|
+
mempool_items.append(mi)
|
|
3245
|
+
[mi1, mi2] = mempool_items
|
|
3246
|
+
latest_lineage_id = version2_id
|
|
3247
|
+
assert latest_lineage_id != version1_id
|
|
3248
|
+
# Bundle coin spends key points to version 1 but the lineage is latest (v2)
|
|
3249
|
+
latest_singleton_lineage1 = mi1.bundle_coin_spends[version1_id].latest_singleton_lineage
|
|
3250
|
+
assert latest_singleton_lineage1 is not None
|
|
3251
|
+
assert latest_singleton_lineage1.coin_id == latest_lineage_id
|
|
3252
|
+
# Both the bundle coin spends key and the lineage point to latest (v2)
|
|
3253
|
+
latest_singleton_lineage2 = mi2.bundle_coin_spends[version2_id].latest_singleton_lineage
|
|
3254
|
+
assert latest_singleton_lineage2 is not None
|
|
3255
|
+
assert latest_singleton_lineage2.coin_id == latest_lineage_id
|
|
3256
|
+
# Let's update the lineage with a new version of the singleton
|
|
3257
|
+
new_latest_lineage = Coin(version2_id, singleton_ph, singleton_spend2.coin.amount)
|
|
3258
|
+
new_latest_lineage_id = new_latest_lineage.name()
|
|
3259
|
+
coins.update_lineage(singleton_ph, new_latest_lineage)
|
|
3260
|
+
await advance_mempool(mempool_manager, [version1_id, version2_id], use_optimization=True)
|
|
3261
|
+
# Both items should get updated with the latest lineage
|
|
3262
|
+
new_mi1 = mempool_manager.get_mempool_item(mi1.spend_bundle_name)
|
|
3263
|
+
assert new_mi1 is not None
|
|
3264
|
+
latest_singleton_lineage1 = new_mi1.bundle_coin_spends[version1_id].latest_singleton_lineage
|
|
3265
|
+
assert latest_singleton_lineage1 is not None
|
|
3266
|
+
assert latest_singleton_lineage1.coin_id == new_latest_lineage_id
|
|
3267
|
+
new_mi2 = mempool_manager.get_mempool_item(mi2.spend_bundle_name)
|
|
3268
|
+
assert new_mi2 is not None
|
|
3269
|
+
latest_singleton_lineage2 = new_mi2.bundle_coin_spends[version2_id].latest_singleton_lineage
|
|
3270
|
+
assert latest_singleton_lineage2 is not None
|
|
3271
|
+
assert latest_singleton_lineage2.coin_id == new_latest_lineage_id
|
|
@@ -258,7 +258,22 @@ def check_removals(
|
|
|
258
258
|
for item in conflicting_items:
|
|
259
259
|
if item in conflicts:
|
|
260
260
|
continue
|
|
261
|
-
conflict_bcs = item.bundle_coin_spends
|
|
261
|
+
conflict_bcs = item.bundle_coin_spends.get(coin_id)
|
|
262
|
+
if conflict_bcs is None:
|
|
263
|
+
# Check if this is an item that spends an older ff singleton
|
|
264
|
+
# version with a latest version that matches our coin ID.
|
|
265
|
+
conflict_bcs = next(
|
|
266
|
+
(
|
|
267
|
+
bcs
|
|
268
|
+
for bcs in item.bundle_coin_spends.values()
|
|
269
|
+
if bcs.latest_singleton_lineage is not None and bcs.latest_singleton_lineage.coin_id == coin_id
|
|
270
|
+
),
|
|
271
|
+
None,
|
|
272
|
+
)
|
|
273
|
+
# We're not expected to get here but let's handle it gracefully
|
|
274
|
+
if conflict_bcs is None:
|
|
275
|
+
log.warning(f"Coin ID {coin_id} expected but not found in mempool item {item.name}")
|
|
276
|
+
return Err.INVALID_SPEND_BUNDLE, []
|
|
262
277
|
# if the spend we're adding to the mempool is not DEDUP nor FF, it's
|
|
263
278
|
# just a regular conflict
|
|
264
279
|
if not coin_bcs.eligible_for_fast_forward and not coin_bcs.eligible_for_dedup:
|
|
@@ -843,7 +858,7 @@ class MempoolManager:
|
|
|
843
858
|
# rebasing a fast forward spend is more expensive than to just
|
|
844
859
|
# evict the item. So, any FF spend we may need to rebase, defer
|
|
845
860
|
# them until after we've gone through all spends
|
|
846
|
-
deferred_ff_items: set[tuple[bytes32,
|
|
861
|
+
deferred_ff_items: set[tuple[bytes32, MempoolItem]] = set()
|
|
847
862
|
|
|
848
863
|
for spend in spent_coins:
|
|
849
864
|
items = self.mempool.get_items_by_coin_id(spend)
|
|
@@ -866,7 +881,7 @@ class MempoolManager:
|
|
|
866
881
|
spendbundle_ids_to_remove.add(item_name)
|
|
867
882
|
continue
|
|
868
883
|
|
|
869
|
-
deferred_ff_items.add((spend,
|
|
884
|
+
deferred_ff_items.add((spend, item))
|
|
870
885
|
|
|
871
886
|
# fast forward spends are indexed under the latest singleton coin ID
|
|
872
887
|
# if it's spent, we need to update the index in the mempool. This
|
|
@@ -874,7 +889,8 @@ class MempoolManager:
|
|
|
874
889
|
# new_coin_id, current_coin_id, mempool item name
|
|
875
890
|
spends_to_update: list[tuple[bytes32, bytes32, bytes32]] = []
|
|
876
891
|
|
|
877
|
-
for spend,
|
|
892
|
+
for spend, item in deferred_ff_items:
|
|
893
|
+
item_name = item.spend_bundle_name
|
|
878
894
|
if item_name in spendbundle_ids_to_remove:
|
|
879
895
|
continue
|
|
880
896
|
# there may be multiple matching spends in the mempool
|
|
@@ -125,7 +125,7 @@ chia/_tests/core/mempool/test_mempool.py,sha256=3U4SzpN9JAfaC2OJDR0rSusz9Jj1SDl2
|
|
|
125
125
|
chia/_tests/core/mempool/test_mempool_fee_estimator.py,sha256=HDUVrV6tNq1w2v7Rq-FGXFrCspnHVoSQfPOKRmwojmw,3711
|
|
126
126
|
chia/_tests/core/mempool/test_mempool_fee_protocol.py,sha256=XUTKqs82IOiiZMGPTPSRhB4Zp8clbus5GlOoUtPtL6A,2165
|
|
127
127
|
chia/_tests/core/mempool/test_mempool_item_queries.py,sha256=k8tM3axB-fdZwN2NqCAcir-4yslSM8AJIQ0QvEJK9V8,6959
|
|
128
|
-
chia/_tests/core/mempool/test_mempool_manager.py,sha256=
|
|
128
|
+
chia/_tests/core/mempool/test_mempool_manager.py,sha256=p1tT8FOszY6DXi-Z7S2SxPvsNxCgCxaCRHY7c2qv2WM,147336
|
|
129
129
|
chia/_tests/core/mempool/test_mempool_performance.py,sha256=a5bLSJ_Q_EVYnUHn96I5RC7VZl7niizBK47yVnzvWn4,2935
|
|
130
130
|
chia/_tests/core/mempool/test_singleton_fast_forward.py,sha256=Fk85FJRgEHwrc_n2k8jTzsunlWdNdLCYh8MqpG-egt8,35060
|
|
131
131
|
chia/_tests/core/node_height.py,sha256=yfkEmmYCsAb3cIe1ZhtE9J2SFB9lG_49SgjxsITdrZk,917
|
|
@@ -544,7 +544,7 @@ chia/full_node/hint_management.py,sha256=8dVKguFPm-h32GEnMWxX2qyITo4WVO1YBKaPFKC
|
|
|
544
544
|
chia/full_node/hint_store.py,sha256=0m6y0_f0rhGIKqfAmhFSGEeyM3LCN-dv-bR1OfIr4Uo,3666
|
|
545
545
|
chia/full_node/mempool.py,sha256=x8Uo5xy1jcxXQgYaPUU2JkRsu9edndYs0hye3fFoZbk,33795
|
|
546
546
|
chia/full_node/mempool_check_conditions.py,sha256=19_uUO8SCVrkJHEUDw0i0NVWwJyXc7BaAQQdVJSVqIE,3583
|
|
547
|
-
chia/full_node/mempool_manager.py,sha256=
|
|
547
|
+
chia/full_node/mempool_manager.py,sha256=KUNu7tdeadhGgBCJWgby4hNM90D5hz4OlMMUVY0SCeM,50881
|
|
548
548
|
chia/full_node/pending_tx_cache.py,sha256=jEL004L7r1n7ppeSdLVe6nsVNfYw0jU86DHmRYe1rH4,3657
|
|
549
549
|
chia/full_node/subscriptions.py,sha256=-3Mjv08_Z1iBUoXgGoHZvYPyTfkVHyWXhHJH2DWwx9A,8659
|
|
550
550
|
chia/full_node/sync_store.py,sha256=pyjhiUVe_5CXJd8r-lk0-VpFbkX2RtO5N-370W47Rko,5206
|
|
@@ -891,8 +891,8 @@ chia/wallet/wallet_user_store.py,sha256=rXiQpk5g8t1X0Chx0bValcQsHonjB1oQ_F_K16bp
|
|
|
891
891
|
chia/wallet/wallet_weight_proof_handler.py,sha256=IcQg_w8EPjpS9xwmEE8GvPcneLePOtu74wWUu1l5uuM,4875
|
|
892
892
|
chia/wallet/wsm_apis.py,sha256=6LmxbHXC-tqNbRyoiGgz-f19PF1nEfMbfm3BTnsNQ6s,3914
|
|
893
893
|
mozilla-ca/cacert.pem,sha256=qz7jZRl3pBeKcCsLgopO57K7uRJyNbCrdA4uFZdL9ds,222971
|
|
894
|
-
chia_blockchain-2.5.
|
|
895
|
-
chia_blockchain-2.5.
|
|
896
|
-
chia_blockchain-2.5.
|
|
897
|
-
chia_blockchain-2.5.
|
|
898
|
-
chia_blockchain-2.5.
|
|
894
|
+
chia_blockchain-2.5.5rc5.dist-info/LICENSE,sha256=0tuU-jTzeRDJJaxF2YCEpBwbywgpbrVSXq1i6fJq63U,11347
|
|
895
|
+
chia_blockchain-2.5.5rc5.dist-info/METADATA,sha256=NFOEYqEMGkFISbjbKhBcfoNigKLJ1tLG52emb9ivbEQ,10687
|
|
896
|
+
chia_blockchain-2.5.5rc5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
897
|
+
chia_blockchain-2.5.5rc5.dist-info/entry_points.txt,sha256=GL2-UvicPVdKz72IP4shnmV3XImfoD5pMzoURfoAYk4,742
|
|
898
|
+
chia_blockchain-2.5.5rc5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|