Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Merkle Blob into Data Layer #18711

Open
wants to merge 83 commits into
base: long_lived/datalayer_merkle_blob
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
c7e697e
add `chia.data_layer.util.merkle_blob`
altendky May 14, 2024
2468b51
raw node [de]serialization tests
altendky May 14, 2024
b85c3fb
`NewType`s and other
altendky May 15, 2024
a622b13
just `RawLeafMerkleNode.key_value`
altendky May 15, 2024
7079391
drop the root node type, internal or leaf might be the root
altendky May 15, 2024
c772ae6
trivial tree deserialization
altendky May 15, 2024
7e0c897
comment
altendky May 15, 2024
4a9e876
add `MerkleBlob.get_lineage()`
altendky May 15, 2024
de2d8c0
store the index on the raw node objects (great? or not...?)
altendky May 15, 2024
b69d91d
Merge branch 'main' into merkle_blob
altendky Jun 4, 2024
a9fd907
Checkpoint.
fchirica Aug 5, 2024
a72a0c1
Some linting.
fchirica Aug 6, 2024
b51e2a5
Some type checking.
fchirica Aug 6, 2024
b591345
Lint.
fchirica Aug 6, 2024
8453b52
Add proof of inclusion code.
fchirica Aug 10, 2024
73e4222
Fix test.
fchirica Aug 10, 2024
03f5119
Lint.
fchirica Aug 10, 2024
a78f0ed
Add free positions.
fchirica Aug 13, 2024
27b341e
Lint.
fchirica Aug 13, 2024
f7bfa2c
Improve test.
fchirica Aug 14, 2024
62973f7
Lint.:
fchirica Aug 14, 2024
64a4b94
Lint.
fchirica Aug 14, 2024
5b76402
Add upsert.
fchirica Aug 15, 2024
d1a2092
Go with lower limits.
fchirica Aug 16, 2024
827e86f
Apply Kyle's change.
fchirica Aug 16, 2024
96cb0a0
Merge branch 'main' into fc.merkle_blob
altendky Aug 16, 2024
6094e08
Lint.
fchirica Aug 16, 2024
90c37a8
ignore astuple mypy complaint
altendky Aug 16, 2024
dda307a
add `c_profile` fixture
altendky Aug 16, 2024
146e4a3
Add cache.
fchirica Aug 28, 2024
d5e114c
Lint.
fchirica Aug 28, 2024
480725e
Lint.
fchirica Aug 28, 2024
77b0965
Add batch autoinsert.
fchirica Sep 5, 2024
0804b67
Lint.
fchirica Sep 5, 2024
e073155
Checkpoint split keys and values ids.
fchirica Sep 16, 2024
7ac2f81
Lint.
fchirica Sep 18, 2024
024b2ad
Lint.
fchirica Sep 18, 2024
489020e
Lint.
fchirica Sep 18, 2024
82f8e94
Lint.
fchirica Sep 18, 2024
3d4158d
Fix tests.
fchirica Sep 20, 2024
6237de6
Lint.
fchirica Sep 20, 2024
8aed02f
Checkpoint integration.
fchirica Sep 30, 2024
89721b6
Checkpoint fix tests.
fchirica Oct 2, 2024
870df12
Fix more tests.
fchirica Oct 8, 2024
4f4c185
Download working.
fchirica Oct 16, 2024
743c455
Merge branch 'long_lived/datalayer_merkle_blob' into fc.dl_integration
fchirica Oct 16, 2024
24495ab
Cherry pick CHIA-1427.
fchirica Oct 16, 2024
1bbbcf8
Lint.
fchirica Oct 16, 2024
1a6153f
Some linting.
fchirica Oct 16, 2024
df75337
Delete data on unsubscribe.
fchirica Oct 18, 2024
557068c
Merge branch 'long_lived/datalayer_merkle_blob' into fc.dl_integration
fchirica Oct 18, 2024
d108e3e
Lint
fchirica Oct 18, 2024
fbf1814
Lint.
fchirica Oct 18, 2024
bdb002e
Lint.
fchirica Oct 18, 2024
f6207f8
Lint.
fchirica Oct 18, 2024
9676318
Lint.
fchirica Oct 18, 2024
c7e1803
Lint.
fchirica Oct 18, 2024
63a58da
Merge branch 'long_lived/datalayer_merkle_blob' into fc.dl_integration
fchirica Oct 21, 2024
bc04800
Fix test.
fchirica Oct 21, 2024
e3b93d9
Fix code after merge conflict.
fchirica Oct 21, 2024
3220d62
Lint.
fchirica Oct 21, 2024
de6d131
Lint.
fchirica Oct 21, 2024
27b36c9
Fix more tests.
fchirica Oct 22, 2024
19a8f35
Lint.
fchirica Oct 22, 2024
de52d38
Migrate old DB.
fchirica Oct 25, 2024
a044f1d
Revert pytest config.
fchirica Oct 25, 2024
81083b2
Merge branch 'long_lived/datalayer_merkle_blob' into fc.dl_integration
fchirica Oct 29, 2024
7765bbd
Lint.
fchirica Oct 29, 2024
11e1c62
Lint.
fchirica Oct 30, 2024
c77fa7b
Fix test.
fchirica Oct 30, 2024
72e271d
Fix tests.
fchirica Nov 5, 2024
3aeffd4
Fix test.
fchirica Nov 5, 2024
cef14db
Fix bug.
fchirica Nov 7, 2024
3f0efa1
Lint.
fchirica Nov 7, 2024
605ceeb
Lint.
fchirica Nov 7, 2024
3745e52
Apply suggestions from code review
fchirica Nov 13, 2024
c308207
Address comments.
fchirica Nov 14, 2024
094e5cf
Lint.
fchirica Nov 14, 2024
404f1c5
Add merkle blob cache.
fchirica Nov 15, 2024
9aad2f7
Mypy.
fchirica Nov 15, 2024
6b543dc
Try with deepcopy.
fchirica Nov 15, 2024
166a734
Use deepcopy everywhere.
fchirica Nov 15, 2024
b768f4c
Fix test.
fchirica Nov 15, 2024
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
49 changes: 40 additions & 9 deletions chia/_tests/core/data_layer/test_data_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@
ProofLayer,
Status,
StoreProofs,
get_delta_filename_path,
get_full_tree_filename_path,
key_hash,
leaf_hash,
)
from chia.data_layer.data_layer_wallet import DataLayerWallet, verify_offer
from chia.data_layer.data_store import DataStore
from chia.data_layer.download_data import get_delta_filename_path, get_full_tree_filename_path
from chia.rpc.data_layer_rpc_api import DataLayerRpcApi
from chia.rpc.data_layer_rpc_client import DataLayerRpcClient
from chia.rpc.wallet_rpc_api import WalletRpcApi
Expand Down Expand Up @@ -129,6 +130,7 @@ async def init_data_layer(
manage_data_interval: int = 5,
maximum_full_file_count: Optional[int] = None,
group_files_by_store: bool = False,
enable_batch_autoinsert: bool = True,
) -> AsyncIterator[DataLayer]:
async with init_data_layer_service(
wallet_rpc_port,
Expand All @@ -137,7 +139,7 @@ async def init_data_layer(
wallet_service,
manage_data_interval,
maximum_full_file_count,
True,
enable_batch_autoinsert,
group_files_by_store,
) as data_layer_service:
yield data_layer_service._api.data_layer
Expand Down Expand Up @@ -251,6 +253,7 @@ def create_mnemonic(seed: bytes = b"ab") -> str:


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
altendky marked this conversation as resolved.
Show resolved Hide resolved
async def test_create_insert_get(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -330,6 +333,7 @@ async def test_create_insert_get(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_upsert(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -360,6 +364,7 @@ async def test_upsert(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_create_double_insert(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -397,6 +402,7 @@ async def test_create_double_insert(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_keys_values_ancestors(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -443,7 +449,7 @@ async def test_keys_values_ancestors(
assert key in dic
val = await data_rpc_api.get_ancestors({"id": store_id.hex(), "hash": val["keys_values"][4]["hash"]})
# todo better assertions for get_ancestors result
assert len(val["ancestors"]) == 3
assert len(val["ancestors"]) == 1
altendky marked this conversation as resolved.
Show resolved Hide resolved
res_before = await data_rpc_api.get_root({"id": store_id.hex()})
assert res_before["confirmed"] is True
assert res_before["timestamp"] > 0
Expand Down Expand Up @@ -473,6 +479,7 @@ async def test_keys_values_ancestors(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_get_roots(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -526,6 +533,7 @@ async def test_get_roots(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_get_root_history(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -580,6 +588,7 @@ async def test_get_root_history(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_get_kv_diff(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -647,13 +656,19 @@ async def test_get_kv_diff(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_batch_update_matches_single_operations(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
wallet_rpc_api, full_node_api, wallet_rpc_port, ph, bt = await init_wallet_and_node(
self_hostname, one_wallet_and_one_simulator_services
)
async with init_data_layer(wallet_rpc_port=wallet_rpc_port, bt=bt, db_path=tmp_path) as data_layer:
async with init_data_layer(
wallet_rpc_port=wallet_rpc_port,
bt=bt,
db_path=tmp_path,
enable_batch_autoinsert=False,
) as data_layer:
data_rpc_api = DataLayerRpcApi(data_layer)
res = await data_rpc_api.create_data_store({})
assert res is not None
Expand Down Expand Up @@ -719,6 +734,7 @@ async def test_batch_update_matches_single_operations(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_get_owned_stores(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -759,6 +775,7 @@ async def test_get_owned_stores(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_subscriptions(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -1591,6 +1608,7 @@ class MakeAndTakeReference:
indirect=["offer_setup"],
)
@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_make_and_take_offer(offer_setup: OfferSetup, reference: MakeAndTakeReference) -> None:
offer_setup = await populate_offer_setup(offer_setup=offer_setup, count=reference.entries_to_insert)

Expand Down Expand Up @@ -1703,6 +1721,7 @@ async def test_make_and_then_take_offer_invalid_inclusion_key(


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_verify_offer_rpc_valid(bare_data_layer_api: DataLayerRpcApi) -> None:
reference = make_one_take_one_reference

Expand All @@ -1721,6 +1740,7 @@ async def test_verify_offer_rpc_valid(bare_data_layer_api: DataLayerRpcApi) -> N


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_verify_offer_rpc_invalid(bare_data_layer_api: DataLayerRpcApi) -> None:
reference = make_one_take_one_reference
broken_taker_offer = copy.deepcopy(reference.make_offer_response)
Expand All @@ -1741,6 +1761,7 @@ async def test_verify_offer_rpc_invalid(bare_data_layer_api: DataLayerRpcApi) ->


@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_make_offer_failure_rolls_back_db(offer_setup: OfferSetup) -> None:
# TODO: only needs the maker and db? wallet?
reference = make_one_take_one_reference
Expand Down Expand Up @@ -1783,6 +1804,7 @@ async def test_make_offer_failure_rolls_back_db(offer_setup: OfferSetup) -> None
],
)
@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_make_and_cancel_offer(offer_setup: OfferSetup, reference: MakeAndTakeReference) -> None:
offer_setup = await populate_offer_setup(offer_setup=offer_setup, count=reference.entries_to_insert)

Expand Down Expand Up @@ -1859,6 +1881,7 @@ async def test_make_and_cancel_offer(offer_setup: OfferSetup, reference: MakeAnd
],
)
@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_make_and_cancel_offer_then_update(
offer_setup: OfferSetup, reference: MakeAndTakeReference, secure: bool
) -> None:
Expand Down Expand Up @@ -1948,6 +1971,7 @@ async def test_make_and_cancel_offer_then_update(
],
)
@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_make_and_cancel_offer_not_secure_clears_pending_roots(
offer_setup: OfferSetup,
reference: MakeAndTakeReference,
Expand Down Expand Up @@ -1990,6 +2014,7 @@ async def test_make_and_cancel_offer_not_secure_clears_pending_roots(

@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
@pytest.mark.anyio
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
async def test_get_sync_status(
self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path
) -> None:
Expand Down Expand Up @@ -3028,7 +3053,12 @@ async def test_pagination_cmds(
wallet_rpc_api, full_node_api, wallet_rpc_port, ph, bt = await init_wallet_and_node(
self_hostname, one_wallet_and_one_simulator_services
)
async with init_data_layer_service(wallet_rpc_port=wallet_rpc_port, bt=bt, db_path=tmp_path) as data_layer_service:
async with init_data_layer_service(
wallet_rpc_port=wallet_rpc_port,
bt=bt,
db_path=tmp_path,
enable_batch_autoinsert=False,
) as data_layer_service:
assert data_layer_service.rpc_server is not None
rpc_port = data_layer_service.rpc_server.listen_port
data_layer = data_layer_service._api.data_layer
Expand Down Expand Up @@ -3180,7 +3210,7 @@ async def test_pagination_cmds(
if max_page_size is None or max_page_size == 100:
assert keys == {
"keys": ["0x61616161", "0x6161"],
"root_hash": "0x889a4a61b17be799ae9d36831246672ef857a24091f54481431a83309d4e890e",
"root_hash": "0x3f4ae7b8e10ef48b3114843537d5def989ee0a3b6568af7e720a71730f260fa1",
"success": True,
"total_bytes": 6,
"total_pages": 1,
Expand All @@ -3200,7 +3230,7 @@ async def test_pagination_cmds(
"value": "0x6161",
},
],
"root_hash": "0x889a4a61b17be799ae9d36831246672ef857a24091f54481431a83309d4e890e",
"root_hash": "0x3f4ae7b8e10ef48b3114843537d5def989ee0a3b6568af7e720a71730f260fa1",
altendky marked this conversation as resolved.
Show resolved Hide resolved
"success": True,
"total_bytes": 9,
"total_pages": 1,
Expand All @@ -3217,7 +3247,7 @@ async def test_pagination_cmds(
elif max_page_size == 5:
assert keys == {
"keys": ["0x61616161"],
"root_hash": "0x889a4a61b17be799ae9d36831246672ef857a24091f54481431a83309d4e890e",
"root_hash": "0x3f4ae7b8e10ef48b3114843537d5def989ee0a3b6568af7e720a71730f260fa1",
"success": True,
"total_bytes": 6,
"total_pages": 2,
Expand All @@ -3231,7 +3261,7 @@ async def test_pagination_cmds(
"value": "0x61",
}
],
"root_hash": "0x889a4a61b17be799ae9d36831246672ef857a24091f54481431a83309d4e890e",
"root_hash": "0x3f4ae7b8e10ef48b3114843537d5def989ee0a3b6568af7e720a71730f260fa1",
"success": True,
"total_bytes": 9,
"total_pages": 2,
Expand Down Expand Up @@ -3689,6 +3719,7 @@ async def test_multistore_update(
await data_rpc_api.multistore_batch_update({"store_updates": store_updates})


@pytest.mark.skip
@pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules")
@pytest.mark.anyio
async def test_unsubmitted_batch_db_migration(
Expand Down
Loading
Loading